#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*/ getchar();
char *io_filepath_from_stdio(char *);
int /*<<< orphan*/ io_print_dir(char *);
int /*<<< orphan*/ io_read_purchases(char *);
int /*<<< orphan*/ puts(char *);
void ui_input_menu() {
  char *file_name;
  puts("Here are the available files\n");
  io_print_dir("./input/");
  puts("Type the name of a file\n");
  do {
    file_name = io_filepath_from_stdio("./input/");
  } while (!file_name);
  io_read_purchases(file_name);
  getchar();
}


x86 assembly (clang, -O0):
<ui_input_menu>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xea1(%rip),%rdi
call   1030 <puts@plt>
lea    0xeb3(%rip),%rdi
call   1040 <io_print_dir@plt>
lea    0xeb0(%rip),%rdi
call   1030 <puts@plt>
lea    0xe9b(%rip),%rdi
call   1070 <io_filepath_from_stdio@plt>
mov    %rax,-0x8(%rbp)
cmpq   $0x0,-0x8(%rbp)
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    117c <ui_input_menu+0x2c>
mov    -0x8(%rbp),%rdi
call   1060 <io_read_purchases@plt>
mov    $0x0,%al
call   1050 <getchar@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ui_input_menu>:
push   %rbx
lea    0xea8(%rip),%rdi
call   1030 <puts@plt>
lea    0xeba(%rip),%rbx
mov    %rbx,%rdi
call   1040 <io_print_dir@plt>
lea    0xeb4(%rip),%rdi
call   1030 <puts@plt>
nopl   0x0(%rax,%rax,1)
mov    %rbx,%rdi
call   1070 <io_filepath_from_stdio@plt>
test   %rax,%rax
je     1180 <ui_input_menu+0x30>
mov    %rax,%rdi
call   1060 <io_read_purchases@plt>
xor    %eax,%eax
pop    %rbx
jmp    1050 <getchar@plt>

LLVM IR (-O0):
@.str = [30 x i8] c"Here are the available files\0A\00"
@.str.1 = [9 x i8] c"./input/\00"
@.str.2 = [25 x i8] c"Type the name of a file\0A\00"
define void @ui_input_menu() {
%1 = alloca i8*
%2 = call i32 @puts(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0))
%3 = call i32 @io_print_dir(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%4 = call i32 @puts(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0))
br label %5
5: ; preds = %7, %0
%6 = call i8* @io_filepath_from_stdio(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
store i8* %6, i8** %1
br label %7
7: ; preds = %5
%8 = load i8*, i8** %1
%9 = icmp ne i8* %8, null
%10 = xor i1 %9, true
br i1 %10, label %5, label %11
11: ; preds = %7
%12 = load i8*, i8** %1
%13 = call i32 @io_read_purchases(i8* %12)
%14 = call i32 (...) @getchar()
ret void
}

LLVM IR (-O2):
@.str = [30 x i8] c"Here are the available files\0A\00"
@.str.1 = [9 x i8] c"./input/\00"
@.str.2 = [25 x i8] c"Type the name of a file\0A\00"
define void @ui_input_menu() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0))
%2 = tail call i32 @io_print_dir(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0))
br label %4
4: ; preds = %4, %0
%5 = tail call i8* @io_filepath_from_stdio(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0))
%6 = icmp eq i8* %5, null
br i1 %6, label %4, label %7
7: ; preds = %4
%8 = tail call i32 @io_read_purchases(i8* %5)
%9 = tail call i32 (...) @getchar()
ret void
}