#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 *);
void show_menu(const short int menu_number) {
  if (menu_number == 1) {
    printf("1 - Pesquisas e listagens\n");
    printf("2 - Inserir e alterar dados\n");
    printf("3 - Carregar ficheiros\n");
    printf("4 - Alterar armazem\n");
    printf("9 - Sair\n\n");
  } else if (menu_number == 2) {
    printf("1 - Mostrar arvore do armazem\n");
    printf("2 - Listar todos os produtos do armazem\n");
    printf("3 - Listar todos os produtos de um corredor\n");
    printf("4 - Listar todos os produtos de um armario\n");
    printf("5 - Procurar por numero de produto\n");
    printf("6 - Procurar pelo stock de produto\n");
    printf("7 - Mostrar produtos vendidos\n");
    printf("9 - Voltar\n\n");
  } else if (menu_number == 3) {
    printf("1 - Inserir produto\n");
    printf("2 - Alterar stock\n");
    printf("9 - Voltar\n\n");
  } else if (menu_number == 4) {
    printf("1 - Carregar ficheiro de stocks\n");
    printf("2 - Carregar ficheiro de encomenda\n");
    printf("9 - Voltar\n\n");
  } else if (menu_number == 5) {
    printf("1 - Inserir corredor\n");
    printf("2 - Inserir armario\n");
    printf("3 - Remover corredor\n");
    printf("4 - Remover armario\n");
    printf("9 - Voltar\n\n");
  }
  printf("Opcao: ");
}


