#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 */
int audit_detect_machine();
char *audit_machine_to_name(int);
int audit_name_to_machine(char *);
int audit_name_to_syscall(char const *, int);
char *audit_syscall_to_name(int, int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ fputs(char *, int /*<<< orphan*/);
scalar_t__ isdigit(char);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stderr;
scalar_t__ strcasestr(char const *, char const *);
scalar_t__ strcmp(char *, char *);
int strtol(char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ usage();
int main(int argc, char *argv[]) {
  int i, rc;
  int machine = -1, syscall_num = -1, dump = 0, exact = 0;
  const char *name = NULL;
  if (argc > 4) {
    fputs("Too many arguments\n", stderr);
    usage();
  }
  for (i = 1; i < argc; i++) {
    if (isdigit(argv[i][0])) {
      if (syscall_num != -1) {
        fputs("Two syscall numbers not allowed\n", stderr);
        usage();
      }
      syscall_num = strtol(argv[i], 0, 10);
    } else if ((rc = audit_name_to_machine(argv[i])) != -1) {
      if (machine != -1) {
        fputs("Two machine types not allowed\n", stderr);
        usage();
      }
      machine = rc;
    } else if (strcmp("--dump", argv[i]) == 0) {
      dump = 1;
    } else if (strcmp("--exact", argv[i]) == 0) {
      exact = 1;
    } else {
      if (name != NULL) {
        fputs("Two syscall names not allowed\n", stderr);
        usage();
      }
      name = argv[i];
    }
  }
  if (machine == -1)
    machine = audit_detect_machine();
  if (machine == -1) {
    fprintf(stderr, "Unable to detect machine type\n");
    return 1;
  }
  if (dump) {
    printf("Using %s syscall table:\n", audit_machine_to_name(machine));
    for (i = 0; i < 8192; i++) {
      name = audit_syscall_to_name(i, machine);
      if (name)
        printf("%d\t%s\n", i, name);
    }
    return 0;
  }
  if (name) {
    if (exact) {
      rc = audit_name_to_syscall(name, machine);
      if (rc < 0) {
        fprintf(stderr, "Unknown syscall %s using %s lookup table\n", name,
                audit_machine_to_name(machine));
        return 1;
      } else
        printf("%d\n", rc);
    } else {
      int found = 0;
      for (i = 0; i < 1400; i++) {
        const char *n = audit_syscall_to_name(i, machine);
        if (n && strcasestr(n, name)) {
          found = 1;
          printf("%-18s %d\n", n, i);
        }
      }
      if (!found) {
        fprintf(stderr, "Unknown syscall %s using %s lookup table\n", name,
                audit_machine_to_name(machine));
        return 1;
      }
    }
  } else if (syscall_num != -1) {
    name = audit_syscall_to_name(syscall_num, machine);
    if (name == NULL) {
      fprintf(stderr, "Unknown syscall %d using %s lookup table\n", syscall_num,
              audit_machine_to_name(machine));
      return 1;
    } else
      printf("%s\n", name);
  } else {
    fputs("Error - either a syscall name or number must "
          "be given with an optional arch\n",
          stderr);
    return 1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0xffffffff,-0x1c(%rbp)
movl   $0xffffffff,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
movl   $0x0,-0x28(%rbp)
movq   $0x0,-0x30(%rbp)
cmpl   $0x4,-0x8(%rbp)
jle    1230 <main+0x60>
mov    0x2dc5(%rip),%rax
mov    (%rax),%esi
lea    0xddc(%rip),%rdi
call   1070 <fputs@plt>
mov    $0x0,%al
call   10d0 <usage@plt>
movl   $0x1,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    13aa <main+0x1da>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movsbl (%rax),%edi
call   1050 <isdigit@plt>
cmp    $0x0,%rax
je     12a7 <main+0xd7>
cmpl   $0xffffffff,-0x20(%rbp)
je     1287 <main+0xb7>
mov    0x2d6e(%rip),%rax
mov    (%rax),%esi
lea    0xd99(%rip),%rdi
call   1070 <fputs@plt>
mov    $0x0,%al
call   10d0 <usage@plt>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
xor    %esi,%esi
mov    $0xa,%edx
call   10b0 <strtol@plt>
mov    %eax,-0x20(%rbp)
jmp    1397 <main+0x1c7>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1040 <audit_name_to_machine@plt>
mov    %eax,-0x18(%rbp)
cmp    $0xffffffff,%eax
je     12f5 <main+0x125>
cmpl   $0xffffffff,-0x1c(%rbp)
je     12ea <main+0x11a>
mov    0x2d0b(%rip),%rax
mov    (%rax),%esi
lea    0xd57(%rip),%rdi
call   1070 <fputs@plt>
mov    $0x0,%al
call   10d0 <usage@plt>
mov    -0x18(%rbp),%eax
mov    %eax,-0x1c(%rbp)
jmp    1392 <main+0x1c2>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
lea    0xd4c(%rip),%rdi
call   1090 <strcmp@plt>
cmp    $0x0,%rax
jne    1323 <main+0x153>
movl   $0x1,-0x24(%rbp)
jmp    138d <main+0x1bd>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
lea    0xd25(%rip),%rdi
call   1090 <strcmp@plt>
cmp    $0x0,%rax
jne    1351 <main+0x181>
movl   $0x1,-0x28(%rbp)
jmp    1388 <main+0x1b8>
cmpq   $0x0,-0x30(%rbp)
je     1378 <main+0x1a8>
mov    0x2c7d(%rip),%rax
mov    (%rax),%esi
lea    0xcf7(%rip),%rdi
call   1070 <fputs@plt>
mov    $0x0,%al
call   10d0 <usage@plt>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x30(%rbp)
jmp    138d <main+0x1bd>
jmp    1392 <main+0x1c2>
jmp    1397 <main+0x1c7>
jmp    139c <main+0x1cc>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1237 <main+0x67>
cmpl   $0xffffffff,-0x1c(%rbp)
jne    13be <main+0x1ee>
mov    $0x0,%al
call   1030 <audit_detect_machine@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0xffffffff,-0x1c(%rbp)
jne    13eb <main+0x21b>
mov    0x2c11(%rip),%rax
mov    (%rax),%edi
lea    0xcaa(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1668 <main+0x498>
cmpl   $0x0,-0x24(%rbp)
je     1470 <main+0x2a0>
mov    -0x1c(%rbp),%edi
call   10f0 <audit_machine_to_name@plt>
mov    %rax,%rsi
lea    0xc9a(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0x0,-0x14(%rbp)
cmpl   $0x2000,-0x14(%rbp)
jge    1464 <main+0x294>
mov    -0x14(%rbp),%edi
mov    -0x1c(%rbp),%esi
call   1080 <audit_syscall_to_name@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
je     1451 <main+0x281>
mov    -0x14(%rbp),%esi
mov    -0x30(%rbp),%rdx
lea    0xc70(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    1456 <main+0x286>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1415 <main+0x245>
movl   $0x0,-0x4(%rbp)
jmp    1668 <main+0x498>
cmpq   $0x0,-0x30(%rbp)
je     15c3 <main+0x3f3>
cmpl   $0x0,-0x28(%rbp)
je     14f4 <main+0x324>
mov    -0x30(%rbp),%rdi
mov    -0x1c(%rbp),%esi
call   10c0 <audit_name_to_syscall@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jge    14de <main+0x30e>
mov    0x2b3b(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4c(%rbp)
mov    -0x30(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    -0x1c(%rbp),%edi
call   10f0 <audit_machine_to_name@plt>
mov    -0x4c(%rbp),%edi
mov    -0x48(%rbp),%rdx
mov    %rax,%rcx
lea    0xbf6(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1668 <main+0x498>
mov    -0x18(%rbp),%esi
lea    0xc09(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    15be <main+0x3ee>
movl   $0x0,-0x34(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x578,-0x14(%rbp)
jge    156f <main+0x39f>
mov    -0x14(%rbp),%edi
mov    -0x1c(%rbp),%esi
call   1080 <audit_syscall_to_name@plt>
mov    %rax,-0x40(%rbp)
cmpq   $0x0,-0x40(%rbp)
je     155c <main+0x38c>
mov    -0x40(%rbp),%rdi
mov    -0x30(%rbp),%rsi
call   10e0 <strcasestr@plt>
cmp    $0x0,%rax
je     155c <main+0x38c>
movl   $0x1,-0x34(%rbp)
mov    -0x40(%rbp),%rsi
mov    -0x14(%rbp),%edx
lea    0xb96(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    1561 <main+0x391>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1502 <main+0x332>
cmpl   $0x0,-0x34(%rbp)
jne    15b9 <main+0x3e9>
mov    0x2a60(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x5c(%rbp)
mov    -0x30(%rbp),%rax
mov    %rax,-0x58(%rbp)
mov    -0x1c(%rbp),%edi
call   10f0 <audit_machine_to_name@plt>
mov    -0x5c(%rbp),%edi
mov    -0x58(%rbp),%rdx
mov    %rax,%rcx
lea    0xb1b(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1668 <main+0x498>
jmp    15be <main+0x3ee>
jmp    1661 <main+0x491>
cmpl   $0xffffffff,-0x20(%rbp)
je     163b <main+0x46b>
mov    -0x20(%rbp),%edi
mov    -0x1c(%rbp),%esi
call   1080 <audit_syscall_to_name@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    1624 <main+0x454>
mov    0x29f2(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x64(%rbp)
mov    -0x20(%rbp),%eax
mov    %eax,-0x60(%rbp)
mov    -0x1c(%rbp),%edi
call   10f0 <audit_machine_to_name@plt>
mov    -0x64(%rbp),%edi
mov    -0x60(%rbp),%edx
mov    %rax,%rcx
lea    0xae4(%rip),%rsi
mov    $0x0,%al
call   10a0 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1668 <main+0x498>
mov    -0x30(%rbp),%rsi
lea    0xa8e(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    165c <main+0x48c>
mov    0x299e(%rip),%rax
mov    (%rax),%esi
lea    0xad4(%rip),%rdi
call   1070 <fputs@plt>
movl   $0x1,-0x4(%rbp)
jmp    1668 <main+0x498>
jmp    1661 <main+0x491>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x70,%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    %rsi,%rbx
mov    %edi,%ebp
cmp    $0x5,%edi
jl     1216 <main+0x36>
mov    0x2de1(%rip),%rax
mov    (%rax),%esi
lea    0xdf8(%rip),%rdi
call   1080 <fputs@plt>
xor    %eax,%eax
call   10e0 <usage@plt>
jmp    121f <main+0x3f>
cmp    $0x2,%ebp
jl     137e <main+0x19e>
mov    %ebp,%r14d
mov    $0xffffffff,%ebp
mov    $0x1,%r12d
xor    %eax,%eax
mov    %rax,0x10(%rsp)
movl   $0x0,0x8(%rsp)
movl   $0x0,0xc(%rsp)
mov    $0xffffffff,%r13d
jmp    126f <main+0x8f>
nopl   0x0(%rax)
mov    (%rbx,%r12,8),%rdi
xor    %esi,%esi
mov    $0xa,%edx
call   10c0 <strtol@plt>
mov    %eax,%ebp
add    $0x1,%r12
cmp    %r12,%r14
je     136d <main+0x18d>
mov    (%rbx,%r12,8),%rax
movsbl (%rax),%edi
call   1050 <isdigit@plt>
test   %rax,%rax
je     12b0 <main+0xd0>
cmp    $0xffffffff,%ebp
je     1250 <main+0x70>
mov    0x2d54(%rip),%rax
mov    (%rax),%esi
lea    0xd7f(%rip),%rdi
call   1080 <fputs@plt>
xor    %eax,%eax
call   10e0 <usage@plt>
jmp    1250 <main+0x70>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    (%rbx,%r12,8),%rdi
call   1040 <audit_name_to_machine@plt>
cmp    $0xffffffff,%eax
je     12ef <main+0x10f>
mov    %eax,%r15d
cmp    $0xffffffff,%r13d
je     134b <main+0x16b>
mov    0x2d0e(%rip),%rax
mov    (%rax),%esi
lea    0xd5a(%rip),%rdi
call   1080 <fputs@plt>
xor    %eax,%eax
call   10e0 <usage@plt>
mov    %r15d,%r13d
jmp    1262 <main+0x82>
mov    (%rbx,%r12,8),%rsi
lea    0xd5a(%rip),%rdi
call   10a0 <strcmp@plt>
test   %rax,%rax
je     1353 <main+0x173>
mov    (%rbx,%r12,8),%rsi
lea    0xd4c(%rip),%rdi
call   10a0 <strcmp@plt>
test   %rax,%rax
je     1360 <main+0x180>
cmpq   $0x0,0x10(%rsp)
je     133d <main+0x15d>
mov    0x2cb8(%rip),%rax
mov    (%rax),%esi
lea    0xd32(%rip),%rdi
call   1080 <fputs@plt>
xor    %eax,%eax
call   10e0 <usage@plt>
mov    (%rbx,%r12,8),%rax
mov    %rax,0x10(%rsp)
jmp    1262 <main+0x82>
mov    %r15d,%r13d
jmp    1262 <main+0x82>
movl   $0x1,0xc(%rsp)
jmp    1262 <main+0x82>
movl   $0x1,0x8(%rsp)
jmp    1262 <main+0x82>
cmp    $0xffffffff,%r13d
mov    0x10(%rsp),%r14
mov    0xc(%rsp),%ebx
jne    13a3 <main+0x1c3>
jmp    1390 <main+0x1b0>
mov    $0xffffffff,%ebp
xor    %r14d,%r14d
movl   $0x0,0x8(%rsp)
xor    %ebx,%ebx
xor    %eax,%eax
call   1030 <audit_detect_machine@plt>
mov    %eax,%r13d
cmp    $0xffffffff,%eax
je     143a <main+0x25a>
test   %ebx,%ebx
je     1403 <main+0x223>
mov    %r13d,%edi
call   1100 <audit_machine_to_name@plt>
lea    0xceb(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1070 <printf@plt>
lea    0xcf3(%rip),%rbx
xor    %ebp,%ebp
jmp    13db <main+0x1fb>
nopl   0x0(%rax,%rax,1)
add    $0x1,%ebp
cmp    $0x2000,%ebp
je     13fb <main+0x21b>
mov    %ebp,%edi
mov    %r13d,%esi
call   1090 <audit_syscall_to_name@plt>
test   %rax,%rax
je     13d0 <main+0x1f0>
mov    %rbx,%rdi
mov    %ebp,%esi
mov    %rax,%rdx
xor    %eax,%eax
call   1070 <printf@plt>
jmp    13d0 <main+0x1f0>
xor    %r15d,%r15d
jmp    1556 <main+0x376>
test   %r14,%r14
je     1456 <main+0x276>
cmpl   $0x0,0x8(%rsp)
je     1482 <main+0x2a2>
mov    %r14,%rdi
mov    %r13d,%esi
call   10d0 <audit_name_to_syscall@plt>
test   %eax,%eax
js     14ea <main+0x30a>
lea    0xcc8(%rip),%rdi
xor    %r15d,%r15d
mov    %eax,%esi
xor    %eax,%eax
call   1070 <printf@plt>
jmp    1556 <main+0x376>
mov    0x2b9f(%rip),%rax
mov    (%rax),%edi
lea    0xc38(%rip),%rsi
xor    %eax,%eax
call   10b0 <fprintf@plt>
jmp    1550 <main+0x370>
cmp    $0xffffffff,%ebp
je     1513 <main+0x333>
mov    %ebp,%edi
mov    %r13d,%esi
call   1090 <audit_syscall_to_name@plt>
test   %rax,%rax
je     152a <main+0x34a>
mov    %rax,%rdi
call   1060 <puts@plt>
xor    %r15d,%r15d
jmp    1556 <main+0x376>
xor    %ebp,%ebp
mov    $0x1,%r15b
lea    0xc5d(%rip),%r12
jmp    149b <main+0x2bb>
add    $0x1,%ebp
cmp    $0x578,%ebp
je     14de <main+0x2fe>
mov    %ebp,%edi
mov    %r13d,%esi
call   1090 <audit_syscall_to_name@plt>
test   %rax,%rax
je     1490 <main+0x2b0>
mov    %rax,%rbx
mov    %rax,%rdi
mov    %r14,%rsi
call   10f0 <strcasestr@plt>
test   %rax,%rax
je     1490 <main+0x2b0>
xor    %r15d,%r15d
mov    %r12,%rdi
mov    %rbx,%rsi
mov    %ebp,%edx
xor    %eax,%eax
call   1070 <printf@plt>
lea    0x1(%rbp),%eax
cmp    $0x577,%ebp
mov    %eax,%ebp
jne    149b <main+0x2bb>
jmp    1556 <main+0x376>
test   $0x1,%r15b
mov    $0x0,%r15d
je     1556 <main+0x376>
mov    0x2aef(%rip),%rax
mov    (%rax),%ebx
mov    %r13d,%edi
call   1100 <audit_machine_to_name@plt>
lea    0xbbf(%rip),%rsi
mov    %ebx,%edi
mov    %r14,%rdx
mov    %rax,%rcx
xor    %eax,%eax
call   10b0 <fprintf@plt>
jmp    1550 <main+0x370>
mov    0x2ac6(%rip),%rax
mov    (%rax),%esi
lea    0xbfc(%rip),%rdi
call   1080 <fputs@plt>
jmp    1550 <main+0x370>
mov    0x2aaf(%rip),%rax
mov    (%rax),%ebx
mov    %r13d,%edi
call   1100 <audit_machine_to_name@plt>
lea    0xbb3(%rip),%rsi
mov    %ebx,%edi
mov    %ebp,%edx
mov    %rax,%rcx
xor    %eax,%eax
call   10b0 <fprintf@plt>
mov    $0x1,%r15d
mov    %r15d,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [20 x i8] c"Too many arguments\0A\00"
@stderr = global i32 0
@.str.1 = [33 x i8] c"Two syscall numbers not allowed\0A\00"
@.str.2 = [31 x i8] c"Two machine types not allowed\0A\00"
@.str.3 = [7 x i8] c"--dump\00"
@.str.4 = [8 x i8] c"--exact\00"
@.str.5 = [31 x i8] c"Two syscall names not allowed\0A\00"
@.str.6 = [31 x i8] c"Unable to detect machine type\0A\00"
@.str.7 = [25 x i8] c"Using %s syscall table:\0A\00"
@.str.8 = [7 x i8] c"%d\09%s\0A\00"
@.str.9 = [42 x i8] c"Unknown syscall %s using %s lookup table\0A\00"
@.str.10 = [4 x i8] c"%d\0A\00"
@.str.11 = [10 x i8] c"%-18s %d\0A\00"
@.str.12 = [42 x i8] c"Unknown syscall %d using %s lookup table\0A\00"
@.str.13 = [4 x i8] c"%s\0A\00"
@.str.14 = [77 x i8] c"Error - either a syscall name or number must be given with an optional arch\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i8*
%13 = alloca i32
%14 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 -1, i32* %8
store i32 -1, i32* %9
store i32 0, i32* %10
store i32 0, i32* %11
store i8* null, i8** %12
%15 = load i32, i32* %4
%16 = icmp sgt i32 %15, 4
br i1 %16, label %17, label %21
17: ; preds = %2
%18 = load i32, i32* @stderr
%19 = call i32 @fputs(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i32 %18)
%20 = call i32 (...) @usage()
br label %21
21: ; preds = %17, %2
store i32 1, i32* %6
br label %22
22: ; preds = %102, %21
%23 = load i32, i32* %6
%24 = load i32, i32* %4
%25 = icmp slt i32 %23, %24
br i1 %25, label %26, label %105
26: ; preds = %22
%27 = load i8**, i8*** %5
%28 = load i32, i32* %6
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds i8*, i8** %27, i64 %29
%31 = load i8*, i8** %30
%32 = getelementptr inbounds i8, i8* %31, i64 0
%33 = load i8, i8* %32
%34 = call i64 @isdigit(i8 signext %33)
%35 = icmp ne i64 %34, 0
br i1 %35, label %36, label %50
36: ; preds = %26
%37 = load i32, i32* %9
%38 = icmp ne i32 %37, -1
br i1 %38, label %39, label %43
39: ; preds = %36
%40 = load i32, i32* @stderr
%41 = call i32 @fputs(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0), i32 %40)
%42 = call i32 (...) @usage()
br label %43
43: ; preds = %39, %36
%44 = load i8**, i8*** %5
%45 = load i32, i32* %6
%46 = sext i32 %45 to i64
%47 = getelementptr inbounds i8*, i8** %44, i64 %46
%48 = load i8*, i8** %47
%49 = call i32 @strtol(i8* %48, i32 0, i32 10)
store i32 %49, i32* %9
br label %101
50: ; preds = %26
%51 = load i8**, i8*** %5
%52 = load i32, i32* %6
%53 = sext i32 %52 to i64
%54 = getelementptr inbounds i8*, i8** %51, i64 %53
%55 = load i8*, i8** %54
%56 = call i32 @audit_name_to_machine(i8* %55)
store i32 %56, i32* %7
%57 = icmp ne i32 %56, -1
br i1 %57, label %58, label %67
58: ; preds = %50
%59 = load i32, i32* %8
%60 = icmp ne i32 %59, -1
br i1 %60, label %61, label %65
61: ; preds = %58
%62 = load i32, i32* @stderr
%63 = call i32 @fputs(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0), i32 %62)
%64 = call i32 (...) @usage()
br label %65
65: ; preds = %61, %58
%66 = load i32, i32* %7
store i32 %66, i32* %8
br label %100
67: ; preds = %50
%68 = load i8**, i8*** %5
%69 = load i32, i32* %6
%70 = sext i32 %69 to i64
%71 = getelementptr inbounds i8*, i8** %68, i64 %70
%72 = load i8*, i8** %71
%73 = call i64 @strcmp(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i8* %72)
%74 = icmp eq i64 %73, 0
br i1 %74, label %75, label %76
75: ; preds = %67
store i32 1, i32* %10
br label %99
76: ; preds = %67
%77 = load i8**, i8*** %5
%78 = load i32, i32* %6
%79 = sext i32 %78 to i64
%80 = getelementptr inbounds i8*, i8** %77, i64 %79
%81 = load i8*, i8** %80
%82 = call i64 @strcmp(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), i8* %81)
%83 = icmp eq i64 %82, 0
br i1 %83, label %84, label %85
84: ; preds = %76
store i32 1, i32* %11
br label %98
85: ; preds = %76
%86 = load i8*, i8** %12
%87 = icmp ne i8* %86, null
br i1 %87, label %88, label %92
88: ; preds = %85
%89 = load i32, i32* @stderr
%90 = call i32 @fputs(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.5, i64 0, i64 0), i32 %89)
%91 = call i32 (...) @usage()
br label %92
92: ; preds = %88, %85
%93 = load i8**, i8*** %5
%94 = load i32, i32* %6
%95 = sext i32 %94 to i64
%96 = getelementptr inbounds i8*, i8** %93, i64 %95
%97 = load i8*, i8** %96
store i8* %97, i8** %12
br label %98
98: ; preds = %92, %84
br label %99
99: ; preds = %98, %75
br label %100
100: ; preds = %99, %65
br label %101
101: ; preds = %100, %43
br label %102
102: ; preds = %101
%103 = load i32, i32* %6
%104 = add nsw i32 %103, 1
store i32 %104, i32* %6
br label %22
105: ; preds = %22
%106 = load i32, i32* %8
%107 = icmp eq i32 %106, -1
br i1 %107, label %108, label %110
108: ; preds = %105
%109 = call i32 (...) @audit_detect_machine()
store i32 %109, i32* %8
br label %110
110: ; preds = %108, %105
%111 = load i32, i32* %8
%112 = icmp eq i32 %111, -1
br i1 %112, label %113, label %116
113: ; preds = %110
%114 = load i32, i32* @stderr
%115 = call i32 (i32, i8*, ...) @fprintf(i32 %114, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.6, i64 0, i64 0))
store i32 1, i32* %3
br label %221
116: ; preds = %110
%117 = load i32, i32* %10
%118 = icmp ne i32 %117, 0
br i1 %118, label %119, label %141
119: ; preds = %116
%120 = load i32, i32* %8
%121 = call i8* @audit_machine_to_name(i32 %120)
%122 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.7, i64 0, i64 0), i8* %121)
store i32 0, i32* %6
br label %123
123: ; preds = %137, %119
%124 = load i32, i32* %6
%125 = icmp slt i32 %124, 8192
br i1 %125, label %126, label %140
126: ; preds = %123
%127 = load i32, i32* %6
%128 = load i32, i32* %8
%129 = call i8* @audit_syscall_to_name(i32 %127, i32 %128)
store i8* %129, i8** %12
%130 = load i8*, i8** %12
%131 = icmp ne i8* %130, null
br i1 %131, label %132, label %136
132: ; preds = %126
%133 = load i32, i32* %6
%134 = load i8*, i8** %12
%135 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.8, i64 0, i64 0), i32 %133, i8* %134)
br label %136
136: ; preds = %132, %126
br label %137
137: ; preds = %136
%138 = load i32, i32* %6
%139 = add nsw i32 %138, 1
store i32 %139, i32* %6
br label %123
140: ; preds = %123
store i32 0, i32* %3
br label %221
141: ; preds = %116
%142 = load i8*, i8** %12
%143 = icmp ne i8* %142, null
br i1 %143, label %144, label %197
144: ; preds = %141
%145 = load i32, i32* %11
%146 = icmp ne i32 %145, 0
br i1 %146, label %147, label %163
147: ; preds = %144
%148 = load i8*, i8** %12
%149 = load i32, i32* %8
%150 = call i32 @audit_name_to_syscall(i8* %148, i32 %149)
store i32 %150, i32* %7
%151 = load i32, i32* %7
%152 = icmp slt i32 %151, 0
br i1 %152, label %153, label %159
153: ; preds = %147
%154 = load i32, i32* @stderr
%155 = load i8*, i8** %12
%156 = load i32, i32* %8
%157 = call i8* @audit_machine_to_name(i32 %156)
%158 = call i32 (i32, i8*, ...) @fprintf(i32 %154, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.9, i64 0, i64 0), i8* %155, i8* %157)
store i32 1, i32* %3
br label %221
159: ; preds = %147
%160 = load i32, i32* %7
%161 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.10, i64 0, i64 0), i32 %160)
br label %162
162: ; preds = %159
br label %196
163: ; preds = %144
store i32 0, i32* %13
store i32 0, i32* %6
br label %164
164: ; preds = %183, %163
%165 = load i32, i32* %6
%166 = icmp slt i32 %165, 1400
br i1 %166, label %167, label %186
167: ; preds = %164
%168 = load i32, i32* %6
%169 = load i32, i32* %8
%170 = call i8* @audit_syscall_to_name(i32 %168, i32 %169)
store i8* %170, i8** %14
%171 = load i8*, i8** %14
%172 = icmp ne i8* %171, null
br i1 %172, label %173, label %182
173: ; preds = %167
%174 = load i8*, i8** %14
%175 = load i8*, i8** %12
%176 = call i64 @strcasestr(i8* %174, i8* %175)
%177 = icmp ne i64 %176, 0
br i1 %177, label %178, label %182
178: ; preds = %173
store i32 1, i32* %13
%179 = load i8*, i8** %14
%180 = load i32, i32* %6
%181 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.11, i64 0, i64 0), i8* %179, i32 %180)
br label %182
182: ; preds = %178, %173, %167
br label %183
183: ; preds = %182
%184 = load i32, i32* %6
%185 = add nsw i32 %184, 1
store i32 %185, i32* %6
br label %164
186: ; preds = %164
%187 = load i32, i32* %13
%188 = icmp ne i32 %187, 0
br i1 %188, label %195, label %189
189: ; preds = %186
%190 = load i32, i32* @stderr
%191 = load i8*, i8** %12
%192 = load i32, i32* %8
%193 = call i8* @audit_machine_to_name(i32 %192)
%194 = call i32 (i32, i8*, ...) @fprintf(i32 %190, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.9, i64 0, i64 0), i8* %191, i8* %193)
store i32 1, i32* %3
br label %221
195: ; preds = %186
br label %196
196: ; preds = %195, %162
br label %220
197: ; preds = %141
%198 = load i32, i32* %9
%199 = icmp ne i32 %198, -1
br i1 %199, label %200, label %216
200: ; preds = %197
%201 = load i32, i32* %9
%202 = load i32, i32* %8
%203 = call i8* @audit_syscall_to_name(i32 %201, i32 %202)
store i8* %203, i8** %12
%204 = load i8*, i8** %12
%205 = icmp eq i8* %204, null
br i1 %205, label %206, label %212
206: ; preds = %200
%207 = load i32, i32* @stderr
%208 = load i32, i32* %9
%209 = load i32, i32* %8
%210 = call i8* @audit_machine_to_name(i32 %209)
%211 = call i32 (i32, i8*, ...) @fprintf(i32 %207, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.12, i64 0, i64 0), i32 %208, i8* %210)
store i32 1, i32* %3
br label %221
212: ; preds = %200
%213 = load i8*, i8** %12
%214 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.13, i64 0, i64 0), i8* %213)
br label %215
215: ; preds = %212
br label %219
216: ; preds = %197
%217 = load i32, i32* @stderr
%218 = call i32 @fputs(i8* getelementptr inbounds ([77 x i8], [77 x i8]* @.str.14, i64 0, i64 0), i32 %217)
store i32 1, i32* %3
br label %221
219: ; preds = %215
br label %220
220: ; preds = %219, %196
store i32 0, i32* %3
br label %221
221: ; preds = %220, %216, %206, %189, %153, %140, %113
%222 = load i32, i32* %3
ret i32 %222
}

