#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*/ print_arith_code(int /*<<< orphan*/ *, char const **);
int /*<<< orphan*/ print_code_footer(int /*<<< orphan*/ *);
int /*<<< orphan*/ print_code_header(int /*<<< orphan*/ *);
int /*<<< orphan*/ print_flow_code(int /*<<< orphan*/ *, char const **);
int /*<<< orphan*/ print_heap_code(int /*<<< orphan*/ *, char const **);
int /*<<< orphan*/ print_io_code(int /*<<< orphan*/ *, char const **);
int /*<<< orphan*/ print_stack_code(int /*<<< orphan*/ *, char const **);
int translate(FILE *fp, const char *code) {
  print_code_header(fp);
  for (; *code != '\0'; code++) {
    switch (*code) {
    case ' ':
      print_stack_code(fp, &code);
      break;
    case '\t':
      switch (*++code) {
      case ' ':
        print_arith_code(fp, &code);
        break;
      case '\t':
        print_heap_code(fp, &code);
        break;
      case '\n':
        print_io_code(fp, &code);
        break;
      }
      break;
    case '\n':
      print_flow_code(fp, &code);
      break;
    }
  }
  print_code_footer(fp);
  return 1;
}


x86 assembly (clang, -O0):
<translate>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1080 <print_code_header@plt>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     1284 <translate+0x114>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
mov    %eax,-0x14(%rbp)
sub    $0x9,%eax
je     11e5 <translate+0x75>
jmp    11b1 <translate+0x41>
mov    -0x14(%rbp),%eax
sub    $0xa,%eax
je     1261 <translate+0xf1>
jmp    11c2 <translate+0x52>
mov    -0x14(%rbp),%eax
sub    $0x20,%eax
jne    126e <translate+0xfe>
jmp    11d3 <translate+0x63>
mov    -0x8(%rbp),%rdi
lea    -0x10(%rbp),%rsi
call   1060 <print_stack_code@plt>
jmp    126e <translate+0xfe>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x10(%rbp)
movsbl 0x1(%rax),%eax
mov    %eax,-0x18(%rbp)
sub    $0x9,%eax
je     123d <translate+0xcd>
jmp    1209 <translate+0x99>
mov    -0x18(%rbp),%eax
sub    $0xa,%eax
je     124f <translate+0xdf>
jmp    121a <translate+0xaa>
mov    -0x18(%rbp),%eax
sub    $0x20,%eax
jne    125c <translate+0xec>
jmp    122b <translate+0xbb>
mov    -0x8(%rbp),%rdi
lea    -0x10(%rbp),%rsi
call   1070 <print_arith_code@plt>
jmp    125c <translate+0xec>
mov    -0x8(%rbp),%rdi
lea    -0x10(%rbp),%rsi
call   1090 <print_heap_code@plt>
jmp    125c <translate+0xec>
mov    -0x8(%rbp),%rdi
lea    -0x10(%rbp),%rsi
call   1050 <print_io_code@plt>
jmp    126e <translate+0xfe>
mov    -0x8(%rbp),%rdi
lea    -0x10(%rbp),%rsi
call   1030 <print_flow_code@plt>
jmp    1273 <translate+0x103>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    1189 <translate+0x19>
mov    -0x8(%rbp),%rdi
call   1040 <print_code_footer@plt>
mov    $0x1,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<translate>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%rbx
mov    %rdi,%r15
mov    %rsi,0x8(%rsp)
call   1080 <print_code_header@plt>
mov    (%rbx),%al
test   %al,%al
je     1223 <translate+0xb3>
lea    0x8(%rsp),%r14
jmp    11c1 <translate+0x51>
nopw   0x0(%rax,%rax,1)
mov    %r15,%rdi
mov    %r14,%rsi
call   1030 <print_flow_code@plt>
mov    0x8(%rsp),%rax
lea    0x1(%rax),%rbx
mov    %rbx,0x8(%rsp)
movzbl 0x1(%rax),%eax
test   %al,%al
je     1223 <translate+0xb3>
movsbl %al,%eax
cmp    $0x9,%eax
je     11e0 <translate+0x70>
cmp    $0xa,%eax
je     11a0 <translate+0x30>
cmp    $0x20,%eax
jne    11ab <translate+0x3b>
mov    %r15,%rdi
mov    %r14,%rsi
call   1060 <print_stack_code@plt>
jmp    11ab <translate+0x3b>
lea    0x1(%rbx),%rax
mov    %rax,0x8(%rsp)
movsbl 0x1(%rbx),%eax
cmp    $0x9,%eax
je     1216 <translate+0xa6>
cmp    $0xa,%eax
je     1209 <translate+0x99>
cmp    $0x20,%eax
jne    11ab <translate+0x3b>
mov    %r15,%rdi
mov    %r14,%rsi
call   1070 <print_arith_code@plt>
jmp    11ab <translate+0x3b>
mov    %r15,%rdi
mov    %r14,%rsi
call   1050 <print_io_code@plt>
jmp    11ab <translate+0x3b>
mov    %r15,%rdi
mov    %r14,%rsi
call   1090 <print_heap_code@plt>
jmp    11ab <translate+0x3b>
mov    %r15,%rdi
call   1040 <print_code_footer@plt>
mov    $0x1,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i32 @translate(i32* %0, i8* %1) {
%3 = alloca i32*
%4 = alloca i8*
store i32* %0, i32** %3
store i8* %1, i8** %4
%5 = load i32*, i32** %3
%6 = call i32 @print_code_header(i32* %5)
br label %7
7: ; preds = %38, %2
%8 = load i8*, i8** %4
%9 = load i8, i8* %8
%10 = sext i8 %9 to i32
%11 = icmp ne i32 %10, 0
br i1 %11, label %12, label %41
12: ; preds = %7
%13 = load i8*, i8** %4
%14 = load i8, i8* %13
%15 = sext i8 %14 to i32
switch i32 %15, label %37 [
i32 32, label %16
i32 9, label %19
i32 10, label %34
]
16: ; preds = %12
%17 = load i32*, i32** %3
%18 = call i32 @print_stack_code(i32* %17, i8** %4)
br label %37
19: ; preds = %12
%20 = load i8*, i8** %4
%21 = getelementptr inbounds i8, i8* %20, i32 1
store i8* %21, i8** %4
%22 = load i8, i8* %21
%23 = sext i8 %22 to i32
switch i32 %23, label %33 [
i32 32, label %24
i32 9, label %27
i32 10, label %30
]
24: ; preds = %19
%25 = load i32*, i32** %3
%26 = call i32 @print_arith_code(i32* %25, i8** %4)
br label %33
27: ; preds = %19
%28 = load i32*, i32** %3
%29 = call i32 @print_heap_code(i32* %28, i8** %4)
br label %33
30: ; preds = %19
%31 = load i32*, i32** %3
%32 = call i32 @print_io_code(i32* %31, i8** %4)
br label %33
33: ; preds = %19, %30, %27, %24
br label %37
34: ; preds = %12
%35 = load i32*, i32** %3
%36 = call i32 @print_flow_code(i32* %35, i8** %4)
br label %37
37: ; preds = %12, %34, %33, %16
br label %38
38: ; preds = %37
%39 = load i8*, i8** %4
%40 = getelementptr inbounds i8, i8* %39, i32 1
store i8* %40, i8** %4
br label %7
41: ; preds = %7
%42 = load i32*, i32** %3
%43 = call i32 @print_code_footer(i32* %42)
ret i32 1
}

