#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 */
char EOF;
int /*<<< orphan*/ assert(int /*<<< orphan*/);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
char fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ puts(char *);
int main() {
  FILE *fp;
  char erg;
  fp = fopen("fucktorial.bf", "r");
  assert(fp != NULL);
  while ((erg = fgetc(fp)) != EOF) {
    switch (erg) {
    case '<':
      puts("DATA 0");
      break;
    case '>':
      puts("DATA -1");
      break;
    case '+':
      puts("DATA -2");
      break;
    case '-':
      puts("DATA -3");
      break;
    case '[':
      puts("DATA -4");
      break;
    case ']':
      puts("DATA -5");
      break;
    case '.':
      puts("DATA -6");
      break;
    case ',':
      puts("DATA -7");
      break;
    default:
      break;
    }
  }
  fclose(fp);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xf66(%rip),%rdi
lea    0xf6d(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
mov    -0x10(%rbp),%rdi
call   1050 <fgetc@plt>
mov    %al,-0x11(%rbp)
movsbl %al,%eax
mov    0x2e4a(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
je     1265 <main+0x115>
movsbl -0x11(%rbp),%eax
add    $0xffffffd5,%eax
mov    %eax,%ecx
mov    %rcx,-0x20(%rbp)
sub    $0x32,%eax
ja     125b <main+0x10b>
mov    -0x20(%rbp),%rax
lea    0xe36(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xf02(%rip),%rdi
call   1030 <puts@plt>
jmp    1260 <main+0x110>
lea    0xef8(%rip),%rdi
call   1030 <puts@plt>
jmp    1260 <main+0x110>
lea    0xeef(%rip),%rdi
call   1030 <puts@plt>
jmp    1260 <main+0x110>
lea    0xee6(%rip),%rdi
call   1030 <puts@plt>
jmp    1260 <main+0x110>
lea    0xedd(%rip),%rdi
call   1030 <puts@plt>
jmp    1260 <main+0x110>
lea    0xed4(%rip),%rdi
call   1030 <puts@plt>
jmp    1260 <main+0x110>
lea    0xecb(%rip),%rdi
call   1030 <puts@plt>
jmp    1260 <main+0x110>
lea    0xec2(%rip),%rdi
call   1030 <puts@plt>
jmp    1260 <main+0x110>
jmp    1260 <main+0x110>
jmp    1188 <main+0x38>
mov    -0x10(%rbp),%rdi
call   1040 <fclose@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0xf6a(%rip),%rdi
lea    0xf71(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,%rbx
xor    %edi,%edi
test   %rax,%rax
setne  %dil
call   1060 <assert@plt>
mov    %rbx,%rdi
call   1050 <fgetc@plt>
mov    0x2e5a(%rip),%r14
cmp    (%r14),%al
jne    11ac <main+0x5c>
mov    %rbx,%rdi
call   1040 <fclose@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xf29(%rip),%r15
lea    0xe46(%rip),%r12
lea    0xf3a(%rip),%rbp
lea    0xf3b(%rip),%r13
jmp    11f2 <main+0xa2>
lea    0xf42(%rip),%rdi
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
call   1030 <puts@plt>
mov    %rbx,%rdi
call   1050 <fgetc@plt>
cmp    (%r14),%al
je     1193 <main+0x43>
movsbl %al,%eax
add    $0xffffffd5,%eax
cmp    $0x32,%eax
ja     11e5 <main+0x95>
movslq (%r12,%rax,4),%rax
add    %r12,%rax
mov    %r15,%rdi
jmp    *%rax
lea    0xedb(%rip),%rdi
jmp    11e0 <main+0x90>
lea    0xeda(%rip),%rdi
jmp    11e0 <main+0x90>
lea    0xee9(%rip),%rdi
jmp    11e0 <main+0x90>
lea    0xeb8(%rip),%rdi
jmp    11e0 <main+0x90>
mov    %rbp,%rdi
jmp    11e0 <main+0x90>
mov    %r13,%rdi
jmp    11e0 <main+0x90>

LLVM IR (-O0):
@.str = [14 x i8] c"fucktorial.bf\00"
@.str.1 = [2 x i8] c"r\00"
@EOF = global i8 0
@.str.2 = [7 x i8] c"DATA 0\00"
@.str.3 = [8 x i8] c"DATA -1\00"
@.str.4 = [8 x i8] c"DATA -2\00"
@.str.5 = [8 x i8] c"DATA -3\00"
@.str.6 = [8 x i8] c"DATA -4\00"
@.str.7 = [8 x i8] c"DATA -5\00"
@.str.8 = [8 x i8] c"DATA -6\00"
@.str.9 = [8 x i8] c"DATA -7\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca i8
store i32 0, i32* %1
%4 = call i32* @fopen(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %4, i32** %2
%5 = load i32*, i32** %2
%6 = icmp ne i32* %5, null
%7 = zext i1 %6 to i32
%8 = call i32 @assert(i32 %7)
br label %9
9: ; preds = %36, %0
%10 = load i32*, i32** %2
%11 = call signext i8 @fgetc(i32* %10)
store i8 %11, i8* %3
%12 = sext i8 %11 to i32
%13 = load i8, i8* @EOF
%14 = sext i8 %13 to i32
%15 = icmp ne i32 %12, %14
br i1 %15, label %16, label %37
16: ; preds = %9
%17 = load i8, i8* %3
%18 = sext i8 %17 to i32
switch i32 %18, label %35 [
i32 60, label %19
i32 62, label %21
i32 43, label %23
i32 45, label %25
i32 91, label %27
i32 93, label %29
i32 46, label %31
i32 44, label %33
]
19: ; preds = %16
%20 = call i32 @puts(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
br label %36
21: ; preds = %16
%22 = call i32 @puts(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0))
br label %36
23: ; preds = %16
%24 = call i32 @puts(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0))
br label %36
25: ; preds = %16
%26 = call i32 @puts(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0))
br label %36
27: ; preds = %16
%28 = call i32 @puts(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.6, i64 0, i64 0))
br label %36
29: ; preds = %16
%30 = call i32 @puts(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.7, i64 0, i64 0))
br label %36
31: ; preds = %16
%32 = call i32 @puts(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.8, i64 0, i64 0))
br label %36
33: ; preds = %16
%34 = call i32 @puts(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.9, i64 0, i64 0))
br label %36
35: ; preds = %16
br label %36
36: ; preds = %35, %33, %31, %29, %27, %25, %23, %21, %19
br label %9
37: ; preds = %9
%38 = load i32*, i32** %2
%39 = call i32 @fclose(i32* %38)
ret i32 0
}

