[T]utorial [A]bout




#
#  Panoramix 7 Nov 20:00 
#  Decompiled source of 0xb2EDc59fC6108884b7BdE8D623887BAdF031Fc4b
# 
#  Let's make the world open source 
# 

#  Constants

const name() = 'Mobile switching'

const decimals() = 4

const symbol() = 'MBSC'


#  Storage definitions and getters

def storage:
  stor1 is addr # mask(160, 0) at storage #1
  balanceOf is uint256 => uint256 # mask(256, 0) at storage #2
  stor4.0.uint8 is addr => uint8 # mask(8, 0) at storage #4
  stor4.0.uint256 is addr => uint256 # mask(256, 0) at storage #4
  stor4.8 is addr => uint256 # mask(248, 8) at storage #4
  totalSupply is uint256 # mask(256, 0) at storage #5
  totalDistributed is uint256 # mask(256, 0) at storage #6
  totalRemaining is uint256 # mask(256, 0) at storage #7
  value is uint256 # mask(256, 0) at storage #8
  stor9.0.uint8 is uint8 # mask(8, 0) at storage #9
  stor9.0.uint256 is uint256 # mask(256, 0) at storage #9
  stor9.8 is uint256 # mask(248, 8) at storage #9

def totalSupply() : # not payable
  return with totalSupply


def value() : # not payable
  return with value


def balanceOf(address _owner) : # not payable
  return with balanceOf[addr(_owner)]


def totalRemaining() : # not payable
  return with totalRemaining


def allowance(address _owner, address _spender) : # not payable
  return with balanceOf[sha3(addr(_owner), 3), addr(_spender)]


def totalDistributed() : # not payable
  return with totalDistributed




#  Regular functions

#  you may find the following here:
# 
#  cd[xx]      -- means calldata (function parameter) at position xx
#                 most of it will look better soon
#
#  not/!       -- 'not' == 'iszero'; '!' == binary not 
#

def approve(address _spender, uint256 _value) : # not payable
  if _value == 0:
      balanceOf[sha3(caller, 3), addr(_spender)] = _value
      log Approval(address,address,uint256), caller, addr(_spender), _value
      return with bool(1)
  if balanceOf[sha3(caller, 3), addr(_spender)] != 0:
      return with bool(0)
  balanceOf[sha3(caller, 3), addr(_spender)] = _value
  log Approval(address,address,uint256), caller, addr(_spender), _value
  return with bool(1)


def transferFrom(address _from, address _to, uint256 _value) : # not payable
  require CALLDATASIZE >= 100
  require addr(_to) != 0
  require _value <= balanceOf[addr(_from)]
  require _value <= balanceOf[sha3(addr(_from), 3), caller]
  require _value <= balanceOf[addr(_from)]
  balanceOf[addr(_from)] = balanceOf[addr(_from)] - _value
  require _value <= balanceOf[sha3(addr(_from), 3), caller]
  balanceOf[sha3(addr(_from), 3), caller] = balanceOf[sha3(addr(_from), 3), caller] - _value
  require (balanceOf[addr(_to)] + _value) >= balanceOf[addr(_to)]
  balanceOf[addr(_to)] = balanceOf[addr(_to)] + _value
  log Transfer(address,address,uint256), addr(_from), addr(_to), _value
  return with bool(1)


def withdraw() : # not payable
  require caller == stor1
  call stor1 with:	# withdraw / default function
       gas 2300 * not eth.balance(this.address) wei
     value eth.balance(this.address) wei
  require ext_call.success
  stop


def burn(uint256 _value) : # not payable
  require caller == stor1
  require _value <= balanceOf[caller]
  balanceOf[caller] = balanceOf[caller] - _value
  require _value <= totalSupply
  totalSupply = totalSupply - _value
  require _value <= totalDistributed
  totalDistributed = totalDistributed - _value
  log Burn(address,uint256), caller, _value
  stop


def finishDistribution() : # not payable
  require caller == stor1
  require not stor9.0.uint8
  stor9.0.uint256 = bool(1) or Mask(248, 8, stor9.8)
  log DistrFinished(), 0
  return with bool(1)