LLVM IR (-O2):
define i32 @translate(i32* %0, i8* %1) {
%3 = alloca i8*
store i8* %1, i8** %3
%4 = tail call i32 @print_code_header(i32* %0)
%5 = load i8, i8* %1
%6 = icmp eq i8 %5, 0
br i1 %6, label %30, label %7
7: ; preds = %2, %25
%8 = phi i8 [ %28, %25 ], [ %5, %2 ]
%9 = phi i8* [ %27, %25 ], [ %1, %2 ]
%10 = sext i8 %8 to i32
switch i32 %10, label %25 [
i32 32, label %11
i32 9, label %13
i32 10, label %23
]
11: ; preds = %7
%12 = call i32 @print_stack_code(i32* %0, i8** %3)
br label %25
13: ; preds = %7
%14 = getelementptr inbounds i8, i8* %9, i64 1
store i8* %14, i8** %3
%15 = load i8, i8* %14
%16 = sext i8 %15 to i32
switch i32 %16, label %25 [
i32 32, label %17
i32 9, label %19
i32 10, label %21
]
17: ; preds = %13
%18 = call i32 @print_arith_code(i32* %0, i8** %3)
br label %25
19: ; preds = %13
%20 = call i32 @print_heap_code(i32* %0, i8** %3)
br label %25
21: ; preds = %13
%22 = call i32 @print_io_code(i32* %0, i8** %3)
br label %25
23: ; preds = %7
%24 = call i32 @print_flow_code(i32* %0, i8** %3)
br label %25
25: ; preds = %11, %23, %7, %13, %21, %19, %17
%26 = load i8*, i8** %3
%27 = getelementptr inbounds i8, i8* %26, i64 1
store i8* %27, i8** %3
%28 = load i8, i8* %27
%29 = icmp eq i8 %28, 0
br i1 %29, label %30, label %7
30: ; preds = %25, %2
%31 = call i32 @print_code_footer(i32* %0)
ret i32 1
}