Created
November 16, 2010 08:20
-
-
Save puffnfresh/701582 to your computer and use it in GitHub Desktop.
Disassembled LLVM bitcode of a C++ "hello world"
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// LLVM_STYLE: old | |
// Solving Intertyper... | |
// Cycle start, items: | |
// Processing using LineSplitter: 1 | |
// New results: 0 out of 0 | |
// Processing using Tokenizer: 102 | |
// New results: 0 out of 0 | |
// Processing using Triager: 102 | |
// New results: 0 out of 0 | |
// Processing using Global: 37 | |
// New results: 23 out of 23 | |
// Processing using FuncHeader: 3 | |
// New results: 3 out of 26 | |
// Processing using Label: 3 | |
// New results: 3 out of 29 | |
// Processing using Assign: 5 | |
// New results: 0 out of 29 | |
// Processing using Reintegrator: 5 | |
// New results: 0 out of 29 | |
// Processing using Call: 2 | |
// New results: 2 out of 31 | |
// Processing using Return: 3 | |
// New results: 3 out of 34 | |
// Processing using FuncEnd: 3 | |
// New results: 3 out of 37 | |
// Processing using External: 20 | |
// New results: 20 out of 57 | |
// Cycle start, items: | |
// Processing using Triager: 5 | |
// New results: 0 out of 57 | |
// Processing using Reintegrator: 5 | |
// New results: 0 out of 57 | |
// Processing using Call: 5 | |
// New results: 0 out of 57 | |
// Cycle start, items: | |
// Processing using Reintegrator: 10 | |
// New results: 5 out of 62 | |
// Cycle start, items: | |
// Completed Intertyper in 0.011 seconds. | |
// Solving Analyzer... | |
// Cycle start, items: | |
// Processing using Sorter: 1 | |
// New results: 0 out of 0 | |
// Processing using Gatherer: 1 | |
// New results: 0 out of 0 | |
// Processing using Identinicer: 1 | |
// New results: 0 out of 0 | |
// Processing using Typevestigator: 1 | |
// New results: 0 out of 0 | |
// Processing using Typeanalyzer: 1 | |
// New results: 0 out of 0 | |
// Processing using VariableAnalyzer: 1 | |
// New results: 0 out of 0 | |
// Processing using LabelAnalyzer: 1 | |
// New results: 0 out of 0 | |
// Processing using StackAnalyzer: 1 | |
// New results: 0 out of 0 | |
// Processing using Relooper: 1 | |
// New results: 0 out of 0 | |
// Processing using LoopOptimizer: 1 | |
// New results: 1 out of 1 | |
// Completed Analyzer in 0.008 seconds. | |
// Solving JSifyer... | |
// Cycle start, items: | |
// Processing using Type: 17 | |
// New results: 17 out of 17 | |
// Processing using GlobalVariable: 6 | |
// New results: 9 out of 26 | |
// Processing using FunctionStub: 20 | |
// New results: 20 out of 46 | |
// Processing using FunctionSplitter: 3 | |
// New results: 0 out of 46 | |
// Processing using FuncLineTriager: 13 | |
// New results: 0 out of 46 | |
// Processing using Intertype:assign: 5 | |
// New results: 0 out of 46 | |
// Processing using AssignReintegrator: 5 | |
// New results: 0 out of 46 | |
// Processing using Intertype:return: 3 | |
// New results: 0 out of 46 | |
// Processing using Intertype:call: 2 | |
// New results: 0 out of 46 | |
// Cycle start, items: | |
// Processing using FunctionReconstructor: 3 | |
// New results: 0 out of 46 | |
// Processing using FuncLineTriager: 10 | |
// New results: 0 out of 46 | |
// Processing using AssignReintegrator: 5 | |
// New results: 0 out of 46 | |
// Processing using Intertype:call: 5 | |
// New results: 0 out of 46 | |
// Cycle start, items: | |
// Processing using FunctionReconstructor: 5 | |
// New results: 1 out of 47 | |
// Processing using FuncLineTriager: 5 | |
// New results: 0 out of 47 | |
// Processing using AssignReintegrator: 10 | |
// New results: 0 out of 47 | |
// Cycle start, items: | |
// Processing using FunctionReconstructor: 5 | |
// New results: 2 out of 49 | |
// Cycle start, items: | |
// Completed JSifyer in 0.002 seconds. | |
// Capture the output of this into a variable, if you want | |
//(function(Module, args) { | |
// Module = Module || {}; | |
// args = args || []; | |
// Runs much faster, for some reason | |
var Module = {}; | |
var args = arguments; | |
// === Auto-generated preamble library stuff === | |
Runtime = { | |
stackAlloc: function stackAlloc(size) { var ret = STACKTOP; assert(size > 0); STACKTOP += size;STACKTOP = Math.ceil(STACKTOP/4)*4;; assert(STACKTOP < STACK_ROOT + STACK_MAX); return ret; }, | |
staticAlloc: function staticAlloc(size) { var ret = STATICTOP; assert(size > 0); STATICTOP += size;STATICTOP = Math.ceil(STATICTOP/4)*4;; return ret; }, | |
alignMemory: function alignMemory(size,quantum) { var ret = size = Math.ceil(size/(quantum ? quantum : 4))*(quantum ? quantum : 4);; return ret; }, | |
getFunctionIndex: function getFunctionIndex(func, ident) { | |
var key = FUNCTION_TABLE.length; | |
FUNCTION_TABLE[key] = func; | |
FUNCTION_TABLE[key+1] = null; // Need to have keys be even numbers, see |polymorph| test | |
Module[ident] = func; // Export using full name, for Closure Compiler | |
return key; | |
}, | |
isNumberType: function (type) { | |
return type in Runtime.INT_TYPES || type in Runtime.FLOAT_TYPES; | |
}, | |
isPointerType: function isPointerType(type) { | |
return pointingLevels(type) > 0; | |
}, | |
isStructType: function isStructType(type) { | |
if (isPointerType(type)) return false; | |
if (new RegExp(/^\[\d+\ x\ (.*)\]/g).test(type)) return true; // [15 x ?] blocks. Like structs | |
// See comment in isStructPointerType() | |
return !Runtime.isNumberType(type) && type[0] == '%'; | |
}, | |
INT_TYPES: {"i1":0,"i8":0,"i16":0,"i32":0,"i64":0}, | |
FLOAT_TYPES: {"float":0,"double":0}, | |
getNativeFieldSize: function getNativeFieldSize(field, alone) { | |
var size; | |
if (4 > 1) { | |
size = { | |
'i1': alone ? 1 : 4, // inside a struct, aligned to 4, | |
'i8': alone ? 1 : 4, // most likely...? XXX | |
'i16': alone ? 2 : 4, // ditto | |
'i32': 4, | |
'i64': 8, | |
'float': 4, | |
'double':8 | |
}[field]; // XXX 32/64 bit stuff | |
if (!size) { | |
size = 4; // Must be a pointer XXX 32/64 | |
} | |
} else { | |
size = 1; | |
} | |
return size; | |
}, | |
dedup: function dedup(items, ident) { | |
var seen = {}; | |
if (ident) { | |
return items.filter(function(item) { | |
if (seen[item[ident]]) return false; | |
seen[item[ident]] = true; | |
return true; | |
}); | |
} else { | |
return items.filter(function(item) { | |
if (seen[item]) return false; | |
seen[item] = true; | |
return true; | |
}); | |
} | |
}, | |
calculateStructAlignment: function calculateStructAlignment(type, otherTypes) { | |
type.flatSize = 0; | |
var diffs = []; | |
var prev = -1, maxSize = -1; | |
type.flatIndexes = type.fields.map(function(field) { | |
var size; | |
if (Runtime.isNumberType(field) || Runtime.isPointerType(field)) { | |
size = Runtime.getNativeFieldSize(field, true); // pack char; char; in structs, also char[X]s. | |
maxSize = Math.max(maxSize, size); | |
} else if (Runtime.isStructType(field)) { | |
size = otherTypes[field].flatSize; | |
maxSize = Math.max(maxSize, 4); | |
} else { | |
dprint('Unclear type in struct: ' + field + ', in ' + type.name_); | |
assert(0); | |
} | |
var curr = Runtime.alignMemory(type.flatSize, Math.min(4, size)); // if necessary, place this on aligned memory | |
type.flatSize = curr + size; | |
if (prev >= 0) { | |
diffs.push(curr-prev); | |
} | |
prev = curr; | |
return curr; | |
}); | |
type.flatSize = Runtime.alignMemory(type.flatSize, maxSize); | |
if (diffs.length == 0) { | |
type.flatFactor = type.flatSize; | |
} else if (Runtime.dedup(diffs).length == 1) { | |
type.flatFactor = diffs[0]; | |
} | |
type.needsFlattening = (type.flatFactor != 1); | |
return type.flatIndexes; | |
}, | |
__dummy__: 0 | |
} | |
function __globalConstructor__() { | |
} | |
// Maps ints ==> functions. This lets us pass around ints, which are | |
// actually pointers to functions, and we convert at call()time | |
var FUNCTION_TABLE = []; | |
var __THREW__ = false; // Used in checking for thrown exceptions. | |
var __ATEXIT__ = []; | |
var ABORT = false; | |
function assert(condition, text) { | |
if (!condition) { | |
var text = "Assertion failed: " + text; | |
print(text + ':\n' + (new Error).stack); | |
ABORT = true; | |
throw "Assertion: " + text; | |
} | |
} | |
function Pointer_niceify(ptr) { | |
return { slab: IHEAP, pos: ptr }; | |
} | |
// Creates a pointer for a certain slab and a certain address in that slab. | |
// If just a slab is given, will allocate room for it and copy it there. In | |
// other words, do whatever is necessary in order to return a pointer, that | |
// points to the slab (and possibly position) we are given. | |
var ALLOC_NORMAL = 0; // Tries to use _malloc() | |
var ALLOC_STACK = 1; // Lives for the duration of the current function call | |
var ALLOC_STATIC = 2; // Cannot be freed | |
function Pointer_make(slab, pos, allocator) { | |
pos = pos ? pos : 0; | |
if (slab === HEAP) return pos; | |
// Flatten out - needed for global consts/vars | |
function flatten(slab) { | |
if (!slab || slab.length === undefined || typeof slab === 'function') return [slab]; | |
return slab.map(flatten).reduce(function(a,b) { return a.concat(b) }, []); | |
} | |
var slab = flatten(slab); | |
// Finalize | |
var ret = [_malloc, Runtime.stackAlloc, Runtime.staticAlloc][allocator ? allocator : ALLOC_STATIC](Math.max(slab.length - pos, 1)); | |
for (var i = 0; i < slab.length - pos; i++) { | |
var curr = slab[pos + i]; | |
if (curr === undefined) throw 'Invalid element in slab'; // This can be caught, and you can try again to allocate later, see globalFuncs in run() | |
if (typeof curr === 'function') { | |
curr = Runtime.getFunctionIndex(curr); | |
} | |
HEAP[ret + i] = curr; | |
} | |
return ret; | |
} | |
function Pointer_stringify(ptr) { | |
ptr = Pointer_niceify(ptr); | |
var ret = ""; | |
var i = 0; | |
var t; | |
while (1) { | |
// if ((ptr.pos + i) >= ptr.slab.length) { return "<< Invalid read: " + (ptr.pos+i) + " : " + ptr.slab.length + " >>"; } else {} | |
if ((ptr.pos+i) >= ptr.slab.length) { break; } else {} | |
t = String.fromCharCode(ptr.slab[ptr.pos + i]); | |
if (t == "\0") { break; } else {} | |
ret += t; | |
i += 1; | |
} | |
return ret; | |
} | |
// Memory management | |
var PAGE_SIZE = 4096; | |
function alignMemoryPage(x) { | |
return Math.ceil(x/PAGE_SIZE)*PAGE_SIZE; | |
} | |
var HEAP, IHEAP, FHEAP; | |
var STACK_ROOT, STACKTOP, STACK_MAX; | |
var STATICTOP; | |
// Mangled |new| and |free| (various manglings, for int, long params; new and new[], etc. | |
var _malloc, _free, __Znwj, __Znaj, __Znam, __Znwm, __ZdlPv, __ZdaPv; | |
function __initializeRuntime__() { | |
// If we don't have malloc/free implemented, use a simple implementation. | |
Module['_malloc'] = _malloc = __Znwj = __Znaj = __Znam = __Znwm = Module['_malloc'] ? Module['_malloc'] : Runtime.staticAlloc; | |
Module['_free'] = _free = __ZdlPv = __ZdaPv = Module['_free'] ? Module['_free'] : function() { }; | |
HEAP = intArrayFromString('(null)'); // So printing %s of NULL gives '(null)' | |
// Also this ensures we leave 0 as an invalid address, 'NULL' | |
IHEAP = HEAP; // We use that name in our runtime code that processes strings etc., see library.js | |
Module['HEAP'] = HEAP; | |
Module['IHEAP'] = IHEAP; | |
Module['FHEAP'] = FHEAP; | |
STACK_ROOT = STACKTOP = alignMemoryPage(10); | |
if (!this['TOTAL_STACK']) TOTAL_STACK = 1024*1024; // Reserved room for stack | |
STACK_MAX = STACK_ROOT + TOTAL_STACK; | |
STATICTOP = alignMemoryPage(STACK_MAX); | |
} | |
function __shutdownRuntime__() { | |
while( __ATEXIT__.length > 0) { | |
var func = __ATEXIT__.pop(); | |
if (typeof func === 'number') { | |
func = FUNCTION_TABLE[func]; | |
} | |
func(); | |
} | |
} | |
// stdio.h | |
// C-style: we work on ints on the HEAP. | |
function __formatString() { | |
var textIndex = arguments[0]; | |
var argIndex = 1; | |
var ret = []; | |
var curr = -1; | |
while (curr != 0) { | |
curr = HEAP[textIndex]; | |
next = HEAP[textIndex+1]; | |
if (curr == '%'.charCodeAt(0) && ['d', 'u', 'f', '.'].indexOf(String.fromCharCode(next)) != -1) { | |
var argText = String(+arguments[argIndex]); // +: boolean=>int | |
// Handle very very simply formatting, namely only %.Xf | |
if (next == '.'.charCodeAt(0)) { | |
var limit = parseInt(String.fromCharCode(HEAP[textIndex+2])); | |
var dotIndex = argText.indexOf('.'); | |
if (dotIndex == -1) { | |
dotIndex = argText.length; | |
argText += '.'; | |
} | |
argText += '00000000000'; // padding | |
argText = argText.substr(0, dotIndex+1+limit); | |
textIndex += 2; | |
} else if (next == 'u'.charCodeAt(0)) { | |
argText = String(unSign(arguments[argIndex], 32)); | |
} | |
argText.split('').forEach(function(chr) { | |
ret.push(chr.charCodeAt(0)); | |
}); | |
argIndex += 1; | |
textIndex += 2; | |
} else if (curr == '%'.charCodeAt(0) && next == 's'.charCodeAt(0)) { | |
ret = ret.concat(String_copy(arguments[argIndex])); | |
argIndex += 1; | |
textIndex += 2; | |
} else if (curr == '%'.charCodeAt(0) && next == 'c'.charCodeAt(0)) { | |
ret = ret.concat(arguments[argIndex]); | |
argIndex += 1; | |
textIndex += 2; | |
} else { | |
ret.push(curr); | |
textIndex += 1; | |
} | |
} | |
return Pointer_make(ret, 0, ALLOC_STACK); // NB: Stored on the stack | |
} | |
// Copies a list of num items on the HEAP into a | |
// a normal JavaScript array of numbers | |
function Array_copy(ptr, num) { | |
return IHEAP.slice(ptr, ptr+num); | |
} | |
// Copies a C-style string, terminated by a zero, from the HEAP into | |
// a normal JavaScript array of numbers | |
function String_copy(ptr, addZero) { | |
return Array_copy(ptr, _strlen(ptr)).concat(addZero ? [0] : []); | |
} | |
// stdlib.h | |
// Get a pointer, return int value of the string it points to | |
function _atoi(s) { | |
return Math.floor(Number(Pointer_stringify(s))); | |
} | |
function _llvm_memcpy_i32(dest, src, num, idunno) { | |
// XXX hardcoded ptr impl | |
for (var i = 0; i < num; i++) { | |
HEAP[dest + i] = HEAP[src + i]; | |
} | |
// dest = Pointer_niceify(dest); | |
// src = Pointer_niceify(src); | |
// dest.slab = src.slab.slice(src.pos); | |
} | |
_llvm_memcpy_i64 = _llvm_memcpy_i32; | |
_llvm_memcpy_p0i8_p0i8_i32 = _llvm_memcpy_i32; | |
function llvm_memset_i32(ptr, value, num) { | |
for (var i = 0; i < num; i++) { | |
HEAP[ptr+i] = value; | |
} | |
} | |
_llvm_memset_p0i8_i64 = _llvm_memset_p0i8_i32 = llvm_memset_i32; | |
function _strlen(ptr) { | |
var i = 0; | |
while (IHEAP[ptr+i] != 0) i++; | |
return i; | |
} | |
// Tools | |
PRINTBUFFER = ''; | |
function __print__(text) { | |
// We print only when we see a '\n', as console JS engines always add | |
// one anyhow. | |
PRINTBUFFER = PRINTBUFFER + text; | |
var endIndex; | |
while ((endIndex = PRINTBUFFER.indexOf('\n')) != -1) { | |
print(PRINTBUFFER.substr(0, endIndex)); | |
PRINTBUFFER = PRINTBUFFER.substr(endIndex + 1); | |
} | |
} | |
function jrint(label, obj) { // XXX manual debugging | |
if (!obj) { | |
obj = label; | |
label = ''; | |
} else | |
label = label + ' : '; | |
print(label + JSON.stringify(obj)); | |
} | |
// This processes a 'normal' string into a C-line array of numbers. | |
// For LLVM-originating strings, see parser.js:parseLLVMString function | |
function intArrayFromString(stringy) { | |
var ret = []; | |
var t; | |
var i = 0; | |
while (i < stringy.length) { | |
ret.push(stringy.charCodeAt(i)); | |
i = i + 1; | |
} | |
ret.push(0); | |
return ret; | |
} | |
// Converts a value we have as signed, into an unsigned value. For | |
// example, -1 in int32 would be a very large number as unsigned. | |
function unSign(value, bits) { | |
if (value >= 0) return value; | |
return 2*Math.abs(1 << (bits-1)) + value; | |
} | |
// === Body === | |
var _0___SIZE = 8; // %0 | |
var _struct__1__pthread_mutex_s___SIZE = 24; // %struct..1__pthread_mutex_s | |
var __struct_std__basic_ios_char_std__char_traits_char_______SIZE = 136; // %"struct.std::basic_ios<char,std::char_traits<char> >" | |
var __struct_std__basic_ios_char_std__char_traits_char_______FLATTENER = [0,112,116,117,120,124,128,132]; | |
var __struct_std__basic_ostream_char_std__char_traits_char_______SIZE = 140; // %"struct.std::basic_ostream<char,std::char_traits<char> >" | |
var __struct_std__basic_streambuf_char_std__char_traits_char_______SIZE = 32; // %"struct.std::basic_streambuf<char,std::char_traits<char> >" | |
var __struct_std__ctype_char_____SIZE = 548; // %"struct.std::ctype<char>" | |
var __struct_std__ctype_char_____FLATTENER = [0,8,12,16,20,24,28,32,288,544]; | |
var __struct_std__ios_base____SIZE = 112; // %"struct.std::ios_base" | |
var __struct_std__ios_base____FLATTENER = [0,4,8,12,16,20,24,28,36,100,104,108]; | |
var __struct_std__ios_base__Init____SIZE = 1; // %"struct.std::ios_base::Init" | |
var __struct_std__ios_base___Callback_list____SIZE = 16; // %"struct.std::ios_base::_Callback_list" | |
var __struct_std__ios_base___Words____SIZE = 8; // %"struct.std::ios_base::_Words" | |
var __struct_std__locale____SIZE = 4; // %"struct.std::locale" | |
var __struct_std__locale___Impl____SIZE = 20; // %"struct.std::locale::_Impl" | |
var __struct_std__locale__facet____SIZE = 8; // %"struct.std::locale::facet" | |
var __struct_std__num_get_char_std__istreambuf_iterator_char__std__char_traits_char_________SIZE = 8; // %"struct.std::num_get<char,std::istreambuf_iterator<char, std::char_traits<char> > >" | |
var _union__0__10___SIZE = 4; // %union..0._10 | |
var _union_pthread_attr_t___SIZE = 36; // %union.pthread_attr_t | |
var _union_pthread_mutex_t___SIZE = 24; // %union.pthread_mutex_t | |
var __ZSt4cout = 0; /* external value? */ | |
var __str; | |
var __str1; | |
var __ZStL8__ioinit; | |
var ___dso_handle = 0; /* external value? */ | |
__globalConstructor__ = function() { | |
__GLOBAL__I_main(); | |
} | |
__ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc = function (stream, data) { | |
__print__(Pointer_stringify(data)); | |
} | |
__ZNSolsEPFRSoS_E = function (stream, data) { | |
__print__('\n'); | |
} | |
__ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_ = 0 | |
__ZNSt8ios_base4InitC1Ev = function () { | |
// need valid 'file descriptors' | |
__ZSt4cout = 1; | |
__ZSt4cerr = 2; | |
} | |
___cxa_atexit = function (func) { | |
__ATEXIT__.push(func); | |
} | |
__ZNSt8ios_base4InitD1Ev = function () { | |
// need valid 'file descriptors' | |
__ZSt4cout = 1; | |
__ZSt4cerr = 2; | |
} | |
// stub for i32 | |
// stub for i8_ | |
// stub for i32 | |
// stub for i32 | |
// stub for i32 | |
// stub for i32 | |
// stub for i32 | |
// stub for i32 | |
// stub for i32 | |
// stub for i32 | |
// stub for i32 | |
// stub for i32 | |
// stub for i32 | |
// stub for i32 | |
function ___tcf_0(_unnamed_arg) { | |
; | |
var __label__; | |
__ZNSt8ios_base4InitD1Ev(__ZStL8__ioinit); | |
; | |
return; | |
} | |
___tcf_0.__index__ = Runtime.getFunctionIndex(___tcf_0, "___tcf_0"); | |
function _main() { | |
; | |
var __label__; | |
var _0 = __ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(__ZSt4cout, __str); | |
var _1 = __ZNSolsEPFRSoS_E(_0, __ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_); | |
var _2 = __ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(__ZSt4cout, __str1); | |
var _3 = __ZNSolsEPFRSoS_E(_2, __ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_); | |
; | |
return 1; | |
} | |
_main.__index__ = Runtime.getFunctionIndex(_main, "_main"); | |
function __GLOBAL__I_main() { | |
; | |
var __label__; | |
__ZNSt8ios_base4InitC1Ev(__ZStL8__ioinit); | |
var _0 = ___cxa_atexit(___tcf_0.__index__, 0, ___dso_handle); | |
; | |
return; | |
} | |
__GLOBAL__I_main.__index__ = Runtime.getFunctionIndex(__GLOBAL__I_main, "__GLOBAL__I_main"); | |
// === Auto-generated postamble setup entry stuff === | |
function run(args) { | |
__initializeRuntime__(); | |
var globalFuncs = []; | |
globalFuncs.push(function() { __ZStL8__ioinit = Pointer_make([0], 0, ALLOC_STATIC) }); | |
globalFuncs.push(function() { __str1 = Pointer_make([87,101,108,99,111,109,101,32,116,111,32,67,43,43,32,80,114,111,103,114,97,109,109,105,110,103,0] /* Welcome to C++ Programming\00*/, 0, ALLOC_STATIC) }); | |
globalFuncs.push(function() { __str = Pointer_make([72,101,108,108,111,32,87,111,114,108,100,33,0] /* Hello World!\00*/, 0, ALLOC_STATIC) }); | |
var counter = Math.pow(globalFuncs.length,2)+1; | |
while (globalFuncs.length > 0 && counter >= 0) { | |
counter--; | |
var func = globalFuncs.pop(); | |
try { | |
func(); | |
} catch (e) { | |
globalFuncs.unshift(func); | |
// We will try again later. The global vars we depend on should be resolved by then | |
// XXX: We leak here, as we malloc, then fail and catch... | |
} | |
} | |
var argc = args.length+1; | |
function pad() { | |
for (var i = 0; i < 4-1; i++) { | |
argv.push(0); | |
} | |
} | |
var argv = [Pointer_make(intArrayFromString("/bin/this.program"), null) ]; | |
pad(); | |
for (var i = 0; i < argc-1; i = i + 1) { | |
argv.push(Pointer_make(intArrayFromString(args[i]), null)); | |
pad(); | |
} | |
argv = Pointer_make(argv, null); | |
__globalConstructor__(); | |
if (Module['_main']) { | |
_main(argc, argv); | |
__shutdownRuntime__(); | |
} | |
} | |
run(args); | |
// {{MODULE_ADDITIONS}} | |
// return Module; | |
//})({}, this.arguments); // Replace parameters as needed | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; ModuleID = 'HelloWorld.bc' | |
target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:32:32-n8:16:32" | |
target triple = "i386-pc-linux-gnu" | |
%0 = type { i32, void ()* } | |
%struct..1__pthread_mutex_s = type { i32, i32, i32, i32, i32, %union..0._10 } | |
%"struct.std::basic_ios<char,std::char_traits<char> >" = type { %"struct.std::ios_base", %"struct.std::basic_ostream<char,std::char_traits<char> >"*, i8, i8, %"struct.std::basic_streambuf<char,std::char_traits<char> >"*, %"struct.std::ctype<char>"*, %"struct.std::num_get<char,std::istreambuf_iterator<char, std::char_traits<char> > >"*, %"struct.std::num_get<char,std::istreambuf_iterator<char, std::char_traits<char> > >"* } | |
%"struct.std::basic_ostream<char,std::char_traits<char> >" = type { i32 (...)**, %"struct.std::basic_ios<char,std::char_traits<char> >" } | |
%"struct.std::basic_streambuf<char,std::char_traits<char> >" = type { i32 (...)**, i8*, i8*, i8*, i8*, i8*, i8*, %"struct.std::locale" } | |
%"struct.std::ctype<char>" = type { %"struct.std::locale::facet", i32*, i8, i32*, i32*, i16*, i8, [256 x i8], [256 x i8], i8 } | |
%"struct.std::ios_base" = type { i32 (...)**, i32, i32, i32, i32, i32, %"struct.std::ios_base::_Callback_list"*, %"struct.std::ios_base::_Words", [8 x %"struct.std::ios_base::_Words"], i32, %"struct.std::ios_base::_Words"*, %"struct.std::locale" } | |
%"struct.std::ios_base::Init" = type <{ i8 }> | |
%"struct.std::ios_base::_Callback_list" = type { %"struct.std::ios_base::_Callback_list"*, void (i32, %"struct.std::ios_base"*, i32)*, i32, i32 } | |
%"struct.std::ios_base::_Words" = type { i8*, i32 } | |
%"struct.std::locale" = type { %"struct.std::locale::_Impl"* } | |
%"struct.std::locale::_Impl" = type { i32, %"struct.std::locale::facet"**, i32, %"struct.std::locale::facet"**, i8** } | |
%"struct.std::locale::facet" = type { i32 (...)**, i32 } | |
%"struct.std::num_get<char,std::istreambuf_iterator<char, std::char_traits<char> > >" = type { %"struct.std::locale::facet" } | |
%union..0._10 = type { i32 } | |
%union.pthread_attr_t = type { i32, [8 x i32] } | |
%union.pthread_mutex_t = type { %struct..1__pthread_mutex_s } | |
@_ZSt4cout = external global %"struct.std::basic_ostream<char,std::char_traits<char> >" ; [#uses=2] | |
@.str = private constant [13 x i8] c"Hello World!\00", align 1 ; [#uses=1] | |
@.str1 = private constant [27 x i8] c"Welcome to C++ Programming\00", align 1 ; [#uses=1] | |
@_ZStL8__ioinit = internal global %"struct.std::ios_base::Init" zeroinitializer ; [#uses=2] | |
@__dso_handle = external global i8* ; [#uses=1] | |
@llvm.global_ctors = appending global [1 x %0] [%0 { i32 65535, void ()* @_GLOBAL__I_main }] ; [#uses=0] | |
@_ZL20__gthrw_pthread_oncePiPFvvE = alias weak i32 (i32*, void ()*)* @pthread_once ; [#uses=0] | |
@_ZL27__gthrw_pthread_getspecificj = alias weak i8* (i32)* @pthread_getspecific ; [#uses=0] | |
@_ZL27__gthrw_pthread_setspecificjPKv = alias weak i32 (i32, i8*)* @pthread_setspecific ; [#uses=0] | |
@_ZL22__gthrw_pthread_createPmPK14pthread_attr_tPFPvS3_ES3_ = alias weak i32 (i32*, %union.pthread_attr_t*, i8* (i8*)*, i8*)* @pthread_create ; [#uses=0] | |
@_ZL22__gthrw_pthread_cancelm = alias weak i32 (i32)* @pthread_cancel ; [#uses=0] | |
@_ZL26__gthrw_pthread_mutex_lockP15pthread_mutex_t = alias weak i32 (%union.pthread_mutex_t*)* @pthread_mutex_lock ; [#uses=0] | |
@_ZL29__gthrw_pthread_mutex_trylockP15pthread_mutex_t = alias weak i32 (%union.pthread_mutex_t*)* @pthread_mutex_trylock ; [#uses=0] | |
@_ZL28__gthrw_pthread_mutex_unlockP15pthread_mutex_t = alias weak i32 (%union.pthread_mutex_t*)* @pthread_mutex_unlock ; [#uses=0] | |
@_ZL26__gthrw_pthread_mutex_initP15pthread_mutex_tPK19pthread_mutexattr_t = alias weak i32 (%union.pthread_mutex_t*, %union..0._10*)* @pthread_mutex_init ; [#uses=0] | |
@_ZL26__gthrw_pthread_key_createPjPFvPvE = alias weak i32 (i32*, void (i8*)*)* @pthread_key_create ; [#uses=0] | |
@_ZL26__gthrw_pthread_key_deletej = alias weak i32 (i32)* @pthread_key_delete ; [#uses=0] | |
@_ZL30__gthrw_pthread_mutexattr_initP19pthread_mutexattr_t = alias weak i32 (%union..0._10*)* @pthread_mutexattr_init ; [#uses=0] | |
@_ZL33__gthrw_pthread_mutexattr_settypeP19pthread_mutexattr_ti = alias weak i32 (%union..0._10*, i32)* @pthread_mutexattr_settype ; [#uses=0] | |
@_ZL33__gthrw_pthread_mutexattr_destroyP19pthread_mutexattr_t = alias weak i32 (%union..0._10*)* @pthread_mutexattr_destroy ; [#uses=0] | |
; [#uses=0] | |
define i32 @main() { | |
entry: | |
%0 = tail call %"struct.std::basic_ostream<char,std::char_traits<char> >"* @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(%"struct.std::basic_ostream<char,std::char_traits<char> >"* @_ZSt4cout, i8* getelementptr inbounds ([13 x i8]* @.str, i32 0, i32 0)) ; [#uses=1] | |
%1 = tail call %"struct.std::basic_ostream<char,std::char_traits<char> >"* @_ZNSolsEPFRSoS_E(%"struct.std::basic_ostream<char,std::char_traits<char> >"* %0, %"struct.std::basic_ostream<char,std::char_traits<char> >"* (%"struct.std::basic_ostream<char,std::char_traits<char> >"*)* @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_) ; [#uses=0] | |
%2 = tail call %"struct.std::basic_ostream<char,std::char_traits<char> >"* @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(%"struct.std::basic_ostream<char,std::char_traits<char> >"* @_ZSt4cout, i8* getelementptr inbounds ([27 x i8]* @.str1, i32 0, i32 0)) ; [#uses=1] | |
%3 = tail call %"struct.std::basic_ostream<char,std::char_traits<char> >"* @_ZNSolsEPFRSoS_E(%"struct.std::basic_ostream<char,std::char_traits<char> >"* %2, %"struct.std::basic_ostream<char,std::char_traits<char> >"* (%"struct.std::basic_ostream<char,std::char_traits<char> >"*)* @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_) ; [#uses=0] | |
ret i32 1 | |
} | |
; [#uses=1] | |
define internal void @_GLOBAL__I_main() { | |
entry: | |
tail call void @_ZNSt8ios_base4InitC1Ev(%"struct.std::ios_base::Init"* @_ZStL8__ioinit) | |
%0 = tail call i32 @__cxa_atexit(void (i8*)* @__tcf_0, i8* null, i8* bitcast (i8** @__dso_handle to i8*)) nounwind ; [#uses=0] | |
ret void | |
} | |
; [#uses=2] | |
declare %"struct.std::basic_ostream<char,std::char_traits<char> >"* @_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc(%"struct.std::basic_ostream<char,std::char_traits<char> >"*, i8*) | |
; [#uses=2] | |
declare %"struct.std::basic_ostream<char,std::char_traits<char> >"* @_ZNSolsEPFRSoS_E(%"struct.std::basic_ostream<char,std::char_traits<char> >"*, %"struct.std::basic_ostream<char,std::char_traits<char> >"* (%"struct.std::basic_ostream<char,std::char_traits<char> >"*)*) | |
; [#uses=2] | |
declare %"struct.std::basic_ostream<char,std::char_traits<char> >"* @_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_(%"struct.std::basic_ostream<char,std::char_traits<char> >"*) | |
; [#uses=1] | |
declare void @_ZNSt8ios_base4InitC1Ev(%"struct.std::ios_base::Init"*) | |
; [#uses=1] | |
declare i32 @__cxa_atexit(void (i8*)*, i8*, i8*) nounwind | |
; [#uses=1] | |
define internal void @__tcf_0(i8* nocapture %unnamed_arg) { | |
entry: | |
tail call void @_ZNSt8ios_base4InitD1Ev(%"struct.std::ios_base::Init"* @_ZStL8__ioinit) | |
ret void | |
} | |
; [#uses=1] | |
declare void @_ZNSt8ios_base4InitD1Ev(%"struct.std::ios_base::Init"*) | |
; [#uses=1] | |
declare extern_weak i32 @pthread_once(i32*, void ()*) | |
; [#uses=1] | |
declare extern_weak i8* @pthread_getspecific(i32) | |
; [#uses=1] | |
declare extern_weak i32 @pthread_setspecific(i32, i8*) | |
; [#uses=1] | |
declare extern_weak i32 @pthread_create(i32*, %union.pthread_attr_t*, i8* (i8*)*, i8*) | |
; [#uses=1] | |
declare extern_weak i32 @pthread_cancel(i32) | |
; [#uses=1] | |
declare extern_weak i32 @pthread_mutex_lock(%union.pthread_mutex_t*) | |
; [#uses=1] | |
declare extern_weak i32 @pthread_mutex_trylock(%union.pthread_mutex_t*) | |
; [#uses=1] | |
declare extern_weak i32 @pthread_mutex_unlock(%union.pthread_mutex_t*) | |
; [#uses=1] | |
declare extern_weak i32 @pthread_mutex_init(%union.pthread_mutex_t*, %union..0._10*) | |
; [#uses=1] | |
declare extern_weak i32 @pthread_key_create(i32*, void (i8*)*) | |
; [#uses=1] | |
declare extern_weak i32 @pthread_key_delete(i32) | |
; [#uses=1] | |
declare extern_weak i32 @pthread_mutexattr_init(%union..0._10*) | |
; [#uses=1] | |
declare extern_weak i32 @pthread_mutexattr_settype(%union..0._10*, i32) | |
; [#uses=1] | |
declare extern_weak i32 @pthread_mutexattr_destroy(%union..0._10*) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment