#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*/ graph(float *, int);
float *load(char *, int *);
int /*<<< orphan*/ print(float *, int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, char *);
int strlen(char *);
int main() {
  char val;
  char buffer[100];
  float *tal = NULL;
  int size = 100;
  do {
    printf("MENY\n");
    printf("1. Load data\n");
    printf("2. Display data\n");
    printf("3. Display graph\n");
    printf("0. Exit\n");
    scanf("%s", buffer);
    val = buffer[0];
    if (strlen(buffer) > 1) {
      printf("Too many characters!\n");
    } else {
      switch (val) {
      case '1':
        tal = load("posneg.txt", &size);
        break;
      case '2':
        print(tal, size);
        break;
      case '3':
        graph(tal, size);
        break;
      case '0':
        printf("Exiting program\n");
        break;
      default:
        printf("Wrong input!\n");
        break;
      }
    }
  } while (val != '0');
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
movl   $0x0,-0x4(%rbp)
movq   $0x0,-0x78(%rbp)
movl   $0x64,-0x7c(%rbp)
lea    0xe88(%rip),%rdi
call   1040 <printf@plt>
lea    0xe82(%rip),%rdi
call   1040 <printf@plt>
lea    0xe84(%rip),%rdi
call   1040 <printf@plt>
lea    0xe89(%rip),%rdi
call   1040 <printf@plt>
lea    0xe8f(%rip),%rdi
call   1040 <printf@plt>
lea    -0x70(%rbp),%rsi
lea    0xe88(%rip),%rdi
call   1060 <scanf@plt>
mov    -0x70(%rbp),%al
mov    %al,-0x5(%rbp)
lea    -0x70(%rbp),%rdi
call   1030 <strlen@plt>
cmp    $0x1,%eax
jle    11f6 <main+0x96>
lea    0xe67(%rip),%rdi
call   1040 <printf@plt>
jmp    1283 <main+0x123>
movsbl -0x5(%rbp),%eax
add    $0xffffffd0,%eax
mov    %eax,%ecx
mov    %rcx,-0x88(%rbp)
sub    $0x3,%eax
ja     1272 <main+0x112>
mov    -0x88(%rbp),%rax
lea    0xde3(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xe3c(%rip),%rdi
lea    -0x7c(%rbp),%rsi
call   1070 <load@plt>
mov    %rax,-0x78(%rbp)
jmp    127e <main+0x11e>
mov    -0x78(%rbp),%rdi
mov    -0x7c(%rbp),%esi
call   1050 <print@plt>
jmp    127e <main+0x11e>
mov    -0x78(%rbp),%rdi
mov    -0x7c(%rbp),%esi
call   1080 <graph@plt>
jmp    127e <main+0x11e>
lea    0xe0c(%rip),%rdi
call   1040 <printf@plt>
jmp    127e <main+0x11e>
lea    0xe0c(%rip),%rdi
call   1040 <printf@plt>
jmp    1283 <main+0x123>
jmp    1288 <main+0x128>
movsbl -0x5(%rbp),%eax
cmp    $0x30,%eax
jne    1181 <main+0x21>
mov    -0x4(%rbp),%eax
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x78,%rsp
movl   $0x64,0x4(%rsp)
xor    %eax,%eax
mov    %rax,0x8(%rsp)
lea    0xeac(%rip),%r12
lea    0xeb5(%rip),%r13
lea    0xebf(%rip),%rbx
lea    0xe77(%rip),%rbp
lea    0x10(%rsp),%r14
jmp    11b6 <main+0x56>
lea    0xecf(%rip),%rdi
call   1030 <puts@plt>
cmp    $0x30,%r15b
je     1273 <main+0x113>
lea    0xe61(%rip),%rdi
call   1030 <puts@plt>
lea    0xe5a(%rip),%rdi
call   1030 <puts@plt>
mov    %r12,%rdi
call   1030 <puts@plt>
mov    %r13,%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
call   1030 <puts@plt>
mov    %rbp,%rdi
mov    %r14,%rsi
call   1060 <scanf@plt>
movsbl 0x10(%rsp),%r15d
mov    %r14,%rdi
call   1040 <strlen@plt>
cmp    $0x2,%eax
jge    11a0 <main+0x40>
lea    -0x30(%r15),%eax
cmp    $0x3,%eax
ja     1226 <main+0xc6>
lea    0xdec(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xe35(%rip),%rdi
jmp    11a7 <main+0x47>
lea    0xe3c(%rip),%rdi
jmp    11a7 <main+0x47>
lea    0xdda(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1070 <load@plt>
mov    %rax,0x8(%rsp)
jmp    11ac <main+0x4c>
mov    0x4(%rsp),%esi
mov    0x8(%rsp),%rdi
call   1050 <print@plt>
jmp    11ac <main+0x4c>
mov    0x4(%rsp),%esi
mov    0x8(%rsp),%rdi
call   1080 <graph@plt>
jmp    11ac <main+0x4c>
xor    %eax,%eax
add    $0x78,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [6 x i8] c"MENY\0A\00"
@.str.1 = [14 x i8] c"1. Load data\0A\00"
@.str.2 = [17 x i8] c"2. Display data\0A\00"
@.str.3 = [18 x i8] c"3. Display graph\0A\00"
@.str.4 = [9 x i8] c"0. Exit\0A\00"
@.str.5 = [3 x i8] c"%s\00"
@.str.6 = [22 x i8] c"Too many characters!\0A\00"
@.str.7 = [11 x i8] c"posneg.txt\00"
@.str.8 = [17 x i8] c"Exiting program\0A\00"
@.str.9 = [14 x i8] c"Wrong input!\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8
%3 = alloca [100 x i8]
%4 = alloca float*
%5 = alloca i32
store i32 0, i32* %1
store float* null, float** %4
store i32 100, i32* %5
br label %6
6: ; preds = %40, %0
%7 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%8 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
%9 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0))
%10 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0))
%11 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0))
%12 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%13 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i8* %12)
%14 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%15 = load i8, i8* %14
store i8 %15, i8* %2
%16 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%17 = call i32 @strlen(i8* %16)
%18 = icmp sgt i32 %17, 1
br i1 %18, label %19, label %21
19: ; preds = %6
%20 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.6, i64 0, i64 0))
br label %39
21: ; preds = %6
%22 = load i8, i8* %2
%23 = sext i8 %22 to i32
switch i32 %23, label %36 [
i32 49, label %24
i32 50, label %26
i32 51, label %30
i32 48, label %34
]
24: ; preds = %21
%25 = call float* @load(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.7, i64 0, i64 0), i32* %5)
store float* %25, float** %4
br label %38
26: ; preds = %21
%27 = load float*, float** %4
%28 = load i32, i32* %5
%29 = call i32 @print(float* %27, i32 %28)
br label %38
30: ; preds = %21
%31 = load float*, float** %4
%32 = load i32, i32* %5
%33 = call i32 @graph(float* %31, i32 %32)
br label %38
34: ; preds = %21
%35 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.8, i64 0, i64 0))
br label %38
36: ; preds = %21
%37 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.9, i64 0, i64 0))
br label %38
38: ; preds = %36, %34, %30, %26, %24
br label %39
39: ; preds = %38, %19
br label %40
40: ; preds = %39
%41 = load i8, i8* %2
%42 = sext i8 %41 to i32
%43 = icmp ne i32 %42, 48
br i1 %43, label %6, label %44
44: ; preds = %40
%45 = load i32, i32* %1
ret i32 %45
}

