#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*/ printf(char *);
int /*<<< orphan*/ scanf(char *, int *);
void main() {
  int opcao;
  do {
    printf("-------Cardapio-------\n");
    printf("1 - Prato 01\n");
    printf("2 - Prato 02\n");
    printf("3 - Prato 03\n");
    printf("4 - Prato 04\n");
    printf("5 - Sair\n");
    printf("Informe o numero do prato: ");
    scanf("%d", &opcao);
    switch (opcao) {
    case 1:
      printf("Prato 01 escolhido!\n");
      break;
    case 2:
      printf("Prato 02 escolhido!\n");
      break;
    case 3:
      printf("Prato 03 escolhido!\n");
      break;
    case 4:
      printf("Prato 04 escolhido!\n");
      break;
    case 5:
      break;
    default:
      printf("Prato invalido!\n");
      break;
    }
  } while (opcao != 5);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xee5(%rip),%rdi
call   1030 <printf@plt>
lea    0xef1(%rip),%rdi
call   1030 <printf@plt>
lea    0xef3(%rip),%rdi
call   1030 <printf@plt>
lea    0xef5(%rip),%rdi
call   1030 <printf@plt>
lea    0xef7(%rip),%rdi
call   1030 <printf@plt>
lea    0xef9(%rip),%rdi
call   1030 <printf@plt>
lea    0xef7(%rip),%rdi
call   1030 <printf@plt>
lea    0xf07(%rip),%rdi
lea    -0x4(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x4(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x10(%rbp)
sub    $0x4,%eax
ja     11fe <main+0xde>
mov    -0x10(%rbp),%rax
lea    0xe54(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xed1(%rip),%rdi
call   1030 <printf@plt>
jmp    120a <main+0xea>
lea    0xed5(%rip),%rdi
call   1030 <printf@plt>
jmp    120a <main+0xea>
lea    0xed9(%rip),%rdi
call   1030 <printf@plt>
jmp    120a <main+0xea>
lea    0xedd(%rip),%rdi
call   1030 <printf@plt>
jmp    120a <main+0xea>
jmp    120a <main+0xea>
lea    0xedc(%rip),%rdi
call   1030 <printf@plt>
jmp    120f <main+0xef>
cmpl   $0x5,-0x4(%rbp)
jne    1128 <main+0x8>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0xf2f(%rip),%rbx
lea    0xf35(%rip),%rbp
lea    0xec4(%rip),%r14
lea    0xed9(%rip),%r15
lea    0x4(%rsp),%r12
lea    0xe9d(%rip),%r13
jmp    1190 <main+0x60>
cs nopw 0x0(%rax,%rax,1)
nop
lea    0xf60(%rip),%rdi
nopw   0x0(%rax,%rax,1)
call   1030 <puts@plt>
cmpl   $0x5,0x4(%rsp)
je     122c <main+0xfc>
lea    0xe9c(%rip),%rdi
call   1030 <puts@plt>
lea    0xea7(%rip),%rdi
call   1030 <puts@plt>
lea    0xea8(%rip),%rdi
call   1030 <puts@plt>
lea    0xea9(%rip),%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
call   1030 <puts@plt>
mov    %rbp,%rdi
call   1030 <puts@plt>
mov    %r14,%rdi
call   1040 <printf@plt>
mov    %r15,%rdi
mov    %r12,%rsi
call   1050 <scanf@plt>
mov    0x4(%rsp),%eax
add    $0xffffffff,%eax
cmp    $0x4,%eax
ja     1170 <main+0x40>
movslq 0x0(%r13,%rax,4),%rax
add    %r13,%rax
lea    0xec5(%rip),%rdi
jmp    *%rax
lea    0xea8(%rip),%rdi
jmp    1180 <main+0x50>
nopl   0x0(%rax)
lea    0xe84(%rip),%rdi
jmp    1180 <main+0x50>
nopl   0x0(%rax)
lea    0xe60(%rip),%rdi
jmp    1180 <main+0x50>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [24 x i8] c"-------Cardapio-------\0A\00"
@.str.1 = [14 x i8] c"1 - Prato 01\0A\00"
@.str.2 = [14 x i8] c"2 - Prato 02\0A\00"
@.str.3 = [14 x i8] c"3 - Prato 03\0A\00"
@.str.4 = [14 x i8] c"4 - Prato 04\0A\00"
@.str.5 = [10 x i8] c"5 - Sair\0A\00"
@.str.6 = [28 x i8] c"Informe o numero do prato: \00"
@.str.7 = [3 x i8] c"%d\00"
@.str.8 = [21 x i8] c"Prato 01 escolhido!\0A\00"
@.str.9 = [21 x i8] c"Prato 02 escolhido!\0A\00"
@.str.10 = [21 x i8] c"Prato 03 escolhido!\0A\00"
@.str.11 = [21 x i8] c"Prato 04 escolhido!\0A\00"
@.str.12 = [17 x i8] c"Prato invalido!\0A\00"
define void @main() {
%1 = alloca i32
br label %2
2: ; preds = %24, %0
%3 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
%5 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0))
%6 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0))
%7 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0))
%8 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0))
%9 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.6, i64 0, i64 0))
%10 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i32* %1)
%11 = load i32, i32* %1
switch i32 %11, label %21 [
i32 1, label %12
i32 2, label %14
i32 3, label %16
i32 4, label %18
i32 5, label %20
]
12: ; preds = %2
%13 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.8, i64 0, i64 0))
br label %23
14: ; preds = %2
%15 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.9, i64 0, i64 0))
br label %23
16: ; preds = %2
%17 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.10, i64 0, i64 0))
br label %23
18: ; preds = %2
%19 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.11, i64 0, i64 0))
br label %23
20: ; preds = %2
br label %23
21: ; preds = %2
%22 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.12, i64 0, i64 0))
br label %23
23: ; preds = %21, %20, %18, %16, %14, %12
br label %24
24: ; preds = %23
%25 = load i32, i32* %1
%26 = icmp ne i32 %25, 5
br i1 %26, label %2, label %27
27: ; preds = %24
ret void
}

