#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*/ fprintf(int /*<<< orphan*/ *, char *);
scalar_t__ fscanf(int /*<<< orphan*/ *, char *, char *);
int tolower(char);
int parse_post_turing(FILE *file, FILE *errfile, int code[1024][2],
                      int *labels) {
  char token[16];
  int line = 0;
  while (fscanf(file, "%15s", token) > 0) {
    switch (tolower(token[0])) {
    case '[':
      labels[token[1]] = line;
      break;
    case 'i':
      fscanf(file, "%15s", token);
      code[line][0] = token[0] + 2;
      fscanf(file, "%15s", token);
      fscanf(file, "%15s", token);
      code[line++][1] = token[0];
      break;
    case 'l':
      code[line++][0] = 1;
      break;
    case 'p':
      code[line][0] = 2;
      fscanf(file, "%15s", token);
      code[line++][1] = token[0];
      break;
    case 'r':
      code[line++][0] = 0;
      break;
    default:
      fprintf(errfile, "Invalid program!!\n\n");
      exit(2);
      break;
    }
  }
  return line;
}


x86 assembly (clang, -O0):
<parse_post_turing>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
movl   $0x0,-0x34(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0x30(%rbp),%rdx
lea    0xef2(%rip),%rsi
call   1030 <fscanf@plt>
cmp    $0x0,%rax
jle    12ca <parse_post_turing+0x18a>
movsbl -0x30(%rbp),%edi
call   1050 <tolower@plt>
add    $0xffffffa5,%eax
mov    %eax,%ecx
mov    %rcx,-0x40(%rbp)
sub    $0x17,%eax
ja     12ab <parse_post_turing+0x16b>
mov    -0x40(%rbp),%rax
lea    0xe5d(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x34(%rbp),%edx
mov    -0x20(%rbp),%rax
movsbq -0x2f(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
jmp    12c5 <parse_post_turing+0x185>
mov    -0x8(%rbp),%rdi
lea    -0x30(%rbp),%rdx
lea    0xe91(%rip),%rsi
call   1030 <fscanf@plt>
movsbl -0x30(%rbp),%edx
add    $0x2,%edx
mov    -0x18(%rbp),%rax
movslq -0x34(%rbp),%rcx
mov    %edx,(%rax,%rcx,8)
mov    -0x8(%rbp),%rdi
lea    -0x30(%rbp),%rdx
lea    0xe6b(%rip),%rsi
call   1030 <fscanf@plt>
mov    -0x8(%rbp),%rdi
lea    -0x30(%rbp),%rdx
lea    0xe57(%rip),%rsi
call   1030 <fscanf@plt>
movsbl -0x30(%rbp),%edx
mov    -0x18(%rbp),%rax
mov    -0x34(%rbp),%ecx
mov    %ecx,%esi
add    $0x1,%esi
mov    %esi,-0x34(%rbp)
movslq %ecx,%rcx
mov    %edx,0x4(%rax,%rcx,8)
jmp    12c5 <parse_post_turing+0x185>
mov    -0x18(%rbp),%rax
mov    -0x34(%rbp),%ecx
mov    %ecx,%edx
add    $0x1,%edx
mov    %edx,-0x34(%rbp)
movslq %ecx,%rcx
movl   $0x1,(%rax,%rcx,8)
jmp    12c5 <parse_post_turing+0x185>
mov    -0x18(%rbp),%rax
movslq -0x34(%rbp),%rcx
movl   $0x2,(%rax,%rcx,8)
mov    -0x8(%rbp),%rdi
lea    -0x30(%rbp),%rdx
lea    0xdf7(%rip),%rsi
call   1030 <fscanf@plt>
movsbl -0x30(%rbp),%edx
mov    -0x18(%rbp),%rax
mov    -0x34(%rbp),%ecx
mov    %ecx,%esi
add    $0x1,%esi
mov    %esi,-0x34(%rbp)
movslq %ecx,%rcx
mov    %edx,0x4(%rax,%rcx,8)
jmp    12c5 <parse_post_turing+0x185>
mov    -0x18(%rbp),%rax
mov    -0x34(%rbp),%ecx
mov    %ecx,%edx
add    $0x1,%edx
mov    %edx,-0x34(%rbp)
movslq %ecx,%rcx
movl   $0x0,(%rax,%rcx,8)
jmp    12c5 <parse_post_turing+0x185>
mov    -0x10(%rbp),%rdi
lea    0xdaf(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0x2,%edi
call   1060 <exit@plt>
jmp    115f <parse_post_turing+0x1f>
mov    -0x34(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_post_turing>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %rcx,0x20(%rsp)
mov    %rdx,0x10(%rsp)
mov    %rsi,%rbx
mov    %rdi,%r14
lea    0xefb(%rip),%rsi
mov    %rsp,%rdx
call   1030 <fscanf@plt>
test   %rax,%rax
jle    126e <parse_post_turing+0x12e>
mov    %rbx,0x18(%rsp)
xor    %r12d,%r12d
lea    0xe7b(%rip),%rbp
lea    0xed4(%rip),%r15
mov    %rsp,%rbx
jmp    11b7 <parse_post_turing+0x77>
movsbq 0x1(%rsp),%rax
mov    0x20(%rsp),%rcx
mov    %r12d,(%rcx,%rax,4)
mov    %r14,%rdi
mov    %r15,%rsi
mov    %rbx,%rdx
call   1030 <fscanf@plt>
test   %rax,%rax
jle    1271 <parse_post_turing+0x131>
movsbl (%rsp),%edi
call   1040 <tolower@plt>
add    $0xffffffa5,%eax
cmp    $0x17,%eax
ja     1283 <parse_post_turing+0x143>
movslq 0x0(%rbp,%rax,4),%rax
add    %rbp,%rax
jmp    *%rax
mov    %r14,%rdi
mov    %r15,%rsi
mov    %rbx,%rdx
call   1030 <fscanf@plt>
movsbl (%rsp),%eax
add    $0x2,%eax
movslq %r12d,%r13
mov    0x10(%rsp),%rbx
mov    %eax,(%rbx,%r13,8)
mov    %r14,%rdi
mov    %r15,%rsi
mov    %rsp,%rdx
call   1030 <fscanf@plt>
jmp    122c <parse_post_turing+0xec>
movslq %r12d,%rax
add    $0x1,%r12d
mov    0x10(%rsp),%rcx
movl   $0x1,(%rcx,%rax,8)
jmp    11a0 <parse_post_turing+0x60>
movslq %r12d,%r13
mov    0x10(%rsp),%rbx
movl   $0x2,(%rbx,%r13,8)
mov    %r14,%rdi
mov    %r15,%rsi
mov    %rsp,%rdx
call   1030 <fscanf@plt>
movsbl (%rsp),%eax
add    $0x1,%r12d
mov    %eax,0x4(%rbx,%r13,8)
lea    0xdb2(%rip),%rbp
mov    %rsp,%rbx
jmp    11a0 <parse_post_turing+0x60>
movslq %r12d,%rax
add    $0x1,%r12d
mov    0x10(%rsp),%rcx
movl   $0x0,(%rcx,%rax,8)
jmp    11a0 <parse_post_turing+0x60>
xor    %r12d,%r12d
mov    %r12d,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xddb(%rip),%rdi
mov    $0x13,%esi
mov    $0x1,%edx
mov    0x18(%rsp),%rcx
call   1060 <fwrite@plt>
mov    $0x2,%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@.str = [5 x i8] c"%15s\00"
@.str.1 = [20 x i8] c"Invalid program!!\0A\0A\00"
define i32 @parse_post_turing(i32* %0, i32* %1, [2 x i32]* %2, i32* %3) {
%5 = alloca i32*
%6 = alloca i32*
%7 = alloca [2 x i32]*
%8 = alloca i32*
%9 = alloca [16 x i8]
%10 = alloca i32
store i32* %0, i32** %5
store i32* %1, i32** %6
store [2 x i32]* %2, [2 x i32]** %7
store i32* %3, i32** %8
store i32 0, i32* %10
br label %11
11: ; preds = %91, %4
%12 = load i32*, i32** %5
%13 = getelementptr inbounds [16 x i8], [16 x i8]* %9, i64 0, i64 0
%14 = call i64 @fscanf(i32* %12, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %13)
%15 = icmp sgt i64 %14, 0
br i1 %15, label %16, label %92
16: ; preds = %11
%17 = getelementptr inbounds [16 x i8], [16 x i8]* %9, i64 0, i64 0
%18 = load i8, i8* %17
%19 = call i32 @tolower(i8 signext %18)
switch i32 %19, label %87 [
i32 91, label %20
i32 105, label %27
i32 108, label %55
i32 112, label %62
i32 114, label %80
]
20: ; preds = %16
%21 = load i32, i32* %10
%22 = load i32*, i32** %8
%23 = getelementptr inbounds [16 x i8], [16 x i8]* %9, i64 0, i64 1
%24 = load i8, i8* %23
%25 = sext i8 %24 to i64
%26 = getelementptr inbounds i32, i32* %22, i64 %25
store i32 %21, i32* %26
br label %91
27: ; preds = %16
%28 = load i32*, i32** %5
%29 = getelementptr inbounds [16 x i8], [16 x i8]* %9, i64 0, i64 0
%30 = call i64 @fscanf(i32* %28, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %29)
%31 = getelementptr inbounds [16 x i8], [16 x i8]* %9, i64 0, i64 0
%32 = load i8, i8* %31
%33 = sext i8 %32 to i32
%34 = add nsw i32 %33, 2
%35 = load [2 x i32]*, [2 x i32]** %7
%36 = load i32, i32* %10
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds [2 x i32], [2 x i32]* %35, i64 %37
%39 = getelementptr inbounds [2 x i32], [2 x i32]* %38, i64 0, i64 0
store i32 %34, i32* %39
%40 = load i32*, i32** %5
%41 = getelementptr inbounds [16 x i8], [16 x i8]* %9, i64 0, i64 0
%42 = call i64 @fscanf(i32* %40, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %41)
%43 = load i32*, i32** %5
%44 = getelementptr inbounds [16 x i8], [16 x i8]* %9, i64 0, i64 0
%45 = call i64 @fscanf(i32* %43, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %44)
%46 = getelementptr inbounds [16 x i8], [16 x i8]* %9, i64 0, i64 0
%47 = load i8, i8* %46
%48 = sext i8 %47 to i32
%49 = load [2 x i32]*, [2 x i32]** %7
%50 = load i32, i32* %10
%51 = add nsw i32 %50, 1
store i32 %51, i32* %10
%52 = sext i32 %50 to i64
%53 = getelementptr inbounds [2 x i32], [2 x i32]* %49, i64 %52
%54 = getelementptr inbounds [2 x i32], [2 x i32]* %53, i64 0, i64 1
store i32 %48, i32* %54
br label %91
55: ; preds = %16
%56 = load [2 x i32]*, [2 x i32]** %7
%57 = load i32, i32* %10
%58 = add nsw i32 %57, 1
store i32 %58, i32* %10
%59 = sext i32 %57 to i64
%60 = getelementptr inbounds [2 x i32], [2 x i32]* %56, i64 %59
%61 = getelementptr inbounds [2 x i32], [2 x i32]* %60, i64 0, i64 0
store i32 1, i32* %61
br label %91
62: ; preds = %16
%63 = load [2 x i32]*, [2 x i32]** %7
%64 = load i32, i32* %10
%65 = sext i32 %64 to i64
%66 = getelementptr inbounds [2 x i32], [2 x i32]* %63, i64 %65
%67 = getelementptr inbounds [2 x i32], [2 x i32]* %66, i64 0, i64 0
store i32 2, i32* %67
%68 = load i32*, i32** %5
%69 = getelementptr inbounds [16 x i8], [16 x i8]* %9, i64 0, i64 0
%70 = call i64 @fscanf(i32* %68, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %69)
%71 = getelementptr inbounds [16 x i8], [16 x i8]* %9, i64 0, i64 0
%72 = load i8, i8* %71
%73 = sext i8 %72 to i32
%74 = load [2 x i32]*, [2 x i32]** %7
%75 = load i32, i32* %10
%76 = add nsw i32 %75, 1
store i32 %76, i32* %10
%77 = sext i32 %75 to i64
%78 = getelementptr inbounds [2 x i32], [2 x i32]* %74, i64 %77
%79 = getelementptr inbounds [2 x i32], [2 x i32]* %78, i64 0, i64 1
store i32 %73, i32* %79
br label %91
80: ; preds = %16
%81 = load [2 x i32]*, [2 x i32]** %7
%82 = load i32, i32* %10
%83 = add nsw i32 %82, 1
store i32 %83, i32* %10
%84 = sext i32 %82 to i64
%85 = getelementptr inbounds [2 x i32], [2 x i32]* %81, i64 %84
%86 = getelementptr inbounds [2 x i32], [2 x i32]* %85, i64 0, i64 0
store i32 0, i32* %86
br label %91
87: ; preds = %16
%88 = load i32*, i32** %6
%89 = call i32 @fprintf(i32* %88, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0))
%90 = call i32 @exit(i32 2)
unreachable
91: ; preds = %80, %62, %55, %27, %20
br label %11
92: ; preds = %11
%93 = load i32, i32* %10
ret i32 %93
}

LLVM IR (-O2):
@.str = [5 x i8] c"%15s\00"
@.str.1 = [20 x i8] c"Invalid program!!\0A\0A\00"
define i32 @parse_post_turing(i32* nocapture %0, i32* nocapture %1, [2 x i32]* nocapture writeonly %2, i32* nocapture writeonly %3) {
%5 = alloca [16 x i8]
%6 = getelementptr inbounds [16 x i8], [16 x i8]* %5, i64 0, i64 0
%7 = call i64 @fscanf(i32* %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %6)
%8 = icmp sgt i64 %7, 0
br i1 %8, label %9, label %55
9: ; preds = %4
%10 = getelementptr inbounds [16 x i8], [16 x i8]* %5, i64 0, i64 1
br label %11
11: ; preds = %9, %51
%12 = phi i32 [ 0, %9 ], [ %52, %51 ]
%13 = load i8, i8* %6
%14 = call i32 @tolower(i8 signext %13)
switch i32 %14, label %48 [
i32 91, label %15
i32 105, label %19
i32 108, label %32
i32 112, label %36
i32 114, label %44
]
15: ; preds = %11
%16 = load i8, i8* %10
%17 = sext i8 %16 to i64
%18 = getelementptr inbounds i32, i32* %3, i64 %17
store i32 %12, i32* %18
br label %51
19: ; preds = %11
%20 = call i64 @fscanf(i32* %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %6)
%21 = load i8, i8* %6
%22 = sext i8 %21 to i32
%23 = add nsw i32 %22, 2
%24 = sext i32 %12 to i64
%25 = getelementptr inbounds [2 x i32], [2 x i32]* %2, i64 %24, i64 0
store i32 %23, i32* %25
%26 = call i64 @fscanf(i32* %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %6)
%27 = call i64 @fscanf(i32* %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %6)
%28 = load i8, i8* %6
%29 = sext i8 %28 to i32
%30 = add nsw i32 %12, 1
%31 = getelementptr inbounds [2 x i32], [2 x i32]* %2, i64 %24, i64 1
store i32 %29, i32* %31
br label %51
32: ; preds = %11
%33 = add nsw i32 %12, 1
%34 = sext i32 %12 to i64
%35 = getelementptr inbounds [2 x i32], [2 x i32]* %2, i64 %34, i64 0
store i32 1, i32* %35
br label %51
36: ; preds = %11
%37 = sext i32 %12 to i64
%38 = getelementptr inbounds [2 x i32], [2 x i32]* %2, i64 %37, i64 0
store i32 2, i32* %38
%39 = call i64 @fscanf(i32* %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %6)
%40 = load i8, i8* %6
%41 = sext i8 %40 to i32
%42 = add nsw i32 %12, 1
%43 = getelementptr inbounds [2 x i32], [2 x i32]* %2, i64 %37, i64 1
store i32 %41, i32* %43
br label %51
44: ; preds = %11
%45 = add nsw i32 %12, 1
%46 = sext i32 %12 to i64
%47 = getelementptr inbounds [2 x i32], [2 x i32]* %2, i64 %46, i64 0
store i32 0, i32* %47
br label %51
48: ; preds = %11
%49 = call i64 @fwrite(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i64 19, i64 1, i32* %1)
%50 = call i32 @exit(i32 2)
unreachable
51: ; preds = %44, %36, %32, %19, %15
%52 = phi i32 [ %45, %44 ], [ %42, %36 ], [ %33, %32 ], [ %30, %19 ], [ %12, %15 ]
%53 = call i64 @fscanf(i32* %0, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %6)
%54 = icmp sgt i64 %53, 0
br i1 %54, label %11, label %55
55: ; preds = %51, %4
%56 = phi i32 [ 0, %4 ], [ %52, %51 ]
ret i32 %56
}