#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 atoi(char *);
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ printf(char *, ...);
int read(int, char *, int);
int /*<<< orphan*/ validation(int, char, int, int, int);
void parse_fd(int fd) {
  static char buf[1];
  static int n = 0;
  char operator= '+';
  int number_position = 0;
  int left_number = 0, right_number = 0, calculation_number = 0,
      remainder_number = 0;
  char left[10] = {'\0'}, right[10] = {'\0'};
  char calculation[10] = {'\0'}, remainder[10] = {'\0'};
  int left_value = 0, right_value = 0, calculation_value = 0,
      remainder_value = 0;
  while ((n = read(fd, buf, 1)) > 0) {
    if (buf[0] >= '0' && buf[0] <= '9') {
      if (number_position == 0) {
        left[left_number++] = buf[0];
      } else if (number_position == 1) {
        right[right_number++] = buf[0];
      } else if (number_position == 2) {
        calculation[calculation_number++] = buf[0];
      } else if (number_position == 3) {
        remainder[remainder_number++] = buf[0];
      }
    } else if (buf[0] == 0x20) {
    } else if (buf[0] == '=') {
      number_position++;
    } else if (buf[0] == '\n') {
      left_value = atoi(left);
      right_value = atoi(right);
      calculation_value = atoi(calculation);
      remainder_value = atoi(remainder);
      if (!validation(left_value, operator, right_value, calculation_value,
                      remainder_value)) {
        if (remainder_value) {
          printf("# %2d %c %2d = %d ~ %d\n", left_value, operator, right_value,
                 calculation_value, remainder_value);
        } else {
          printf("# %2d %c %2d = %d\n", left_value, operator, right_value,
                 calculation_value);
        }
      }
      number_position = 0;
      left_number = 0, right_number = 0, calculation_number = 0,
      remainder_number = 0;
      left_value = 0, right_value = 0, calculation_value = 0,
      remainder_value = 0;
      memset(left, 0, 10);
      memset(right, 0, 10);
      memset(calculation, 0, 10);
      memset(remainder, 0, 10);
    } else {
      if (number_position == 0) {
        operator= buf[0];
      }
      number_position++;
    }
  }
  if (n == -1) {
    printf("# read error for fd : %d\n", fd);
  } else {
    printf("# arithmetic checker finished");
  }
}


