#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int EOF;
char *cleanup_assembly(char *);
scalar_t__ create_asm(char *, unsigned char const *, unsigned long,
                      unsigned long);
scalar_t__ create_gdb_commands(char *, unsigned long);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ free(char *);
int getc(int /*<<< orphan*/ *);
scalar_t__ malloc(unsigned long);
int /*<<< orphan*/ pclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *popen(char *, char *);
int /*<<< orphan*/ putc(char, int /*<<< orphan*/);
scalar_t__ realloc(char *, unsigned long);
int /*<<< orphan*/ remove(char *);
int sscanf(char *, char *, unsigned long *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ strncmp(char *, char *, int);
scalar_t__ system(char *);
char *disasm(const unsigned char *mem, unsigned long num_bytes,
             unsigned long starting_address) {
  FILE *gdb_fp;
  char *buf;
  unsigned long size, max_size;
  int c;
  if (create_asm("/tmp/bytes.s", mem, num_bytes, starting_address))
    return NULL;
  if (system("gcc -b i486-linuxaout -g -c /tmp/bytes.s -o /tmp/bytes.o"))
    return NULL;
  if (create_gdb_commands("/tmp/gdbcmds", num_bytes))
    return NULL;
  gdb_fp = popen("gdb -nx -batch -cd /tmp -x gdbcmds bytes.o", "r");
  if (gdb_fp == NULL) {
    fprintf(stderr, "Problems executing gdb.\n");
    return NULL;
  }
  max_size = 1024;
  buf = (char *)malloc(max_size);
  while ((c = getc(gdb_fp)) != EOF && c != '\n')
    ;
  for (size = 0; (c = getc(gdb_fp)) != EOF; size++) {
    if (size >= max_size - 1) {
      if (max_size >= 4 * 1024 * 1024)
        max_size += 4 * 1024 * 1024;
      else
        max_size *= 2;
      buf = (char *)realloc(buf, max_size);
      if (buf == NULL) {
        fprintf(stderr, "Virtual memory exhausted!\n");
        exit(-100);
      }
    }
    buf[size] = c;
  }
  pclose(gdb_fp);
  if (size >= (sizeof("End of assembler dump.\n") - 1) &&
      !strncmp(buf + size - (sizeof("End of assembler dump.\n") - 1),
               "End of assembler dump.\n",
               (sizeof("End of assembler dump.\n") - 1)))
    size -= (sizeof("End of assembler dump.\n") - 1);
  buf[size] = '\0';
  buf = (char *)realloc(buf, size + 1);
  if (buf == NULL) {
    fprintf(stderr, "realloc problem!\n");
    exit(-102);
  }
  remove("/tmp/disassembly");
  remove("/tmp/gdbcmds");
  remove("/tmp/bytes.s");
  remove("/tmp/bytes");
  if (size > 2) {
    unsigned long first_addr;
    if (buf[0] != '0' || buf[1] != 'x' ||
        sscanf(buf + 2, "%lx", &first_addr) != 1) {
      int i;
      fprintf(stderr, "Unable to verify first address!  First line:\n");
      for (i = 0; buf[i] != '\n' && buf[i] != '\0'; i++)
        putc(buf[i], stderr);
      putc('\n', stderr);
      free(buf);
      return NULL;
    }
    if (first_addr != starting_address) {
      fprintf(stderr,
              "Internal error: wanted to start code at 0x%lX, "
              "but started it at 0x%lX.\n",
              starting_address, first_addr);
      free(buf);
      return NULL;
    }
  }
  return cleanup_assembly(buf);
}


x86 assembly (clang, -O0):
<disasm>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rcx
lea    0xdd9(%rip),%rdi
call   10c0 <create_asm@plt>
cmp    $0x0,%rax
je     1243 <disasm+0x43>
movq   $0x0,-0x8(%rbp)
jmp    1606 <disasm+0x406>
lea    0xdc3(%rip),%rdi
call   1070 <system@plt>
cmp    $0x0,%rax
je     1266 <disasm+0x66>
movq   $0x0,-0x8(%rbp)
jmp    1606 <disasm+0x406>
mov    -0x18(%rbp),%rsi
lea    0xdd5(%rip),%rdi
call   10b0 <create_gdb_commands@plt>
cmp    $0x0,%rax
je     128d <disasm+0x8d>
movq   $0x0,-0x8(%rbp)
jmp    1606 <disasm+0x406>
lea    0xdbf(%rip),%rdi
lea    0xde3(%rip),%rsi
call   1100 <popen@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    12d3 <disasm+0xd3>
mov    0x2d22(%rip),%rax
mov    (%rax),%edi
lea    0xdc1(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
movq   $0x0,-0x8(%rbp)
jmp    1606 <disasm+0x406>
movq   $0x400,-0x40(%rbp)
mov    -0x40(%rbp),%rdi
call   10d0 <malloc@plt>
mov    %rax,-0x30(%rbp)
mov    -0x28(%rbp),%rdi
call   1120 <getc@plt>
mov    %eax,%ecx
mov    %ecx,-0x44(%rbp)
xor    %eax,%eax
mov    0x2ce9(%rip),%rdx
cmp    (%rdx),%ecx
mov    %al,-0x55(%rbp)
je     1314 <disasm+0x114>
cmpl   $0xa,-0x44(%rbp)
setne  %al
mov    %al,-0x55(%rbp)
mov    -0x55(%rbp),%al
test   $0x1,%al
jne    1324 <disasm+0x124>
jmp    1329 <disasm+0x129>
jmp    12e8 <disasm+0xe8>
movq   $0x0,-0x38(%rbp)
mov    -0x28(%rbp),%rdi
call   1120 <getc@plt>
mov    %eax,-0x44(%rbp)
mov    0x2ca4(%rip),%rcx
cmp    (%rcx),%eax
je     13f1 <disasm+0x1f1>
mov    -0x38(%rbp),%rax
mov    -0x40(%rbp),%rcx
sub    $0x1,%rcx
cmp    %rcx,%rax
jb     13d0 <disasm+0x1d0>
cmpq   $0x400000,-0x40(%rbp)
jb     1382 <disasm+0x182>
mov    -0x40(%rbp),%rax
add    $0x400000,%rax
mov    %rax,-0x40(%rbp)
jmp    138e <disasm+0x18e>
mov    -0x40(%rbp),%rax
shl    $0x1,%rax
mov    %rax,-0x40(%rbp)
mov    -0x30(%rbp),%rdi
mov    -0x40(%rbp),%rsi
call   10f0 <realloc@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    13cb <disasm+0x1cb>
mov    0x2c27(%rip),%rax
mov    (%rax),%edi
lea    0xcdf(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
mov    $0xffffff9c,%edi
call   1110 <exit@plt>
jmp    13d0 <disasm+0x1d0>
mov    -0x44(%rbp),%eax
mov    %al,%dl
mov    -0x30(%rbp),%rax
mov    -0x38(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x38(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x38(%rbp)
jmp    1331 <disasm+0x131>
mov    -0x28(%rbp),%rdi
call   1080 <pclose@plt>
cmpq   $0x17,-0x38(%rbp)
jb     1437 <disasm+0x237>
mov    -0x30(%rbp),%rdi
add    -0x38(%rbp),%rdi
add    $0xffffffffffffffe9,%rdi
lea    0xc9c(%rip),%rsi
mov    $0x17,%edx
call   1050 <strncmp@plt>
cmp    $0x0,%eax
jne    1437 <disasm+0x237>
mov    -0x38(%rbp),%rax
sub    $0x17,%rax
mov    %rax,-0x38(%rbp)
mov    -0x30(%rbp),%rax
mov    -0x38(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x30(%rbp),%rdi
mov    -0x38(%rbp),%rsi
add    $0x1,%rsi
call   10f0 <realloc@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    1484 <disasm+0x284>
mov    0x2b6e(%rip),%rax
mov    (%rax),%edi
lea    0xc59(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
mov    $0xffffff9a,%edi
call   1110 <exit@plt>
lea    0xc53(%rip),%rdi
call   1040 <remove@plt>
lea    0xbaf(%rip),%rdi
call   1040 <remove@plt>
lea    0xb5d(%rip),%rdi
call   1040 <remove@plt>
lea    0xc40(%rip),%rdi
call   1040 <remove@plt>
cmpq   $0x2,-0x38(%rbp)
jbe    15f9 <disasm+0x3f9>
mov    -0x30(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x30,%eax
jne    1501 <disasm+0x301>
mov    -0x30(%rbp),%rax
movsbl 0x1(%rax),%eax
cmp    $0x78,%eax
jne    1501 <disasm+0x301>
mov    -0x30(%rbp),%rdi
add    $0x2,%rdi
lea    0xc0b(%rip),%rsi
lea    -0x50(%rbp),%rdx
call   10e0 <sscanf@plt>
cmp    $0x1,%eax
je     15b1 <disasm+0x3b1>
mov    0x2ad0(%rip),%rax
mov    (%rax),%edi
lea    0xbed(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
movl   $0x0,-0x54(%rbp)
mov    -0x30(%rbp),%rax
movslq -0x54(%rbp),%rcx
movsbl (%rax,%rcx,1),%ecx
xor    %eax,%eax
cmp    $0xa,%ecx
mov    %al,-0x56(%rbp)
je     154e <disasm+0x34e>
mov    -0x30(%rbp),%rax
movslq -0x54(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x0,%eax
setne  %al
mov    %al,-0x56(%rbp)
mov    -0x56(%rbp),%al
test   $0x1,%al
jne    155e <disasm+0x35e>
jmp    1588 <disasm+0x388>
mov    -0x30(%rbp),%rax
movslq -0x54(%rbp),%rcx
mov    (%rax,%rcx,1),%al
mov    0x2a68(%rip),%rcx
mov    (%rcx),%esi
movsbl %al,%edi
call   1090 <putc@plt>
mov    -0x54(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x54(%rbp)
jmp    151f <disasm+0x31f>
mov    0x2a49(%rip),%rax
mov    (%rax),%esi
mov    $0xa,%edi
call   1090 <putc@plt>
mov    -0x30(%rbp),%rdi
call   1030 <free@plt>
movq   $0x0,-0x8(%rbp)
jmp    1606 <disasm+0x406>
mov    -0x50(%rbp),%rax
cmp    -0x20(%rbp),%rax
je     15f4 <disasm+0x3f4>
mov    0x2a12(%rip),%rax
mov    (%rax),%edi
mov    -0x20(%rbp),%rdx
mov    -0x50(%rbp),%rcx
lea    0xb55(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
mov    -0x30(%rbp),%rdi
call   1030 <free@plt>
movq   $0x0,-0x8(%rbp)
jmp    1606 <disasm+0x406>
jmp    15f9 <disasm+0x3f9>
mov    -0x30(%rbp),%rdi
call   1060 <cleanup_assembly@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<disasm>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rdx,%r13
mov    %rsi,%rbx
mov    %rdi,%rsi
lea    0xde2(%rip),%rdi
mov    %rbx,%rdx
mov    %r13,%rcx
call   10c0 <create_asm@plt>
test   %rax,%rax
jne    1253 <disasm+0x53>
lea    0xdd8(%rip),%rdi
call   1070 <system@plt>
test   %rax,%rax
jne    1253 <disasm+0x53>
lea    0xe00(%rip),%rdi
mov    %rbx,%rsi
call   10b0 <create_gdb_commands@plt>
test   %rax,%rax
je     1267 <disasm+0x67>
xor    %ebp,%ebp
mov    %rbp,%rax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xde5(%rip),%rdi
lea    0xe09(%rip),%rsi
call   1100 <popen@plt>
test   %rax,%rax
je     12cc <disasm+0xcc>
mov    %rax,%r12
mov    $0x400,%edi
call   10d0 <malloc@plt>
mov    %rax,%r15
mov    0x2d52(%rip),%rbx
cs nopw 0x0(%rax,%rax,1)
mov    %r12,%rdi
call   1120 <getc@plt>
cmp    $0xa,%eax
je     12b1 <disasm+0xb1>
cmp    (%rbx),%eax
jne    12a0 <disasm+0xa0>
mov    %r12,%rdi
call   1120 <getc@plt>
cmp    (%rbx),%eax
jne    12ea <disasm+0xea>
mov    %r12,%rdi
call   1080 <pclose@plt>
xor    %ebp,%ebp
jmp    13ab <disasm+0x1ab>
mov    0x2d05(%rip),%rax
mov    (%rax),%edi
lea    0xda4(%rip),%rsi
xor    %ebp,%ebp
xor    %eax,%eax
call   10a0 <fprintf@plt>
jmp    1255 <disasm+0x55>
mov    %eax,%ebp
mov    %r13,0x8(%rsp)
mov    $0x400,%r13d
mov    $0xffffffffffffffe9,%r14
jmp    1317 <disasm+0x117>
mov    %bpl,0x17(%r15,%r14,1)
mov    %r12,%rdi
call   1120 <getc@plt>
mov    %eax,%ebp
add    $0x1,%r14
cmp    (%rbx),%eax
je     1379 <disasm+0x179>
lea    0x17(%r14),%rax
lea    -0x1(%r13),%rcx
cmp    %rcx,%rax
jb     1300 <disasm+0x100>
lea    0x400000(%r13),%rax
mov    %r15,%rdi
mov    %rbx,%r15
mov    %r13,%rbx
add    %r13,%rbx
cmp    $0x400000,%r13
cmovae %rax,%rbx
mov    %rbx,%rsi
call   10f0 <realloc@plt>
mov    %rbx,%r13
mov    %r15,%rbx
mov    %rax,%r15
test   %rax,%rax
jne    1300 <disasm+0x100>
mov    0x2c79(%rip),%rax
mov    (%rax),%edi
lea    0xd31(%rip),%rsi
xor    %eax,%eax
call   10a0 <fprintf@plt>
mov    $0xffffff9c,%edi
call   1110 <exit@plt>
mov    %r12,%rdi
call   1080 <pclose@plt>
lea    0x17(%r14),%rbp
cmp    $0x17,%rbp
mov    0x8(%rsp),%r13
jb     13ab <disasm+0x1ab>
lea    (%r15,%r14,1),%rdi
lea    0xd19(%rip),%rsi
mov    $0x17,%edx
call   1050 <strncmp@plt>
test   %eax,%eax
cmove  %r14,%rbp
movb   $0x0,(%r15,%rbp,1)
lea    0x1(%rbp),%rsi
mov    %r15,%rdi
call   10f0 <realloc@plt>
test   %rax,%rax
je     14bf <disasm+0x2bf>
mov    %rax,%r14
lea    0xd0f(%rip),%rdi
call   1040 <remove@plt>
lea    0xc6b(%rip),%rdi
call   1040 <remove@plt>
lea    0xc19(%rip),%rdi
call   1040 <remove@plt>
lea    0xcfc(%rip),%rdi
call   1040 <remove@plt>
cmp    $0x3,%rbp
jb     1432 <disasm+0x232>
cmpb   $0x30,(%r14)
jne    1442 <disasm+0x242>
cmpb   $0x78,0x1(%r14)
jne    1442 <disasm+0x242>
mov    %r14,%rdi
add    $0x2,%rdi
lea    0xce1(%rip),%rsi
lea    0x10(%rsp),%rdx
call   10e0 <sscanf@plt>
cmp    $0x1,%eax
jne    1442 <disasm+0x242>
mov    0x10(%rsp),%rcx
cmp    %r13,%rcx
jne    1496 <disasm+0x296>
mov    %r14,%rdi
call   1060 <cleanup_assembly@plt>
mov    %rax,%rbp
jmp    1255 <disasm+0x55>
mov    0x2b8f(%rip),%rbp
mov    0x0(%rbp),%edi
lea    0xcab(%rip),%rsi
xor    %eax,%eax
call   10a0 <fprintf@plt>
mov    %r14,%rbx
nopl   (%rax)
movzbl (%rbx),%eax
test   %al,%al
je     147c <disasm+0x27c>
cmp    $0xa,%al
je     147c <disasm+0x27c>
mov    0x0(%rbp),%esi
movsbl %al,%edi
call   1090 <putc@plt>
add    $0x1,%rbx
jmp    1460 <disasm+0x260>
mov    0x0(%rbp),%esi
mov    $0xa,%edi
call   1090 <putc@plt>
mov    %r14,%rdi
call   1030 <free@plt>
jmp    1253 <disasm+0x53>
mov    0x2b3b(%rip),%rax
mov    (%rax),%edi
lea    0xc86(%rip),%rsi
xor    %ebp,%ebp
mov    %r13,%rdx
xor    %eax,%eax
call   10a0 <fprintf@plt>
mov    %r14,%rdi
call   1030 <free@plt>
jmp    1255 <disasm+0x55>
mov    0x2b12(%rip),%rax
mov    (%rax),%edi
lea    0xbfd(%rip),%rsi
xor    %eax,%eax
call   10a0 <fprintf@plt>
mov    $0xffffff9a,%edi
call   1110 <exit@plt>

LLVM IR (-O0):
@.str = [13 x i8] c"/tmp/bytes.s\00"
@.str.1 = [57 x i8] c"gcc -b i486-linuxaout -g -c /tmp/bytes.s -o /tmp/bytes.o\00"
@.str.2 = [13 x i8] c"/tmp/gdbcmds\00"
@.str.3 = [43 x i8] c"gdb -nx -batch -cd /tmp -x gdbcmds bytes.o\00"
@.str.4 = [2 x i8] c"r\00"
@stderr = global i32 0
@.str.5 = [25 x i8] c"Problems executing gdb.\0A\00"
@EOF = global i32 0
@.str.6 = [27 x i8] c"Virtual memory exhausted!\0A\00"
@.str.7 = [24 x i8] c"End of assembler dump.\0A\00"
@.str.8 = [18 x i8] c"realloc problem!\0A\00"
@.str.9 = [17 x i8] c"/tmp/disassembly\00"
@.str.10 = [11 x i8] c"/tmp/bytes\00"
@.str.11 = [4 x i8] c"%lx\00"
@.str.12 = [46 x i8] c"Unable to verify first address! First line:\0A\00"
@.str.13 = [73 x i8] c"Internal error: wanted to start code at 0x%lX, but started it at 0x%lX.\0A\00"
define i8* @disasm(i8* %0, i64 %1, i64 %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i64
%7 = alloca i64
%8 = alloca i32*
%9 = alloca i8*
%10 = alloca i64
%11 = alloca i64
%12 = alloca i32
%13 = alloca i64
%14 = alloca i32
store i8* %0, i8** %5
store i64 %1, i64* %6
store i64 %2, i64* %7
%15 = load i8*, i8** %5
%16 = load i64, i64* %6
%17 = load i64, i64* %7
%18 = call i64 @create_asm(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* %15, i64 %16, i64 %17)
%19 = icmp ne i64 %18, 0
br i1 %19, label %20, label %21
20: ; preds = %3
store i8* null, i8** %4
br label %199
21: ; preds = %3
%22 = call i64 @system(i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str.1, i64 0, i64 0))
%23 = icmp ne i64 %22, 0
br i1 %23, label %24, label %25
24: ; preds = %21
store i8* null, i8** %4
br label %199
25: ; preds = %21
%26 = load i64, i64* %6
%27 = call i64 @create_gdb_commands(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i64 %26)
%28 = icmp ne i64 %27, 0
br i1 %28, label %29, label %30
29: ; preds = %25
store i8* null, i8** %4
br label %199
30: ; preds = %25
%31 = call i32* @popen(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
store i32* %31, i32** %8
%32 = load i32*, i32** %8
%33 = icmp eq i32* %32, null
br i1 %33, label %34, label %37
34: ; preds = %30
%35 = load i32, i32* @stderr
%36 = call i32 (i32, i8*, ...) @fprintf(i32 %35, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.5, i64 0, i64 0))
store i8* null, i8** %4
br label %199
37: ; preds = %30
store i64 1024, i64* %11
%38 = load i64, i64* %11
%39 = call i64 @malloc(i64 %38)
%40 = inttoptr i64 %39 to i8*
store i8* %40, i8** %9
br label %41
41: ; preds = %51, %37
%42 = load i32*, i32** %8
%43 = call i32 @getc(i32* %42)
store i32 %43, i32* %12
%44 = load i32, i32* @EOF
%45 = icmp ne i32 %43, %44
br i1 %45, label %46, label %49
46: ; preds = %41
%47 = load i32, i32* %12
%48 = icmp ne i32 %47, 10
br label %49
49: ; preds = %46, %41
%50 = phi i1 [ false, %41 ], [ %48, %46 ]
br i1 %50, label %51, label %52
51: ; preds = %49
br label %41
52: ; preds = %49
store i64 0, i64* %10
br label %53
53: ; preds = %90, %52
%54 = load i32*, i32** %8
%55 = call i32 @getc(i32* %54)
store i32 %55, i32* %12
%56 = load i32, i32* @EOF
%57 = icmp ne i32 %55, %56
br i1 %57, label %58, label %93
58: ; preds = %53
%59 = load i64, i64* %10
%60 = load i64, i64* %11
%61 = sub i64 %60, 1
%62 = icmp uge i64 %59, %61
br i1 %62, label %63, label %84
63: ; preds = %58
%64 = load i64, i64* %11
%65 = icmp uge i64 %64, 4194304
br i1 %65, label %66, label %69
66: ; preds = %63
%67 = load i64, i64* %11
%68 = add i64 %67, 4194304
store i64 %68, i64* %11
br label %72
69: ; preds = %63
%70 = load i64, i64* %11
%71 = mul i64 %70, 2
store i64 %71, i64* %11
br label %72
72: ; preds = %69, %66
%73 = load i8*, i8** %9
%74 = load i64, i64* %11
%75 = call i64 @realloc(i8* %73, i64 %74)
%76 = inttoptr i64 %75 to i8*
store i8* %76, i8** %9
%77 = load i8*, i8** %9
%78 = icmp eq i8* %77, null
br i1 %78, label %79, label %83
79: ; preds = %72
%80 = load i32, i32* @stderr
%81 = call i32 (i32, i8*, ...) @fprintf(i32 %80, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.6, i64 0, i64 0))
%82 = call i32 @exit(i32 -100)
unreachable
83: ; preds = %72
br label %84
84: ; preds = %83, %58
%85 = load i32, i32* %12
%86 = trunc i32 %85 to i8
%87 = load i8*, i8** %9
%88 = load i64, i64* %10
%89 = getelementptr inbounds i8, i8* %87, i64 %88
store i8 %86, i8* %89
br label %90
90: ; preds = %84
%91 = load i64, i64* %10
%92 = add i64 %91, 1
store i64 %92, i64* %10
br label %53
93: ; preds = %53
%94 = load i32*, i32** %8
%95 = call i32 @pclose(i32* %94)
%96 = load i64, i64* %10
%97 = icmp uge i64 %96, 23
br i1 %97, label %98, label %108
98: ; preds = %93
%99 = load i8*, i8** %9
%100 = load i64, i64* %10
%101 = getelementptr inbounds i8, i8* %99, i64 %100
%102 = getelementptr inbounds i8, i8* %101, i64 -23
%103 = call i32 @strncmp(i8* %102, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.7, i64 0, i64 0), i32 23)
%104 = icmp ne i32 %103, 0
br i1 %104, label %108, label %105
105: ; preds = %98
%106 = load i64, i64* %10
%107 = sub i64 %106, 23
store i64 %107, i64* %10
br label %108
108: ; preds = %105, %98, %93
%109 = load i8*, i8** %9
%110 = load i64, i64* %10
%111 = getelementptr inbounds i8, i8* %109, i64 %110
store i8 0, i8* %111
%112 = load i8*, i8** %9
%113 = load i64, i64* %10
%114 = add i64 %113, 1
%115 = call i64 @realloc(i8* %112, i64 %114)
%116 = inttoptr i64 %115 to i8*
store i8* %116, i8** %9
%117 = load i8*, i8** %9
%118 = icmp eq i8* %117, null
br i1 %118, label %119, label %123
119: ; preds = %108
%120 = load i32, i32* @stderr
%121 = call i32 (i32, i8*, ...) @fprintf(i32 %120, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.8, i64 0, i64 0))
%122 = call i32 @exit(i32 -102)
unreachable
123: ; preds = %108
%124 = call i32 @remove(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.9, i64 0, i64 0))
%125 = call i32 @remove(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0))
%126 = call i32 @remove(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
%127 = call i32 @remove(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.10, i64 0, i64 0))
%128 = load i64, i64* %10
%129 = icmp ugt i64 %128, 2
br i1 %129, label %130, label %196
130: ; preds = %123
%131 = load i8*, i8** %9
%132 = getelementptr inbounds i8, i8* %131, i64 0
%133 = load i8, i8* %132
%134 = sext i8 %133 to i32
%135 = icmp ne i32 %134, 48
br i1 %135, label %147, label %136
136: ; preds = %130
%137 = load i8*, i8** %9
%138 = getelementptr inbounds i8, i8* %137, i64 1
%139 = load i8, i8* %138
%140 = sext i8 %139 to i32
%141 = icmp ne i32 %140, 120
br i1 %141, label %147, label %142
142: ; preds = %136
%143 = load i8*, i8** %9
%144 = getelementptr inbounds i8, i8* %143, i64 2
%145 = call i32 @sscanf(i8* %144, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.11, i64 0, i64 0), i64* %13)
%146 = icmp ne i32 %145, 1
br i1 %146, label %147, label %184
147: ; preds = %142, %136, %130
%148 = load i32, i32* @stderr
%149 = call i32 (i32, i8*, ...) @fprintf(i32 %148, i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.12, i64 0, i64 0))
store i32 0, i32* %14
br label %150
150: ; preds = %176, %147
%151 = load i8*, i8** %9
%152 = load i32, i32* %14
%153 = sext i32 %152 to i64
%154 = getelementptr inbounds i8, i8* %151, i64 %153
%155 = load i8, i8* %154
%156 = sext i8 %155 to i32
%157 = icmp ne i32 %156, 10
br i1 %157, label %158, label %166
158: ; preds = %150
%159 = load i8*, i8** %9
%160 = load i32, i32* %14
%161 = sext i32 %160 to i64
%162 = getelementptr inbounds i8, i8* %159, i64 %161
%163 = load i8, i8* %162
%164 = sext i8 %163 to i32
%165 = icmp ne i32 %164, 0
br label %166
166: ; preds = %158, %150
%167 = phi i1 [ false, %150 ], [ %165, %158 ]
br i1 %167, label %168, label %179
168: ; preds = %166
%169 = load i8*, i8** %9
%170 = load i32, i32* %14
%171 = sext i32 %170 to i64
%172 = getelementptr inbounds i8, i8* %169, i64 %171
%173 = load i8, i8* %172
%174 = load i32, i32* @stderr
%175 = call i32 @putc(i8 signext %173, i32 %174)
br label %176
176: ; preds = %168
%177 = load i32, i32* %14
%178 = add nsw i32 %177, 1
store i32 %178, i32* %14
br label %150
179: ; preds = %166
%180 = load i32, i32* @stderr
%181 = call i32 @putc(i8 signext 10, i32 %180)
%182 = load i8*, i8** %9
%183 = call i32 @free(i8* %182)
store i8* null, i8** %4
br label %199
184: ; preds = %142
%185 = load i64, i64* %13
%186 = load i64, i64* %7
%187 = icmp ne i64 %185, %186
br i1 %187, label %188, label %195
188: ; preds = %184
%189 = load i32, i32* @stderr
%190 = load i64, i64* %7
%191 = load i64, i64* %13
%192 = call i32 (i32, i8*, ...) @fprintf(i32 %189, i8* getelementptr inbounds ([73 x i8], [73 x i8]* @.str.13, i64 0, i64 0), i64 %190, i64 %191)
%193 = load i8*, i8** %9
%194 = call i32 @free(i8* %193)
store i8* null, i8** %4
br label %199
195: ; preds = %184
br label %196
196: ; preds = %195, %123
%197 = load i8*, i8** %9
%198 = call i8* @cleanup_assembly(i8* %197)
store i8* %198, i8** %4
br label %199
199: ; preds = %196, %188, %179, %34, %29, %24, %20
%200 = load i8*, i8** %4
ret i8* %200
}

LLVM IR (-O2):
@.str = [13 x i8] c"/tmp/bytes.s\00"
@.str.1 = [57 x i8] c"gcc -b i486-linuxaout -g -c /tmp/bytes.s -o /tmp/bytes.o\00"
@.str.2 = [13 x i8] c"/tmp/gdbcmds\00"
@.str.3 = [43 x i8] c"gdb -nx -batch -cd /tmp -x gdbcmds bytes.o\00"
@.str.4 = [2 x i8] c"r\00"
@stderr = global i32 0
@.str.5 = [25 x i8] c"Problems executing gdb.\0A\00"
@EOF = global i32 0
@.str.6 = [27 x i8] c"Virtual memory exhausted!\0A\00"
@.str.7 = [24 x i8] c"End of assembler dump.\0A\00"
@.str.8 = [18 x i8] c"realloc problem!\0A\00"
@.str.9 = [17 x i8] c"/tmp/disassembly\00"
@.str.10 = [11 x i8] c"/tmp/bytes\00"
@.str.11 = [4 x i8] c"%lx\00"
@.str.12 = [46 x i8] c"Unable to verify first address! First line:\0A\00"
@.str.13 = [73 x i8] c"Internal error: wanted to start code at 0x%lX, but started it at 0x%lX.\0A\00"
define i8* @disasm(i8* %0, i64 %1, i64 %2) {
%4 = alloca i64
%5 = tail call i64 @create_asm(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* %0, i64 %1, i64 %2)
%6 = icmp eq i64 %5, 0
br i1 %6, label %7, label %127
7: ; preds = %3
%8 = tail call i64 @system(i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str.1, i64 0, i64 0))
%9 = icmp eq i64 %8, 0
br i1 %9, label %10, label %127
10: ; preds = %7
%11 = tail call i64 @create_gdb_commands(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i64 %1)
%12 = icmp eq i64 %11, 0
br i1 %12, label %13, label %127
13: ; preds = %10
%14 = tail call i32* @popen(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%15 = icmp eq i32* %14, null
br i1 %15, label %16, label %19
16: ; preds = %13
%17 = load i32, i32* @stderr
%18 = tail call i32 (i32, i8*, ...) @fprintf(i32 %17, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.5, i64 0, i64 0))
br label %127
19: ; preds = %13
%20 = tail call i64 @malloc(i64 1024)
br label %21
21: ; preds = %21, %19
%22 = tail call i32 @getc(i32* %14)
%23 = load i32, i32* @EOF
%24 = icmp ne i32 %22, %23
%25 = icmp ne i32 %22, 10
%26 = and i1 %25, %24
br i1 %26, label %21, label %27
27: ; preds = %21
%28 = inttoptr i64 %20 to i8*
%29 = tail call i32 @getc(i32* %14)
%30 = load i32, i32* @EOF
%31 = icmp eq i32 %29, %30
br i1 %31, label %32, label %34
32: ; preds = %27
%33 = tail call i32 @pclose(i32* %14)
br label %72
34: ; preds = %27, %53
%35 = phi i32 [ %59, %53 ], [ %29, %27 ]
%36 = phi i64 [ %55, %53 ], [ 1024, %27 ]
%37 = phi i64 [ %58, %53 ], [ 0, %27 ]
%38 = phi i8* [ %54, %53 ], [ %28, %27 ]
%39 = add i64 %36, -1
%40 = icmp ult i64 %37, %39
br i1 %40, label %53, label %41
41: ; preds = %34
%42 = icmp ugt i64 %36, 4194303
%43 = add i64 %36, 4194304
%44 = shl i64 %36, 1
%45 = select i1 %42, i64 %43, i64 %44
%46 = tail call i64 @realloc(i8* %38, i64 %45)
%47 = inttoptr i64 %46 to i8*
%48 = icmp eq i64 %46, 0
br i1 %48, label %49, label %53
49: ; preds = %41
%50 = load i32, i32* @stderr
%51 = tail call i32 (i32, i8*, ...) @fprintf(i32 %50, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.6, i64 0, i64 0))
%52 = tail call i32 @exit(i32 -100)
unreachable
53: ; preds = %41, %34
%54 = phi i8* [ %47, %41 ], [ %38, %34 ]
%55 = phi i64 [ %45, %41 ], [ %36, %34 ]
%56 = trunc i32 %35 to i8
%57 = getelementptr inbounds i8, i8* %54, i64 %37
store i8 %56, i8* %57
%58 = add i64 %37, 1
%59 = tail call i32 @getc(i32* %14)
%60 = load i32, i32* @EOF
%61 = icmp eq i32 %59, %60
br i1 %61, label %62, label %34
62: ; preds = %53
%63 = tail call i32 @pclose(i32* %14)
%64 = icmp ugt i64 %58, 22
br i1 %64, label %65, label %72
65: ; preds = %62
%66 = getelementptr inbounds i8, i8* %54, i64 %58
%67 = getelementptr inbounds i8, i8* %66, i64 -23
%68 = tail call i32 @strncmp(i8* %67, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.7, i64 0, i64 0), i32 23)
%69 = icmp eq i32 %68, 0
%70 = add i64 %37, -22
%71 = select i1 %69, i64 %70, i64 %58
br label %72
72: ; preds = %32, %65, %62
%73 = phi i8* [ %54, %62 ], [ %54, %65 ], [ %28, %32 ]
%74 = phi i64 [ %58, %62 ], [ %71, %65 ], [ 0, %32 ]
%75 = getelementptr inbounds i8, i8* %73, i64 %74
store i8 0, i8* %75
%76 = add i64 %74, 1
%77 = tail call i64 @realloc(i8* %73, i64 %76)
%78 = inttoptr i64 %77 to i8*
%79 = icmp eq i64 %77, 0
br i1 %79, label %80, label %84
80: ; preds = %72
%81 = load i32, i32* @stderr
%82 = tail call i32 (i32, i8*, ...) @fprintf(i32 %81, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.8, i64 0, i64 0))
%83 = tail call i32 @exit(i32 -102)
unreachable
84: ; preds = %72
%85 = tail call i32 @remove(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.9, i64 0, i64 0))
%86 = tail call i32 @remove(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0))
%87 = tail call i32 @remove(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
%88 = tail call i32 @remove(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.10, i64 0, i64 0))
%89 = icmp ugt i64 %74, 2
br i1 %89, label %90, label %125
90: ; preds = %84
%91 = bitcast i64* %4 to i8*
%92 = load i8, i8* %78
%93 = icmp eq i8 %92, 48
br i1 %93, label %94, label %102
94: ; preds = %90
%95 = getelementptr inbounds i8, i8* %78, i64 1
%96 = load i8, i8* %95
%97 = icmp eq i8 %96, 120
br i1 %97, label %98, label %102
98: ; preds = %94
%99 = getelementptr inbounds i8, i8* %78, i64 2
%100 = call i32 @sscanf(i8* %99, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.11, i64 0, i64 0), i64* %4)
%101 = icmp eq i32 %100, 1
br i1 %101, label %117, label %102
102: ; preds = %98, %94, %90
%103 = load i32, i32* @stderr
%104 = call i32 (i32, i8*, ...) @fprintf(i32 %103, i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.12, i64 0, i64 0))
br label %105
105: ; preds = %109, %102
%106 = phi i64 [ %112, %109 ], [ 0, %102 ]
%107 = getelementptr inbounds i8, i8* %78, i64 %106
%108 = load i8, i8* %107
switch i8 %108, label %109 [
i8 10, label %113
i8 0, label %113
]
109: ; preds = %105
%110 = load i32, i32* @stderr
%111 = call i32 @putc(i8 signext %108, i32 %110)
%112 = add nuw i64 %106, 1
br label %105
113: ; preds = %105, %105
%114 = load i32, i32* @stderr
%115 = call i32 @putc(i8 signext 10, i32 %114)
%116 = call i32 @free(i8* %78)
br label %127
117: ; preds = %98
%118 = load i64, i64* %4
%119 = icmp eq i64 %118, %2
br i1 %119, label %124, label %120
120: ; preds = %117
%121 = load i32, i32* @stderr
%122 = call i32 (i32, i8*, ...) @fprintf(i32 %121, i8* getelementptr inbounds ([73 x i8], [73 x i8]* @.str.13, i64 0, i64 0), i64 %2, i64 %118)
%123 = call i32 @free(i8* %78)
br label %127
124: ; preds = %117
br label %125
125: ; preds = %124, %84
%126 = call i8* @cleanup_assembly(i8* %78)
br label %127
127: ; preds = %113, %120, %10, %7, %3, %125, %16
%128 = phi i8* [ null, %16 ], [ %126, %125 ], [ null, %3 ], [ null, %7 ], [ null, %10 ], [ null, %120 ], [ null, %113 ]
ret i8* %128
}