#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 */

/* Variables and functions */
#define E2BIG 143
#define EACCES 142
#define EFAULT 141
#define EIO 140
#define EISDIR 139
#define ELIBBAD 138
#define ELOOP 137
#define EMFILE 136
#define ENAMETOOLONG 135
#define ENFILE 134
#define ENOENT 133
#define ENOEXEC 132
#define ENOMEM 131
#define ENOTDIR 130
#define EPERM 129
#define ETXTBSY 128
int /*<<< orphan*/ EXIT_FAILURE;
int /*<<< orphan*/ EXIT_SUCCESS;
int /*<<< orphan*/ assert_has_file(int, int, char *const *);
int errno;
scalar_t__ execve(char *, char *const *, char **const);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ has_libc_start_main(char *);
char *join_strings(char *, char *const);
char **malloc(int);
char **merge_envp(char *const *, char **);
int /*<<< orphan*/ printf(char *, ...);
scalar_t__ strcmp(char const *, char *);
int strlen(char const *);
int main(int argc, char *const argv[], char *const envp1[]) {
  const int NUM_ENVP_EXTRA = 10;
  char **envp2 = malloc(sizeof(char *) * NUM_ENVP_EXTRA);
  int env2_index = 0;
  int i = 1;
  while (i < argc) {
    const char *s = argv[i];
    int len = strlen(s);
    if (strcmp(s, "-h") == 0 || strcmp(s, "--help") == 0) {
      printf("Help:  trap-trace\n"
             "traces through a program step by step, starting at "
             "__lib_start_main\n"
             "arguments:\n"
             " -h, --help:                       print this help\n"
             " -v, --version:                    print version\n"
             " -s <file>, --syscalls <file>:     store system calls in <file>, "
             "use - for stdout\n"
             " -i <file>, --instructions <file>: store every encountered "
             "instruction in <file>, - for stdout\n"
             " --stats <file>:                   store instruction stats in "
             "file, - for stdout\n");
      exit(EXIT_SUCCESS);
    }
    if ((strcmp(s, "-v") == 0) || (strcmp(s, "--version") == 0)) {
      printf("traptrace v%s\n", ("0.0.1"));
      exit(EXIT_SUCCESS);
    }
    if ((strcmp(s, "-s") == 0) || (strcmp(s, "--syscalls") == 0)) {
      assert_has_file(i, argc, argv);
      envp2[env2_index++] =
          join_strings(("___trap_trace_syscalls_file_"), argv[i + 1]);
      i += 1;
    } else if ((strcmp(s, "-i") == 0) || (strcmp(s, "--instructions") == 0)) {
      assert_has_file(i, argc, argv);
      envp2[env2_index++] =
          join_strings(("___trap_trace_instructions_file_"), argv[i + 1]);
      i += 1;
    } else if ((strcmp(s, "--stats") == 0)) {
      assert_has_file(i, argc, argv);
      envp2[env2_index++] =
          join_strings(("___trap_trace_stats_file_"), argv[i + 1]);
      i += 1;
    } else if (s[0] == '-') {
      printf("unkown option %s\n", s);
      exit(EXIT_FAILURE);
    } else {
      break;
    }
    i += 1;
  }
  char *program = argv[i];
  if (!has_libc_start_main(program)) {
    printf("program '%s' does not have main to override (%s)\n", program,
           ("__libc_start_main"));
    exit(EXIT_FAILURE);
  }
  envp2[env2_index++] = join_strings("LD_PRELOAD", ("./traptrace.so"));
  char **const new_envp = merge_envp(envp1, envp2);
  printf("[execute '%s']\n", program);
  if (execve(program, argv + i, new_envp) < 0) {
    printf("executing '%s' failed: ", argv[i]);
    switch (errno) {
    case E2BIG:
      printf("E2BIG");
      break;
    case EACCES:
      printf("EACCES");
      break;
    case EFAULT:
      printf("EFAULT");
      break;
    case EIO:
      printf("EIO");
      break;
    case EISDIR:
      printf("EISDIR");
      break;
    case ELIBBAD:
      printf("ELIBBAD");
      break;
    case ELOOP:
      printf("ELOOP");
      break;
    case EMFILE:
      printf("EMFILE");
      break;
    case ENAMETOOLONG:
      printf("ENAMETOOLONG");
      break;
    case ENFILE:
      printf("ENFILE");
      break;
    case ENOENT:
      printf("ENOENT");
      break;
    case ENOEXEC:
      printf("ENOEXEC");
      break;
    case ENOMEM:
      printf("ENOMEM");
      break;
    case ENOTDIR:
      printf("ENOTDIR");
      break;
    case EPERM:
      printf("EPERM");
      break;
    case ETXTBSY:
      printf("ETXTBSY");
      break;
    default:
      printf("unknown error");
    }
    printf("\n");
    exit(EXIT_FAILURE);
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movl   $0xa,-0x1c(%rbp)
mov    $0x50,%edi
call   10a0 <malloc@plt>
mov    %rax,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
movl   $0x1,-0x30(%rbp)
mov    -0x30(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1474 <main+0x2d4>
mov    -0x10(%rbp),%rax
movslq -0x30(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x3c(%rbp)
mov    -0x38(%rbp),%rdi
lea    0xe30(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
je     1239 <main+0x99>
mov    -0x38(%rbp),%rdi
lea    0xe19(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
jne    1255 <main+0xb5>
lea    0xe0a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    0x2d82(%rip),%rax
mov    (%rax),%edi
call   10c0 <exit@plt>
mov    -0x38(%rbp),%rdi
lea    0xfb2(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
je     1289 <main+0xe9>
mov    -0x38(%rbp),%rdi
lea    0xf9b(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
jne    12ac <main+0x10c>
lea    0xf8f(%rip),%rdi
lea    0xf97(%rip),%rsi
mov    $0x0,%al
call   1040 <printf@plt>
mov    0x2d2b(%rip),%rax
mov    (%rax),%edi
call   10c0 <exit@plt>
mov    -0x38(%rbp),%rdi
lea    0xf7d(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
je     12e0 <main+0x140>
mov    -0x38(%rbp),%rdi
lea    0xf66(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
jne    1333 <main+0x193>
mov    -0x30(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    -0x10(%rbp),%rdx
call   1080 <assert_has_file@plt>
mov    -0x10(%rbp),%rax
mov    -0x30(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rsi
lea    0xf3b(%rip),%rdi
call   10b0 <join_strings@plt>
mov    %rax,%rdx
mov    -0x28(%rbp),%rax
mov    -0x2c(%rbp),%ecx
mov    %ecx,%esi
add    $0x1,%esi
mov    %esi,-0x2c(%rbp)
movslq %ecx,%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    1466 <main+0x2c6>
mov    -0x38(%rbp),%rdi
lea    0xf21(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
je     1367 <main+0x1c7>
mov    -0x38(%rbp),%rdi
lea    0xf0a(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
jne    13ba <main+0x21a>
mov    -0x30(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    -0x10(%rbp),%rdx
call   1080 <assert_has_file@plt>
mov    -0x10(%rbp),%rax
mov    -0x30(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rsi
lea    0xee3(%rip),%rdi
call   10b0 <join_strings@plt>
mov    %rax,%rdx
mov    -0x28(%rbp),%rax
mov    -0x2c(%rbp),%ecx
mov    %ecx,%esi
add    $0x1,%esi
mov    %esi,-0x2c(%rbp)
movslq %ecx,%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    1461 <main+0x2c1>
mov    -0x38(%rbp),%rdi
lea    0xecd(%rip),%rsi
call   1070 <strcmp@plt>
cmp    $0x0,%rax
jne    1427 <main+0x287>
mov    -0x30(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    -0x10(%rbp),%rdx
call   1080 <assert_has_file@plt>
mov    -0x10(%rbp),%rax
mov    -0x30(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rsi
lea    0xe9f(%rip),%rdi
call   10b0 <join_strings@plt>
mov    %rax,%rdx
mov    -0x28(%rbp),%rax
mov    -0x2c(%rbp),%ecx
mov    %ecx,%esi
add    $0x1,%esi
mov    %esi,-0x2c(%rbp)
movslq %ecx,%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    145c <main+0x2bc>
mov    -0x38(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2d,%eax
jne    1457 <main+0x2b7>
mov    -0x38(%rbp),%rsi
lea    0xe72(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    0x2b88(%rip),%rax
mov    (%rax),%edi
call   10c0 <exit@plt>
jmp    1474 <main+0x2d4>
jmp    1461 <main+0x2c1>
jmp    1466 <main+0x2c6>
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    11dd <main+0x3d>
mov    -0x10(%rbp),%rax
movslq -0x30(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x48(%rbp)
mov    -0x48(%rbp),%rdi
call   1050 <has_libc_start_main@plt>
cmp    $0x0,%eax
jne    14bd <main+0x31d>
mov    -0x48(%rbp),%rsi
lea    0xe25(%rip),%rdi
lea    0xe50(%rip),%rdx
mov    $0x0,%al
call   1040 <printf@plt>
mov    0x2b22(%rip),%rax
mov    (%rax),%edi
call   10c0 <exit@plt>
lea    0xe46(%rip),%rdi
lea    0xe4a(%rip),%rsi
call   10b0 <join_strings@plt>
mov    %rax,%rdx
mov    -0x28(%rbp),%rax
mov    -0x2c(%rbp),%ecx
mov    %ecx,%esi
add    $0x1,%esi
mov    %esi,-0x2c(%rbp)
movslq %ecx,%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x18(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   1090 <merge_envp@plt>
mov    %rax,-0x50(%rbp)
mov    -0x48(%rbp),%rsi
lea    0xe1f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x48(%rbp),%rdi
mov    -0x10(%rbp),%rsi
movslq -0x30(%rbp),%rax
shl    $0x3,%rax
add    %rax,%rsi
mov    -0x50(%rbp),%rdx
call   1060 <execve@plt>
cmp    $0x0,%rax
jge    16d5 <main+0x535>
mov    -0x10(%rbp),%rax
movslq -0x30(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
lea    0xdef(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x2a8d(%rip),%rax
mov    (%rax),%eax
add    $0xffffff80,%eax
mov    %eax,%ecx
mov    %rcx,-0x58(%rbp)
sub    $0xf,%eax
ja     16ab <main+0x50b>
mov    -0x58(%rbp),%rax
lea    0xa8e(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xdca(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    16b9 <main+0x519>
lea    0xdbd(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    16b9 <main+0x519>
lea    0xdb1(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    16b9 <main+0x519>
lea    0xda5(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    16b9 <main+0x519>
lea    0xd96(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    16b9 <main+0x519>
lea    0xd8a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    16b9 <main+0x519>
lea    0xd7f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    16b9 <main+0x519>
lea    0xd72(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    16b9 <main+0x519>
lea    0xd66(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    16b9 <main+0x519>
lea    0xd60(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    16b9 <main+0x519>
lea    0xd54(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    16b9 <main+0x519>
lea    0xd48(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    16b9 <main+0x519>
lea    0xd3d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    16b9 <main+0x519>
lea    0xd31(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    16b9 <main+0x519>
lea    0xd26(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    16b9 <main+0x519>
lea    0xd19(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    16b9 <main+0x519>
lea    0xd0e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xc36(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    0x290a(%rip),%rax
mov    (%rax),%edi
call   10c0 <exit@plt>
mov    -0x4(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rdx,0x10(%rsp)
mov    %rsi,%r12
mov    %edi,%ebp
mov    $0x50,%edi
call   10c0 <malloc@plt>
mov    %rax,0x8(%rsp)
cmp    $0x2,%ebp
jl     1355 <main+0x195>
mov    $0x1,%ebx
xor    %r15d,%r15d
jmp    1232 <main+0x72>
nopw   0x0(%rax,%rax,1)
mov    %ebx,%edi
mov    %ebp,%esi
mov    %r12,%rdx
call   10a0 <assert_has_file@plt>
mov    0x8(%r12,%rbx,8),%rsi
mov    %r13,%rdi
call   10d0 <join_strings@plt>
mov    0x8(%rsp),%rcx
mov    %rax,(%rcx,%r15,8)
add    $0x1,%r15
add    $0x2,%rbx
cmp    %ebp,%ebx
jge    135d <main+0x19d>
mov    (%r12,%rbx,8),%r14
mov    %r14,%rdi
call   1050 <strlen@plt>
mov    %r14,%rdi
lea    0xdb8(%rip),%rsi
call   1090 <strcmp@plt>
test   %rax,%rax
je     13d9 <main+0x219>
mov    %r14,%rdi
lea    0xda3(%rip),%rsi
call   1090 <strcmp@plt>
test   %rax,%rax
je     13d9 <main+0x219>
mov    %r14,%rdi
lea    0xd92(%rip),%rsi
call   1090 <strcmp@plt>
test   %rax,%rax
je     13e7 <main+0x227>
mov    %r14,%rdi
lea    0xd7d(%rip),%rsi
call   1090 <strcmp@plt>
test   %rax,%rax
je     13e7 <main+0x227>
mov    %r14,%rdi
lea    0xd84(%rip),%rsi
call   1090 <strcmp@plt>
lea    0xd86(%rip),%r13
test   %rax,%rax
je     1200 <main+0x40>
mov    %r14,%rdi
lea    0xd68(%rip),%rsi
call   1090 <strcmp@plt>
lea    0xd67(%rip),%r13
test   %rax,%rax
je     1200 <main+0x40>
mov    %r14,%rdi
lea    0xd71(%rip),%rsi
call   1090 <strcmp@plt>
lea    0xd77(%rip),%r13
test   %rax,%rax
je     1200 <main+0x40>
mov    %r14,%rdi
lea    0xd55(%rip),%rsi
call   1090 <strcmp@plt>
lea    0xd58(%rip),%r13
test   %rax,%rax
je     1200 <main+0x40>
mov    %r14,%rdi
lea    0xd66(%rip),%rsi
call   1090 <strcmp@plt>
lea    0xd62(%rip),%r13
test   %rax,%rax
je     1200 <main+0x40>
cmpb   $0x2d,(%r14)
jne    135d <main+0x19d>
lea    0xd66(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
jmp    1470 <main+0x2b0>
mov    $0x1,%ebx
xor    %r15d,%r15d
movslq %ebx,%rbp
mov    (%r12,%rbp,8),%rbx
mov    %rbx,%rdi
call   1070 <has_libc_start_main@plt>
test   %eax,%eax
je     140a <main+0x24a>
lea    (%r12,%rbp,8),%r14
lea    0xd83(%rip),%rdi
lea    0xd87(%rip),%rsi
call   10d0 <join_strings@plt>
mov    %r15d,%ecx
mov    0x8(%rsp),%rsi
mov    %rax,(%rsi,%rcx,8)
mov    0x10(%rsp),%rdi
call   10b0 <merge_envp@plt>
mov    %rax,%rbp
lea    0xd71(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %rbp,%rdx
call   1080 <execve@plt>
test   %rax,%rax
js     1424 <main+0x264>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xde6(%rip),%rdi
call   1040 <puts@plt>
jmp    13fc <main+0x23c>
lea    0xc29(%rip),%rdi
lea    0xc31(%rip),%rsi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x2bcd(%rip),%rax
mov    (%rax),%edi
call   10e0 <exit@plt>
lea    0xcad(%rip),%rdi
lea    0xcd8(%rip),%rdx
mov    %rbx,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
jmp    1470 <main+0x2b0>
mov    (%r14),%rsi
lea    0xcfe(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x2ba4(%rip),%rax
mov    (%rax),%eax
add    $0xffffff80,%eax
cmp    $0xf,%eax
ja     1458 <main+0x298>
cltq
lea    0xf41(%rip),%rcx
movslq (%rcx,%rax,4),%rdi
add    %rcx,%rdi
jmp    145f <main+0x29f>
lea    0xd59(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    0x2b61(%rip),%rax
mov    (%rax),%edi
call   10e0 <exit@plt>

LLVM IR (-O0):
@.str = [3 x i8] c"-h\00"
@.str.1 = [7 x i8] c"--help\00"
@.str.2 = [456 x i8] c"Help: trap-trace\0Atraces through a program step by step, starting at __lib_start_main\0Aarguments:\0A -h, --help: print this help\0A -v, --version: print version\0A -s <file>, --syscalls <file>: store system calls in <file>, use - for stdout\0A -i <file>, --instructions <file>: store every encountered instruction in <file>, - for stdout\0A --stats <file>: store instruction stats in file, - for stdout\0A\00"
@EXIT_SUCCESS = global i32 0
@.str.3 = [3 x i8] c"-v\00"
@.str.4 = [10 x i8] c"--version\00"
@.str.5 = [15 x i8] c"traptrace v%s\0A\00"
@.str.6 = [6 x i8] c"0.0.1\00"
@.str.7 = [3 x i8] c"-s\00"
@.str.8 = [11 x i8] c"--syscalls\00"
@.str.9 = [29 x i8] c"___trap_trace_syscalls_file_\00"
@.str.10 = [3 x i8] c"-i\00"
@.str.11 = [15 x i8] c"--instructions\00"
@.str.12 = [33 x i8] c"___trap_trace_instructions_file_\00"
@.str.13 = [8 x i8] c"--stats\00"
@.str.14 = [26 x i8] c"___trap_trace_stats_file_\00"
@.str.15 = [18 x i8] c"unkown option %s\0A\00"
@EXIT_FAILURE = global i32 0
@.str.16 = [50 x i8] c"program '%s' does not have main to override (%s)\0A\00"
@.str.17 = [18 x i8] c"__libc_start_main\00"
@.str.18 = [11 x i8] c"LD_PRELOAD\00"
@.str.19 = [15 x i8] c"./traptrace.so\00"
@.str.20 = [16 x i8] c"[execute '%s']\0A\00"
@.str.21 = [24 x i8] c"executing '%s' failed: \00"
@errno = global i32 0
@.str.22 = [6 x i8] c"E2BIG\00"
@.str.23 = [7 x i8] c"EACCES\00"
@.str.24 = [7 x i8] c"EFAULT\00"
@.str.25 = [4 x i8] c"EIO\00"
@.str.26 = [7 x i8] c"EISDIR\00"
@.str.27 = [8 x i8] c"ELIBBAD\00"
@.str.28 = [6 x i8] c"ELOOP\00"
@.str.29 = [7 x i8] c"EMFILE\00"
@.str.30 = [13 x i8] c"ENAMETOOLONG\00"
@.str.31 = [7 x i8] c"ENFILE\00"
@.str.32 = [7 x i8] c"ENOENT\00"
@.str.33 = [8 x i8] c"ENOEXEC\00"
@.str.34 = [7 x i8] c"ENOMEM\00"
@.str.35 = [8 x i8] c"ENOTDIR\00"
@.str.36 = [6 x i8] c"EPERM\00"
@.str.37 = [8 x i8] c"ETXTBSY\00"
@.str.38 = [14 x i8] c"unknown error\00"
@.str.39 = [2 x i8] c"\0A\00"
define i32 @main(i32 %0, i8** %1, i8** %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8**
%7 = alloca i8**
%8 = alloca i32
%9 = alloca i8**
%10 = alloca i32
%11 = alloca i32
%12 = alloca i8*
%13 = alloca i32
%14 = alloca i8*
%15 = alloca i8**
store i32 0, i32* %4
store i32 %0, i32* %5
store i8** %1, i8*** %6
store i8** %2, i8*** %7
store i32 10, i32* %8
%16 = call i8** @malloc(i32 80)
store i8** %16, i8*** %9
store i32 0, i32* %10
store i32 1, i32* %11
br label %17
17: ; preds = %143, %3
%18 = load i32, i32* %11
%19 = load i32, i32* %5
%20 = icmp slt i32 %18, %19
br i1 %20, label %21, label %146
21: ; preds = %17
%22 = load i8**, i8*** %6
%23 = load i32, i32* %11
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds i8*, i8** %22, i64 %24
%26 = load i8*, i8** %25
store i8* %26, i8** %12
%27 = load i8*, i8** %12
%28 = call i32 @strlen(i8* %27)
store i32 %28, i32* %13
%29 = load i8*, i8** %12
%30 = call i64 @strcmp(i8* %29, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%31 = icmp eq i64 %30, 0
br i1 %31, label %36, label %32
32: ; preds = %21
%33 = load i8*, i8** %12
%34 = call i64 @strcmp(i8* %33, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%35 = icmp eq i64 %34, 0
br i1 %35, label %36, label %40
36: ; preds = %32, %21
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([456 x i8], [456 x i8]* @.str.2, i64 0, i64 0))
%38 = load i32, i32* @EXIT_SUCCESS
%39 = call i32 @exit(i32 %38)
unreachable
40: ; preds = %32
%41 = load i8*, i8** %12
%42 = call i64 @strcmp(i8* %41, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%43 = icmp eq i64 %42, 0
br i1 %43, label %48, label %44
44: ; preds = %40
%45 = load i8*, i8** %12
%46 = call i64 @strcmp(i8* %45, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0))
%47 = icmp eq i64 %46, 0
br i1 %47, label %48, label %52
48: ; preds = %44, %40
%49 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0))
%50 = load i32, i32* @EXIT_SUCCESS
%51 = call i32 @exit(i32 %50)
unreachable
52: ; preds = %44
%53 = load i8*, i8** %12
%54 = call i64 @strcmp(i8* %53, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0))
%55 = icmp eq i64 %54, 0
br i1 %55, label %60, label %56
56: ; preds = %52
%57 = load i8*, i8** %12
%58 = call i64 @strcmp(i8* %57, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.8, i64 0, i64 0))
%59 = icmp eq i64 %58, 0
br i1 %59, label %60, label %79
60: ; preds = %56, %52
%61 = load i32, i32* %11
%62 = load i32, i32* %5
%63 = load i8**, i8*** %6
%64 = call i32 @assert_has_file(i32 %61, i32 %62, i8** %63)
%65 = load i8**, i8*** %6
%66 = load i32, i32* %11
%67 = add nsw i32 %66, 1
%68 = sext i32 %67 to i64
%69 = getelementptr inbounds i8*, i8** %65, i64 %68
%70 = load i8*, i8** %69
%71 = call i8* @join_strings(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.9, i64 0, i64 0), i8* %70)
%72 = load i8**, i8*** %9
%73 = load i32, i32* %10
%74 = add nsw i32 %73, 1
store i32 %74, i32* %10
%75 = sext i32 %73 to i64
%76 = getelementptr inbounds i8*, i8** %72, i64 %75
store i8* %71, i8** %76
%77 = load i32, i32* %11
%78 = add nsw i32 %77, 1
store i32 %78, i32* %11
br label %143
79: ; preds = %56
%80 = load i8*, i8** %12
%81 = call i64 @strcmp(i8* %80, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.10, i64 0, i64 0))
%82 = icmp eq i64 %81, 0
br i1 %82, label %87, label %83
83: ; preds = %79
%84 = load i8*, i8** %12
%85 = call i64 @strcmp(i8* %84, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.11, i64 0, i64 0))
%86 = icmp eq i64 %85, 0
br i1 %86, label %87, label %106
87: ; preds = %83, %79
%88 = load i32, i32* %11
%89 = load i32, i32* %5
%90 = load i8**, i8*** %6
%91 = call i32 @assert_has_file(i32 %88, i32 %89, i8** %90)
%92 = load i8**, i8*** %6
%93 = load i32, i32* %11
%94 = add nsw i32 %93, 1
%95 = sext i32 %94 to i64
%96 = getelementptr inbounds i8*, i8** %92, i64 %95
%97 = load i8*, i8** %96
%98 = call i8* @join_strings(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.12, i64 0, i64 0), i8* %97)
%99 = load i8**, i8*** %9
%100 = load i32, i32* %10
%101 = add nsw i32 %100, 1
store i32 %101, i32* %10
%102 = sext i32 %100 to i64
%103 = getelementptr inbounds i8*, i8** %99, i64 %102
store i8* %98, i8** %103
%104 = load i32, i32* %11
%105 = add nsw i32 %104, 1
store i32 %105, i32* %11
br label %142
106: ; preds = %83
%107 = load i8*, i8** %12
%108 = call i64 @strcmp(i8* %107, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.13, i64 0, i64 0))
%109 = icmp eq i64 %108, 0
br i1 %109, label %110, label %129
110: ; preds = %106
%111 = load i32, i32* %11
%112 = load i32, i32* %5
%113 = load i8**, i8*** %6
%114 = call i32 @assert_has_file(i32 %111, i32 %112, i8** %113)
%115 = load i8**, i8*** %6
%116 = load i32, i32* %11
%117 = add nsw i32 %116, 1
%118 = sext i32 %117 to i64
%119 = getelementptr inbounds i8*, i8** %115, i64 %118
%120 = load i8*, i8** %119
%121 = call i8* @join_strings(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.14, i64 0, i64 0), i8* %120)
%122 = load i8**, i8*** %9
%123 = load i32, i32* %10
%124 = add nsw i32 %123, 1
store i32 %124, i32* %10
%125 = sext i32 %123 to i64
%126 = getelementptr inbounds i8*, i8** %122, i64 %125
store i8* %121, i8** %126
%127 = load i32, i32* %11
%128 = add nsw i32 %127, 1
store i32 %128, i32* %11
br label %141
129: ; preds = %106
%130 = load i8*, i8** %12
%131 = getelementptr inbounds i8, i8* %130, i64 0
%132 = load i8, i8* %131
%133 = sext i8 %132 to i32
%134 = icmp eq i32 %133, 45
br i1 %134, label %135, label %140
135: ; preds = %129
%136 = load i8*, i8** %12
%137 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.15, i64 0, i64 0), i8* %136)
%138 = load i32, i32* @EXIT_FAILURE
%139 = call i32 @exit(i32 %138)
unreachable
140: ; preds = %129
br label %146
141: ; preds = %110
br label %142
142: ; preds = %141, %87
br label %143
143: ; preds = %142, %60
%144 = load i32, i32* %11
%145 = add nsw i32 %144, 1
store i32 %145, i32* %11
br label %17
146: ; preds = %140, %17
%147 = load i8**, i8*** %6
%148 = load i32, i32* %11
%149 = sext i32 %148 to i64
%150 = getelementptr inbounds i8*, i8** %147, i64 %149
%151 = load i8*, i8** %150
store i8* %151, i8** %14
%152 = load i8*, i8** %14
%153 = call i32 @has_libc_start_main(i8* %152)
%154 = icmp ne i32 %153, 0
br i1 %154, label %160, label %155
155: ; preds = %146
%156 = load i8*, i8** %14
%157 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.16, i64 0, i64 0), i8* %156, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.17, i64 0, i64 0))
%158 = load i32, i32* @EXIT_FAILURE
%159 = call i32 @exit(i32 %158)
unreachable
160: ; preds = %146
%161 = call i8* @join_strings(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.18, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.19, i64 0, i64 0))
%162 = load i8**, i8*** %9
%163 = load i32, i32* %10
%164 = add nsw i32 %163, 1
store i32 %164, i32* %10
%165 = sext i32 %163 to i64
%166 = getelementptr inbounds i8*, i8** %162, i64 %165
store i8* %161, i8** %166
%167 = load i8**, i8*** %7
%168 = load i8**, i8*** %9
%169 = call i8** @merge_envp(i8** %167, i8** %168)
store i8** %169, i8*** %15
%170 = load i8*, i8** %14
%171 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.20, i64 0, i64 0), i8* %170)
%172 = load i8*, i8** %14
%173 = load i8**, i8*** %6
%174 = load i32, i32* %11
%175 = sext i32 %174 to i64
%176 = getelementptr inbounds i8*, i8** %173, i64 %175
%177 = load i8**, i8*** %15
%178 = call i64 @execve(i8* %172, i8** %176, i8** %177)
%179 = icmp slt i64 %178, 0
br i1 %179, label %180, label %226
180: ; preds = %160
%181 = load i8**, i8*** %6
%182 = load i32, i32* %11
%183 = sext i32 %182 to i64
%184 = getelementptr inbounds i8*, i8** %181, i64 %183
%185 = load i8*, i8** %184
%186 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.21, i64 0, i64 0), i8* %185)
%187 = load i32, i32* @errno
switch i32 %187, label %220 [
i32 143, label %188
i32 142, label %190
i32 141, label %192
i32 140, label %194
i32 139, label %196
i32 138, label %198
i32 137, label %200
i32 136, label %202
i32 135, label %204
i32 134, label %206
i32 133, label %208
i32 132, label %210
i32 131, label %212
i32 130, label %214
i32 129, label %216
i32 128, label %218
]
188: ; preds = %180
%189 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.22, i64 0, i64 0))
br label %222
190: ; preds = %180
%191 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.23, i64 0, i64 0))
br label %222
192: ; preds = %180
%193 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.24, i64 0, i64 0))
br label %222
194: ; preds = %180
%195 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.25, i64 0, i64 0))
br label %222
196: ; preds = %180
%197 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.26, i64 0, i64 0))
br label %222
198: ; preds = %180
%199 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.27, i64 0, i64 0))
br label %222
200: ; preds = %180
%201 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.28, i64 0, i64 0))
br label %222
202: ; preds = %180
%203 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.29, i64 0, i64 0))
br label %222
204: ; preds = %180
%205 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.30, i64 0, i64 0))
br label %222
206: ; preds = %180
%207 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.31, i64 0, i64 0))
br label %222
208: ; preds = %180
%209 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.32, i64 0, i64 0))
br label %222
210: ; preds = %180
%211 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.33, i64 0, i64 0))
br label %222
212: ; preds = %180
%213 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.34, i64 0, i64 0))
br label %222
214: ; preds = %180
%215 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.35, i64 0, i64 0))
br label %222
216: ; preds = %180
%217 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.36, i64 0, i64 0))
br label %222
218: ; preds = %180
%219 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.37, i64 0, i64 0))
br label %222
220: ; preds = %180
%221 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.38, i64 0, i64 0))
br label %222
222: ; preds = %220, %218, %216, %214, %212, %210, %208, %206, %204, %202, %200, %198, %196, %194, %192, %190, %188
%223 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.39, i64 0, i64 0))
%224 = load i32, i32* @EXIT_FAILURE
%225 = call i32 @exit(i32 %224)
unreachable
226: ; preds = %160
%227 = load i32, i32* %4
ret i32 %227
}

