#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 scanf(char *, ...);
int showMenu() {
  printf("play/pause ------------->1\n");
  printf("stop       ------------->2\n");
  printf("prev       ------------->3\n");
  printf("next       ------------->4\n");
  printf("chmd       ------------->5\n");
  printf("exit       ------------->0\n");
  printf("\tenter your choice:");
  int c;
  while (scanf("%d", &c) != 1) {
    scanf("%*[^\n]");
    printf("\tenter your choice:");
  }
  return c;
}


x86 assembly (clang, -O0):
<showMenu>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xed1(%rip),%rdi
call   1030 <printf@plt>
lea    0xee1(%rip),%rdi
call   1030 <printf@plt>
lea    0xef1(%rip),%rdi
call   1030 <printf@plt>
lea    0xf01(%rip),%rdi
call   1030 <printf@plt>
lea    0xf11(%rip),%rdi
call   1030 <printf@plt>
lea    0xf21(%rip),%rdi
call   1030 <printf@plt>
lea    0xf31(%rip),%rdi
call   1030 <printf@plt>
lea    0xf39(%rip),%rdi
lea    -0x4(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
cmp    $0x1,%eax
je     11b6 <showMenu+0x96>
lea    0xf21(%rip),%rdi
mov    $0x0,%al
call   1040 <scanf@plt>
lea    0xefc(%rip),%rdi
call   1030 <printf@plt>
jmp    117c <showMenu+0x5c>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<showMenu>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
lea    0xedf(%rip),%rdi
call   1030 <puts@plt>
lea    0xeee(%rip),%rdi
call   1030 <puts@plt>
lea    0xefd(%rip),%rdi
call   1030 <puts@plt>
lea    0xf0c(%rip),%rdi
call   1030 <puts@plt>
lea    0xf1b(%rip),%rdi
call   1030 <puts@plt>
lea    0xf2a(%rip),%rdi
call   1030 <puts@plt>
lea    0xe79(%rip),%rdi
call   1040 <printf@plt>
lea    0xe81(%rip),%rdi
lea    0x4(%rsp),%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
cmp    $0x1,%eax
je     11e4 <showMenu+0xb4>
lea    0xe6c(%rip),%r14
lea    0xe4e(%rip),%r15
lea    0xe5b(%rip),%r12
lea    0x4(%rsp),%rbx
xchg   %ax,%ax
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <scanf@plt>
mov    %r15,%rdi
call   1040 <printf@plt>
mov    %r12,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
cmp    $0x1,%eax
jne    11c0 <showMenu+0x90>
mov    0x4(%rsp),%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [28 x i8] c"play/pause ------------->1\0A\00"
@.str.1 = [28 x i8] c"stop ------------->2\0A\00"
@.str.2 = [28 x i8] c"prev ------------->3\0A\00"
@.str.3 = [28 x i8] c"next ------------->4\0A\00"
@.str.4 = [28 x i8] c"chmd ------------->5\0A\00"
@.str.5 = [28 x i8] c"exit ------------->0\0A\00"
@.str.6 = [20 x i8] c"\09enter your choice:\00"
@.str.7 = [3 x i8] c"%d\00"
@.str.8 = [7 x i8] c"%*[^\0A]\00"
define i32 @showMenu() {
%1 = alloca i32
%2 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0))
%3 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0))
%4 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0))
%5 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.3, i64 0, i64 0))
%6 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.4, i64 0, i64 0))
%7 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.5, i64 0, i64 0))
%8 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.6, i64 0, i64 0))
br label %9
9: ; preds = %12, %0
%10 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i32* %1)
%11 = icmp ne i32 %10, 1
br i1 %11, label %12, label %15
12: ; preds = %9
%13 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.8, i64 0, i64 0))
%14 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.6, i64 0, i64 0))
br label %9
15: ; preds = %9
%16 = load i32, i32* %1
ret i32 %16
}

LLVM IR (-O2):
@.str.6 = [20 x i8] c"\09enter your choice:\00"
@.str.7 = [3 x i8] c"%d\00"
@.str.8 = [7 x i8] c"%*[^\0A]\00"
@str = [27 x i8] c"play/pause ------------->1\00"
@str.9 = [27 x i8] c"stop ------------->2\00"
@str.10 = [27 x i8] c"prev ------------->3\00"
@str.11 = [27 x i8] c"next ------------->4\00"
@str.12 = [27 x i8] c"chmd ------------->5\00"
@str.13 = [27 x i8] c"exit ------------->0\00"
define i32 @showMenu() {
%1 = alloca i32
%2 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str, i64 0, i64 0))
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str.9, i64 0, i64 0))
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str.10, i64 0, i64 0))
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str.11, i64 0, i64 0))
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str.12, i64 0, i64 0))
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str.13, i64 0, i64 0))
%8 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.6, i64 0, i64 0))
%9 = bitcast i32* %1 to i8*
%10 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i32* %1)
%11 = icmp eq i32 %10, 1
br i1 %11, label %17, label %12
12: ; preds = %0, %12
%13 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.8, i64 0, i64 0))
%14 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.6, i64 0, i64 0))
%15 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i32* %1)
%16 = icmp eq i32 %15, 1
br i1 %16, label %17, label %12
17: ; preds = %12, %0
%18 = load i32, i32* %1
ret i32 %18
}