#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*/ temp_buffer;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int STDIN_FILENO;
int atoi(char *);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ *fdopen(int, char *);
scalar_t__ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, char *, char *, int);
char *strtok(char *, char *);
int main(int argc, char **argv) {
  int fd = STDIN_FILENO;
  FILE *fp;
  int x = 0;
  char temp_buffer[1024];
  char *ptr1 = NULL;
  char *ptr2 = NULL;
  if (argc < 2)
    exit(1);
  x = atoi(argv[1]);
  fp = fdopen(fd, "r");
  while (fgets(temp_buffer, sizeof(temp_buffer), fp)) {
    ptr1 = strtok(temp_buffer, " ");
    ptr2 = strtok(NULL, " ");
    printf("%s %-44s %d\n", (ptr1 == NULL) ? "NULL" : ptr1,
           (ptr2 == NULL) ? "NULL" : ptr2, x);
    x++;
  }
  exit(1);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x460,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2e60(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x14(%rbp)
movl   $0x0,-0x24(%rbp)
movq   $0x0,-0x438(%rbp)
movq   $0x0,-0x440(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    11b6 <main+0x56>
mov    $0x1,%edi
call   1080 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1070 <atoi@plt>
mov    %eax,-0x24(%rbp)
mov    -0x14(%rbp),%edi
lea    0xe30(%rip),%rsi
call   1050 <fdopen@plt>
mov    %rax,-0x20(%rbp)
lea    -0x430(%rbp),%rdi
mov    -0x20(%rbp),%rdx
mov    $0x400,%esi
call   1040 <fgets@plt>
cmp    $0x0,%rax
je     12c0 <main+0x160>
lea    -0x430(%rbp),%rdi
lea    0xdfc(%rip),%rsi
call   1060 <strtok@plt>
mov    %rax,-0x438(%rbp)
xor    %eax,%eax
mov    %eax,%edi
lea    0xde5(%rip),%rsi
call   1060 <strtok@plt>
mov    %rax,-0x440(%rbp)
cmpq   $0x0,-0x438(%rbp)
jne    124a <main+0xea>
lea    0xdd3(%rip),%rax
mov    %rax,-0x448(%rbp)
jmp    1258 <main+0xf8>
mov    -0x438(%rbp),%rax
mov    %rax,-0x448(%rbp)
mov    -0x448(%rbp),%rax
mov    %rax,-0x450(%rbp)
cmpq   $0x0,-0x440(%rbp)
jne    1287 <main+0x127>
lea    0xd96(%rip),%rax
mov    %rax,-0x458(%rbp)
jmp    1295 <main+0x135>
mov    -0x440(%rbp),%rax
mov    %rax,-0x458(%rbp)
mov    -0x450(%rbp),%rsi
mov    -0x458(%rbp),%rdx
mov    -0x24(%rbp),%ecx
lea    0xd57(%rip),%rdi
call   1030 <printf@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    11d9 <main+0x79>
mov    $0x1,%edi
call   1080 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x408,%rsp
cmp    $0x1,%edi
jle    1222 <main+0xc2>
mov    0x2e5f(%rip),%rax
mov    (%rax),%ebp
mov    0x8(%rsi),%rdi
call   1070 <atoi@plt>
mov    %eax,%ebx
lea    0xe6b(%rip),%rsi
mov    %ebp,%edi
call   1050 <fdopen@plt>
mov    %rax,%r14
mov    %rsp,%rdi
mov    $0x400,%esi
mov    %rax,%rdx
call   1040 <fgets@plt>
test   %rax,%rax
je     1222 <main+0xc2>
lea    0xe47(%rip),%r15
mov    %rsp,%r12
lea    0xe4c(%rip),%r13
cs nopw 0x0(%rax,%rax,1)
nop
mov    %r12,%rdi
mov    %r15,%rsi
call   1060 <strtok@plt>
mov    %rax,%rbp
xor    %edi,%edi
mov    %r15,%rsi
call   1060 <strtok@plt>
test   %rbp,%rbp
cmove  %r13,%rbp
test   %rax,%rax
cmove  %r13,%rax
lea    0xe07(%rip),%rdi
mov    %rbp,%rsi
mov    %rax,%rdx
mov    %ebx,%ecx
call   1030 <printf@plt>
add    $0x1,%ebx
mov    %r12,%rdi
mov    $0x400,%esi
mov    %r14,%rdx
call   1040 <fgets@plt>
test   %rax,%rax
jne    11d0 <main+0x70>
mov    $0x1,%edi
call   1080 <exit@plt>

LLVM IR (-O0):
@STDIN_FILENO = global i32 0
@.str = [2 x i8] c"r\00"
@.str.1 = [2 x i8] c" \00"
@.str.2 = [13 x i8] c"%s %-44s %d\0A\00"
@.str.3 = [5 x i8] c"NULL\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 [1024 x i8]
%10 = alloca i8*
%11 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%12 = load i32, i32* @STDIN_FILENO
store i32 %12, i32* %6
store i32 0, i32* %8
store i8* null, i8** %10
store i8* null, i8** %11
%13 = load i32, i32* %4
%14 = icmp slt i32 %13, 2
br i1 %14, label %15, label %17
15: ; preds = %2
%16 = call i32 @exit(i32 1)
unreachable
17: ; preds = %2
%18 = load i8**, i8*** %5
%19 = getelementptr inbounds i8*, i8** %18, i64 1
%20 = load i8*, i8** %19
%21 = call i32 @atoi(i8* %20)
store i32 %21, i32* %8
%22 = load i32, i32* %6
%23 = call i32* @fdopen(i32 %22, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %23, i32** %7
br label %24
24: ; preds = %45, %17
%25 = getelementptr inbounds [1024 x i8], [1024 x i8]* %9, i64 0, i64 0
%26 = load i32*, i32** %7
%27 = call i64 @fgets(i8* %25, i32 1024, i32* %26)
%28 = icmp ne i64 %27, 0
br i1 %28, label %29, label %51
29: ; preds = %24
%30 = getelementptr inbounds [1024 x i8], [1024 x i8]* %9, i64 0, i64 0
%31 = call i8* @strtok(i8* %30, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i8* %31, i8** %10
%32 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i8* %32, i8** %11
%33 = load i8*, i8** %10
%34 = icmp eq i8* %33, null
br i1 %34, label %35, label %36
35: ; preds = %29
br label %38
36: ; preds = %29
%37 = load i8*, i8** %10
br label %38
38: ; preds = %36, %35
%39 = phi i8* [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), %35 ], [ %37, %36 ]
%40 = load i8*, i8** %11
%41 = icmp eq i8* %40, null
br i1 %41, label %42, label %43
42: ; preds = %38
br label %45
43: ; preds = %38
%44 = load i8*, i8** %11
br label %45
45: ; preds = %43, %42
%46 = phi i8* [ getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), %42 ], [ %44, %43 ]
%47 = load i32, i32* %8
%48 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i8* %39, i8* %46, i32 %47)
%49 = load i32, i32* %8
%50 = add nsw i32 %49, 1
store i32 %50, i32* %8
br label %24
51: ; preds = %24
%52 = call i32 @exit(i32 1)
unreachable
}

LLVM IR (-O2):
@STDIN_FILENO = global i32 0
@.str = [2 x i8] c"r\00"
@.str.1 = [2 x i8] c" \00"
@.str.2 = [13 x i8] c"%s %-44s %d\0A\00"
@.str.3 = [5 x i8] c"NULL\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [1024 x i8]
%4 = load i32, i32* @STDIN_FILENO
%5 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%6 = icmp slt i32 %0, 2
br i1 %6, label %7, label %9
7: ; preds = %2
%8 = tail call i32 @exit(i32 1)
unreachable
9: ; preds = %2
%10 = getelementptr inbounds i8*, i8** %1, i64 1
%11 = load i8*, i8** %10
%12 = tail call i32 @atoi(i8* %11)
%13 = tail call i32* @fdopen(i32 %4, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%14 = call i64 @fgets(i8* %5, i32 1024, i32* %13)
%15 = icmp eq i64 %14, 0
br i1 %15, label %28, label %16
16: ; preds = %9, %16
%17 = phi i32 [ %25, %16 ], [ %12, %9 ]
%18 = call i8* @strtok(i8* %5, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%19 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%20 = icmp eq i8* %18, null
%21 = select i1 %20, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i8* %18
%22 = icmp eq i8* %19, null
%23 = select i1 %22, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i8* %19
%24 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i8* %21, i8* %23, i32 %17)
%25 = add nsw i32 %17, 1
%26 = call i64 @fgets(i8* %5, i32 1024, i32* %13)
%27 = icmp eq i64 %26, 0
br i1 %27, label %28, label %16
28: ; preds = %16, %9
%29 = call i32 @exit(i32 1)
unreachable
}