#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*/ SEEK_END;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
unsigned char fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char const *, char *);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, int /*<<< orphan*/,
                         int /*<<< orphan*/);
int ftell(int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, ...);
unsigned char *realloc(unsigned char *, int);
int /*<<< orphan*/ rewind(int /*<<< orphan*/ *);
int Parse_file(const char *file_name, unsigned char *ptr) {
  int file_length;
  int i;
  int counter = 0;
  unsigned char c;
  int max = 2;
  unsigned char *hilfspointer = ptr;
  FILE *bf_file;
  bf_file = fopen(file_name, "r");
  if (bf_file == NULL) {
    printf("%s", "[ERR] reading the file failed\n");
    return 4;
  }
  fseek(bf_file, 0, SEEK_END);
  file_length = ftell(bf_file);
  rewind(bf_file);
  for (i = 0; i < file_length; i++) {
    if (counter == max) {
      max += max;
      hilfspointer = realloc(hilfspointer, sizeof(char) * max);
      printf("speicher erhöht\n");
    }
    c = fgetc(bf_file);
    switch (c) {
    case '>':
      *ptr = '>';
      break;
    case '<':
      *ptr = '<';
      break;
    case '+':
      *ptr = '+';
      break;
    case '-':
      *ptr = '-';
      break;
    case '.':
      *ptr = '.';
      break;
    case ',':
      *ptr = ',';
      break;
    case '[':
      *ptr = '[';
      break;
    case ']':
      *ptr = ']';
      break;
    default:
      --ptr;
      --counter;
      break;
    }
    ++ptr;
    ++counter;
    printf("%d, %d\n", counter, max);
  }
  fclose(bf_file);
  printf("success\n");
  return 0;
}