LLVM IR (-O2):
@.str.6 = [28 x i8] c"Informe o numero do prato: \00"
@.str.7 = [3 x i8] c"%d\00"
@str = [23 x i8] c"-------Cardapio-------\00"
@str.13 = [13 x i8] c"1 - Prato 01\00"
@str.14 = [13 x i8] c"2 - Prato 02\00"
@str.15 = [13 x i8] c"3 - Prato 03\00"
@str.16 = [13 x i8] c"4 - Prato 04\00"
@str.17 = [9 x i8] c"5 - Sair\00"
@str.18 = [20 x i8] c"Prato 04 escolhido!\00"
@str.19 = [20 x i8] c"Prato 03 escolhido!\00"
@str.20 = [20 x i8] c"Prato 02 escolhido!\00"
@str.21 = [20 x i8] c"Prato 01 escolhido!\00"
@str.22 = [16 x i8] c"Prato invalido!\00"
define void @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
br label %3
3: ; preds = %17, %0
%4 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str, i64 0, i64 0))
%5 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @str.13, i64 0, i64 0))
%6 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @str.14, i64 0, i64 0))
%7 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @str.15, i64 0, i64 0))
%8 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @str.16, i64 0, i64 0))
%9 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @str.17, i64 0, i64 0))
%10 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.6, i64 0, i64 0))
%11 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i32* %1)
%12 = load i32, i32* %1
switch i32 %12, label %16 [
i32 1, label %17
i32 2, label %13
i32 3, label %14
i32 4, label %15
i32 5, label %22
]
13: ; preds = %3
br label %17
14: ; preds = %3
br label %17
15: ; preds = %3
br label %17
16: ; preds = %3
br label %17
17: ; preds = %3, %13, %14, %15, %16
%18 = phi i8* [ getelementptr inbounds ([20 x i8], [20 x i8]* @str.20, i64 0, i64 0), %13 ], [ getelementptr inbounds ([20 x i8], [20 x i8]* @str.19, i64 0, i64 0), %14 ], [ getelementptr inbounds ([20 x i8], [20 x i8]* @str.18, i64 0, i64 0), %15 ], [ getelementptr inbounds ([16 x i8], [16 x i8]* @str.22, i64 0, i64 0), %16 ], [ getelementptr inbounds ([20 x i8], [20 x i8]* @str.21, i64 0, i64 0), %3 ]
%19 = call i32 @puts(i8* dereferenceable(1) %18)
%20 = load i32, i32* %1
%21 = icmp eq i32 %20, 5
br i1 %21, label %22, label %3
22: ; preds = %3, %17
ret void
}