LLVM IR (-O2):
@.str = [14 x i8] c"fucktorial.bf\00"
@.str.1 = [2 x i8] c"r\00"
@EOF = global i8 0
@.str.2 = [7 x i8] c"DATA 0\00"
@.str.3 = [8 x i8] c"DATA -1\00"
@.str.4 = [8 x i8] c"DATA -2\00"
@.str.5 = [8 x i8] c"DATA -3\00"
@.str.6 = [8 x i8] c"DATA -4\00"
@.str.7 = [8 x i8] c"DATA -5\00"
@.str.8 = [8 x i8] c"DATA -6\00"
@.str.9 = [8 x i8] c"DATA -7\00"
define i32 @main() {
%1 = tail call i32* @fopen(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%2 = icmp ne i32* %1, null
%3 = zext i1 %2 to i32
%4 = tail call i32 @assert(i32 %3)
%5 = tail call signext i8 @fgetc(i32* %1)
%6 = load i8, i8* @EOF
%7 = icmp eq i8 %5, %6
br i1 %7, label %25, label %8
8: ; preds = %0, %21
%9 = phi i8 [ %22, %21 ], [ %5, %0 ]
%10 = sext i8 %9 to i32
switch i32 %10, label %21 [
i32 60, label %18
i32 62, label %11
i32 43, label %12
i32 45, label %13
i32 91, label %14
i32 93, label %15
i32 46, label %16
i32 44, label %17
]
11: ; preds = %8
br label %18
12: ; preds = %8
br label %18
13: ; preds = %8
br label %18
14: ; preds = %8
br label %18
15: ; preds = %8
br label %18
16: ; preds = %8
br label %18
17: ; preds = %8
br label %18
18: ; preds = %8, %11, %12, %13, %14, %15, %16, %17
%19 = phi i8* [ getelementptr inbounds ([8 x i8], [8 x i8]* @.str.9, i64 0, i64 0), %17 ], [ getelementptr inbounds ([8 x i8], [8 x i8]* @.str.8, i64 0, i64 0), %16 ], [ getelementptr inbounds ([8 x i8], [8 x i8]* @.str.7, i64 0, i64 0), %15 ], [ getelementptr inbounds ([8 x i8], [8 x i8]* @.str.6, i64 0, i64 0), %14 ], [ getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0), %13 ], [ getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), %12 ], [ getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0), %11 ], [ getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), %8 ]
%20 = tail call i32 @puts(i8* dereferenceable(1) %19)
br label %21
21: ; preds = %18, %8
%22 = tail call signext i8 @fgetc(i32* %1)
%23 = load i8, i8* @EOF
%24 = icmp eq i8 %22, %23
br i1 %24, label %25, label %8
25: ; preds = %21, %0
%26 = tail call i32 @fclose(i32* %1)
ret i32 0
}