x86 assembly (clang, -O0):
<show_menu>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %di,%ax
mov    %ax,-0x2(%rbp)
movswl -0x2(%rbp),%eax
cmp    $0x1,%eax
jne    116d <show_menu+0x5d>
lea    0xecd(%rip),%rdi
call   1030 <printf@plt>
lea    0xedc(%rip),%rdi
call   1030 <printf@plt>
lea    0xeed(%rip),%rdi
call   1030 <printf@plt>
lea    0xef9(%rip),%rdi
call   1030 <printf@plt>
lea    0xf02(%rip),%rdi
call   1030 <printf@plt>
jmp    12a8 <show_menu+0x198>
movswl -0x2(%rbp),%eax
cmp    $0x2,%eax
jne    11df <show_menu+0xcf>
lea    0xeef(%rip),%rdi
call   1030 <printf@plt>
lea    0xf02(%rip),%rdi
call   1030 <printf@plt>
lea    0xf1f(%rip),%rdi
call   1030 <printf@plt>
lea    0xf40(%rip),%rdi
call   1030 <printf@plt>
lea    0xf60(%rip),%rdi
call   1030 <printf@plt>
lea    0xf78(%rip),%rdi
call   1030 <printf@plt>
lea    0xf90(%rip),%rdi
call   1030 <printf@plt>
lea    0xfa3(%rip),%rdi
call   1030 <printf@plt>
jmp    12a3 <show_menu+0x193>
movswl -0x2(%rbp),%eax
cmp    $0x3,%eax
jne    1215 <show_menu+0x105>
lea    0xf92(%rip),%rdi
call   1030 <printf@plt>
lea    0xf9b(%rip),%rdi
call   1030 <printf@plt>
lea    0xf6d(%rip),%rdi
call   1030 <printf@plt>
jmp    129e <show_menu+0x18e>
movswl -0x2(%rbp),%eax
cmp    $0x4,%eax
jne    124b <show_menu+0x13b>
lea    0xf84(%rip),%rdi
call   1030 <printf@plt>
lea    0xf99(%rip),%rdi
call   1030 <printf@plt>
lea    0xf37(%rip),%rdi
call   1030 <printf@plt>
jmp    1299 <show_menu+0x189>
movswl -0x2(%rbp),%eax
cmp    $0x5,%eax
jne    1294 <show_menu+0x184>
lea    0xf93(%rip),%rdi
call   1030 <printf@plt>
lea    0xf9d(%rip),%rdi
call   1030 <printf@plt>
lea    0xfa6(%rip),%rdi
call   1030 <printf@plt>
lea    0xfb0(%rip),%rdi
call   1030 <printf@plt>
lea    0xee9(%rip),%rdi
call   1030 <printf@plt>
jmp    1299 <show_menu+0x189>
jmp    129e <show_menu+0x18e>
jmp    12a3 <show_menu+0x193>
jmp    12a8 <show_menu+0x198>
lea    0xf99(%rip),%rdi
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<show_menu>:
mov    %edi,%eax
add    $0xffffffff,%eax
cmp    $0x4,%ax
ja     122b <show_menu+0x10b>
push   %r14
push   %rbx
push   %rax
lea    0x109e(%rip),%r14
lea    0xf84(%rip),%rbx
lea    0xf69(%rip),%rdi
movzwl %ax,%eax
lea    0xeae(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0x1082(%rip),%rdi
call   1030 <puts@plt>
lea    0x1090(%rip),%rdi
call   1030 <puts@plt>
lea    0x10cb(%rip),%r14
lea    0x10b0(%rip),%rbx
lea    0x1092(%rip),%rdi
jmp    120f <show_menu+0xef>
lea    0xf43(%rip),%rdi
call   1030 <puts@plt>
lea    0xf55(%rip),%rdi
call   1030 <puts@plt>
lea    0xf71(%rip),%rdi
call   1030 <puts@plt>
lea    0xf91(%rip),%rdi
call   1030 <puts@plt>
lea    0xfb0(%rip),%rdi
call   1030 <puts@plt>
lea    0xfea(%rip),%rbx
lea    0xfc0(%rip),%rdi
jmp    120f <show_menu+0xef>
lea    0xeae(%rip),%rbx
lea    0xe87(%rip),%rdi
jmp    120f <show_menu+0xef>
lea    0xe2c(%rip),%rdi
call   1030 <puts@plt>
lea    0xe35(%rip),%rdi
call   1030 <puts@plt>
lea    0xe52(%rip),%rbx
lea    0xe36(%rip),%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
call   1030 <puts@plt>
mov    %r14,%rdi
call   1030 <puts@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r14
lea    0xde2(%rip),%rdi
jmp    1040 <printf@plt>

LLVM IR (-O0):
@.str = [27 x i8] c"1 - Pesquisas e listagens\0A\00"
@.str.1 = [29 x i8] c"2 - Inserir e alterar dados\0A\00"
@.str.2 = [24 x i8] c"3 - Carregar ficheiros\0A\00"
@.str.3 = [21 x i8] c"4 - Alterar armazem\0A\00"
@.str.4 = [11 x i8] c"9 - Sair\0A\0A\00"
@.str.5 = [31 x i8] c"1 - Mostrar arvore do armazem\0A\00"
@.str.6 = [41 x i8] c"2 - Listar todos os produtos do armazem\0A\00"
@.str.7 = [45 x i8] c"3 - Listar todos os produtos de um corredor\0A\00"
@.str.8 = [44 x i8] c"4 - Listar todos os produtos de um armario\0A\00"
@.str.9 = [36 x i8] c"5 - Procurar por numero de produto\0A\00"
@.str.10 = [36 x i8] c"6 - Procurar pelo stock de produto\0A\00"
@.str.11 = [31 x i8] c"7 - Mostrar produtos vendidos\0A\00"
@.str.12 = [13 x i8] c"9 - Voltar\0A\0A\00"
@.str.13 = [21 x i8] c"1 - Inserir produto\0A\00"
@.str.14 = [19 x i8] c"2 - Alterar stock\0A\00"
@.str.15 = [33 x i8] c"1 - Carregar ficheiro de stocks\0A\00"
@.str.16 = [36 x i8] c"2 - Carregar ficheiro de encomenda\0A\00"
@.str.17 = [22 x i8] c"1 - Inserir corredor\0A\00"
@.str.18 = [21 x i8] c"2 - Inserir armario\0A\00"
@.str.19 = [22 x i8] c"3 - Remover corredor\0A\00"
@.str.20 = [21 x i8] c"4 - Remover armario\0A\00"
@.str.21 = [8 x i8] c"Opcao: \00"
define void @show_menu(i16 signext %0) {
%2 = alloca i16
store i16 %0, i16* %2
%3 = load i16, i16* %2
%4 = sext i16 %3 to i32
%5 = icmp eq i32 %4, 1
br i1 %5, label %6, label %12
6: ; preds = %1
%7 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0))
%8 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0))
%9 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0))
%10 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0))
%11 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0))
br label %55
12: ; preds = %1
%13 = load i16, i16* %2
%14 = sext i16 %13 to i32
%15 = icmp eq i32 %14, 2
br i1 %15, label %16, label %25
16: ; preds = %12
%17 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.5, i64 0, i64 0))
%18 = call i32 @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.6, i64 0, i64 0))
%19 = call i32 @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.7, i64 0, i64 0))
%20 = call i32 @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.8, i64 0, i64 0))
%21 = call i32 @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.9, i64 0, i64 0))
%22 = call i32 @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.10, i64 0, i64 0))
%23 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.11, i64 0, i64 0))
%24 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.12, i64 0, i64 0))
br label %54
25: ; preds = %12
%26 = load i16, i16* %2
%27 = sext i16 %26 to i32
%28 = icmp eq i32 %27, 3
br i1 %28, label %29, label %33
29: ; preds = %25
%30 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.13, i64 0, i64 0))
%31 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.14, i64 0, i64 0))
%32 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.12, i64 0, i64 0))
br label %53
33: ; preds = %25
%34 = load i16, i16* %2
%35 = sext i16 %34 to i32
%36 = icmp eq i32 %35, 4
br i1 %36, label %37, label %41
37: ; preds = %33
%38 = call i32 @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.15, i64 0, i64 0))
%39 = call i32 @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.16, i64 0, i64 0))
%40 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.12, i64 0, i64 0))
br label %52
41: ; preds = %33
%42 = load i16, i16* %2
%43 = sext i16 %42 to i32
%44 = icmp eq i32 %43, 5
br i1 %44, label %45, label %51
45: ; preds = %41
%46 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.17, i64 0, i64 0))
%47 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.18, i64 0, i64 0))
%48 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.19, i64 0, i64 0))
%49 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.20, i64 0, i64 0))
%50 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.12, i64 0, i64 0))
br label %51
51: ; preds = %45, %41
br label %52
52: ; preds = %51, %37
br label %53
53: ; preds = %52, %29
br label %54
54: ; preds = %53, %16
br label %55
55: ; preds = %54, %6
%56 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.21, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str.21 = [8 x i8] c"Opcao: \00"
@str = [21 x i8] c"1 - Inserir corredor\00"
@str.22 = [20 x i8] c"2 - Inserir armario\00"
@str.23 = [21 x i8] c"3 - Remover corredor\00"
@str.24 = [20 x i8] c"4 - Remover armario\00"
@str.26 = [32 x i8] c"1 - Carregar ficheiro de stocks\00"
@str.27 = [35 x i8] c"2 - Carregar ficheiro de encomenda\00"
@str.29 = [20 x i8] c"1 - Inserir produto\00"
@str.30 = [18 x i8] c"2 - Alterar stock\00"
@str.32 = [30 x i8] c"1 - Mostrar arvore do armazem\00"
@str.33 = [40 x i8] c"2 - Listar todos os produtos do armazem\00"
@str.34 = [44 x i8] c"3 - Listar todos os produtos de um corredor\00"
@str.35 = [43 x i8] c"4 - Listar todos os produtos de um armario\00"
@str.36 = [35 x i8] c"5 - Procurar por numero de produto\00"
@str.37 = [35 x i8] c"6 - Procurar pelo stock de produto\00"
@str.38 = [30 x i8] c"7 - Mostrar produtos vendidos\00"
@str.39 = [12 x i8] c"9 - Voltar\0A\00"
@str.40 = [26 x i8] c"1 - Pesquisas e listagens\00"
@str.41 = [28 x i8] c"2 - Inserir e alterar dados\00"
@str.42 = [23 x i8] c"3 - Carregar ficheiros\00"
@str.43 = [20 x i8] c"4 - Alterar armazem\00"
@str.44 = [10 x i8] c"9 - Sair\0A\00"
define void @show_menu(i16 signext %0) {
switch i16 %0, label %22 [
i16 1, label %2
i16 2, label %5
i16 3, label %15
i16 4, label %11
i16 5, label %12
]
2: ; preds = %1
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @str.40, i64 0, i64 0))
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @str.41, i64 0, i64 0))
br label %15
5: ; preds = %1
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @str.32, i64 0, i64 0))
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @str.33, i64 0, i64 0))
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @str.34, i64 0, i64 0))
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @str.35, i64 0, i64 0))
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @str.36, i64 0, i64 0))
br label %15
11: ; preds = %1
br label %15
12: ; preds = %1
%13 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str, i64 0, i64 0))
%14 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str.22, i64 0, i64 0))
br label %15
15: ; preds = %1, %2, %12, %11, %5
%16 = phi i8* [ getelementptr inbounds ([35 x i8], [35 x i8]* @str.37, i64 0, i64 0), %5 ], [ getelementptr inbounds ([32 x i8], [32 x i8]* @str.26, i64 0, i64 0), %11 ], [ getelementptr inbounds ([21 x i8], [21 x i8]* @str.23, i64 0, i64 0), %12 ], [ getelementptr inbounds ([23 x i8], [23 x i8]* @str.42, i64 0, i64 0), %2 ], [ getelementptr inbounds ([20 x i8], [20 x i8]* @str.29, i64 0, i64 0), %1 ]
%17 = phi i8* [ getelementptr inbounds ([30 x i8], [30 x i8]* @str.38, i64 0, i64 0), %5 ], [ getelementptr inbounds ([35 x i8], [35 x i8]* @str.27, i64 0, i64 0), %11 ], [ getelementptr inbounds ([20 x i8], [20 x i8]* @str.24, i64 0, i64 0), %12 ], [ getelementptr inbounds ([20 x i8], [20 x i8]* @str.43, i64 0, i64 0), %2 ], [ getelementptr inbounds ([18 x i8], [18 x i8]* @str.30, i64 0, i64 0), %1 ]
%18 = phi i8* [ getelementptr inbounds ([12 x i8], [12 x i8]* @str.39, i64 0, i64 0), %5 ], [ getelementptr inbounds ([12 x i8], [12 x i8]* @str.39, i64 0, i64 0), %11 ], [ getelementptr inbounds ([12 x i8], [12 x i8]* @str.39, i64 0, i64 0), %12 ], [ getelementptr inbounds ([10 x i8], [10 x i8]* @str.44, i64 0, i64 0), %2 ], [ getelementptr inbounds ([12 x i8], [12 x i8]* @str.39, i64 0, i64 0), %1 ]
%19 = tail call i32 @puts(i8* dereferenceable(1) %16)
%20 = tail call i32 @puts(i8* dereferenceable(1) %17)
%21 = tail call i32 @puts(i8* dereferenceable(1) %18)
br label %22
22: ; preds = %15, %1
%23 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.21, i64 0, i64 0))
ret void
}