#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*/ print(char *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ scanf(char *, int *);
int main(void) {
  int whatToDo = 0;
  do {
    printf("\nMENU\n");
    printf("\n 1. Novo");
    printf("\n 2. Abrir");
    printf("\n 3. Salvar");
    printf("\n 4. Sair\n");
    printf("\n:");
    scanf(" %d", &whatToDo);
    switch (whatToDo) {
    case 1:
      printf("\n Novo arquivo\n");
      break;
    case 2:
      printf("\n Abir arquivo\n");
      break;
    case 3:
      printf("\n Salvar arquivo\n");
      break;
    case 4:
      printf("\n Sair\n");
      exit(0);
    default:
      printf("\n Opção errada...\n");
    }
  } while (whatToDo > 1 || whatToDo < 4);
  print("\nBye\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
lea    0xeb3(%rip),%rdi
call   1030 <printf@plt>
lea    0xeae(%rip),%rdi
call   1030 <printf@plt>
lea    0xeac(%rip),%rdi
call   1030 <printf@plt>
lea    0xeab(%rip),%rdi
call   1030 <printf@plt>
lea    0xeab(%rip),%rdi
call   1030 <printf@plt>
lea    0xeaa(%rip),%rdi
call   1030 <printf@plt>
lea    0xea1(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1050 <scanf@plt>
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x10(%rbp)
sub    $0x3,%eax
ja     121d <main+0xdd>
mov    -0x10(%rbp),%rax
lea    0xe32(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xe6c(%rip),%rdi
call   1030 <printf@plt>
jmp    1229 <main+0xe9>
lea    0xe6b(%rip),%rdi
call   1030 <printf@plt>
jmp    1229 <main+0xe9>
lea    0xe6a(%rip),%rdi
call   1030 <printf@plt>
jmp    1229 <main+0xe9>
lea    0xe6b(%rip),%rdi
call   1030 <printf@plt>
xor    %edi,%edi
call   1060 <exit@plt>
lea    0xe60(%rip),%rdi
call   1030 <printf@plt>
jmp    122e <main+0xee>
mov    $0x1,%al
cmpl   $0x1,-0x8(%rbp)
mov    %al,-0x11(%rbp)
jg     1247 <main+0x107>
cmpl   $0x4,-0x8(%rbp)
setl   %al
mov    %al,-0x11(%rbp)
mov    -0x11(%rbp),%al
test   $0x1,%al
jne    1156 <main+0x16>
lea    0xe40(%rip),%rdi
call   1040 <print@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
movl   $0x0,0x4(%rsp)
lea    0xecb(%rip),%r13
lea    0xedd(%rip),%rbx
lea    0xec9(%rip),%rbp
lea    0xec5(%rip),%r14
lea    0x4(%rsp),%r15
lea    0xe85(%rip),%r12
jmp    118c <main+0x4c>
nopl   (%rax)
lea    0xef7(%rip),%rdi
call   1030 <puts@plt>
lea    0xea5(%rip),%rdi
call   1030 <puts@plt>
lea    0xe71(%rip),%rdi
call   1040 <printf@plt>
lea    0xe6f(%rip),%rdi
call   1040 <printf@plt>
mov    %r13,%rdi
call   1040 <printf@plt>
mov    %rbx,%rdi
call   1030 <puts@plt>
mov    %rbp,%rdi
call   1040 <printf@plt>
mov    %r14,%rdi
mov    %r15,%rsi
call   1050 <scanf@plt>
mov    0x4(%rsp),%eax
add    $0xffffffff,%eax
cmp    $0x3,%eax
ja     1180 <main+0x40>
movslq (%r12,%rax,4),%rax
add    %r12,%rax
lea    0xe82(%rip),%rdi
jmp    *%rax
lea    0xe6a(%rip),%rdi
call   1030 <puts@plt>
jmp    118c <main+0x4c>
nopl   (%rax)
lea    0xe48(%rip),%rdi
call   1030 <puts@plt>
jmp    118c <main+0x4c>
lea    0xe30(%rip),%rdi
call   1030 <puts@plt>
xor    %edi,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@.str = [7 x i8] c"\0AMENU\0A\00"
@.str.1 = [10 x i8] c"\0A 1. Novo\00"
@.str.2 = [11 x i8] c"\0A 2. Abrir\00"
@.str.3 = [12 x i8] c"\0A 3. Salvar\00"
@.str.4 = [11 x i8] c"\0A 4. Sair\0A\00"
@.str.5 = [3 x i8] c"\0A:\00"
@.str.6 = [4 x i8] c" %d\00"
@.str.7 = [16 x i8] c"\0A Novo arquivo\0A\00"
@.str.8 = [16 x i8] c"\0A Abir arquivo\0A\00"
@.str.9 = [18 x i8] c"\0A Salvar arquivo\0A\00"
@.str.10 = [8 x i8] c"\0A Sair\0A\00"
@.str.11 = [21 x i8] c"\0A Op\C3\A7\C3\A3o errada...\0A\00"
@.str.12 = [6 x i8] c"\0ABye\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %2
br label %3
3: ; preds = %30, %0
%4 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%5 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
%6 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0))
%7 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0))
%8 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0))
%9 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
%10 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i32* %2)
%11 = load i32, i32* %2
switch i32 %11, label %21 [
i32 1, label %12
i32 2, label %14
i32 3, label %16
i32 4, label %18
]
12: ; preds = %3
%13 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.7, i64 0, i64 0))
br label %23
14: ; preds = %3
%15 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.8, i64 0, i64 0))
br label %23
16: ; preds = %3
%17 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.9, i64 0, i64 0))
br label %23
18: ; preds = %3
%19 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.10, i64 0, i64 0))
%20 = call i32 @exit(i32 0)
unreachable
21: ; preds = %3
%22 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.11, i64 0, i64 0))
br label %23
23: ; preds = %21, %16, %14, %12
br label %24
24: ; preds = %23
%25 = load i32, i32* %2
%26 = icmp sgt i32 %25, 1
br i1 %26, label %30, label %27
27: ; preds = %24
%28 = load i32, i32* %2
%29 = icmp slt i32 %28, 4
br label %30
30: ; preds = %27, %24
%31 = phi i1 [ true, %24 ], [ %29, %27 ]
br i1 %31, label %3, label %32
32: ; preds = %30
%33 = call i32 @print(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.12, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [10 x i8] c"\0A 1. Novo\00"
@.str.2 = [11 x i8] c"\0A 2. Abrir\00"
@.str.3 = [12 x i8] c"\0A 3. Salvar\00"
@.str.5 = [3 x i8] c"\0A:\00"
@.str.6 = [4 x i8] c" %d\00"
@str = [6 x i8] c"\0AMENU\00"
@str.13 = [10 x i8] c"\0A 4. Sair\00"
@str.14 = [7 x i8] c"\0A Sair\00"
@str.15 = [17 x i8] c"\0A Salvar arquivo\00"
@str.16 = [15 x i8] c"\0A Abir arquivo\00"
@str.17 = [15 x i8] c"\0A Novo arquivo\00"
@str.18 = [20 x i8] c"\0A Op\C3\A7\C3\A3o errada...\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
store i32 0, i32* %1
br label %3
3: ; preds = %18, %0
%4 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @str, i64 0, i64 0))
%5 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
%6 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0))
%7 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0))
%8 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @str.13, i64 0, i64 0))
%9 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
%10 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i32* %1)
%11 = load i32, i32* %1
switch i32 %11, label %17 [
i32 1, label %18
i32 2, label %12
i32 3, label %13
i32 4, label %14
]
12: ; preds = %3
br label %18
13: ; preds = %3
br label %18
14: ; preds = %3
%15 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @str.14, i64 0, i64 0))
%16 = call i32 @exit(i32 0)
unreachable
17: ; preds = %3
br label %18
18: ; preds = %3, %12, %13, %17
%19 = phi i8* [ getelementptr inbounds ([15 x i8], [15 x i8]* @str.16, i64 0, i64 0), %12 ], [ getelementptr inbounds ([17 x i8], [17 x i8]* @str.15, i64 0, i64 0), %13 ], [ getelementptr inbounds ([20 x i8], [20 x i8]* @str.18, i64 0, i64 0), %17 ], [ getelementptr inbounds ([15 x i8], [15 x i8]* @str.17, i64 0, i64 0), %3 ]
%20 = call i32 @puts(i8* dereferenceable(1) %19)
br label %3
}