#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 /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ free(char *);
char getchar();
char *malloc(int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ remove(char *);
int /*<<< orphan*/ setbuf(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ stdin;
int /*<<< orphan*/ stdout;
scalar_t__ system(char *);
scalar_t__ toCode(char *);
int main(int argc, char *argv[]) {
  setbuf(stdout, 0);
  setbuf(stdin, 0);
  int i;
  char *codes = malloc(0x100);
  char ch;
  for (i = 0; i < 0x100; i++) {
    ch = getchar();
    if (ch == 'q') {
      codes[i] = 0;
      break;
    }
    if (ch != '.' && ch != ',' && ch != '[' && ch != ']' && ch != '-' &&
        ch != '+' && ch != '>' && ch != '<') {
      printf("some thing wrong\n");
      exit(0);
    }
    codes[i] = ch;
  }
  if (toCode(codes)) {
    printf("some thing wrong\n");
  }
  if (system("gcc brainFuckCode.c -o brainFuckCode")) {
    remove("brainFuckCode.c");
    printf("some thing wrong\n");
    exit(0);
  }
  remove("brainFuckCode.c");
  system("./brainFuckCode");
  remove("brainFuckCode");
  free(codes);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2e2b(%rip),%rax
mov    (%rax),%edi
xor    %esi,%esi
call   1060 <setbuf@plt>
mov    0x2e2b(%rip),%rax
mov    (%rax),%edi
xor    %esi,%esi
call   1060 <setbuf@plt>
mov    $0x100,%edi
call   10a0 <malloc@plt>
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x100,-0x14(%rbp)
jge    12a7 <main+0x117>
mov    $0x0,%al
call   1090 <getchar@plt>
mov    %al,-0x21(%rbp)
movsbl -0x21(%rbp),%eax
cmp    $0x71,%eax
jne    1210 <main+0x80>
mov    -0x20(%rbp),%rax
movslq -0x14(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
jmp    12a7 <main+0x117>
movsbl -0x21(%rbp),%eax
cmp    $0x2e,%eax
je     128b <main+0xfb>
movsbl -0x21(%rbp),%eax
cmp    $0x2c,%eax
je     128b <main+0xfb>
movsbl -0x21(%rbp),%eax
cmp    $0x5b,%eax
je     128b <main+0xfb>
movsbl -0x21(%rbp),%eax
cmp    $0x5d,%eax
je     128b <main+0xfb>
movsbl -0x21(%rbp),%eax
cmp    $0x2d,%eax
je     128b <main+0xfb>
movsbl -0x21(%rbp),%eax
cmp    $0x2b,%eax
je     128b <main+0xfb>
movsbl -0x21(%rbp),%eax
cmp    $0x3e,%eax
je     128b <main+0xfb>
movsbl -0x21(%rbp),%eax
cmp    $0x3c,%eax
je     128b <main+0xfb>
lea    0xd81(%rip),%rdi
call   1080 <printf@plt>
xor    %edi,%edi
call   10b0 <exit@plt>
mov    -0x21(%rbp),%dl
mov    -0x20(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11db <main+0x4b>
mov    -0x20(%rbp),%rdi
call   1050 <toCode@plt>
cmp    $0x0,%rax
je     12c6 <main+0x136>
lea    0xd3f(%rip),%rdi
call   1080 <printf@plt>
lea    0xd45(%rip),%rdi
call   1070 <system@plt>
cmp    $0x0,%rax
je     12fb <main+0x16b>
lea    0xd54(%rip),%rdi
call   1040 <remove@plt>
lea    0xd11(%rip),%rdi
call   1080 <printf@plt>
xor    %edi,%edi
call   10b0 <exit@plt>
lea    0xd35(%rip),%rdi
call   1040 <remove@plt>
lea    0xd39(%rip),%rdi
call   1070 <system@plt>
lea    0xd0f(%rip),%rdi
call   1040 <remove@plt>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
mov    0x2e3c(%rip),%rax
mov    (%rax),%edi
xor    %esi,%esi
call   1070 <setbuf@plt>
mov    0x2e3c(%rip),%rax
mov    (%rax),%edi
xor    %esi,%esi
call   1070 <setbuf@plt>
mov    $0x100,%edi
call   10a0 <malloc@plt>
mov    %rax,%r15
lea    0xe37(%rip),%r14
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1090 <getchar@plt>
lea    -0x2b(%rax),%ecx
cmp    $0x46,%cl
ja     1268 <main+0xd8>
movzbl %cl,%ecx
movslq (%r14,%rcx,4),%rcx
add    %r14,%rcx
jmp    *%rcx
mov    %al,(%r15,%rbx,1)
add    $0x1,%rbx
cmp    $0x100,%rbx
jne    11d0 <main+0x40>
mov    %r15,%rdi
call   1060 <toCode@plt>
test   %rax,%rax
je     1219 <main+0x89>
lea    0xf4d(%rip),%rdi
call   1050 <puts@plt>
lea    0xefc(%rip),%rdi
call   1080 <system@plt>
mov    %rax,%r14
lea    0xf12(%rip),%rdi
call   1040 <remove@plt>
test   %r14,%r14
jne    1268 <main+0xd8>
lea    0xf11(%rip),%rdi
call   1080 <system@plt>
lea    0xee7(%rip),%rdi
call   1040 <remove@plt>
mov    %r15,%rdi
call   1030 <free@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
ret
movb   $0x0,(%r15,%rbx,1)
jmp    1200 <main+0x70>
lea    0xef2(%rip),%rdi
call   1050 <puts@plt>
xor    %edi,%edi
call   10b0 <exit@plt>

LLVM IR (-O0):
@stdout = global i32 0
@stdin = global i32 0
@.str = [18 x i8] c"some thing wrong\0A\00"
@.str.1 = [37 x i8] c"gcc brainFuckCode.c -o brainFuckCode\00"
@.str.2 = [16 x i8] c"brainFuckCode.c\00"
@.str.3 = [16 x i8] c"./brainFuckCode\00"
@.str.4 = [14 x i8] c"brainFuckCode\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i8
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = load i32, i32* @stdout
%10 = call i32 @setbuf(i32 %9, i32 0)
%11 = load i32, i32* @stdin
%12 = call i32 @setbuf(i32 %11, i32 0)
%13 = call i8* @malloc(i32 256)
store i8* %13, i8** %7
store i32 0, i32* %6
br label %14
14: ; preds = %68, %2
%15 = load i32, i32* %6
%16 = icmp slt i32 %15, 256
br i1 %16, label %17, label %71
17: ; preds = %14
%18 = call signext i8 (...) @getchar()
store i8 %18, i8* %8
%19 = load i8, i8* %8
%20 = sext i8 %19 to i32
%21 = icmp eq i32 %20, 113
br i1 %21, label %22, label %27
22: ; preds = %17
%23 = load i8*, i8** %7
%24 = load i32, i32* %6
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds i8, i8* %23, i64 %25
store i8 0, i8* %26
br label %71
27: ; preds = %17
%28 = load i8, i8* %8
%29 = sext i8 %28 to i32
%30 = icmp ne i32 %29, 46
br i1 %30, label %31, label %62
31: ; preds = %27
%32 = load i8, i8* %8
%33 = sext i8 %32 to i32
%34 = icmp ne i32 %33, 44
br i1 %34, label %35, label %62
35: ; preds = %31
%36 = load i8, i8* %8
%37 = sext i8 %36 to i32
%38 = icmp ne i32 %37, 91
br i1 %38, label %39, label %62
39: ; preds = %35
%40 = load i8, i8* %8
%41 = sext i8 %40 to i32
%42 = icmp ne i32 %41, 93
br i1 %42, label %43, label %62
43: ; preds = %39
%44 = load i8, i8* %8
%45 = sext i8 %44 to i32
%46 = icmp ne i32 %45, 45
br i1 %46, label %47, label %62
47: ; preds = %43
%48 = load i8, i8* %8
%49 = sext i8 %48 to i32
%50 = icmp ne i32 %49, 43
br i1 %50, label %51, label %62
51: ; preds = %47
%52 = load i8, i8* %8
%53 = sext i8 %52 to i32
%54 = icmp ne i32 %53, 62
br i1 %54, label %55, label %62
55: ; preds = %51
%56 = load i8, i8* %8
%57 = sext i8 %56 to i32
%58 = icmp ne i32 %57, 60
br i1 %58, label %59, label %62
59: ; preds = %55
%60 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
%61 = call i32 @exit(i32 0)
unreachable
62: ; preds = %55, %51, %47, %43, %39, %35, %31, %27
%63 = load i8, i8* %8
%64 = load i8*, i8** %7
%65 = load i32, i32* %6
%66 = sext i32 %65 to i64
%67 = getelementptr inbounds i8, i8* %64, i64 %66
store i8 %63, i8* %67
br label %68
68: ; preds = %62
%69 = load i32, i32* %6
%70 = add nsw i32 %69, 1
store i32 %70, i32* %6
br label %14
71: ; preds = %22, %14
%72 = load i8*, i8** %7
%73 = call i64 @toCode(i8* %72)
%74 = icmp ne i64 %73, 0
br i1 %74, label %75, label %77
75: ; preds = %71
%76 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
br label %77
77: ; preds = %75, %71
%78 = call i64 @system(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.1, i64 0, i64 0))
%79 = icmp ne i64 %78, 0
br i1 %79, label %80, label %84
80: ; preds = %77
%81 = call i32 @remove(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0))
%82 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
%83 = call i32 @exit(i32 0)
unreachable
84: ; preds = %77
%85 = call i32 @remove(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0))
%86 = call i64 @system(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0))
%87 = call i32 @remove(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0))
%88 = load i8*, i8** %7
%89 = call i32 @free(i8* %88)
ret i32 0
}

