#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*/ exit(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ printf(char *, int /*<<< orphan*/, char *);
int /*<<< orphan*/ stderr;
int main(int argc, char **argv) {
  FILE *ioptr1;
  char str[256];
  char *p, *strtok();
  int i = 1;
  (void)argc;
  if ((ioptr1 = fopen(argv[1], "r")) == NULL) {
    fprintf(stderr, "ndx:  CANNOT OPEN FILE %s\n", argv[1]);
    exit(1);
  } else {
    while ((fgets(str, 256, ioptr1)) != NULL) {
      if ((p = strtok(str, " \t")) != NULL) {
      }
      if ((p = strtok(0, "\n")) != NULL) {
        while (*p == ' ' || *p == '\t')
          p++;
        if (*p == '~')
          p++;
        printf("%d]  %s\n", i++, p);
      }
    }
  }
  fclose(ioptr1);
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x130,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x1,-0x12c(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe5e(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jne    11dc <main+0x6c>
mov    0x2e24(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
lea    0xe35(%rip),%rsi
call   1060 <fprintf@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
jmp    11e1 <main+0x71>
lea    -0x120(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    $0x100,%esi
call   1050 <fgets@plt>
cmp    $0x0,%rax
je     12f8 <main+0x188>
lea    -0x120(%rbp),%rdi
lea    0xe0f(%rip),%rsi
call   1080 <strtok@plt>
mov    %rax,-0x128(%rbp)
cmp    $0x0,%rax
je     1229 <main+0xb9>
jmp    1229 <main+0xb9>
xor    %eax,%eax
mov    %eax,%edi
lea    0xdf3(%rip),%rsi
call   1080 <strtok@plt>
mov    %rax,-0x128(%rbp)
cmp    $0x0,%rax
je     12f3 <main+0x183>
jmp    124f <main+0xdf>
mov    -0x128(%rbp),%rax
movsbl (%rax),%ecx
mov    $0x1,%al
cmp    $0x20,%ecx
mov    %al,-0x12d(%rbp)
je     1280 <main+0x110>
mov    -0x128(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x9,%eax
sete   %al
mov    %al,-0x12d(%rbp)
mov    -0x12d(%rbp),%al
test   $0x1,%al
jne    1293 <main+0x123>
jmp    12aa <main+0x13a>
mov    -0x128(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x128(%rbp)
jmp    124f <main+0xdf>
mov    -0x128(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x7e,%eax
jne    12cf <main+0x15f>
mov    -0x128(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x128(%rbp)
mov    -0x12c(%rbp),%esi
mov    %esi,%eax
add    $0x1,%eax
mov    %eax,-0x12c(%rbp)
mov    -0x128(%rbp),%rdx
lea    0xd32(%rip),%rdi
call   1040 <printf@plt>
jmp    11e1 <main+0x71>
jmp    12fd <main+0x18d>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
xor    %edi,%edi
call   1090 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x108,%rsp
mov    %rsi,%rbx
mov    0x8(%rsi),%rdi
lea    0xe71(%rip),%rsi
call   1070 <fopen@plt>
test   %rax,%rax
jne    11bc <main+0x4c>
mov    0x2e40(%rip),%rax
mov    (%rax),%edi
mov    0x8(%rbx),%rdx
lea    0xe55(%rip),%rsi
call   1060 <fprintf@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
mov    %rax,%r15
mov    %rsp,%rdi
mov    $0x100,%esi
mov    %rax,%rdx
call   1050 <fgets@plt>
test   %rax,%rax
jne    11e3 <main+0x73>
mov    %r15,%rdi
call   1030 <fclose@plt>
xor    %edi,%edi
call   1090 <exit@plt>
mov    $0x1,%ebx
lea    0xe2e(%rip),%r14
mov    %rsp,%r13
lea    0xe2e(%rip),%r12
jmp    122b <main+0xbb>
nopl   0x0(%rax,%rax,1)
lea    0x1(%rbx),%ebp
lea    0xe16(%rip),%rdi
mov    %ebx,%esi
mov    %rax,%rdx
call   1040 <printf@plt>
mov    %ebp,%ebx
mov    %r13,%rdi
mov    $0x100,%esi
mov    %r15,%rdx
call   1050 <fgets@plt>
test   %rax,%rax
je     11d4 <main+0x64>
mov    %r13,%rdi
mov    %r14,%rsi
call   1080 <strtok@plt>
xor    %edi,%edi
mov    %r12,%rsi
call   1080 <strtok@plt>
test   %rax,%rax
jne    1254 <main+0xe4>
jmp    1216 <main+0xa6>
nopw   0x0(%rax,%rax,1)
add    $0x1,%rax
movzbl (%rax),%ecx
cmp    $0x9,%cl
je     1250 <main+0xe0>
cmp    $0x20,%cl
je     1250 <main+0xe0>
cmp    $0x7e,%cl
jne    1200 <main+0x90>
add    $0x1,%rax
jmp    1200 <main+0x90>

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@stderr = global i32 0
@.str.1 = [27 x i8] c"ndx: CANNOT OPEN FILE %s\0A\00"
@.str.2 = [3 x i8] c" \09\00"
@.str.3 = [2 x i8] c"\0A\00"
@.str.4 = [9 x i8] c"%d] %s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca [256 x i8]
%8 = alloca i8*
%9 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 1, i32* %9
%10 = load i32, i32* %4
%11 = load i8**, i8*** %5
%12 = getelementptr inbounds i8*, i8** %11, i64 1
%13 = load i8*, i8** %12
%14 = call i32* @fopen(i8* %13, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %14, i32** %6
%15 = icmp eq i32* %14, null
br i1 %15, label %16, label %23
16: ; preds = %2
%17 = load i32, i32* @stderr
%18 = load i8**, i8*** %5
%19 = getelementptr inbounds i8*, i8** %18, i64 1
%20 = load i8*, i8** %19
%21 = call i32 @fprintf(i32 %17, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0), i8* %20)
%22 = call i32 @exit(i32 1)
unreachable
23: ; preds = %2
br label %24
24: ; preds = %66, %23
%25 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 0
%26 = load i32*, i32** %6
%27 = call i32* @fgets(i8* %25, i32 256, i32* %26)
%28 = icmp ne i32* %27, null
br i1 %28, label %29, label %67
29: ; preds = %24
%30 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 0
%31 = call i8* @strtok(i8* %30, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
store i8* %31, i8** %8
%32 = icmp ne i8* %31, null
br i1 %32, label %33, label %34
33: ; preds = %29
br label %34
34: ; preds = %33, %29
%35 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i8* %35, i8** %8
%36 = icmp ne i8* %35, null
br i1 %36, label %37, label %66
37: ; preds = %34
br label %38
38: ; preds = %50, %37
%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 = load i8, i8* %54
%56 = sext i8 %55 to i32
%57 = icmp eq i32 %56, 126
br i1 %57, label %58, label %61
58: ; preds = %53
%59 = load i8*, i8** %8
%60 = getelementptr inbounds i8, i8* %59, i32 1
store i8* %60, i8** %8
br label %61
61: ; preds = %58, %53
%62 = load i32, i32* %9
%63 = add nsw i32 %62, 1
store i32 %63, i32* %9
%64 = load i8*, i8** %8
%65 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0), i32 %62, i8* %64)
br label %66
66: ; preds = %61, %34
br label %24
67: ; preds = %24
br label %68
68: ; preds = %67
%69 = load i32*, i32** %6
%70 = call i32 @fclose(i32* %69)
%71 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@stderr = global i32 0
@.str.1 = [27 x i8] c"ndx: CANNOT OPEN FILE %s\0A\00"
@.str.2 = [3 x i8] c" \09\00"
@.str.3 = [2 x i8] c"\0A\00"
@.str.4 = [9 x i8] c"%d] %s\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [256 x i8]
%4 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%5 = getelementptr inbounds i8*, i8** %1, i64 1
%6 = load i8*, i8** %5
%7 = tail call i32* @fopen(i8* %6, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%8 = icmp eq i32* %7, null
br i1 %8, label %12, label %9
9: ; preds = %2
%10 = call i32* @fgets(i8* %4, i32 256, i32* %7)
%11 = icmp eq i32* %10, null
br i1 %11, label %37, label %17
12: ; preds = %2
%13 = load i32, i32* @stderr
%14 = load i8*, i8** %5
%15 = tail call i32 @fprintf(i32 %13, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0), i8* %14)
%16 = tail call i32 @exit(i32 1)
unreachable
17: ; preds = %9, %33
%18 = phi i32 [ %34, %33 ], [ 1, %9 ]
%19 = call i8* @strtok(i8* %4, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%20 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%21 = icmp eq i8* %20, null
br i1 %21, label %33, label %22
22: ; preds = %17, %25
%23 = phi i8* [ %26, %25 ], [ %20, %17 ]
%24 = load i8, i8* %23
switch i8 %24, label %29 [
i8 32, label %25
i8 9, label %25
i8 126, label %27
]
25: ; preds = %22, %22
%26 = getelementptr inbounds i8, i8* %23, i64 1
br label %22
27: ; preds = %22
%28 = getelementptr inbounds i8, i8* %23, i64 1
br label %29
29: ; preds = %22, %27
%30 = phi i8* [ %28, %27 ], [ %23, %22 ]
%31 = add nsw i32 %18, 1
%32 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0), i32 %18, i8* %30)
br label %33
33: ; preds = %29, %17
%34 = phi i32 [ %31, %29 ], [ %18, %17 ]
%35 = call i32* @fgets(i8* %4, i32 256, i32* %7)
%36 = icmp eq i32* %35, null
br i1 %36, label %37, label %17
37: ; preds = %33, %9
%38 = call i32 @fclose(i32* %7)
%39 = call i32 @exit(i32 0)
unreachable
}