#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*/ add_function(char *, int /*<<< orphan*/ *);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int getline(char **, int *, int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, ...);
int main(int argc, char **argv) {
  if (argc != 3) {
    printf("Please enter file names as argument.\n");
    return 1;
  }
  char c;
  int nbytes = 10;
  FILE *fin = fopen(argv[1], "r");
  FILE *fout = fopen(argv[2], "w");
  printf("start");
  char *line = NULL;
  int a = getline(&line, &nbytes, fin);
  printf("sdsadsad");
  while (a != -1) {
    int eq_count = 0;
    int i = 0;
    for (i = 0; line[i] != '\0'; i++) {
      printf("%c", line[i]);
      if (line[i] == '+') {
        add_function(line, fout);
        break;
      }
      if (line[i] == '-') {
        break;
      }
      if (line[i] == '*') {
        break;
      }
      if (line[i] == '/') {
        break;
      }
      if (line[i] == '*') {
        break;
      }
      if (line[i] == '=') {
        eq_count++;
      }
    }
    if (eq_count == 1) {
    }
    a = getline(&line, &nbytes, fin);
  }
  fclose(fin);
  fclose(fout);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x3,-0x8(%rbp)
je     118a <main+0x3a>
lea    0xe89(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1348 <main+0x1f8>
movl   $0xa,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe86(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xe70(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x28(%rbp)
lea    0xe62(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movq   $0x0,-0x30(%rbp)
mov    -0x20(%rbp),%rdx
lea    -0x30(%rbp),%rdi
lea    -0x18(%rbp),%rsi
call   1070 <getline@plt>
mov    %eax,-0x34(%rbp)
lea    0xe3e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
cmpl   $0xffffffff,-0x34(%rbp)
je     132f <main+0x1df>
movl   $0x0,-0x38(%rbp)
movl   $0x0,-0x3c(%rbp)
movl   $0x0,-0x3c(%rbp)
mov    -0x30(%rbp),%rax
movslq -0x3c(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x0,%eax
je     1307 <main+0x1b7>
mov    -0x30(%rbp),%rax
movslq -0x3c(%rbp),%rcx
movsbl (%rax,%rcx,1),%esi
lea    0xdf9(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x30(%rbp),%rax
movslq -0x3c(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x2b,%eax
jne    126e <main+0x11e>
mov    -0x30(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   1050 <add_function@plt>
jmp    1307 <main+0x1b7>
mov    -0x30(%rbp),%rax
movslq -0x3c(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x2d,%eax
jne    1288 <main+0x138>
jmp    1307 <main+0x1b7>
mov    -0x30(%rbp),%rax
movslq -0x3c(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x2a,%eax
jne    12a2 <main+0x152>
jmp    1307 <main+0x1b7>
mov    -0x30(%rbp),%rax
movslq -0x3c(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x2f,%eax
jne    12bc <main+0x16c>
jmp    1307 <main+0x1b7>
mov    -0x30(%rbp),%rax
movslq -0x3c(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x2a,%eax
jne    12d6 <main+0x186>
jmp    1307 <main+0x1b7>
mov    -0x30(%rbp),%rax
movslq -0x3c(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x3d,%eax
jne    12f4 <main+0x1a4>
mov    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
jmp    12f9 <main+0x1a9>
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    1218 <main+0xc8>
cmpl   $0x1,-0x38(%rbp)
jne    1316 <main+0x1c6>
jmp    1316 <main+0x1c6>
mov    -0x20(%rbp),%rdx
lea    -0x30(%rbp),%rdi
lea    -0x18(%rbp),%rsi
call   1070 <getline@plt>
mov    %eax,-0x34(%rbp)
jmp    11f9 <main+0xa9>
mov    -0x20(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x28(%rbp),%rdi
call   1030 <fclose@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
cmp    $0x3,%edi
jne    127d <main+0x10d>
mov    %rsi,%rbp
movl   $0xa,0xc(%rsp)
mov    0x8(%rsi),%rdi
lea    0xe7b(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,%rbx
mov    0x10(%rbp),%rdi
lea    0xe6a(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,%r15
lea    0xe5d(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
movq   $0x0,0x10(%rsp)
lea    0x10(%rsp),%rdi
lea    0xc(%rsp),%rsi
mov    %rbx,%rdx
call   1090 <getline@plt>
mov    %eax,%ebp
lea    0xe38(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
cmp    $0xffffffff,%ebp
je     1290 <main+0x120>
lea    0x10(%rsp),%r12
lea    0xc(%rsp),%r13
lea    0xdf5(%rip),%rbp
jmp    1223 <main+0xb3>
nopl   (%rax)
mov    %r12,%rdi
mov    %r13,%rsi
mov    %rbx,%rdx
call   1090 <getline@plt>
cmp    $0xffffffff,%eax
je     1290 <main+0x120>
mov    0x10(%rsp),%rax
mov    (%rax),%al
test   %al,%al
je     1210 <main+0xa0>
mov    $0x1,%r14d
jmp    124d <main+0xdd>
cs nopw 0x0(%rax,%rax,1)
movzbl (%rdi,%r14,1),%eax
add    $0x1,%r14
test   %al,%al
je     1210 <main+0xa0>
movsbl %al,%edi
call   1030 <putchar@plt>
mov    0x10(%rsp),%rdi
movzbl -0x1(%rdi,%r14,1),%eax
add    $0xd6,%al
cmp    $0x5,%al
ja     1240 <main+0xd0>
movzbl %al,%eax
movslq 0x0(%rbp,%rax,4),%rax
add    %rbp,%rax
jmp    *%rax
mov    %r15,%rsi
call   1070 <add_function@plt>
jmp    1210 <main+0xa0>
lea    0xda7(%rip),%rdi
call   1040 <puts@plt>
mov    $0x1,%eax
jmp    12a2 <main+0x132>
mov    %rbx,%rdi
call   1050 <fclose@plt>
mov    %r15,%rdi
call   1050 <fclose@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [38 x i8] c"Please enter file names as argument.\0A\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [2 x i8] c"w\00"
@.str.3 = [6 x i8] c"start\00"
@.str.4 = [9 x i8] c"sdsadsad\00"
@.str.5 = [3 x i8] c"%c\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8
%7 = alloca i32
%8 = alloca i32*
%9 = alloca i32*
%10 = alloca i8*
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%14 = load i32, i32* %4
%15 = icmp ne i32 %14, 3
br i1 %15, label %16, label %18
16: ; preds = %2
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %3
br label %125
18: ; preds = %2
store i32 10, i32* %7
%19 = load i8**, i8*** %5
%20 = getelementptr inbounds i8*, i8** %19, i64 1
%21 = load i8*, i8** %20
%22 = call i32* @fopen(i8* %21, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %22, i32** %8
%23 = load i8**, i8*** %5
%24 = getelementptr inbounds i8*, i8** %23, i64 2
%25 = load i8*, i8** %24
%26 = call i32* @fopen(i8* %25, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32* %26, i32** %9
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
store i8* null, i8** %10
%28 = load i32*, i32** %8
%29 = call i32 @getline(i8** %10, i32* %7, i32* %28)
store i32 %29, i32* %11
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0))
br label %31
31: ; preds = %117, %18
%32 = load i32, i32* %11
%33 = icmp ne i32 %32, -1
br i1 %33, label %34, label %120
34: ; preds = %31
store i32 0, i32* %12
store i32 0, i32* %13
store i32 0, i32* %13
br label %35
35: ; preds = %110, %34
%36 = load i8*, i8** %10
%37 = load i32, i32* %13
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds i8, i8* %36, i64 %38
%40 = load i8, i8* %39
%41 = sext i8 %40 to i32
%42 = icmp ne i32 %41, 0
br i1 %42, label %43, label %113
43: ; preds = %35
%44 = load i8*, i8** %10
%45 = load i32, i32* %13
%46 = sext i32 %45 to i64
%47 = getelementptr inbounds i8, i8* %44, i64 %46
%48 = load i8, i8* %47
%49 = sext i8 %48 to i32
%50 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32 %49)
%51 = load i8*, i8** %10
%52 = load i32, i32* %13
%53 = sext i32 %52 to i64
%54 = getelementptr inbounds i8, i8* %51, i64 %53
%55 = load i8, i8* %54
%56 = sext i8 %55 to i32
%57 = icmp eq i32 %56, 43
br i1 %57, label %58, label %62
58: ; preds = %43
%59 = load i8*, i8** %10
%60 = load i32*, i32** %9
%61 = call i32 @add_function(i8* %59, i32* %60)
br label %113
62: ; preds = %43
%63 = load i8*, i8** %10
%64 = load i32, i32* %13
%65 = sext i32 %64 to i64
%66 = getelementptr inbounds i8, i8* %63, i64 %65
%67 = load i8, i8* %66
%68 = sext i8 %67 to i32
%69 = icmp eq i32 %68, 45
br i1 %69, label %70, label %71
70: ; preds = %62
br label %113
71: ; preds = %62
%72 = load i8*, i8** %10
%73 = load i32, i32* %13
%74 = sext i32 %73 to i64
%75 = getelementptr inbounds i8, i8* %72, i64 %74
%76 = load i8, i8* %75
%77 = sext i8 %76 to i32
%78 = icmp eq i32 %77, 42
br i1 %78, label %79, label %80
79: ; preds = %71
br label %113
80: ; preds = %71
%81 = load i8*, i8** %10
%82 = load i32, i32* %13
%83 = sext i32 %82 to i64
%84 = getelementptr inbounds i8, i8* %81, i64 %83
%85 = load i8, i8* %84
%86 = sext i8 %85 to i32
%87 = icmp eq i32 %86, 47
br i1 %87, label %88, label %89
88: ; preds = %80
br label %113
89: ; preds = %80
%90 = load i8*, i8** %10
%91 = load i32, i32* %13
%92 = sext i32 %91 to i64
%93 = getelementptr inbounds i8, i8* %90, i64 %92
%94 = load i8, i8* %93
%95 = sext i8 %94 to i32
%96 = icmp eq i32 %95, 42
br i1 %96, label %97, label %98
97: ; preds = %89
br label %113
98: ; preds = %89
%99 = load i8*, i8** %10
%100 = load i32, i32* %13
%101 = sext i32 %100 to i64
%102 = getelementptr inbounds i8, i8* %99, i64 %101
%103 = load i8, i8* %102
%104 = sext i8 %103 to i32
%105 = icmp eq i32 %104, 61
br i1 %105, label %106, label %109
106: ; preds = %98
%107 = load i32, i32* %12
%108 = add nsw i32 %107, 1
store i32 %108, i32* %12
br label %109
109: ; preds = %106, %98
br label %110
110: ; preds = %109
%111 = load i32, i32* %13
%112 = add nsw i32 %111, 1
store i32 %112, i32* %13
br label %35
113: ; preds = %97, %88, %79, %70, %58, %35
%114 = load i32, i32* %12
%115 = icmp eq i32 %114, 1
br i1 %115, label %116, label %117
116: ; preds = %113
br label %117
117: ; preds = %116, %113
%118 = load i32*, i32** %8
%119 = call i32 @getline(i8** %10, i32* %7, i32* %118)
store i32 %119, i32* %11
br label %31
120: ; preds = %31
%121 = load i32*, i32** %8
%122 = call i32 @fclose(i32* %121)
%123 = load i32*, i32** %9
%124 = call i32 @fclose(i32* %123)
store i32 0, i32* %3
br label %125
125: ; preds = %120, %16
%126 = load i32, i32* %3
ret i32 %126
}

LLVM IR (-O2):
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [2 x i8] c"w\00"
@.str.3 = [6 x i8] c"start\00"
@.str.4 = [9 x i8] c"sdsadsad\00"
@str = [37 x i8] c"Please enter file names as argument.\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = icmp eq i32 %0, 3
br i1 %5, label %8, label %6
6: ; preds = %2
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @str, i64 0, i64 0))
br label %46
8: ; preds = %2
%9 = bitcast i32* %3 to i8*
store i32 10, i32* %3
%10 = getelementptr inbounds i8*, i8** %1, i64 1
%11 = load i8*, i8** %10
%12 = tail call i32* @fopen(i8* %11, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%13 = getelementptr inbounds i8*, i8** %1, i64 2
%14 = load i8*, i8** %13
%15 = tail call i32* @fopen(i8* %14, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%16 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
%17 = bitcast i8** %4 to i8*
store i8* null, i8** %4
%18 = call i32 @getline(i8** %4, i32* %3, i32* %12)
%19 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0))
%20 = icmp eq i32 %18, -1
br i1 %20, label %43, label %21
21: ; preds = %8, %40
%22 = load i8*, i8** %4
%23 = load i8, i8* %22
%24 = icmp eq i8 %23, 0
br i1 %24, label %40, label %25
25: ; preds = %21, %35
%26 = phi i64 [ %36, %35 ], [ 0, %21 ]
%27 = phi i8 [ %38, %35 ], [ %23, %21 ]
%28 = sext i8 %27 to i32
%29 = call i32 @putchar(i32 %28)
%30 = load i8*, i8** %4
%31 = getelementptr inbounds i8, i8* %30, i64 %26
%32 = load i8, i8* %31
switch i8 %32, label %35 [
i8 43, label %33
i8 45, label %40
i8 42, label %40
i8 47, label %40
]
33: ; preds = %25
%34 = call i32 @add_function(i8* %30, i32* %15)
br label %40
35: ; preds = %25
%36 = add nuw i64 %26, 1
%37 = getelementptr inbounds i8, i8* %30, i64 %36
%38 = load i8, i8* %37
%39 = icmp eq i8 %38, 0
br i1 %39, label %40, label %25
40: ; preds = %35, %25, %25, %25, %21, %33
%41 = call i32 @getline(i8** %4, i32* %3, i32* %12)
%42 = icmp eq i32 %41, -1
br i1 %42, label %43, label %21
43: ; preds = %40, %8
%44 = call i32 @fclose(i32* %12)
%45 = call i32 @fclose(i32* %15)
br label %46
46: ; preds = %43, %6
%47 = phi i32 [ 1, %6 ], [ 0, %43 ]
ret i32 %47
}