LLVM IR (-O2):
@.str = [20 x i8] c"Too many arguments\0A\00"
@stderr = global i32 0
@.str.1 = [33 x i8] c"Two syscall numbers not allowed\0A\00"
@.str.2 = [31 x i8] c"Two machine types not allowed\0A\00"
@.str.3 = [7 x i8] c"--dump\00"
@.str.4 = [8 x i8] c"--exact\00"
@.str.5 = [31 x i8] c"Two syscall names not allowed\0A\00"
@.str.6 = [31 x i8] c"Unable to detect machine type\0A\00"
@.str.7 = [25 x i8] c"Using %s syscall table:\0A\00"
@.str.8 = [7 x i8] c"%d\09%s\0A\00"
@.str.9 = [42 x i8] c"Unknown syscall %s using %s lookup table\0A\00"
@.str.10 = [4 x i8] c"%d\0A\00"
@.str.11 = [10 x i8] c"%-18s %d\0A\00"
@.str.12 = [42 x i8] c"Unknown syscall %d using %s lookup table\0A\00"
@.str.14 = [77 x i8] c"Error - either a syscall name or number must be given with an optional arch\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp sgt i32 %0, 4
br i1 %3, label %4, label %8
4: ; preds = %2
%5 = load i32, i32* @stderr
%6 = tail call i32 @fputs(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i32 %5)
%7 = tail call i32 (...) @usage()
br label %10
8: ; preds = %2
%9 = icmp sgt i32 %0, 1
br i1 %9, label %10, label %69
10: ; preds = %4, %8
%11 = zext i32 %0 to i64
br label %12
12: ; preds = %10, %59
%13 = phi i64 [ 1, %10 ], [ %65, %59 ]
%14 = phi i8* [ null, %10 ], [ %64, %59 ]
%15 = phi i32 [ 0, %10 ], [ %63, %59 ]
%16 = phi i32 [ 0, %10 ], [ %62, %59 ]
%17 = phi i32 [ -1, %10 ], [ %61, %59 ]
%18 = phi i32 [ -1, %10 ], [ %60, %59 ]
%19 = getelementptr inbounds i8*, i8** %1, i64 %13
%20 = load i8*, i8** %19
%21 = load i8, i8* %20
%22 = tail call i64 @isdigit(i8 signext %21)
%23 = icmp eq i64 %22, 0
br i1 %23, label %33, label %24
24: ; preds = %12
%25 = icmp eq i32 %17, -1
br i1 %25, label %30, label %26
26: ; preds = %24
%27 = load i32, i32* @stderr
%28 = tail call i32 @fputs(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0), i32 %27)
%29 = tail call i32 (...) @usage()
br label %30
30: ; preds = %26, %24
%31 = load i8*, i8** %19
%32 = tail call i32 @strtol(i8* %31, i32 0, i32 10)
br label %59
33: ; preds = %12
%34 = load i8*, i8** %19
%35 = tail call i32 @audit_name_to_machine(i8* %34)
%36 = icmp eq i32 %35, -1
br i1 %36, label %43, label %37
37: ; preds = %33
%38 = icmp eq i32 %18, -1
br i1 %38, label %59, label %39
39: ; preds = %37
%40 = load i32, i32* @stderr
%41 = tail call i32 @fputs(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0), i32 %40)
%42 = tail call i32 (...) @usage()
br label %59
43: ; preds = %33
%44 = load i8*, i8** %19
%45 = tail call i64 @strcmp(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i8* %44)
%46 = icmp eq i64 %45, 0
br i1 %46, label %59, label %47
47: ; preds = %43
%48 = load i8*, i8** %19
%49 = tail call i64 @strcmp(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), i8* %48)
%50 = icmp eq i64 %49, 0
br i1 %50, label %59, label %51
51: ; preds = %47
%52 = icmp eq i8* %14, null
br i1 %52, label %57, label %53
53: ; preds = %51
%54 = load i32, i32* @stderr
%55 = tail call i32 @fputs(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.5, i64 0, i64 0), i32 %54)
%56 = tail call i32 (...) @usage()
br label %57
57: ; preds = %53, %51
%58 = load i8*, i8** %19
br label %59
59: ; preds = %47, %43, %37, %39, %30, %57
%60 = phi i32 [ %18, %30 ], [ %18, %57 ], [ %35, %39 ], [ %35, %37 ], [ %18, %43 ], [ %18, %47 ]
%61 = phi i32 [ %32, %30 ], [ %17, %57 ], [ %17, %39 ], [ %17, %37 ], [ %17, %43 ], [ %17, %47 ]
%62 = phi i32 [ %16, %30 ], [ %16, %57 ], [ %16, %39 ], [ %16, %37 ], [ 1, %43 ], [ %16, %47 ]
%63 = phi i32 [ %15, %30 ], [ %15, %57 ], [ %15, %39 ], [ %15, %37 ], [ %15, %43 ], [ 1, %47 ]
%64 = phi i8* [ %14, %30 ], [ %58, %57 ], [ %14, %39 ], [ %14, %37 ], [ %14, %43 ], [ %14, %47 ]
%65 = add nuw nsw i64 %13, 1
%66 = icmp eq i64 %65, %11
br i1 %66, label %67, label %12
67: ; preds = %59
%68 = icmp eq i32 %60, -1
br i1 %68, label %69, label %79
69: ; preds = %8, %67
%70 = phi i8* [ %64, %67 ], [ null, %8 ]
%71 = phi i32 [ %63, %67 ], [ 0, %8 ]
%72 = phi i32 [ %62, %67 ], [ 0, %8 ]
%73 = phi i32 [ %61, %67 ], [ -1, %8 ]
%74 = tail call i32 (...) @audit_detect_machine()
%75 = icmp eq i32 %74, -1
br i1 %75, label %76, label %79
76: ; preds = %69
%77 = load i32, i32* @stderr
%78 = tail call i32 (i32, i8*, ...) @fprintf(i32 %77, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.6, i64 0, i64 0))
br label %147
79: ; preds = %67, %69
%80 = phi i8* [ %70, %69 ], [ %64, %67 ]
%81 = phi i32 [ %71, %69 ], [ %63, %67 ]
%82 = phi i32 [ %72, %69 ], [ %62, %67 ]
%83 = phi i32 [ %73, %69 ], [ %61, %67 ]
%84 = phi i32 [ %74, %69 ], [ %60, %67 ]
%85 = icmp eq i32 %82, 0
br i1 %85, label %98, label %86
86: ; preds = %79
%87 = tail call i8* @audit_machine_to_name(i32 %84)
%88 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.7, i64 0, i64 0), i8* %87)
br label %89
89: ; preds = %86, %95
%90 = phi i32 [ 0, %86 ], [ %96, %95 ]
%91 = tail call i8* @audit_syscall_to_name(i32 %90, i32 %84)
%92 = icmp eq i8* %91, null
br i1 %92, label %95, label %93
93: ; preds = %89
%94 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.8, i64 0, i64 0), i32 %90, i8* %91)
br label %95
95: ; preds = %89, %93
%96 = add nuw nsw i32 %90, 1
%97 = icmp eq i32 %96, 8192
br i1 %97, label %147, label %89
98: ; preds = %79
%99 = icmp eq i8* %80, null
br i1 %99, label %133, label %100
100: ; preds = %98
%101 = icmp eq i32 %81, 0
br i1 %101, label %102, label %105
102: ; preds = %100, %124
%103 = phi i1 [ false, %124 ], [ true, %100 ]
%104 = phi i32 [ %126, %124 ], [ 0, %100 ]
br label %114
105: ; preds = %100
%106 = tail call i32 @audit_name_to_syscall(i8* %80, i32 %84)
%107 = icmp slt i32 %106, 0
br i1 %107, label %108, label %112
108: ; preds = %105
%109 = load i32, i32* @stderr
%110 = tail call i8* @audit_machine_to_name(i32 %84)
%111 = tail call i32 (i32, i8*, ...) @fprintf(i32 %109, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.9, i64 0, i64 0), i8* %80, i8* %110)
br label %147
112: ; preds = %105
%113 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.10, i64 0, i64 0), i32 %106)
br label %147
114: ; preds = %102, %121
%115 = phi i32 [ %122, %121 ], [ %104, %102 ]
%116 = tail call i8* @audit_syscall_to_name(i32 %115, i32 %84)
%117 = icmp eq i8* %116, null
br i1 %117, label %121, label %118
118: ; preds = %114
%119 = tail call i64 @strcasestr(i8* %116, i8* %80)
%120 = icmp eq i64 %119, 0
br i1 %120, label %121, label %124
121: ; preds = %118, %114
%122 = add nuw nsw i32 %115, 1
%123 = icmp eq i32 %122, 1400
br i1 %123, label %128, label %114
124: ; preds = %118
%125 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.11, i64 0, i64 0), i8* %116, i32 %115)
%126 = add nuw nsw i32 %115, 1
%127 = icmp eq i32 %126, 1400
br i1 %127, label %147, label %102
128: ; preds = %121
br i1 %103, label %129, label %147
129: ; preds = %128
%130 = load i32, i32* @stderr
%131 = tail call i8* @audit_machine_to_name(i32 %84)
%132 = tail call i32 (i32, i8*, ...) @fprintf(i32 %130, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.9, i64 0, i64 0), i8* %80, i8* %131)
br label %147
133: ; preds = %98
%134 = icmp eq i32 %83, -1
br i1 %134, label %144, label %135
135: ; preds = %133
%136 = tail call i8* @audit_syscall_to_name(i32 %83, i32 %84)
%137 = icmp eq i8* %136, null
br i1 %137, label %138, label %142
138: ; preds = %135
%139 = load i32, i32* @stderr
%140 = tail call i8* @audit_machine_to_name(i32 %84)
%141 = tail call i32 (i32, i8*, ...) @fprintf(i32 %139, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.12, i64 0, i64 0), i32 %83, i8* %140)
br label %147
142: ; preds = %135
%143 = tail call i32 @puts(i8* %136)
br label %147
144: ; preds = %133
%145 = load i32, i32* @stderr
%146 = tail call i32 @fputs(i8* getelementptr inbounds ([77 x i8], [77 x i8]* @.str.14, i64 0, i64 0), i32 %145)
br label %147
147: ; preds = %95, %124, %142, %112, %128, %129, %144, %138, %108, %76
%148 = phi i32 [ 1, %76 ], [ 1, %108 ], [ 1, %138 ], [ 1, %144 ], [ 1, %129 ], [ 0, %128 ], [ 0, %112 ], [ 0, %142 ], [ 0, %124 ], [ 0, %95 ]
ret i32 %148
}