#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*/ fputs(char *, int /*<<< orphan*/ *);
int /*<<< orphan*/ *stderr;
void print_arith_code(FILE *fp, const char **code_ptr) {
  const char *code = *code_ptr;
  switch (*++code) {
  case ' ':
    switch (*++code) {
    case ' ':
      fputs("  "
            "arith_add();\n",
            fp);
      break;
    case '\t':
      fputs("  "
            "arith_sub();\n",
            fp);
      break;
    case '\n':
      fputs("  "
            "arith_mul();\n",
            fp);
      break;
    }
    break;
  case '\t':
    switch (*++code) {
    case ' ':
      fputs("  "
            "arith_div();\n",
            fp);
      break;
    case '\t':
      fputs("  "
            "arith_mod();\n",
            fp);
      break;
    case '\n':
      fputs("Undefined arithmetic command is detected: [TS][TN]\n", stderr);
      break;
    }
    break;
  case '\n':
    fputs("Undefined arithmetic command is detected: [TS][N]\n", stderr);
    break;
  }
  *code_ptr = code;
}


x86 assembly (clang, -O0):
<print_arith_code>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x18(%rbp)
movsbl 0x1(%rax),%eax
mov    %eax,-0x1c(%rbp)
sub    $0x9,%eax
je     11f6 <print_arith_code+0xe6>
jmp    114f <print_arith_code+0x3f>
mov    -0x1c(%rbp),%eax
sub    $0xa,%eax
je     1281 <print_arith_code+0x171>
jmp    1160 <print_arith_code+0x50>
mov    -0x1c(%rbp),%eax
sub    $0x20,%eax
jne    1297 <print_arith_code+0x187>
jmp    1171 <print_arith_code+0x61>
mov    -0x18(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x18(%rbp)
movsbl 0x1(%rax),%eax
mov    %eax,-0x20(%rbp)
sub    $0x9,%eax
je     11cc <print_arith_code+0xbc>
jmp    1195 <print_arith_code+0x85>
mov    -0x20(%rbp),%eax
sub    $0xa,%eax
je     11e1 <print_arith_code+0xd1>
jmp    11a6 <print_arith_code+0x96>
mov    -0x20(%rbp),%eax
sub    $0x20,%eax
jne    11f1 <print_arith_code+0xe1>
jmp    11b7 <print_arith_code+0xa7>
mov    -0x8(%rbp),%rsi
lea    0xe3e(%rip),%rdi
call   1030 <fputs@plt>
jmp    11f1 <print_arith_code+0xe1>
mov    -0x8(%rbp),%rsi
lea    0xe39(%rip),%rdi
call   1030 <fputs@plt>
jmp    11f1 <print_arith_code+0xe1>
mov    -0x8(%rbp),%rsi
lea    0xe34(%rip),%rdi
call   1030 <fputs@plt>
jmp    1297 <print_arith_code+0x187>
mov    -0x18(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x18(%rbp)
movsbl 0x1(%rax),%eax
mov    %eax,-0x24(%rbp)
sub    $0x9,%eax
je     1251 <print_arith_code+0x141>
jmp    121a <print_arith_code+0x10a>
mov    -0x24(%rbp),%eax
sub    $0xa,%eax
je     1266 <print_arith_code+0x156>
jmp    122b <print_arith_code+0x11b>
mov    -0x24(%rbp),%eax
sub    $0x20,%eax
jne    127c <print_arith_code+0x16c>
jmp    123c <print_arith_code+0x12c>
mov    -0x8(%rbp),%rsi
lea    0xde9(%rip),%rdi
call   1030 <fputs@plt>
jmp    127c <print_arith_code+0x16c>
mov    -0x8(%rbp),%rsi
lea    0xde4(%rip),%rdi
call   1030 <fputs@plt>
jmp    127c <print_arith_code+0x16c>
mov    0x2d73(%rip),%rax
mov    (%rax),%rsi
lea    0xdd9(%rip),%rdi
call   1030 <fputs@plt>
jmp    1297 <print_arith_code+0x187>
mov    0x2d58(%rip),%rax
mov    (%rax),%rsi
lea    0xdf2(%rip),%rdi
call   1030 <fputs@plt>
mov    -0x18(%rbp),%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_arith_code>:
push   %r15
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %rdi,%rcx
mov    (%rsi),%r15
movsbl 0x1(%r15),%eax
cmp    $0x9,%eax
je     115b <print_arith_code+0x4b>
lea    0x1(%r15),%rbx
cmp    $0xa,%eax
je     117c <print_arith_code+0x6c>
cmp    $0x20,%eax
jne    11c9 <print_arith_code+0xb9>
movsbl 0x2(%r15),%eax
add    $0x2,%r15
cmp    $0x9,%eax
je     119e <print_arith_code+0x8e>
cmp    $0xa,%eax
je     11a7 <print_arith_code+0x97>
cmp    $0x20,%eax
jne    11c6 <print_arith_code+0xb6>
lea    0xea7(%rip),%rdi
jmp    11b7 <print_arith_code+0xa7>
movsbl 0x2(%r15),%eax
add    $0x2,%r15
cmp    $0x9,%eax
je     11b0 <print_arith_code+0xa0>
cmp    $0xa,%eax
je     11d2 <print_arith_code+0xc2>
cmp    $0x20,%eax
jne    11c6 <print_arith_code+0xb6>
lea    0xeb6(%rip),%rdi
jmp    11b7 <print_arith_code+0xa7>
mov    0x2e5d(%rip),%rax
mov    (%rax),%rcx
lea    0xef7(%rip),%rdi
mov    $0x32,%esi
mov    $0x1,%edx
call   1030 <fwrite@plt>
jmp    11c9 <print_arith_code+0xb9>
lea    0xe6b(%rip),%rdi
jmp    11b7 <print_arith_code+0xa7>
lea    0xe72(%rip),%rdi
jmp    11b7 <print_arith_code+0xa7>
lea    0xe89(%rip),%rdi
mov    $0xf,%esi
mov    $0x1,%edx
call   1030 <fwrite@plt>
mov    %r15,%rbx
mov    %rbx,(%r14)
pop    %rbx
pop    %r14
pop    %r15
ret
mov    0x2e07(%rip),%rax
mov    (%rax),%rcx
lea    0xe6d(%rip),%rdi
mov    $0x33,%esi
jmp    11bc <print_arith_code+0xac>

LLVM IR (-O0):
@.str = [16 x i8] c" arith_add();\0A\00"
@.str.1 = [16 x i8] c" arith_sub();\0A\00"
@.str.2 = [16 x i8] c" arith_mul();\0A\00"
@.str.3 = [16 x i8] c" arith_div();\0A\00"
@.str.4 = [16 x i8] c" arith_mod();\0A\00"
@.str.5 = [52 x i8] c"Undefined arithmetic command is detected: [TS][TN]\0A\00"
@stderr = global i32* null
@.str.6 = [51 x i8] c"Undefined arithmetic command is detected: [TS][N]\0A\00"
define void @print_arith_code(i32* %0, i8** %1) {
%3 = alloca i32*
%4 = alloca i8**
%5 = alloca i8*
store i32* %0, i32** %3
store i8** %1, i8*** %4
%6 = load i8**, i8*** %4
%7 = load i8*, i8** %6
store i8* %7, i8** %5
%8 = load i8*, i8** %5
%9 = getelementptr inbounds i8, i8* %8, i32 1
store i8* %9, i8** %5
%10 = load i8, i8* %9
%11 = sext i8 %10 to i32
switch i32 %11, label %45 [
i32 32, label %12
i32 9, label %27
i32 10, label %42
]
12: ; preds = %2
%13 = load i8*, i8** %5
%14 = getelementptr inbounds i8, i8* %13, i32 1
store i8* %14, i8** %5
%15 = load i8, i8* %14
%16 = sext i8 %15 to i32
switch i32 %16, label %26 [
i32 32, label %17
i32 9, label %20
i32 10, label %23
]
17: ; preds = %12
%18 = load i32*, i32** %3
%19 = call i32 @fputs(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i32* %18)
br label %26
20: ; preds = %12
%21 = load i32*, i32** %3
%22 = call i32 @fputs(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i32* %21)
br label %26
23: ; preds = %12
%24 = load i32*, i32** %3
%25 = call i32 @fputs(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i32* %24)
br label %26
26: ; preds = %12, %23, %20, %17
br label %45
27: ; preds = %2
%28 = load i8*, i8** %5
%29 = getelementptr inbounds i8, i8* %28, i32 1
store i8* %29, i8** %5
%30 = load i8, i8* %29
%31 = sext i8 %30 to i32
switch i32 %31, label %41 [
i32 32, label %32
i32 9, label %35
i32 10, label %38
]
32: ; preds = %27
%33 = load i32*, i32** %3
%34 = call i32 @fputs(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i32* %33)
br label %41
35: ; preds = %27
%36 = load i32*, i32** %3
%37 = call i32 @fputs(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0), i32* %36)
br label %41
38: ; preds = %27
%39 = load i32*, i32** @stderr
%40 = call i32 @fputs(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.5, i64 0, i64 0), i32* %39)
br label %41
41: ; preds = %27, %38, %35, %32
br label %45
42: ; preds = %2
%43 = load i32*, i32** @stderr
%44 = call i32 @fputs(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.6, i64 0, i64 0), i32* %43)
br label %45
45: ; preds = %2, %42, %41, %26
%46 = load i8*, i8** %5
%47 = load i8**, i8*** %4
store i8* %46, i8** %47
ret void
}