LLVM IR (-O2):
@stdout = global i32 0
@stdin = global i32 0
@.str.1 = [37 x i8] c"gcc brainFuckCode.c -o brainFuckCode\00"
@.str.2 = [16 x i8] c"brainFuckCode.c\00"
@.str.3 = [16 x i8] c"./brainFuckCode\00"
@.str.4 = [14 x i8] c"brainFuckCode\00"
@str.6 = [17 x i8] c"some thing wrong\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = load i32, i32* @stdout
%4 = tail call i32 @setbuf(i32 %3, i32 0)
%5 = load i32, i32* @stdin
%6 = tail call i32 @setbuf(i32 %5, i32 0)
%7 = tail call dereferenceable_or_null(256) i8* @malloc(i32 256)
br label %8
8: ; preds = %2, %17
%9 = phi i64 [ 0, %2 ], [ %19, %17 ]
%10 = tail call signext i8 (...) @getchar()
switch i8 %10, label %14 [
i8 113, label %11
i8 93, label %17
i8 91, label %17
i8 62, label %17
i8 60, label %17
i8 46, label %17
i8 45, label %17
i8 44, label %17
i8 43, label %17
]
11: ; preds = %8
%12 = and i64 %9, 4294967295
%13 = getelementptr inbounds i8, i8* %7, i64 %12
store i8 0, i8* %13
br label %21
14: ; preds = %8
%15 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str.6, i64 0, i64 0))
%16 = tail call i32 @exit(i32 0)
unreachable
17: ; preds = %8, %8, %8, %8, %8, %8, %8, %8
%18 = getelementptr inbounds i8, i8* %7, i64 %9
store i8 %10, i8* %18
%19 = add nuw nsw i64 %9, 1
%20 = icmp eq i64 %19, 256
br i1 %20, label %21, label %8
21: ; preds = %17, %11
%22 = tail call i64 @toCode(i8* %7)
%23 = icmp eq i64 %22, 0
br i1 %23, label %26, label %24
24: ; preds = %21
%25 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str.6, i64 0, i64 0))
br label %26
26: ; preds = %24, %21
%27 = tail call i64 @system(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.1, i64 0, i64 0))
%28 = icmp eq i64 %27, 0
%29 = tail call i32 @remove(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0))
br i1 %28, label %33, label %30
30: ; preds = %26
%31 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str.6, i64 0, i64 0))
%32 = tail call i32 @exit(i32 0)
unreachable
33: ; preds = %26
%34 = tail call i64 @system(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0))
%35 = tail call i32 @remove(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0))
%36 = tail call i32 @free(i8* %7)
ret i32 0
}