#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 *);
int menu(void) {
  int x = -1;
  printf("\n1.Create image\n");
  printf("2.Open image\n");
  printf("3.Show image contents\n");
  printf("4.Close image\n");
  printf("5.Insert file\n");
  printf("6.Delete file\n");
  printf("7.Extract file\n");
  printf("\n0.EXIT\n\n");
  while ((x < 0) || (x > 7)) {
    printf(">");
    scanf("%d", &x);
  }
  return x;
}


x86 assembly (clang, -O0):
<menu>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0xffffffff,-0x4(%rbp)
lea    0xeca(%rip),%rdi
call   1030 <printf@plt>
lea    0xecf(%rip),%rdi
call   1030 <printf@plt>
lea    0xed1(%rip),%rdi
call   1030 <printf@plt>
lea    0xedc(%rip),%rdi
call   1030 <printf@plt>
lea    0xedf(%rip),%rdi
call   1030 <printf@plt>
lea    0xee2(%rip),%rdi
call   1030 <printf@plt>
lea    0xee5(%rip),%rdi
call   1030 <printf@plt>
lea    0xee9(%rip),%rdi
call   1030 <printf@plt>
mov    $0x1,%al
cmpl   $0x0,-0x4(%rbp)
mov    %al,-0x5(%rbp)
jl     11a8 <menu+0x88>
cmpl   $0x7,-0x4(%rbp)
setg   %al
mov    %al,-0x5(%rbp)
mov    -0x5(%rbp),%al
test   $0x1,%al
jne    11b8 <menu+0x98>
jmp    11d9 <menu+0xb9>
lea    0xebe(%rip),%rdi
call   1030 <printf@plt>
lea    0xeb4(%rip),%rdi
lea    -0x4(%rbp),%rsi
call   1040 <scanf@plt>
jmp    118f <menu+0x6f>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<menu>:
push   %r14
push   %rbx
push   %rax
movl   $0xffffffff,0x4(%rsp)
ff
lea    0xec0(%rip),%rdi
call   1040 <puts@plt>
lea    0xec4(%rip),%rdi
call   1040 <puts@plt>
lea    0xec5(%rip),%rdi
call   1040 <puts@plt>
lea    0xecf(%rip),%rdi
call   1040 <puts@plt>
lea    0xed1(%rip),%rdi
call   1040 <puts@plt>
lea    0xed3(%rip),%rdi
call   1040 <puts@plt>
lea    0xed5(%rip),%rdi
call   1040 <puts@plt>
lea    0xed8(%rip),%rdi
call   1040 <puts@plt>
lea    0xe5d(%rip),%r14
lea    0x4(%rsp),%rbx
nopl   0x0(%rax,%rax,1)
mov    $0x3e,%edi
call   1030 <putchar@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1050 <scanf@plt>
mov    0x4(%rsp),%eax
cmp    $0x7,%eax
ja     11b0 <menu+0x80>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [17 x i8] c"\0A1.Create image\0A\00"
@.str.1 = [14 x i8] c"2.Open image\0A\00"
@.str.2 = [23 x i8] c"3.Show image contents\0A\00"
@.str.3 = [15 x i8] c"4.Close image\0A\00"
@.str.4 = [15 x i8] c"5.Insert file\0A\00"
@.str.5 = [15 x i8] c"6.Delete file\0A\00"
@.str.6 = [16 x i8] c"7.Extract file\0A\00"
@.str.7 = [10 x i8] c"\0A0.EXIT\0A\0A\00"
@.str.8 = [2 x i8] c">\00"
@.str.9 = [3 x i8] c"%d\00"
define i32 @menu() {
%1 = alloca i32
store i32 -1, i32* %1
%2 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0))
%3 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
%4 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0))
%5 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0))
%6 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0))
%7 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0))
%8 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.6, i64 0, i64 0))
%9 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.7, i64 0, i64 0))
br label %10
10: ; preds = %18, %0
%11 = load i32, i32* %1
%12 = icmp slt i32 %11, 0
br i1 %12, label %16, label %13
13: ; preds = %10
%14 = load i32, i32* %1
%15 = icmp sgt i32 %14, 7
br label %16
16: ; preds = %13, %10
%17 = phi i1 [ true, %10 ], [ %15, %13 ]
br i1 %17, label %18, label %21
18: ; preds = %16
%19 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0))
%20 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i64 0, i64 0), i32* %1)
br label %10
21: ; preds = %16
%22 = load i32, i32* %1
ret i32 %22
}

LLVM IR (-O2):
@.str.9 = [3 x i8] c"%d\00"
@str = [16 x i8] c"\0A1.Create image\00"
@str.10 = [13 x i8] c"2.Open image\00"
@str.11 = [22 x i8] c"3.Show image contents\00"
@str.12 = [14 x i8] c"4.Close image\00"
@str.13 = [14 x i8] c"5.Insert file\00"
@str.14 = [14 x i8] c"6.Delete file\00"
@str.15 = [15 x i8] c"7.Extract file\00"
@str.16 = [9 x i8] c"\0A0.EXIT\0A\00"
define i32 @menu() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
store i32 -1, i32* %1
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str, i64 0, i64 0))
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @str.10, i64 0, i64 0))
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str.11, i64 0, i64 0))
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str.12, i64 0, i64 0))
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str.13, i64 0, i64 0))
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str.14, i64 0, i64 0))
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str.15, i64 0, i64 0))
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @str.16, i64 0, i64 0))
br label %11
11: ; preds = %0, %11
%12 = call i32 @putchar(i32 62)
%13 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.9, i64 0, i64 0), i32* %1)
%14 = load i32, i32* %1
%15 = icmp ugt i32 %14, 7
br i1 %15, label %11, label %16
16: ; preds = %11
ret i32 %14
}