LLVM IR (-O2):
@.str = [16 x i8] c" arith_add();\0A\00"
@.str.1 = [16 x i8] c" arith_sub();\0A\00"
@.str.2 = [16 x i8] c" arith_mul();\0A\00"
@.str.3 = [16 x i8] c" arith_div();\0A\00"
@.str.4 = [16 x i8] c" arith_mod();\0A\00"
@.str.5 = [52 x i8] c"Undefined arithmetic command is detected: [TS][TN]\0A\00"
@stderr = global i32* null
@.str.6 = [51 x i8] c"Undefined arithmetic command is detected: [TS][N]\0A\00"
define void @print_arith_code(i32* nocapture %0, i8** nocapture %1) {
%3 = load i8*, i8** %1
%4 = getelementptr inbounds i8, i8* %3, i64 1
%5 = load i8, i8* %4
%6 = sext i8 %5 to i32
switch i32 %6, label %31 [
i32 32, label %7
i32 9, label %17
i32 10, label %28
]
7: ; preds = %2
%8 = getelementptr inbounds i8, i8* %3, i64 2
%9 = load i8, i8* %8
%10 = sext i8 %9 to i32
switch i32 %10, label %31 [
i32 32, label %11
i32 9, label %13
i32 10, label %15
]
11: ; preds = %7
%12 = tail call i64 @fwrite(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i64 15, i64 1, i32* %0)
br label %31
13: ; preds = %7
%14 = tail call i64 @fwrite(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i64 15, i64 1, i32* %0)
br label %31
15: ; preds = %7
%16 = tail call i64 @fwrite(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i64 15, i64 1, i32* %0)
br label %31
17: ; preds = %2
%18 = getelementptr inbounds i8, i8* %3, i64 2
%19 = load i8, i8* %18
%20 = sext i8 %19 to i32
switch i32 %20, label %31 [
i32 32, label %21
i32 9, label %23
i32 10, label %25
]
21: ; preds = %17
%22 = tail call i64 @fwrite(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0), i64 15, i64 1, i32* %0)
br label %31
23: ; preds = %17
%24 = tail call i64 @fwrite(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0), i64 15, i64 1, i32* %0)
br label %31
25: ; preds = %17
%26 = load i32*, i32** @stderr
%27 = tail call i64 @fwrite(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.5, i64 0, i64 0), i64 51, i64 1, i32* %26)
br label %31
28: ; preds = %2
%29 = load i32*, i32** @stderr
%30 = tail call i64 @fwrite(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.6, i64 0, i64 0), i64 50, i64 1, i32* %29)
br label %31
31: ; preds = %21, %23, %25, %17, %11, %13, %15, %7, %2, %28
%32 = phi i8* [ %4, %2 ], [ %4, %28 ], [ %18, %17 ], [ %18, %25 ], [ %18, %23 ], [ %18, %21 ], [ %8, %7 ], [ %8, %15 ], [ %8, %13 ], [ %8, %11 ]
store i8* %32, i8** %1
ret void
}