Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

define i32 @main() {
%buf = alloca i8, i32 24, align 16
%r = call i32 @llvm.eh.sjlj.setjmp(i8* %buf)
;%r = add i32 0, 1
%normal = icmp eq i32 %r, 0
br i1 %normal, label %Normal, label %Jump
Normal:
@chfast
chfast / gist:b9871f4bddab05803199
Last active August 29, 2015 14:15
PerformanceTester
contract PerformanceTester {
function ackermann(uint m, uint n) returns (uint) {
if (m == 0)
return n + 1;
if (n == 0)
return ackermann(m - 1, 1);
return ackermann(m - 1, ackermann(m, n - 1));
}
@chfast
chfast / shift.ll
Last active August 29, 2015 14:16
LLVM shift test
; RUN: opt < %s -constprop -S | FileCheck %s
; CHECK-LABEL: shift_undef_65
define void @shift_undef_65(i65* %p) {
%r1 = lshr i65 2, 18446744073709551617
; CHECK: store i65 undef, %p
store i65 %r1, i65* %p
%r2 = ashr i65 4, 18446744073709551617
; CHECK: store i65 undef, %p
@chfast
chfast / context.cpp
Created June 2, 2015 22:33
boost context
// Copyright Oliver Kowalke 2009.
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
#include <cstdlib>
#include <cstring>
#include <iostream>
@chfast
chfast / bt
Created June 12, 2015 09:28
Assertion `_peer->m_asking == Asking::Nothing' failed
alethzero: /home/chfast/Projects/ethereum/cpp-ethereum/libethereum/EthereumHost.cpp:621: void dev::eth::EthereumHost::continueSync(dev::eth::EthereumPeer*): Assertion `_peer->m_asking == Asking::Nothing' failed.
[New Thread 0x7fff377f5700 (LWP 14688)]
[New Thread 0x7fff2cffc700 (LWP 14690)]
[New Thread 0x7fff36bf4700 (LWP 14689)]
[New Thread 0x7fff457fa700 (LWP 14680)]
[New Thread 0x7fff45ffb700 (LWP 14679)]
[New Thread 0x7fff467fc700 (LWP 14678)]
[New Thread 0x7fff46ffd700 (LWP 14677)]
[New Thread 0x7fff477fe700 (LWP 14676)]
[New Thread 0x7fff47fff700 (LWP 14675)]
-- The C compiler identification is GNU 4.9.2
-- The CXX compiler identification is GNU 4.9.2
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
Scanning dependencies of target alethzero_automoc
[ 0%] Automatic moc and uic for target alethzero
Generating ui_AlethZero.h
Generating ui_Connect.h
Generating ui_AllAccounts.h
Generating ui_BrainWallet.h
Generating ui_ImportKey.h
Generating ui_NewAccount.h
Generating ui_BlockList.h
Generating ui_ExportState.h
@chfast
chfast / boost-div.cpp
Created September 13, 2015 16:01
boost multiprecision div bug test case
#include <iostream>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/version.hpp>
using u256 = boost::multiprecision::number<boost::multiprecision::cpp_int_backend<256, 256, boost::multiprecision::unsigned_magnitude, boost::multiprecision::unchecked, void>>;
int main()
{
std::cout << "Boost " << BOOST_VERSION << std::endl;
// Bank Of Deposit
//
// This contract keeps user's ethers in its internal storage. This approach
// allows cheaper batch transfers than series of individual Ethereum
// transactions.
contract BankOfDeposit {
// OPT: solidity additionally hashes the key of the map what in case of
// address is a waste of gas
mapping(address => uint) _balance;
contract Timestamping {
mapping(bytes32 => uint256) stamps;
function Timestamping() {
set_stamp("hello world");
}
function set_stamp(bytes32 hash) {
stamps[hash] = block.timestamp;