x86 assembly (clang, -O0):
<parse_fd>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %edi,-0x4(%rbp)
movb   $0x2b,-0x5(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
lea    -0x26(%rbp),%rdi
xor    %esi,%esi
mov    $0xa,%edx
call   1040 <memset@plt>
lea    -0x30(%rbp),%rdi
xor    %esi,%esi
mov    $0xa,%edx
call   1040 <memset@plt>
lea    -0x3a(%rbp),%rdi
xor    %esi,%esi
mov    $0xa,%edx
call   1040 <memset@plt>
lea    -0x44(%rbp),%rdi
xor    %esi,%esi
mov    $0xa,%edx
call   1040 <memset@plt>
movl   $0x0,-0x48(%rbp)
movl   $0x0,-0x4c(%rbp)
movl   $0x0,-0x50(%rbp)
movl   $0x0,-0x54(%rbp)
mov    -0x4(%rbp),%edi
lea    0x2e64(%rip),%rsi
mov    $0x1,%edx
call   1050 <read@plt>
mov    %eax,0x2e58(%rip)
cmp    $0x0,%eax
jle    1460 <parse_fd+0x310>
movsbl 0x2e44(%rip),%eax
cmp    $0x30,%eax
jl     12c8 <parse_fd+0x178>
movsbl 0x2e34(%rip),%eax
cmp    $0x39,%eax
jg     12c8 <parse_fd+0x178>
cmpl   $0x0,-0xc(%rbp)
jne    1247 <parse_fd+0xf7>
mov    0x2e1b(%rip),%cl
mov    -0x10(%rbp),%eax
mov    %eax,%edx
add    $0x1,%edx
mov    %edx,-0x10(%rbp)
cltq
mov    %cl,-0x26(%rbp,%rax,1)
jmp    12c3 <parse_fd+0x173>
cmpl   $0x1,-0xc(%rbp)
jne    126d <parse_fd+0x11d>
mov    0x2df5(%rip),%cl
mov    -0x14(%rbp),%eax
mov    %eax,%edx
add    $0x1,%edx
mov    %edx,-0x14(%rbp)
cltq
mov    %cl,-0x30(%rbp,%rax,1)
jmp    12be <parse_fd+0x16e>
cmpl   $0x2,-0xc(%rbp)
jne    1293 <parse_fd+0x143>
mov    0x2dcf(%rip),%cl
mov    -0x18(%rbp),%eax
mov    %eax,%edx
add    $0x1,%edx
mov    %edx,-0x18(%rbp)
cltq
mov    %cl,-0x3a(%rbp,%rax,1)
jmp    12b9 <parse_fd+0x169>
cmpl   $0x3,-0xc(%rbp)
jne    12b4 <parse_fd+0x164>
mov    0x2da9(%rip),%cl
mov    -0x1c(%rbp),%eax
mov    %eax,%edx
add    $0x1,%edx
mov    %edx,-0x1c(%rbp)
cltq
mov    %cl,-0x44(%rbp,%rax,1)
jmp    12b9 <parse_fd+0x169>
jmp    12be <parse_fd+0x16e>
jmp    12c3 <parse_fd+0x173>
jmp    145b <parse_fd+0x30b>
movsbl 0x2d7d(%rip),%eax
cmp    $0x20,%eax
jne    12dd <parse_fd+0x18d>
jmp    1456 <parse_fd+0x306>
movsbl 0x2d68(%rip),%eax
cmp    $0x3d,%eax
jne    12fb <parse_fd+0x1ab>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1451 <parse_fd+0x301>
movsbl 0x2d4a(%rip),%eax
cmp    $0xa,%eax
jne    1430 <parse_fd+0x2e0>
lea    -0x26(%rbp),%rdi
call   1070 <atoi@plt>
mov    %eax,-0x48(%rbp)
lea    -0x30(%rbp),%rdi
call   1070 <atoi@plt>
mov    %eax,-0x4c(%rbp)
lea    -0x3a(%rbp),%rdi
call   1070 <atoi@plt>
mov    %eax,-0x50(%rbp)
lea    -0x44(%rbp),%rdi
call   1070 <atoi@plt>
mov    %eax,-0x54(%rbp)
mov    -0x48(%rbp),%edi
mov    -0x5(%rbp),%al
mov    -0x4c(%rbp),%edx
mov    -0x50(%rbp),%ecx
mov    -0x54(%rbp),%r8d
movsbl %al,%esi
call   1060 <validation@plt>
cmp    $0x0,%eax
jne    13ac <parse_fd+0x25c>
cmpl   $0x0,-0x54(%rbp)
je     138b <parse_fd+0x23b>
mov    -0x48(%rbp),%esi
movsbl -0x5(%rbp),%edx
mov    -0x4c(%rbp),%ecx
mov    -0x50(%rbp),%r8d
mov    -0x54(%rbp),%r9d
lea    0xc81(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    13a7 <parse_fd+0x257>
mov    -0x48(%rbp),%esi
movsbl -0x5(%rbp),%edx
mov    -0x4c(%rbp),%ecx
mov    -0x50(%rbp),%r8d
lea    0xc78(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    13ac <parse_fd+0x25c>
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x48(%rbp)
movl   $0x0,-0x4c(%rbp)
movl   $0x0,-0x50(%rbp)
movl   $0x0,-0x54(%rbp)
lea    -0x26(%rbp),%rdi
xor    %esi,%esi
mov    $0xa,%edx
call   1040 <memset@plt>
lea    -0x30(%rbp),%rdi
xor    %esi,%esi
mov    $0xa,%edx
call   1040 <memset@plt>
lea    -0x3a(%rbp),%rdi
xor    %esi,%esi
mov    $0xa,%edx
call   1040 <memset@plt>
lea    -0x44(%rbp),%rdi
xor    %esi,%esi
mov    $0xa,%edx
call   1040 <memset@plt>
jmp    144c <parse_fd+0x2fc>
cmpl   $0x0,-0xc(%rbp)
jne    1443 <parse_fd+0x2f3>
mov    0x2c0c(%rip),%al
mov    %al,-0x5(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1451 <parse_fd+0x301>
jmp    1456 <parse_fd+0x306>
jmp    145b <parse_fd+0x30b>
jmp    11de <parse_fd+0x8e>
cmpl   $0xffffffff,0x2be9(%rip)
jne    1483 <parse_fd+0x333>
mov    -0x4(%rbp),%esi
lea    0xbb4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1491 <parse_fd+0x341>
lea    0xbbb(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_fd>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x58,%rsp
movw   $0x0,0x28(%rsp)
movq   $0x0,0x20(%rsp)
movw   $0x0,0x18(%rsp)
movq   $0x0,0x10(%rsp)
movw   $0x0,0x48(%rsp)
movq   $0x0,0x40(%rsp)
movw   $0x0,0x38(%rsp)
movq   $0x0,0x30(%rsp)
lea    0x2ea4(%rip),%rsi
mov    %edi,0xc(%rsp)
mov    $0x1,%edx
call   1050 <read@plt>
test   %eax,%eax
jle    13bc <parse_fd+0x26c>
mov    $0x2b,%al
mov    %eax,0x8(%rsp)
lea    0x20(%rsp),%rbx
lea    0x10(%rsp),%rdx
lea    0x40(%rsp),%rsi
lea    0x30(%rsp),%rdi
xor    %r12d,%r12d
xor    %r15d,%r15d
xor    %r14d,%r14d
xor    %r13d,%r13d
xor    %ebp,%ebp
jmp    1224 <parse_fd+0xd4>
cs nopw 0x0(%rax,%rax,1)
nop
add    $0x1,%ebp
mov    0xc(%rsp),%edi
lea    0x2e4b(%rip),%rsi
mov    $0x1,%edx
call   1050 <read@plt>
test   %eax,%eax
lea    0x20(%rsp),%rbx
lea    0x10(%rsp),%rdx
lea    0x40(%rsp),%rsi
lea    0x30(%rsp),%rdi
jle    13bc <parse_fd+0x26c>
movzbl 0x2e1e(%rip),%eax
lea    -0x30(%rax),%ecx
cmp    $0x9,%cl
ja     1260 <parse_fd+0x110>
cmp    $0x3,%ebp
ja     11f3 <parse_fd+0xa3>
mov    %ebp,%ecx
lea    0xdbf(%rip),%rdx
movslq (%rdx,%rcx,4),%rcx
add    %rdx,%rcx
jmp    *%rcx
movslq %r13d,%rcx
add    $0x1,%r13d
mov    %al,0x20(%rsp,%rcx,1)
xor    %ebp,%ebp
jmp    11f3 <parse_fd+0xa3>
nopl   0x0(%rax)
cmp    $0xa,%al
je     1284 <parse_fd+0x134>
cmp    $0x20,%al
je     11f3 <parse_fd+0xa3>
cmp    $0x3d,%al
je     11f0 <parse_fd+0xa0>
test   %ebp,%ebp
movzbl %al,%eax
mov    0x8(%rsp),%ecx
movzbl %cl,%ecx
cmove  %eax,%ecx
mov    %ecx,0x8(%rsp)
jmp    11f0 <parse_fd+0xa0>
mov    %rbx,%r14
mov    %rdx,%r12
mov    %rsi,%rbx
mov    %rdi,%rbp
mov    %r14,%rdi
call   1070 <atoi@plt>
mov    %eax,0x54(%rsp)
mov    %r12,%rdi
call   1070 <atoi@plt>
mov    %eax,%r15d
mov    %rbx,%rdi
call   1070 <atoi@plt>
mov    %eax,%r13d
mov    %rbp,%rdi
mov    0x54(%rsp),%ebp
call   1070 <atoi@plt>
movsbl 0x8(%rsp),%ebx
mov    %ebp,%edi
mov    %ebx,%esi
mov    %r15d,0x50(%rsp)
mov    %r15d,%edx
mov    %r12,%r15
mov    %eax,%r12d
mov    %r13d,%ecx
mov    %eax,%r8d
call   1060 <validation@plt>
test   %eax,%eax
jne    1369 <parse_fd+0x219>
mov    0x50(%rsp),%ecx
test   %r12d,%r12d
je     134a <parse_fd+0x1fa>
lea    0xd18(%rip),%rdi
mov    %ebp,%esi
mov    %ebx,%edx
mov    %r13d,%r8d
mov    %r12d,%r9d
xor    %eax,%eax
call   1030 <printf@plt>
jmp    135f <parse_fd+0x20f>
movslq %r14d,%rcx
add    $0x1,%r14d
mov    %al,0x10(%rsp,%rcx,1)
mov    $0x1,%ebp
jmp    11f3 <parse_fd+0xa3>
movslq %r15d,%rcx
add    $0x1,%r15d
mov    %al,0x40(%rsp,%rcx,1)
mov    $0x2,%ebp
jmp    11f3 <parse_fd+0xa3>
movslq %r12d,%rcx
add    $0x1,%r12d
mov    %al,0x30(%rsp,%rcx,1)
mov    $0x3,%ebp
jmp    11f3 <parse_fd+0xa3>
lea    0xcd7(%rip),%rdi
mov    %ebp,%esi
mov    %ebx,%edx
mov    %r13d,%r8d
xor    %eax,%eax
call   1030 <printf@plt>
lea    0x20(%rsp),%r14
lea    0x10(%rsp),%r15
xor    %ebp,%ebp
mov    %r14,%rdi
xor    %esi,%esi
mov    $0xa,%edx
call   1040 <memset@plt>
mov    %r15,%rdi
xor    %esi,%esi
mov    $0xa,%edx
call   1040 <memset@plt>
lea    0x40(%rsp),%rdi
xor    %esi,%esi
mov    $0xa,%edx
call   1040 <memset@plt>
lea    0x30(%rsp),%rdi
xor    %esi,%esi
mov    $0xa,%edx
call   1040 <memset@plt>
xor    %r13d,%r13d
xor    %r14d,%r14d
xor    %r15d,%r15d
xor    %r12d,%r12d
jmp    11f3 <parse_fd+0xa3>
cmp    $0xffffffff,%eax
je     13d1 <parse_fd+0x281>
lea    0xc8d(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
jmp    13e3 <parse_fd+0x293>
lea    0xc63(%rip),%rdi
mov    0xc(%rsp),%esi
xor    %eax,%eax
call   1030 <printf@plt>
add    $0x58,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@parse_fd.buf = internal global [1 x i8] zeroinitializer
@parse_fd.n = internal global i32 0
@.str = [24 x i8] c"# %2d %c %2d = %d ~ %d\0A\00"
@.str.1 = [19 x i8] c"# %2d %c %2d = %d\0A\00"
@.str.2 = [26 x i8] c"# read error for fd : %d\0A\00"
@.str.3 = [30 x i8] c"# arithmetic checker finished\00"
define void @parse_fd(i32 %0) {
%2 = alloca i32
%3 = alloca i8
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca [10 x i8]
%10 = alloca [10 x i8]
%11 = alloca [10 x i8]
%12 = alloca [10 x i8]
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
store i32 %0, i32* %2
store i8 43, i8* %3
store i32 0, i32* %4
store i32 0, i32* %5
store i32 0, i32* %6
store i32 0, i32* %7
store i32 0, i32* %8
%17 = bitcast [10 x i8]* %9 to i8*
%18 = bitcast [10 x i8]* %10 to i8*
%19 = bitcast [10 x i8]* %11 to i8*
%20 = bitcast [10 x i8]* %12 to i8*
store i32 0, i32* %13
store i32 0, i32* %14
store i32 0, i32* %15
store i32 0, i32* %16
br label %21
21: ; preds = %144, %1
%22 = load i32, i32* %2
%23 = call i32 @read(i32 %22, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @parse_fd.buf, i64 0, i64 0), i32 1)
store i32 %23, i32* @parse_fd.n
%24 = icmp sgt i32 %23, 0
br i1 %24, label %25, label %145
25: ; preds = %21
%26 = load i8, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @parse_fd.buf, i64 0, i64 0)
%27 = sext i8 %26 to i32
%28 = icmp sge i32 %27, 48
br i1 %28, label %29, label %73
29: ; preds = %25
%30 = load i8, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @parse_fd.buf, i64 0, i64 0)
%31 = sext i8 %30 to i32
%32 = icmp sle i32 %31, 57
br i1 %32, label %33, label %73
33: ; preds = %29
%34 = load i32, i32* %4
%35 = icmp eq i32 %34, 0
br i1 %35, label %36, label %42
36: ; preds = %33
%37 = load i8, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @parse_fd.buf, i64 0, i64 0)
%38 = load i32, i32* %5
%39 = add nsw i32 %38, 1
store i32 %39, i32* %5
%40 = sext i32 %38 to i64
%41 = getelementptr inbounds [10 x i8], [10 x i8]* %9, i64 0, i64 %40
store i8 %37, i8* %41
br label %72
42: ; preds = %33
%43 = load i32, i32* %4
%44 = icmp eq i32 %43, 1
br i1 %44, label %45, label %51
45: ; preds = %42
%46 = load i8, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @parse_fd.buf, i64 0, i64 0)
%47 = load i32, i32* %6
%48 = add nsw i32 %47, 1
store i32 %48, i32* %6
%49 = sext i32 %47 to i64
%50 = getelementptr inbounds [10 x i8], [10 x i8]* %10, i64 0, i64 %49
store i8 %46, i8* %50
br label %71
51: ; preds = %42
%52 = load i32, i32* %4
%53 = icmp eq i32 %52, 2
br i1 %53, label %54, label %60
54: ; preds = %51
%55 = load i8, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @parse_fd.buf, i64 0, i64 0)
%56 = load i32, i32* %7
%57 = add nsw i32 %56, 1
store i32 %57, i32* %7
%58 = sext i32 %56 to i64
%59 = getelementptr inbounds [10 x i8], [10 x i8]* %11, i64 0, i64 %58
store i8 %55, i8* %59
br label %70
60: ; preds = %51
%61 = load i32, i32* %4
%62 = icmp eq i32 %61, 3
br i1 %62, label %63, label %69
63: ; preds = %60
%64 = load i8, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @parse_fd.buf, i64 0, i64 0)
%65 = load i32, i32* %8
%66 = add nsw i32 %65, 1
store i32 %66, i32* %8
%67 = sext i32 %65 to i64
%68 = getelementptr inbounds [10 x i8], [10 x i8]* %12, i64 0, i64 %67
store i8 %64, i8* %68
br label %69
69: ; preds = %63, %60
br label %70
70: ; preds = %69, %54
br label %71
71: ; preds = %70, %45
br label %72
72: ; preds = %71, %36
br label %144
73: ; preds = %29, %25
%74 = load i8, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @parse_fd.buf, i64 0, i64 0)
%75 = sext i8 %74 to i32
%76 = icmp eq i32 %75, 32
br i1 %76, label %77, label %78
77: ; preds = %73
br label %143
78: ; preds = %73
%79 = load i8, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @parse_fd.buf, i64 0, i64 0)
%80 = sext i8 %79 to i32
%81 = icmp eq i32 %80, 61
br i1 %81, label %82, label %85
82: ; preds = %78
%83 = load i32, i32* %4
%84 = add nsw i32 %83, 1
store i32 %84, i32* %4
br label %142
85: ; preds = %78
%86 = load i8, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @parse_fd.buf, i64 0, i64 0)
%87 = sext i8 %86 to i32
%88 = icmp eq i32 %87, 10
br i1 %88, label %89, label %133
89: ; preds = %85
%90 = getelementptr inbounds [10 x i8], [10 x i8]* %9, i64 0, i64 0
%91 = call i32 @atoi(i8* %90)
store i32 %91, i32* %13
%92 = getelementptr inbounds [10 x i8], [10 x i8]* %10, i64 0, i64 0
%93 = call i32 @atoi(i8* %92)
store i32 %93, i32* %14
%94 = getelementptr inbounds [10 x i8], [10 x i8]* %11, i64 0, i64 0
%95 = call i32 @atoi(i8* %94)
store i32 %95, i32* %15
%96 = getelementptr inbounds [10 x i8], [10 x i8]* %12, i64 0, i64 0
%97 = call i32 @atoi(i8* %96)
store i32 %97, i32* %16
%98 = load i32, i32* %13
%99 = load i8, i8* %3
%100 = load i32, i32* %14
%101 = load i32, i32* %15
%102 = load i32, i32* %16
%103 = call i32 @validation(i32 %98, i8 signext %99, i32 %100, i32 %101, i32 %102)
%104 = icmp ne i32 %103, 0
br i1 %104, label %124, label %105
105: ; preds = %89
%106 = load i32, i32* %16
%107 = icmp ne i32 %106, 0
br i1 %107, label %108, label %116
108: ; preds = %105
%109 = load i32, i32* %13
%110 = load i8, i8* %3
%111 = sext i8 %110 to i32
%112 = load i32, i32* %14
%113 = load i32, i32* %15
%114 = load i32, i32* %16
%115 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i32 %109, i32 %111, i32 %112, i32 %113, i32 %114)
br label %123
116: ; preds = %105
%117 = load i32, i32* %13
%118 = load i8, i8* %3
%119 = sext i8 %118 to i32
%120 = load i32, i32* %14
%121 = load i32, i32* %15
%122 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i32 %117, i32 %119, i32 %120, i32 %121)
br label %123
123: ; preds = %116, %108
br label %124
124: ; preds = %123, %89
store i32 0, i32* %4
store i32 0, i32* %5
store i32 0, i32* %6
store i32 0, i32* %7
store i32 0, i32* %8
store i32 0, i32* %13
store i32 0, i32* %14
store i32 0, i32* %15
store i32 0, i32* %16
%125 = getelementptr inbounds [10 x i8], [10 x i8]* %9, i64 0, i64 0
%126 = call i32 @memset(i8* %125, i32 0, i32 10)
%127 = getelementptr inbounds [10 x i8], [10 x i8]* %10, i64 0, i64 0
%128 = call i32 @memset(i8* %127, i32 0, i32 10)
%129 = getelementptr inbounds [10 x i8], [10 x i8]* %11, i64 0, i64 0
%130 = call i32 @memset(i8* %129, i32 0, i32 10)
%131 = getelementptr inbounds [10 x i8], [10 x i8]* %12, i64 0, i64 0
%132 = call i32 @memset(i8* %131, i32 0, i32 10)
br label %141
133: ; preds = %85
%134 = load i32, i32* %4
%135 = icmp eq i32 %134, 0
br i1 %135, label %136, label %138
136: ; preds = %133
%137 = load i8, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @parse_fd.buf, i64 0, i64 0)
store i8 %137, i8* %3
br label %138
138: ; preds = %136, %133
%139 = load i32, i32* %4
%140 = add nsw i32 %139, 1
store i32 %140, i32* %4
br label %141
141: ; preds = %138, %124
br label %142
142: ; preds = %141, %82
br label %143
143: ; preds = %142, %77
br label %144
144: ; preds = %143, %72
br label %21
145: ; preds = %21
%146 = load i32, i32* @parse_fd.n
%147 = icmp eq i32 %146, -1
br i1 %147, label %148, label %151
148: ; preds = %145
%149 = load i32, i32* %2
%150 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0), i32 %149)
br label %153
151: ; preds = %145
%152 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.3, i64 0, i64 0))
br label %153
153: ; preds = %151, %148
ret void
}

