#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 /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
scalar_t__ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stderr;
char *strchr(char *, char);
scalar_t__ strncmp(char *, char *, int);
char *strstr(char *, char *);
int main(int argc, char **argv) {
  if (argc != 2) {
    printf("usage: %s /usr/include/x86_64-linux-gnu/bits/syscall.h\n", argv[0]);
    return 1;
  }
  FILE *fp = fopen(argv[1], "r");
  if (!fp) {
    fprintf(stderr, "Error: cannot open file\n");
    return 1;
  }
  char buf[4096];
  while (fgets(buf, 4096, fp)) {
    char *start = buf;
    while (*start == ' ' || *start == '\t')
      start++;
    char *end = strchr(start, '\n');
    if (end)
      *end = '\0';
    if (strncmp(start, "# error", 7) == 0)
      continue;
    if (strncmp(start, "#endif", 6) == 0)
      printf("%s\n", start);
    if (strncmp(start, "#endif", 6) == 0)
      printf("%s\n", start);
    else if (strncmp(start, "#if", 3) == 0)
      printf("%s\n", start);
    else if (strncmp(start, "#define", 7) == 0) {
      char *ptr1 = strstr(start, "SYS_");
      char *ptr2 = strstr(start, "__NR_");
      if (!ptr1 || !ptr2) {
        fprintf(stderr, "Error: cannot parse \"%s\"\n", start);
        fclose(fp);
        return 1;
      }
      *(ptr2 - 1) = '\0';
      char *ptr3 = ptr1;
      while (*ptr3 != ' ' && *ptr3 != '\t' && *ptr3 != '\0')
        ptr3++;
      *ptr3 = '\0';
      ptr3 = ptr2;
      while (*ptr3 != ' ' && *ptr3 != '\t' && *ptr3 != '\0')
        ptr3++;
      *ptr3 = '\0';
      ptr3 = ptr1;
      while (*ptr3 != '_')
        ptr3++;
      ptr3++;
      printf("#ifdef %s\n", ptr1);
      printf("#ifdef %s\n", ptr2);
      printf("\t{\"%s\", %s},\n", ptr3, ptr2);
      printf("#endif\n");
      printf("#endif\n");
    }
  }
  fclose(fp);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1050,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
je     11c4 <main+0x44>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe4f(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1634 <main+0x4b4>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe84(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    120a <main+0x8a>
mov    0x2df2(%rip),%rax
mov    (%rax),%edi
lea    0xe41(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1634 <main+0x4b4>
jmp    120f <main+0x8f>
lea    -0x1020(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    $0x1000,%esi
call   1070 <fgets@plt>
cmp    $0x0,%rax
je     1624 <main+0x4a4>
lea    -0x1020(%rbp),%rax
mov    %rax,-0x1028(%rbp)
mov    -0x1028(%rbp),%rax
movsbl (%rax),%ecx
mov    $0x1,%al
cmp    $0x20,%ecx
mov    %al,-0x1049(%rbp)
je     126d <main+0xed>
mov    -0x1028(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x9,%eax
sete   %al
mov    %al,-0x1049(%rbp)
mov    -0x1049(%rbp),%al
test   $0x1,%al
jne    1280 <main+0x100>
jmp    1297 <main+0x117>
mov    -0x1028(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x1028(%rbp)
jmp    123c <main+0xbc>
mov    -0x1028(%rbp),%rdi
mov    $0xa,%esi
call   1050 <strchr@plt>
mov    %rax,-0x1030(%rbp)
cmpq   $0x0,-0x1030(%rbp)
je     12c7 <main+0x147>
mov    -0x1030(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x1028(%rbp),%rdi
lea    0xd7c(%rip),%rsi
mov    $0x7,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    12ee <main+0x16e>
jmp    120f <main+0x8f>
mov    -0x1028(%rbp),%rdi
lea    0xd5d(%rip),%rsi
mov    $0x6,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    1325 <main+0x1a5>
mov    -0x1028(%rbp),%rsi
lea    0xd7a(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x1028(%rbp),%rdi
lea    0xd26(%rip),%rsi
mov    $0x6,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    1361 <main+0x1e1>
mov    -0x1028(%rbp),%rsi
lea    0xd43(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    161f <main+0x49f>
mov    -0x1028(%rbp),%rdi
lea    0xcf1(%rip),%rsi
mov    $0x3,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    139d <main+0x21d>
mov    -0x1028(%rbp),%rsi
lea    0xd07(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    161a <main+0x49a>
mov    -0x1028(%rbp),%rdi
lea    0xcb9(%rip),%rsi
mov    $0x7,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    1615 <main+0x495>
mov    -0x1028(%rbp),%rdi
lea    0xc9f(%rip),%rsi
call   10a0 <strstr@plt>
mov    %rax,-0x1038(%rbp)
mov    -0x1028(%rbp),%rdi
lea    0xc8a(%rip),%rsi
call   10a0 <strstr@plt>
mov    %rax,-0x1040(%rbp)
cmpq   $0x0,-0x1038(%rbp)
je     140f <main+0x28f>
cmpq   $0x0,-0x1040(%rbp)
jne    1442 <main+0x2c2>
mov    0x2bca(%rip),%rax
mov    (%rax),%edi
mov    -0x1028(%rbp),%rdx
lea    0xc51(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    -0x18(%rbp),%rdi
call   1040 <fclose@plt>
movl   $0x1,-0x4(%rbp)
jmp    1634 <main+0x4b4>
mov    -0x1040(%rbp),%rax
movb   $0x0,-0x1(%rax)
mov    -0x1038(%rbp),%rax
mov    %rax,-0x1048(%rbp)
mov    -0x1048(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x20,%ecx
mov    %al,-0x104a(%rbp)
je     14a7 <main+0x327>
mov    -0x1048(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x9,%ecx
mov    %al,-0x104a(%rbp)
je     14a7 <main+0x327>
mov    -0x1048(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
setne  %al
mov    %al,-0x104a(%rbp)
mov    -0x104a(%rbp),%al
test   $0x1,%al
jne    14ba <main+0x33a>
jmp    14d1 <main+0x351>
mov    -0x1048(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x1048(%rbp)
jmp    145b <main+0x2db>
mov    -0x1048(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x1040(%rbp),%rax
mov    %rax,-0x1048(%rbp)
mov    -0x1048(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x20,%ecx
mov    %al,-0x104b(%rbp)
je     1535 <main+0x3b5>
mov    -0x1048(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x9,%ecx
mov    %al,-0x104b(%rbp)
je     1535 <main+0x3b5>
mov    -0x1048(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
setne  %al
mov    %al,-0x104b(%rbp)
mov    -0x104b(%rbp),%al
test   $0x1,%al
jne    1548 <main+0x3c8>
jmp    155f <main+0x3df>
mov    -0x1048(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x1048(%rbp)
jmp    14e9 <main+0x369>
mov    -0x1048(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x1038(%rbp),%rax
mov    %rax,-0x1048(%rbp)
mov    -0x1048(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x5f,%eax
je     15a1 <main+0x421>
mov    -0x1048(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x1048(%rbp)
jmp    1577 <main+0x3f7>
mov    -0x1048(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x1048(%rbp)
mov    -0x1038(%rbp),%rsi
lea    0xad0(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x1040(%rbp),%rsi
lea    0xabb(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x1048(%rbp),%rsi
mov    -0x1040(%rbp),%rdx
lea    0xaaa(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xaaa(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xa9c(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    161a <main+0x49a>
jmp    161f <main+0x49f>
jmp    120f <main+0x8f>
mov    -0x18(%rbp),%rdi
call   1040 <fclose@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x1050,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x1018,%rsp
cmp    $0x2,%edi
jne    13e5 <main+0x255>
mov    0x8(%rsi),%rdi
lea    0xea2(%rip),%rsi
call   10a0 <fopen@plt>
test   %rax,%rax
je     13f8 <main+0x268>
mov    %rax,%r15
lea    0x10(%rsp),%rbp
mov    %rbp,%rdi
mov    $0x1000,%esi
mov    %rax,%rdx
call   1080 <fgets@plt>
test   %rax,%rax
je     13d9 <main+0x249>
lea    0xe66(%rip),%r12
lea    0xeb1(%rip),%rbx
lea    0xe60(%rip),%r13
mov    %rbp,%r14
mov    %r15,0x8(%rsp)
jmp    1214 <main+0x84>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
add    $0x1,%r14
mov    (%r14),%al
cmp    $0x20,%al
je     1210 <main+0x80>
cmp    $0x9,%al
je     1210 <main+0x80>
mov    %r14,%rdi
mov    $0xa,%esi
call   1060 <strchr@plt>
test   %rax,%rax
je     1234 <main+0xa4>
movb   $0x0,(%rax)
mov    %r14,%rdi
mov    %r12,%rsi
mov    $0x7,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     13bd <main+0x22d>
mov    %r14,%rdi
mov    %rbx,%rsi
mov    $0x6,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
jne    126a <main+0xda>
mov    %r14,%rdi
call   1040 <puts@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
mov    $0x6,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     13b5 <main+0x225>
mov    %r14,%rdi
mov    %r13,%rsi
mov    $0x3,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     13b5 <main+0x225>
mov    %r14,%rdi
lea    0xdb7(%rip),%rsi
mov    $0x7,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
jne    13bd <main+0x22d>
mov    %r14,%rdi
lea    0xda2(%rip),%rsi
call   10b0 <strstr@plt>
mov    %rax,%r15
mov    %r14,%rdi
lea    0xd95(%rip),%rsi
call   10b0 <strstr@plt>
test   %r15,%r15
je     1428 <main+0x298>
mov    %rax,%r13
test   %rax,%rax
je     1428 <main+0x298>
movb   $0x0,-0x1(%r13)
mov    %r15,%rax
movabs $0x100000201,%rdx
jmp    1314 <main+0x184>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
add    $0x1,%rax
movzbl (%rax),%ecx
cmp    $0x20,%rcx
ja     1310 <main+0x180>
bt     %rcx,%rdx
jae    1310 <main+0x180>
movb   $0x0,(%rax)
mov    %r13,%rax
jmp    1334 <main+0x1a4>
nopl   0x0(%rax,%rax,1)
add    $0x1,%rax
movzbl (%rax),%ecx
cmp    $0x20,%rcx
ja     1330 <main+0x1a0>
bt     %rcx,%rdx
jae    1330 <main+0x1a0>
mov    %r12,%r14
movb   $0x0,(%rax)
mov    %r15,%rbp
nopl   0x0(%rax)
cmpb   $0x5f,0x0(%rbp)
lea    0x1(%rbp),%rbp
jne    1350 <main+0x1c0>
lea    0xd29(%rip),%r12
mov    %r12,%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1070 <printf@plt>
mov    %r12,%rdi
mov    %r13,%rsi
xor    %eax,%eax
call   1070 <printf@plt>
lea    0xd13(%rip),%rdi
mov    %rbp,%rsi
mov    %r13,%rdx
xor    %eax,%eax
call   1070 <printf@plt>
mov    %rbx,%rdi
call   1040 <puts@plt>
mov    %rbx,%rdi
call   1040 <puts@plt>
mov    %r14,%r12
lea    0x10(%rsp),%rbp
mov    0x8(%rsp),%r15
lea    0xca6(%rip),%r13
jmp    13bd <main+0x22d>
mov    %r14,%rdi
call   1040 <puts@plt>
mov    %rbp,%rdi
mov    $0x1000,%esi
mov    %r15,%rdx
call   1080 <fgets@plt>
mov    %rbp,%r14
test   %rax,%rax
jne    1214 <main+0x84>
xor    %ebp,%ebp
mov    %r15,%rdi
call   1050 <fclose@plt>
jmp    1414 <main+0x284>
mov    (%rsi),%rsi
lea    0xc11(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
jmp    140f <main+0x27f>
mov    0x2be1(%rip),%rax
mov    (%rax),%edi
lea    0xc30(%rip),%rsi
xor    %eax,%eax
call   1090 <fprintf@plt>
mov    $0x1,%ebp
mov    %ebp,%eax
add    $0x1018,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2bb1(%rip),%rax
mov    (%rax),%edi
lea    0xc38(%rip),%rsi
mov    %r14,%rdx
xor    %eax,%eax
call   1090 <fprintf@plt>
mov    $0x1,%ebp
mov    0x8(%rsp),%r15
jmp    13db <main+0x24b>

LLVM IR (-O0):
@.str = [56 x i8] c"usage: %s /usr/include/x86_64-linux-gnu/bits/syscall.h\0A\00"
@.str.1 = [2 x i8] c"r\00"
@stderr = global i32 0
@.str.2 = [25 x i8] c"Error: cannot open file\0A\00"
@.str.3 = [8 x i8] c"# error\00"
@.str.4 = [7 x i8] c"#endif\00"
@.str.5 = [4 x i8] c"%s\0A\00"
@.str.6 = [4 x i8] c"#if\00"
@.str.7 = [8 x i8] c"#define\00"
@.str.8 = [5 x i8] c"SYS_\00"
@.str.9 = [6 x i8] c"__NR_\00"
@.str.10 = [26 x i8] c"Error: cannot parse \22%s\22\0A\00"
@.str.11 = [11 x i8] c"#ifdef %s\0A\00"
@.str.12 = [14 x i8] c"\09{\22%s\22, %s},\0A\00"
@.str.13 = [8 x i8] c"#endif\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca [4096 x i8]
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i8*
%12 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%13 = load i32, i32* %4
%14 = icmp ne i32 %13, 2
br i1 %14, label %15, label %20
15: ; preds = %2
%16 = load i8**, i8*** %5
%17 = getelementptr inbounds i8*, i8** %16, i64 0
%18 = load i8*, i8** %17
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str, i64 0, i64 0), i8* %18)
store i32 1, i32* %3
br label %182
20: ; preds = %2
%21 = load i8**, i8*** %5
%22 = getelementptr inbounds i8*, i8** %21, i64 1
%23 = load i8*, i8** %22
%24 = call i32* @fopen(i8* %23, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %24, i32** %6
%25 = load i32*, i32** %6
%26 = icmp ne i32* %25, null
br i1 %26, label %30, label %27
27: ; preds = %20
%28 = load i32, i32* @stderr
%29 = call i32 (i32, i8*, ...) @fprintf(i32 %28, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0))
store i32 1, i32* %3
br label %182
30: ; preds = %20
br label %31
31: ; preds = %178, %64, %30
%32 = getelementptr inbounds [4096 x i8], [4096 x i8]* %7, i64 0, i64 0
%33 = load i32*, i32** %6
%34 = call i64 @fgets(i8* %32, i32 4096, i32* %33)
%35 = icmp ne i64 %34, 0
br i1 %35, label %36, label %179
36: ; preds = %31
%37 = getelementptr inbounds [4096 x i8], [4096 x i8]* %7, i64 0, i64 0
store i8* %37, i8** %8
br label %38
38: ; preds = %50, %36
%39 = load i8*, i8** %8
%40 = load i8, i8* %39
%41 = sext i8 %40 to i32
%42 = icmp eq i32 %41, 32
br i1 %42, label %48, label %43
43: ; preds = %38
%44 = load i8*, i8** %8
%45 = load i8, i8* %44
%46 = sext i8 %45 to i32
%47 = icmp eq i32 %46, 9
br label %48
48: ; preds = %43, %38
%49 = phi i1 [ true, %38 ], [ %47, %43 ]
br i1 %49, label %50, label %53
50: ; preds = %48
%51 = load i8*, i8** %8
%52 = getelementptr inbounds i8, i8* %51, i32 1
store i8* %52, i8** %8
br label %38
53: ; preds = %48
%54 = load i8*, i8** %8
%55 = call i8* @strchr(i8* %54, i8 signext 10)
store i8* %55, i8** %9
%56 = load i8*, i8** %9
%57 = icmp ne i8* %56, null
br i1 %57, label %58, label %60
58: ; preds = %53
%59 = load i8*, i8** %9
store i8 0, i8* %59
br label %60
60: ; preds = %58, %53
%61 = load i8*, i8** %8
%62 = call i64 @strncmp(i8* %61, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i32 7)
%63 = icmp eq i64 %62, 0
br i1 %63, label %64, label %65
64: ; preds = %60
br label %31
65: ; preds = %60
%66 = load i8*, i8** %8
%67 = call i64 @strncmp(i8* %66, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), i32 6)
%68 = icmp eq i64 %67, 0
br i1 %68, label %69, label %72
69: ; preds = %65
%70 = load i8*, i8** %8
%71 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i8* %70)
br label %72
72: ; preds = %69, %65
%73 = load i8*, i8** %8
%74 = call i64 @strncmp(i8* %73, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), i32 6)
%75 = icmp eq i64 %74, 0
br i1 %75, label %76, label %79
76: ; preds = %72
%77 = load i8*, i8** %8
%78 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i8* %77)
br label %178
79: ; preds = %72
%80 = load i8*, i8** %8
%81 = call i64 @strncmp(i8* %80, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i32 3)
%82 = icmp eq i64 %81, 0
br i1 %82, label %83, label %86
83: ; preds = %79
%84 = load i8*, i8** %8
%85 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i8* %84)
br label %177
86: ; preds = %79
%87 = load i8*, i8** %8
%88 = call i64 @strncmp(i8* %87, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.7, i64 0, i64 0), i32 7)
%89 = icmp eq i64 %88, 0
br i1 %89, label %90, label %176
90: ; preds = %86
%91 = load i8*, i8** %8
%92 = call i8* @strstr(i8* %91, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.8, i64 0, i64 0))
store i8* %92, i8** %10
%93 = load i8*, i8** %8
%94 = call i8* @strstr(i8* %93, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.9, i64 0, i64 0))
store i8* %94, i8** %11
%95 = load i8*, i8** %10
%96 = icmp ne i8* %95, null
br i1 %96, label %97, label %100
97: ; preds = %90
%98 = load i8*, i8** %11
%99 = icmp ne i8* %98, null
br i1 %99, label %106, label %100
100: ; preds = %97, %90
%101 = load i32, i32* @stderr
%102 = load i8*, i8** %8
%103 = call i32 (i32, i8*, ...) @fprintf(i32 %101, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.10, i64 0, i64 0), i8* %102)
%104 = load i32*, i32** %6
%105 = call i32 @fclose(i32* %104)
store i32 1, i32* %3
br label %182
106: ; preds = %97
%107 = load i8*, i8** %11
%108 = getelementptr inbounds i8, i8* %107, i64 -1
store i8 0, i8* %108
%109 = load i8*, i8** %10
store i8* %109, i8** %12
br label %110
110: ; preds = %127, %106
%111 = load i8*, i8** %12
%112 = load i8, i8* %111
%113 = sext i8 %112 to i32
%114 = icmp ne i32 %113, 32
br i1 %114, label %115, label %125
115: ; preds = %110
%116 = load i8*, i8** %12
%117 = load i8, i8* %116
%118 = sext i8 %117 to i32
%119 = icmp ne i32 %118, 9
br i1 %119, label %120, label %125
120: ; preds = %115
%121 = load i8*, i8** %12
%122 = load i8, i8* %121
%123 = sext i8 %122 to i32
%124 = icmp ne i32 %123, 0
br label %125
125: ; preds = %120, %115, %110
%126 = phi i1 [ false, %115 ], [ false, %110 ], [ %124, %120 ]
br i1 %126, label %127, label %130
127: ; preds = %125
%128 = load i8*, i8** %12
%129 = getelementptr inbounds i8, i8* %128, i32 1
store i8* %129, i8** %12
br label %110
130: ; preds = %125
%131 = load i8*, i8** %12
store i8 0, i8* %131
%132 = load i8*, i8** %11
store i8* %132, i8** %12
br label %133
133: ; preds = %150, %130
%134 = load i8*, i8** %12
%135 = load i8, i8* %134
%136 = sext i8 %135 to i32
%137 = icmp ne i32 %136, 32
br i1 %137, label %138, label %148
138: ; preds = %133
%139 = load i8*, i8** %12
%140 = load i8, i8* %139
%141 = sext i8 %140 to i32
%142 = icmp ne i32 %141, 9
br i1 %142, label %143, label %148
143: ; preds = %138
%144 = load i8*, i8** %12
%145 = load i8, i8* %144
%146 = sext i8 %145 to i32
%147 = icmp ne i32 %146, 0
br label %148
148: ; preds = %143, %138, %133
%149 = phi i1 [ false, %138 ], [ false, %133 ], [ %147, %143 ]
br i1 %149, label %150, label %153
150: ; preds = %148
%151 = load i8*, i8** %12
%152 = getelementptr inbounds i8, i8* %151, i32 1
store i8* %152, i8** %12
br label %133
153: ; preds = %148
%154 = load i8*, i8** %12
store i8 0, i8* %154
%155 = load i8*, i8** %10
store i8* %155, i8** %12
br label %156
156: ; preds = %161, %153
%157 = load i8*, i8** %12
%158 = load i8, i8* %157
%159 = sext i8 %158 to i32
%160 = icmp ne i32 %159, 95
br i1 %160, label %161, label %164
161: ; preds = %156
%162 = load i8*, i8** %12
%163 = getelementptr inbounds i8, i8* %162, i32 1
store i8* %163, i8** %12
br label %156
164: ; preds = %156
%165 = load i8*, i8** %12
%166 = getelementptr inbounds i8, i8* %165, i32 1
store i8* %166, i8** %12
%167 = load i8*, i8** %10
%168 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.11, i64 0, i64 0), i8* %167)
%169 = load i8*, i8** %11
%170 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.11, i64 0, i64 0), i8* %169)
%171 = load i8*, i8** %12
%172 = load i8*, i8** %11
%173 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.12, i64 0, i64 0), i8* %171, i8* %172)
%174 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.13, i64 0, i64 0))
%175 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.13, i64 0, i64 0))
br label %176
176: ; preds = %164, %86
br label %177
177: ; preds = %176, %83
br label %178
178: ; preds = %177, %76
br label %31
179: ; preds = %31
%180 = load i32*, i32** %6
%181 = call i32 @fclose(i32* %180)
store i32 0, i32* %3
br label %182
182: ; preds = %179, %100, %27, %15
%183 = load i32, i32* %3
ret i32 %183
}

LLVM IR (-O2):
@.str = [56 x i8] c"usage: %s /usr/include/x86_64-linux-gnu/bits/syscall.h\0A\00"
@.str.1 = [2 x i8] c"r\00"
@stderr = global i32 0
@.str.2 = [25 x i8] c"Error: cannot open file\0A\00"
@.str.3 = [8 x i8] c"# error\00"
@.str.6 = [4 x i8] c"#if\00"
@.str.7 = [8 x i8] c"#define\00"
@.str.8 = [5 x i8] c"SYS_\00"
@.str.9 = [6 x i8] c"__NR_\00"
@.str.10 = [26 x i8] c"Error: cannot parse \22%s\22\0A\00"
@.str.11 = [11 x i8] c"#ifdef %s\0A\00"
@.str.12 = [14 x i8] c"\09{\22%s\22, %s},\0A\00"
@str.14 = [7 x i8] c"#endif\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [4096 x i8]
%4 = icmp eq i32 %0, 2
br i1 %4, label %8, label %5
5: ; preds = %2
%6 = load i8*, i8** %1
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([56 x i8], [56 x i8]* @.str, i64 0, i64 0), i8* %6)
br label %92
8: ; preds = %2
%9 = getelementptr inbounds i8*, i8** %1, i64 1
%10 = load i8*, i8** %9
%11 = tail call i32* @fopen(i8* %10, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%12 = icmp eq i32* %11, null
br i1 %12, label %13, label %16
13: ; preds = %8
%14 = load i32, i32* @stderr
%15 = tail call i32 (i32, i8*, ...) @fprintf(i32 %14, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0))
br label %92
16: ; preds = %8
%17 = getelementptr inbounds [4096 x i8], [4096 x i8]* %3, i64 0, i64 0
%18 = call i64 @fgets(i8* %17, i32 4096, i32* %11)
%19 = icmp eq i64 %18, 0
br i1 %19, label %89, label %20
20: ; preds = %16, %25
%21 = phi i8* [ %26, %25 ], [ %17, %16 ]
%22 = load i8, i8* %21
switch i8 %22, label %27 [
i8 32, label %23
i8 9, label %23
]
23: ; preds = %20, %20
%24 = getelementptr inbounds i8, i8* %21, i64 1
br label %25
25: ; preds = %23, %86
%26 = phi i8* [ %24, %23 ], [ %17, %86 ]
br label %20
27: ; preds = %20
%28 = call i8* @strchr(i8* %21, i8 signext 10)
%29 = icmp eq i8* %28, null
br i1 %29, label %31, label %30
30: ; preds = %27
store i8 0, i8* %28
br label %31
31: ; preds = %30, %27
%32 = call i64 @strncmp(i8* %21, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), i32 7)
%33 = icmp eq i64 %32, 0
br i1 %33, label %86, label %34
34: ; preds = %31
%35 = call i64 @strncmp(i8* %21, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @str.14, i64 0, i64 0), i32 6)
%36 = icmp eq i64 %35, 0
br i1 %36, label %37, label %39
37: ; preds = %34
%38 = call i32 @puts(i8* %21)
br label %39
39: ; preds = %37, %34
%40 = call i64 @strncmp(i8* %21, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @str.14, i64 0, i64 0), i32 6)
%41 = icmp eq i64 %40, 0
br i1 %41, label %42, label %44
42: ; preds = %39
%43 = call i32 @puts(i8* %21)
br label %86
44: ; preds = %39
%45 = call i64 @strncmp(i8* %21, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i32 3)
%46 = icmp eq i64 %45, 0
br i1 %46, label %47, label %49
47: ; preds = %44
%48 = call i32 @puts(i8* %21)
br label %86
49: ; preds = %44
%50 = call i64 @strncmp(i8* %21, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.7, i64 0, i64 0), i32 7)
%51 = icmp eq i64 %50, 0
br i1 %51, label %52, label %86
52: ; preds = %49
%53 = call i8* @strstr(i8* %21, i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.8, i64 0, i64 0))
%54 = call i8* @strstr(i8* %21, i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.9, i64 0, i64 0))
%55 = icmp ne i8* %53, null
%56 = icmp ne i8* %54, null
%57 = select i1 %55, i1 %56, i1 false
br i1 %57, label %61, label %58
58: ; preds = %52
%59 = load i32, i32* @stderr
%60 = call i32 (i32, i8*, ...) @fprintf(i32 %59, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.10, i64 0, i64 0), i8* %21)
br label %89
61: ; preds = %52
%62 = getelementptr inbounds i8, i8* %54, i64 -1
store i8 0, i8* %62
br label %63
63: ; preds = %66, %61
%64 = phi i8* [ %53, %61 ], [ %67, %66 ]
%65 = load i8, i8* %64
switch i8 %65, label %66 [
i8 32, label %68
i8 9, label %68
i8 0, label %68
]
66: ; preds = %63
%67 = getelementptr inbounds i8, i8* %64, i64 1
br label %63
68: ; preds = %63, %63, %63
store i8 0, i8* %64
br label %69
69: ; preds = %72, %68
%70 = phi i8* [ %54, %68 ], [ %73, %72 ]
%71 = load i8, i8* %70
switch i8 %71, label %72 [
i8 32, label %74
i8 9, label %74
i8 0, label %74
]
72: ; preds = %69
%73 = getelementptr inbounds i8, i8* %70, i64 1
br label %69
74: ; preds = %69, %69, %69
store i8 0, i8* %70
br label %75
75: ; preds = %75, %74
%76 = phi i8* [ %53, %74 ], [ %79, %75 ]
%77 = load i8, i8* %76
%78 = icmp eq i8 %77, 95
%79 = getelementptr inbounds i8, i8* %76, i64 1
br i1 %78, label %80, label %75
80: ; preds = %75
%81 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.11, i64 0, i64 0), i8* %53)
%82 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.11, i64 0, i64 0), i8* %54)
%83 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.12, i64 0, i64 0), i8* %79, i8* %54)
%84 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @str.14, i64 0, i64 0))
%85 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @str.14, i64 0, i64 0))
br label %86
86: ; preds = %80, %42, %49, %47, %31
%87 = call i64 @fgets(i8* %17, i32 4096, i32* %11)
%88 = icmp eq i64 %87, 0
br i1 %88, label %89, label %25
89: ; preds = %86, %16, %58
%90 = phi i32 [ 1, %58 ], [ 0, %16 ], [ 0, %86 ]
%91 = call i32 @fclose(i32* %11)
br label %92
92: ; preds = %13, %89, %5
%93 = phi i32 [ 1, %5 ], [ %90, %89 ], [ 1, %13 ]
ret i32 %93
}