#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*/ is_valid_item(int, int, int);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ scanf(char *, int *);
int /*<<< orphan*/ system(char *);
int display_menu(char menu_title[], char menu_items[], int num_items,
                 int min_items) {
  int option = 0;
  do {
    printf("%s\n\n", menu_title);
    printf("%s\n", menu_items);
    scanf(" %d", &option);
    system("cls");
  } while (!is_valid_item(option, num_items, min_items));
  return option;
}


x86 assembly (clang, -O0):
<display_menu>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x8(%rbp),%rsi
lea    0xe98(%rip),%rdi
call   1040 <printf@plt>
mov    -0x10(%rbp),%rsi
lea    0xe8d(%rip),%rdi
call   1040 <printf@plt>
lea    0xe85(%rip),%rdi
lea    -0x1c(%rbp),%rsi
call   1060 <scanf@plt>
lea    0xe79(%rip),%rdi
call   1030 <system@plt>
mov    -0x1c(%rbp),%edi
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
call   1050 <is_valid_item@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    115d <display_menu+0x1d>
mov    -0x1c(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<display_menu>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %ecx,%r14d
mov    %edx,%r15d
mov    %rsi,%rbx
mov    %rdi,%rbp
movl   $0x0,0x4(%rsp)
lea    0x4(%rsp),%r13
lea    0xea2(%rip),%r12
nopl   0x0(%rax,%rax,1)
lea    0xe89(%rip),%rdi
mov    %rbp,%rsi
call   1040 <printf@plt>
lea    0xe7f(%rip),%rdi
mov    %rbx,%rsi
call   1040 <printf@plt>
lea    0xe74(%rip),%rdi
mov    %r13,%rsi
call   1060 <scanf@plt>
mov    %r12,%rdi
call   1030 <system@plt>
mov    0x4(%rsp),%edi
mov    %r15d,%esi
mov    %r14d,%edx
call   1050 <is_valid_item@plt>
test   %eax,%eax
je     1170 <display_menu+0x30>
mov    0x4(%rsp),%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [5 x i8] c"%s\0A\0A\00"
@.str.1 = [4 x i8] c"%s\0A\00"
@.str.2 = [4 x i8] c" %d\00"
@.str.3 = [4 x i8] c"cls\00"
define i32 @display_menu(i8* %0, i8* %1, i32 %2, i32 %3) {
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i8* %0, i8** %5
store i8* %1, i8** %6
store i32 %2, i32* %7
store i32 %3, i32* %8
store i32 0, i32* %9
br label %10
10: ; preds = %17, %4
%11 = load i8*, i8** %5
%12 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %11)
%13 = load i8*, i8** %6
%14 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %13)
%15 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32* %9)
%16 = call i32 @system(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
br label %17
17: ; preds = %10
%18 = load i32, i32* %9
%19 = load i32, i32* %7
%20 = load i32, i32* %8
%21 = call i32 @is_valid_item(i32 %18, i32 %19, i32 %20)
%22 = icmp ne i32 %21, 0
%23 = xor i1 %22, true
br i1 %23, label %10, label %24
24: ; preds = %17
%25 = load i32, i32* %9
ret i32 %25
}

LLVM IR (-O2):
@.str = [5 x i8] c"%s\0A\0A\00"
@.str.1 = [4 x i8] c"%s\0A\00"
@.str.2 = [4 x i8] c" %d\00"
@.str.3 = [4 x i8] c"cls\00"
define i32 @display_menu(i8* %0, i8* %1, i32 %2, i32 %3) {
%5 = alloca i32
%6 = bitcast i32* %5 to i8*
store i32 0, i32* %5
br label %7
7: ; preds = %7, %4
%8 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %0)
%9 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %1)
%10 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32* %5)
%11 = call i32 @system(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
%12 = load i32, i32* %5
%13 = call i32 @is_valid_item(i32 %12, i32 %2, i32 %3)
%14 = icmp eq i32 %13, 0
br i1 %14, label %7, label %15
15: ; preds = %7
%16 = load i32, i32* %5
ret i32 %16
}