def transfer(address _to, uint256 _value) : # not payable
  require CALLDATASIZE >= 68
  require addr(_to) != 0
  require _value <= balanceOf[caller]
  balanceOf[caller] = balanceOf[caller] - _value
  require (balanceOf[addr(_to)] + _value) >= balanceOf[addr(_to)]
  balanceOf[addr(_to)] = balanceOf[addr(_to)] + _value
  log Transfer(address,address,uint256), caller, addr(_to), _value
  return with bool(1)


def getTokens() payable: 
  require not stor9.0.uint8
  require bool(stor4[caller].0.uint8) == bool(0)
  if value > totalRemaining:
      value = totalRemaining
      revert
  require not stor9.0.uint8
  require (totalDistributed + value) >= totalDistributed
  totalDistributed = totalDistributed + value
  require value <= totalRemaining
  totalRemaining = totalRemaining - value
  require (balanceOf[caller] + value) >= balanceOf[caller]
  balanceOf[caller] = balanceOf[caller] + value
  log 0x8940c4b8, caller, value
  log Transfer(address,address,uint256), 0, caller, value
  if value <= 0:
      if totalDistributed < totalSupply:
          require 500 <= value
          value = value - 500
          stop
      stor9.0.uint256 = bool(1) or Mask(248, 8, stor9.8)
      require 500 <= value
      value = value - 500
      value = value - 500
      stop
  stor4[caller].0.uint256 = bool(1) or Mask(248, 8, stor4[caller].8)
  if totalDistributed < totalSupply:
      require 500 <= value
      value = value - 500
      stop
  stor9.0.uint256 = bool(1) or Mask(248, 8, stor9.8)
  require 500 <= value
  value = value - 500
  value = value - 500
  stop


def distributionFinished() : # not payable
  return with bool(stor9.0.uint8)


def getTokenBalance(address _tokenAddress, address _who) : # not payable
  require ext_code.size(addr(_tokenAddress))
  call addr(_tokenAddress).balanceOf(address) with:
       gas gas_remaining wei
      args addr(_who)
  if not ext_call.success:
      revert with 0
  return with ext_call.return_data


def unknownc868d5ac(?) : # not payable
  stor1 = caller
  balanceOf[stor1] = totalDistributed
  stop


def withdrawForeignTokens(address _tokenContract) : # not payable
  require caller == stor1
  require ext_code.size(addr(_tokenContract))
  call addr(_tokenContract).balanceOf(address) with:
       gas gas_remaining wei
      args addr(this.address)
  if not ext_call.success:
      revert with 0
  require ext_code.size(addr(_tokenContract))
  call addr(_tokenContract).transfer(address,uint256) with:
       gas gas_remaining wei
      args stor1, ext_call.return_data
  if not ext_call.success:
      revert with 0
  return with bool(ext_call.return_data)


def transferOwnership(address _newOwner) : # not payable
  require caller == stor1
  if addr(_newOwner) == 0:
      stop
  stor1 = addr(_newOwner)
  stop


def blacklist(address _param1) : # not payable
  return with bool(stor4[addr(_param1)].0.uint8)


def _fallback() payable: # default function
  require not stor9.0.uint8
  require bool(stor4[caller].0.uint8) == bool(0)
  if value > totalRemaining:
      value = totalRemaining
      revert
  require not stor9.0.uint8
  require (totalDistributed + value) >= totalDistributed
  totalDistributed = totalDistributed + value
  require value <= totalRemaining
  totalRemaining = totalRemaining - value
  require (balanceOf[caller] + value) >= balanceOf[caller]
  balanceOf[caller] = balanceOf[caller] + value
  log 0x8940c4b8, caller, value
  log Transfer(address,address,uint256), 0, caller, value
  if value <= 0:
      if totalDistributed < totalSupply:
          require 500 <= value
          value = value - 500
          stop
      stor9.0.uint256 = bool(1) or Mask(248, 8, stor9.8)
      require 500 <= value
      value = value - 500
      value = value - 500
      stop
  stor4[caller].0.uint256 = bool(1) or Mask(248, 8, stor4[caller].8)
  if totalDistributed < totalSupply:
      require 500 <= value
      value = value - 500
      stop
  stor9.0.uint256 = bool(1) or Mask(248, 8, stor9.8)
  require 500 <= value
  value = value - 500
  value = value - 500
  stop