LLVM IR (-O2):
@.str.5 = [3 x i8] c"%s\00"
@.str.7 = [11 x i8] c"posneg.txt\00"
@str = [5 x i8] c"MENY\00"
@str.10 = [13 x i8] c"1. Load data\00"
@str.11 = [16 x i8] c"2. Display data\00"
@str.12 = [17 x i8] c"3. Display graph\00"
@str.13 = [8 x i8] c"0. Exit\00"
@str.14 = [16 x i8] c"Exiting program\00"
@str.15 = [13 x i8] c"Wrong input!\00"
@str.16 = [21 x i8] c"Too many characters!\00"
define i32 @main() {
%1 = alloca [100 x i8]
%2 = alloca i32
%3 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%4 = bitcast i32* %2 to i8*
store i32 100, i32* %2
br label %5
5: ; preds = %32, %0
%6 = phi float* [ null, %0 ], [ %33, %32 ]
%7 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @str, i64 0, i64 0))
%8 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @str.10, i64 0, i64 0))
%9 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str.11, i64 0, i64 0))
%10 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str.12, i64 0, i64 0))
%11 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @str.13, i64 0, i64 0))
%12 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i8* %3)
%13 = load i8, i8* %3
%14 = call i32 @strlen(i8* %3)
%15 = icmp sgt i32 %14, 1
br i1 %15, label %16, label %18
16: ; preds = %5
%17 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str.16, i64 0, i64 0))
br label %32
18: ; preds = %5
%19 = sext i8 %13 to i32
switch i32 %19, label %30 [
i32 49, label %20
i32 50, label %22
i32 51, label %25
i32 48, label %28
]
20: ; preds = %18
%21 = call float* @load(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.7, i64 0, i64 0), i32* %2)
br label %32
22: ; preds = %18
%23 = load i32, i32* %2
%24 = call i32 @print(float* %6, i32 %23)
br label %32
25: ; preds = %18
%26 = load i32, i32* %2
%27 = call i32 @graph(float* %6, i32 %26)
br label %32
28: ; preds = %18
%29 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str.14, i64 0, i64 0))
br label %32
30: ; preds = %18
%31 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @str.15, i64 0, i64 0))
br label %32
32: ; preds = %16, %30, %28, %25, %22, %20
%33 = phi float* [ %6, %16 ], [ %6, %30 ], [ %6, %28 ], [ %6, %25 ], [ %6, %22 ], [ %21, %20 ]
%34 = icmp eq i8 %13, 48
br i1 %34, label %35, label %5
35: ; preds = %32
ret i32 0
}