LLVM IR (-O2):
@.str = [3 x i8] c"-h\00"
@.str.1 = [7 x i8] c"--help\00"
@EXIT_SUCCESS = global i32 0
@.str.3 = [3 x i8] c"-v\00"
@.str.4 = [10 x i8] c"--version\00"
@.str.5 = [15 x i8] c"traptrace v%s\0A\00"
@.str.6 = [6 x i8] c"0.0.1\00"
@.str.7 = [3 x i8] c"-s\00"
@.str.8 = [11 x i8] c"--syscalls\00"
@.str.9 = [29 x i8] c"___trap_trace_syscalls_file_\00"
@.str.10 = [3 x i8] c"-i\00"
@.str.11 = [15 x i8] c"--instructions\00"
@.str.12 = [33 x i8] c"___trap_trace_instructions_file_\00"
@.str.13 = [8 x i8] c"--stats\00"
@.str.14 = [26 x i8] c"___trap_trace_stats_file_\00"
@.str.15 = [18 x i8] c"unkown option %s\0A\00"
@EXIT_FAILURE = global i32 0
@.str.16 = [50 x i8] c"program '%s' does not have main to override (%s)\0A\00"
@.str.17 = [18 x i8] c"__libc_start_main\00"
@.str.18 = [11 x i8] c"LD_PRELOAD\00"
@.str.19 = [15 x i8] c"./traptrace.so\00"
@.str.20 = [16 x i8] c"[execute '%s']\0A\00"
@.str.21 = [24 x i8] c"executing '%s' failed: \00"
@errno = global i32 0
@.str.22 = [6 x i8] c"E2BIG\00"
@.str.23 = [7 x i8] c"EACCES\00"
@.str.24 = [7 x i8] c"EFAULT\00"
@.str.25 = [4 x i8] c"EIO\00"
@.str.26 = [7 x i8] c"EISDIR\00"
@.str.27 = [8 x i8] c"ELIBBAD\00"
@.str.28 = [6 x i8] c"ELOOP\00"
@.str.29 = [7 x i8] c"EMFILE\00"
@.str.30 = [13 x i8] c"ENAMETOOLONG\00"
@.str.31 = [7 x i8] c"ENFILE\00"
@.str.32 = [7 x i8] c"ENOENT\00"
@.str.33 = [8 x i8] c"ENOEXEC\00"
@.str.34 = [7 x i8] c"ENOMEM\00"
@.str.35 = [8 x i8] c"ENOTDIR\00"
@.str.36 = [6 x i8] c"EPERM\00"
@.str.37 = [8 x i8] c"ETXTBSY\00"
@.str.38 = [14 x i8] c"unknown error\00"
@str = [455 x i8] c"Help: trap-trace\0Atraces through a program step by step, starting at __lib_start_main\0Aarguments:\0A -h, --help: print this help\0A -v, --version: print version\0A -s <file>, --syscalls <file>: store system calls in <file>, use - for stdout\0A -i <file>, --instructions <file>: store every encountered instruction in <file>, - for stdout\0A --stats <file>: store instruction stats in file, - for stdout\00"
@reltable.main = [16 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([8 x i8]* @.str.37 to i64), i64 ptrtoint ([16 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([6 x i8]* @.str.36 to i64), i64 ptrtoint ([16 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([8 x i8]* @.str.35 to i64), i64 ptrtoint ([16 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([7 x i8]* @.str.34 to i64), i64 ptrtoint ([16 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([8 x i8]* @.str.33 to i64), i64 ptrtoint ([16 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([7 x i8]* @.str.32 to i64), i64 ptrtoint ([16 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([7 x i8]* @.str.31 to i64), i64 ptrtoint ([16 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([13 x i8]* @.str.30 to i64), i64 ptrtoint ([16 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([7 x i8]* @.str.29 to i64), i64 ptrtoint ([16 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([6 x i8]* @.str.28 to i64), i64 ptrtoint ([16 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([8 x i8]* @.str.27 to i64), i64 ptrtoint ([16 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([7 x i8]* @.str.26 to i64), i64 ptrtoint ([16 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([4 x i8]* @.str.25 to i64), i64 ptrtoint ([16 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([7 x i8]* @.str.24 to i64), i64 ptrtoint ([16 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([7 x i8]* @.str.23 to i64), i64 ptrtoint ([16 x i32]* @reltable.main to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([6 x i8]* @.str.22 to i64), i64 ptrtoint ([16 x i32]* @reltable.main to i64)) to i32)]
define i32 @main(i32 %0, i8** %1, i8** %2) {
%4 = tail call i8** @malloc(i32 80)
%5 = icmp sgt i32 %0, 1
br i1 %5, label %6, label %66
6: ; preds = %3, %54
%7 = phi i64 [ %63, %54 ], [ 0, %3 ]
%8 = phi i32 [ %64, %54 ], [ 1, %3 ]
%9 = zext i32 %8 to i64
%10 = getelementptr inbounds i8*, i8** %1, i64 %9
%11 = load i8*, i8** %10
%12 = tail call i32 @strlen(i8* %11)
%13 = tail call i64 @strcmp(i8* %11, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%14 = icmp eq i64 %13, 0
br i1 %14, label %18, label %15
15: ; preds = %6
%16 = tail call i64 @strcmp(i8* %11, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%17 = icmp eq i64 %16, 0
br i1 %17, label %18, label %22
18: ; preds = %15, %6
%19 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([455 x i8], [455 x i8]* @str, i64 0, i64 0))
%20 = load i32, i32* @EXIT_SUCCESS
%21 = tail call i32 @exit(i32 %20)
unreachable
22: ; preds = %15
%23 = tail call i64 @strcmp(i8* %11, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%24 = icmp eq i64 %23, 0
br i1 %24, label %28, label %25
25: ; preds = %22
%26 = tail call i64 @strcmp(i8* %11, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0))
%27 = icmp eq i64 %26, 0
br i1 %27, label %28, label %32
28: ; preds = %25, %22
%29 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0))
%30 = load i32, i32* @EXIT_SUCCESS
%31 = tail call i32 @exit(i32 %30)
unreachable
32: ; preds = %25
%33 = tail call i64 @strcmp(i8* %11, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0))
%34 = icmp eq i64 %33, 0
br i1 %34, label %54, label %35
35: ; preds = %32
%36 = tail call i64 @strcmp(i8* %11, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.8, i64 0, i64 0))
%37 = icmp eq i64 %36, 0
br i1 %37, label %54, label %38
38: ; preds = %35
%39 = tail call i64 @strcmp(i8* %11, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.10, i64 0, i64 0))
%40 = icmp eq i64 %39, 0
br i1 %40, label %54, label %41
41: ; preds = %38
%42 = tail call i64 @strcmp(i8* %11, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.11, i64 0, i64 0))
%43 = icmp eq i64 %42, 0
br i1 %43, label %54, label %44
44: ; preds = %41
%45 = tail call i64 @strcmp(i8* %11, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.13, i64 0, i64 0))
%46 = icmp eq i64 %45, 0
br i1 %46, label %54, label %47
47: ; preds = %44
%48 = load i8, i8* %11
%49 = icmp eq i8 %48, 45
br i1 %49, label %50, label %66
50: ; preds = %47
%51 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.15, i64 0, i64 0), i8* %11)
%52 = load i32, i32* @EXIT_FAILURE
%53 = tail call i32 @exit(i32 %52)
unreachable
54: ; preds = %44, %38, %41, %32, %35
%55 = phi i8* [ getelementptr inbounds ([29 x i8], [29 x i8]* @.str.9, i64 0, i64 0), %35 ], [ getelementptr inbounds ([29 x i8], [29 x i8]* @.str.9, i64 0, i64 0), %32 ], [ getelementptr inbounds ([33 x i8], [33 x i8]* @.str.12, i64 0, i64 0), %41 ], [ getelementptr inbounds ([33 x i8], [33 x i8]* @.str.12, i64 0, i64 0), %38 ], [ getelementptr inbounds ([26 x i8], [26 x i8]* @.str.14, i64 0, i64 0), %44 ]
%56 = tail call i32 @assert_has_file(i32 %8, i32 %0, i8** %1)
%57 = add nuw nsw i32 %8, 1
%58 = zext i32 %57 to i64
%59 = getelementptr inbounds i8*, i8** %1, i64 %58
%60 = load i8*, i8** %59
%61 = tail call i8* @join_strings(i8* %55, i8* %60)
%62 = getelementptr inbounds i8*, i8** %4, i64 %7
store i8* %61, i8** %62
%63 = add nuw i64 %7, 1
%64 = add nuw nsw i32 %8, 2
%65 = icmp slt i32 %64, %0
br i1 %65, label %6, label %66
66: ; preds = %54, %3, %47
%67 = phi i32 [ %8, %47 ], [ 1, %3 ], [ %64, %54 ]
%68 = phi i64 [ %7, %47 ], [ 0, %3 ], [ %63, %54 ]
%69 = sext i32 %67 to i64
%70 = getelementptr inbounds i8*, i8** %1, i64 %69
%71 = load i8*, i8** %70
%72 = tail call i32 @has_libc_start_main(i8* %71)
%73 = icmp eq i32 %72, 0
br i1 %73, label %74, label %78
74: ; preds = %66
%75 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([50 x i8], [50 x i8]* @.str.16, i64 0, i64 0), i8* %71, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.17, i64 0, i64 0))
%76 = load i32, i32* @EXIT_FAILURE
%77 = tail call i32 @exit(i32 %76)
unreachable
78: ; preds = %66
%79 = tail call i8* @join_strings(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.18, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.19, i64 0, i64 0))
%80 = and i64 %68, 4294967295
%81 = getelementptr inbounds i8*, i8** %4, i64 %80
store i8* %79, i8** %81
%82 = tail call i8** @merge_envp(i8** %2, i8** %4)
%83 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.20, i64 0, i64 0), i8* %71)
%84 = tail call i64 @execve(i8* %71, i8** %70, i8** %82)
%85 = icmp slt i64 %84, 0
br i1 %85, label %86, label %102
86: ; preds = %78
%87 = load i8*, i8** %70
%88 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.21, i64 0, i64 0), i8* %87)
%89 = load i32, i32* @errno
%90 = add i32 %89, -128
%91 = icmp ult i32 %90, 16
br i1 %91, label %92, label %96
92: ; preds = %86
%93 = sext i32 %90 to i64
%94 = shl i64 %93, 2
%95 = call i8* @llvm.load.relative.i64(i8* bitcast ([16 x i32]* @reltable.main to i8*), i64 %94)
br label %96
96: ; preds = %86, %92
%97 = phi i8* [ %95, %92 ], [ getelementptr inbounds ([14 x i8], [14 x i8]* @.str.38, i64 0, i64 0), %86 ]
%98 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) %97)
%99 = tail call i32 @putchar(i32 10)
%100 = load i32, i32* @EXIT_FAILURE
%101 = tail call i32 @exit(i32 %100)
unreachable
102: ; preds = %78
ret i32 0
}