LLVM IR (-O2):
@parse_fd.buf = internal global [1 x i8] zeroinitializer
@.str = [24 x i8] c"# %2d %c %2d = %d ~ %d\0A\00"
@.str.1 = [19 x i8] c"# %2d %c %2d = %d\0A\00"
@.str.2 = [26 x i8] c"# read error for fd : %d\0A\00"
@.str.3 = [30 x i8] c"# arithmetic checker finished\00"
define void @parse_fd(i32 %0) {
%2 = alloca [10 x i8]
%3 = alloca [10 x i8]
%4 = alloca [10 x i8]
%5 = alloca [10 x i8]
%6 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 0
%7 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 0
%8 = getelementptr inbounds [10 x i8], [10 x i8]* %4, i64 0, i64 0
%9 = getelementptr inbounds [10 x i8], [10 x i8]* %5, i64 0, i64 0
%10 = call i32 @read(i32 %0, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @parse_fd.buf, i64 0, i64 0), i32 1)
%11 = icmp sgt i32 %10, 0
br i1 %11, label %12, label %74
12: ; preds = %1, %65
%13 = phi i32 [ %71, %65 ], [ 0, %1 ]
%14 = phi i32 [ %70, %65 ], [ 0, %1 ]
%15 = phi i32 [ %69, %65 ], [ 0, %1 ]
%16 = phi i32 [ %68, %65 ], [ 0, %1 ]
%17 = phi i32 [ %67, %65 ], [ 0, %1 ]
%18 = phi i8 [ %66, %65 ], [ 43, %1 ]
%19 = load i8, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @parse_fd.buf, i64 0, i64 0)
%20 = add i8 %19, -48
%21 = icmp ult i8 %20, 10
br i1 %21, label %22, label %39
22: ; preds = %12
switch i32 %17, label %65 [
i32 0, label %23
i32 1, label %27
i32 2, label %31
i32 3, label %35
]
23: ; preds = %22
%24 = add nsw i32 %16, 1
%25 = sext i32 %16 to i64
%26 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 %25
store i8 %19, i8* %26
br label %65
27: ; preds = %22
%28 = add nsw i32 %15, 1
%29 = sext i32 %15 to i64
%30 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 %29
store i8 %19, i8* %30
br label %65
31: ; preds = %22
%32 = add nsw i32 %14, 1
%33 = sext i32 %14 to i64
%34 = getelementptr inbounds [10 x i8], [10 x i8]* %4, i64 0, i64 %33
store i8 %19, i8* %34
br label %65
35: ; preds = %22
%36 = add nsw i32 %13, 1
%37 = sext i32 %13 to i64
%38 = getelementptr inbounds [10 x i8], [10 x i8]* %5, i64 0, i64 %37
store i8 %19, i8* %38
br label %65
39: ; preds = %12
switch i8 %19, label %61 [
i8 32, label %65
i8 61, label %40
i8 10, label %42
]
40: ; preds = %39
%41 = add nsw i32 %17, 1
br label %65
42: ; preds = %39
%43 = call i32 @atoi(i8* %6)
%44 = call i32 @atoi(i8* %7)
%45 = call i32 @atoi(i8* %8)
%46 = call i32 @atoi(i8* %9)
%47 = call i32 @validation(i32 %43, i8 signext %18, i32 %44, i32 %45, i32 %46)
%48 = icmp eq i32 %47, 0
br i1 %48, label %49, label %56
49: ; preds = %42
%50 = icmp eq i32 %46, 0
%51 = sext i8 %18 to i32
br i1 %50, label %54, label %52
52: ; preds = %49
%53 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0), i32 %43, i32 %51, i32 %44, i32 %45, i32 %46)
br label %56
54: ; preds = %49
%55 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i32 %43, i32 %51, i32 %44, i32 %45)
br label %56
56: ; preds = %52, %54, %42
%57 = call i32 @memset(i8* %6, i32 0, i32 10)
%58 = call i32 @memset(i8* %7, i32 0, i32 10)
%59 = call i32 @memset(i8* %8, i32 0, i32 10)
%60 = call i32 @memset(i8* %9, i32 0, i32 10)
br label %65
61: ; preds = %39
%62 = icmp eq i32 %17, 0
%63 = select i1 %62, i8 %19, i8 %18
%64 = add nsw i32 %17, 1
br label %65
65: ; preds = %39, %22, %56, %61, %40, %23, %31, %35, %27
%66 = phi i8 [ %18, %23 ], [ %18, %27 ], [ %18, %31 ], [ %18, %35 ], [ %18, %39 ], [ %18, %40 ], [ %18, %56 ], [ %63, %61 ], [ %18, %22 ]
%67 = phi i32 [ 0, %23 ], [ 1, %27 ], [ 2, %31 ], [ 3, %35 ], [ %17, %39 ], [ %41, %40 ], [ 0, %56 ], [ %64, %61 ], [ %17, %22 ]
%68 = phi i32 [ %24, %23 ], [ %16, %27 ], [ %16, %31 ], [ %16, %35 ], [ %16, %39 ], [ %16, %40 ], [ 0, %56 ], [ %16, %61 ], [ %16, %22 ]
%69 = phi i32 [ %15, %23 ], [ %28, %27 ], [ %15, %31 ], [ %15, %35 ], [ %15, %39 ], [ %15, %40 ], [ 0, %56 ], [ %15, %61 ], [ %15, %22 ]
%70 = phi i32 [ %14, %23 ], [ %14, %27 ], [ %32, %31 ], [ %14, %35 ], [ %14, %39 ], [ %14, %40 ], [ 0, %56 ], [ %14, %61 ], [ %14, %22 ]
%71 = phi i32 [ %13, %23 ], [ %13, %27 ], [ %13, %31 ], [ %36, %35 ], [ %13, %39 ], [ %13, %40 ], [ 0, %56 ], [ %13, %61 ], [ %13, %22 ]
%72 = call i32 @read(i32 %0, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @parse_fd.buf, i64 0, i64 0), i32 1)
%73 = icmp sgt i32 %72, 0
br i1 %73, label %12, label %74
74: ; preds = %65, %1
%75 = phi i32 [ %10, %1 ], [ %72, %65 ]
%76 = icmp eq i32 %75, -1
br i1 %76, label %77, label %79
77: ; preds = %74
%78 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0), i32 %0)
br label %81
79: ; preds = %74
%80 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.3, i64 0, i64 0))
br label %81
81: ; preds = %79, %77
ret void
}