x86 assembly (clang, -O0):
<Parse_file>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movl   $0x0,-0x24(%rbp)
movl   $0x2,-0x2c(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xf1b(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x40(%rbp)
cmpq   $0x0,-0x40(%rbp)
jne    11e6 <Parse_file+0x66>
lea    0xf02(%rip),%rdi
lea    0xefe(%rip),%rsi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x4,-0x4(%rbp)
jmp    135c <Parse_file+0x1dc>
mov    -0x40(%rbp),%rdi
mov    0x2df7(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1080 <fseek@plt>
mov    -0x40(%rbp),%rdi
call   1070 <ftell@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x40(%rbp),%rdi
call   1050 <rewind@plt>
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    133e <Parse_file+0x1be>
mov    -0x24(%rbp),%eax
cmp    -0x2c(%rbp),%eax
jne    125c <Parse_file+0xdc>
mov    -0x2c(%rbp),%eax
add    -0x2c(%rbp),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x38(%rbp),%rdi
movslq -0x2c(%rbp),%rax
shl    $0x0,%rax
mov    %eax,%esi
call   1090 <realloc@plt>
mov    %rax,-0x38(%rbp)
lea    0xe9b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x40(%rbp),%rdi
call   1060 <fgetc@plt>
mov    %al,-0x25(%rbp)
movzbl -0x25(%rbp),%eax
add    $0xffffffd5,%eax
mov    %eax,%ecx
mov    %rcx,-0x48(%rbp)
sub    $0x32,%eax
ja     12f2 <Parse_file+0x172>
mov    -0x48(%rbp),%rax
lea    0xd77(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x18(%rbp),%rax
movb   $0x3e,(%rax)
jmp    1307 <Parse_file+0x187>
mov    -0x18(%rbp),%rax
movb   $0x3c,(%rax)
jmp    1307 <Parse_file+0x187>
mov    -0x18(%rbp),%rax
movb   $0x2b,(%rax)
jmp    1307 <Parse_file+0x187>
mov    -0x18(%rbp),%rax
movb   $0x2d,(%rax)
jmp    1307 <Parse_file+0x187>
mov    -0x18(%rbp),%rax
movb   $0x2e,(%rax)
jmp    1307 <Parse_file+0x187>
mov    -0x18(%rbp),%rax
movb   $0x2c,(%rax)
jmp    1307 <Parse_file+0x187>
mov    -0x18(%rbp),%rax
movb   $0x5b,(%rax)
jmp    1307 <Parse_file+0x187>
mov    -0x18(%rbp),%rax
movb   $0x5d,(%rax)
jmp    1307 <Parse_file+0x187>
mov    -0x18(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x18(%rbp)
mov    -0x24(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x24(%rbp)
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%esi
mov    -0x2c(%rbp),%edx
lea    0xdd9(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1216 <Parse_file+0x96>
mov    -0x40(%rbp),%rdi
call   1030 <fclose@plt>
lea    0xdbc(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Parse_file>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,(%rsp)
lea    0xf26(%rip),%rsi
call   10b0 <fopen@plt>
test   %rax,%rax
je     12b5 <Parse_file+0x125>
mov    %rax,%r12
mov    0x2e2a(%rip),%rax
mov    (%rax),%edx
mov    %r12,%rdi
xor    %esi,%esi
call   1090 <fseek@plt>
mov    %r12,%rdi
call   1080 <ftell@plt>
mov    %eax,%ebx
mov    %r12,%rdi
call   1060 <rewind@plt>
test   %ebx,%ebx
jle    12a2 <Parse_file+0x112>
mov    $0x2,%ebp
lea    0xe10(%rip),%r14
mov    (%rsp),%r15
xor    %r13d,%r13d
jmp    1230 <Parse_file+0xa0>
add    $0xffffffffffffffff,%r15
add    $0xffffffff,%r13d
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
add    $0x1,%r15
add    $0x1,%r13d
lea    0xeaf(%rip),%rdi
mov    %r13d,%esi
mov    %ebp,%edx
xor    %eax,%eax
call   1050 <printf@plt>
add    $0xffffffff,%ebx
je     12a2 <Parse_file+0x112>
cmp    %ebp,%r13d
jne    1252 <Parse_file+0xc2>
add    %ebp,%ebp
mov    (%rsp),%rdi
mov    %ebp,%esi
call   10a0 <realloc@plt>
mov    %rax,(%rsp)
lea    0xe91(%rip),%rdi
call   1030 <puts@plt>
mov    %r12,%rdi
call   1070 <fgetc@plt>
add    $0xd5,%al
cmp    $0x32,%al
ja     11f9 <Parse_file+0x69>
movzbl %al,%eax
movslq (%r14,%rax,4),%rax
add    %r14,%rax
jmp    *%rax
movb   $0x2b,(%r15)
jmp    1210 <Parse_file+0x80>
movb   $0x2c,(%r15)
jmp    1210 <Parse_file+0x80>
movb   $0x2d,(%r15)
jmp    1210 <Parse_file+0x80>
movb   $0x2e,(%r15)
jmp    1210 <Parse_file+0x80>
movb   $0x3c,(%r15)
jmp    1210 <Parse_file+0x80>
movb   $0x3e,(%r15)
jmp    1210 <Parse_file+0x80>
movb   $0x5b,(%r15)
jmp    1210 <Parse_file+0x80>
movb   $0x5d,(%r15)
jmp    1210 <Parse_file+0x80>
mov    %r12,%rdi
call   1040 <fclose@plt>
lea    0xe25(%rip),%rdi
xor    %ebx,%ebx
jmp    12c1 <Parse_file+0x131>
mov    $0x4,%ebx
lea    0xe2e(%rip),%rdi
call   1030 <puts@plt>
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [31 x i8] c"[ERR] reading the file failed\0A\00"
@SEEK_END = global i32 0
@.str.3 = [18 x i8] c"speicher erh\C3\B6ht\0A\00"
@.str.4 = [8 x i8] c"%d, %d\0A\00"
@.str.5 = [9 x i8] c"success\0A\00"
define i32 @Parse_file(i8* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i8
%10 = alloca i32
%11 = alloca i8*
%12 = alloca i32*
store i8* %0, i8** %4
store i8* %1, i8** %5
store i32 0, i32* %8
store i32 2, i32* %10
%13 = load i8*, i8** %5
store i8* %13, i8** %11
%14 = load i8*, i8** %4
%15 = call i32* @fopen(i8* %14, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %15, i32** %12
%16 = load i32*, i32** %12
%17 = icmp eq i32* %16, null
br i1 %17, label %18, label %20
18: ; preds = %2
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0))
store i32 4, i32* %3
br label %88
20: ; preds = %2
%21 = load i32*, i32** %12
%22 = load i32, i32* @SEEK_END
%23 = call i32 @fseek(i32* %21, i32 0, i32 %22)
%24 = load i32*, i32** %12
%25 = call i32 @ftell(i32* %24)
store i32 %25, i32* %6
%26 = load i32*, i32** %12
%27 = call i32 @rewind(i32* %26)
store i32 0, i32* %7
br label %28
28: ; preds = %81, %20
%29 = load i32, i32* %7
%30 = load i32, i32* %6
%31 = icmp slt i32 %29, %30
br i1 %31, label %32, label %84
32: ; preds = %28
%33 = load i32, i32* %8
%34 = load i32, i32* %10
%35 = icmp eq i32 %33, %34
br i1 %35, label %36, label %47
36: ; preds = %32
%37 = load i32, i32* %10
%38 = load i32, i32* %10
%39 = add nsw i32 %38, %37
store i32 %39, i32* %10
%40 = load i8*, i8** %11
%41 = load i32, i32* %10
%42 = sext i32 %41 to i64
%43 = mul i64 1, %42
%44 = trunc i64 %43 to i32
%45 = call i8* @realloc(i8* %40, i32 %44)
store i8* %45, i8** %11
%46 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0))
br label %47
47: ; preds = %36, %32
%48 = load i32*, i32** %12
%49 = call zeroext i8 @fgetc(i32* %48)
store i8 %49, i8* %9
%50 = load i8, i8* %9
%51 = zext i8 %50 to i32
switch i32 %51, label %68 [
i32 62, label %52
i32 60, label %54
i32 43, label %56
i32 45, label %58
i32 46, label %60
i32 44, label %62
i32 91, label %64
i32 93, label %66
]
52: ; preds = %47
%53 = load i8*, i8** %5
store i8 62, i8* %53
br label %73
54: ; preds = %47
%55 = load i8*, i8** %5
store i8 60, i8* %55
br label %73
56: ; preds = %47
%57 = load i8*, i8** %5
store i8 43, i8* %57
br label %73
58: ; preds = %47
%59 = load i8*, i8** %5
store i8 45, i8* %59
br label %73
60: ; preds = %47
%61 = load i8*, i8** %5
store i8 46, i8* %61
br label %73
62: ; preds = %47
%63 = load i8*, i8** %5
store i8 44, i8* %63
br label %73
64: ; preds = %47
%65 = load i8*, i8** %5
store i8 91, i8* %65
br label %73
66: ; preds = %47
%67 = load i8*, i8** %5
store i8 93, i8* %67
br label %73
68: ; preds = %47
%69 = load i8*, i8** %5
%70 = getelementptr inbounds i8, i8* %69, i32 -1
store i8* %70, i8** %5
%71 = load i32, i32* %8
%72 = add nsw i32 %71, -1
store i32 %72, i32* %8
br label %73
73: ; preds = %68, %66, %64, %62, %60, %58, %56, %54, %52
%74 = load i8*, i8** %5
%75 = getelementptr inbounds i8, i8* %74, i32 1
store i8* %75, i8** %5
%76 = load i32, i32* %8
%77 = add nsw i32 %76, 1
store i32 %77, i32* %8
%78 = load i32, i32* %8
%79 = load i32, i32* %10
%80 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), i32 %78, i32 %79)
br label %81
81: ; preds = %73
%82 = load i32, i32* %7
%83 = add nsw i32 %82, 1
store i32 %83, i32* %7
br label %28
84: ; preds = %28
%85 = load i32*, i32** %12
%86 = call i32 @fclose(i32* %85)
%87 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.5, i64 0, i64 0))
store i32 0, i32* %3
br label %88
88: ; preds = %84, %18
%89 = load i32, i32* %3
ret i32 %89
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@SEEK_END = global i32 0
@.str.4 = [8 x i8] c"%d, %d\0A\00"
@str = [8 x i8] c"success\00"
@str.6 = [17 x i8] c"speicher erh\C3\B6ht\00"
@str.7 = [30 x i8] c"[ERR] reading the file failed\00"
define i32 @Parse_file(i8* nocapture %0, i8* %1) {
%3 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%4 = icmp eq i32* %3, null
br i1 %4, label %47, label %5
5: ; preds = %2
%6 = load i32, i32* @SEEK_END
%7 = tail call i32 @fseek(i32* %3, i32 0, i32 %6)
%8 = tail call i32 @ftell(i32* %3)
%9 = tail call i32 @rewind(i32* %3)
%10 = icmp sgt i32 %8, 0
br i1 %10, label %11, label %45
11: ; preds = %5, %37
%12 = phi i8* [ %24, %37 ], [ %1, %5 ]
%13 = phi i32 [ %23, %37 ], [ 2, %5 ]
%14 = phi i8* [ %40, %37 ], [ %1, %5 ]
%15 = phi i32 [ %41, %37 ], [ 0, %5 ]
%16 = phi i32 [ %43, %37 ], [ 0, %5 ]
%17 = icmp eq i32 %15, %13
br i1 %17, label %18, label %22
18: ; preds = %11
%19 = shl nsw i32 %13, 1
%20 = tail call i8* @realloc(i8* %12, i32 %19)
%21 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str.6, i64 0, i64 0))
br label %22
22: ; preds = %18, %11
%23 = phi i32 [ %19, %18 ], [ %13, %11 ]
%24 = phi i8* [ %20, %18 ], [ %12, %11 ]
%25 = tail call zeroext i8 @fgetc(i32* %3)
switch i8 %25, label %34 [
i8 62, label %26
i8 60, label %27
i8 43, label %28
i8 45, label %29
i8 46, label %30
i8 44, label %31
i8 91, label %32
i8 93, label %33
]
26: ; preds = %22
store i8 62, i8* %14
br label %37
27: ; preds = %22
store i8 60, i8* %14
br label %37
28: ; preds = %22
store i8 43, i8* %14
br label %37
29: ; preds = %22
store i8 45, i8* %14
br label %37
30: ; preds = %22
store i8 46, i8* %14
br label %37
31: ; preds = %22
store i8 44, i8* %14
br label %37
32: ; preds = %22
store i8 91, i8* %14
br label %37
33: ; preds = %22
store i8 93, i8* %14
br label %37
34: ; preds = %22
%35 = getelementptr inbounds i8, i8* %14, i64 -1
%36 = add nsw i32 %15, -1
br label %37
37: ; preds = %34, %33, %32, %31, %30, %29, %28, %27, %26
%38 = phi i32 [ %36, %34 ], [ %15, %33 ], [ %15, %32 ], [ %15, %31 ], [ %15, %30 ], [ %15, %29 ], [ %15, %28 ], [ %15, %27 ], [ %15, %26 ]
%39 = phi i8* [ %35, %34 ], [ %14, %33 ], [ %14, %32 ], [ %14, %31 ], [ %14, %30 ], [ %14, %29 ], [ %14, %28 ], [ %14, %27 ], [ %14, %26 ]
%40 = getelementptr inbounds i8, i8* %39, i64 1
%41 = add nsw i32 %38, 1
%42 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.4, i64 0, i64 0), i32 %41, i32 %23)
%43 = add nuw nsw i32 %16, 1
%44 = icmp eq i32 %43, %8
br i1 %44, label %45, label %11
45: ; preds = %37, %5
%46 = tail call i32 @fclose(i32* %3)
br label %47
47: ; preds = %2, %45
%48 = phi i8* [ getelementptr inbounds ([8 x i8], [8 x i8]* @str, i64 0, i64 0), %45 ], [ getelementptr inbounds ([30 x i8], [30 x i8]* @str.7, i64 0, i64 0), %2 ]
%49 = phi i32 [ 0, %45 ], [ 4, %2 ]
%50 = tail call i32 @puts(i8* dereferenceable(1) %48)
ret i32 %49
}