cdmenu(search_str) char *search_str;
{
  char *get_pwd();
  char *array[1024];
  char select_dir[80];
  int selection;
  load_menus(array, search_str);
  if ((selection = make_select(array)) == 99)
    strcpy(select_dir, get_pwd());
  else
    strcpy(select_dir, array[selection]);
  free_array(array);
  chdir(array[selection]);
}


x86 assembly (clang, -O0):
<cdmenu>:
push   %rbp
mov    %rsp,%rbp
sub    $0x2070,%rsp
mov    %rdi,-0x10(%rbp)
lea    -0x2010(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    $0x0,%al
call   1050 <load_menus@plt>
lea    -0x2010(%rbp),%rdi
mov    $0x0,%al
call   1080 <make_select@plt>
mov    %eax,-0x2064(%rbp)
cmp    $0x63,%eax
jne    11c7 <cdmenu+0x67>
lea    -0x2060(%rbp),%rax
mov    %rax,-0x2070(%rbp)
mov    $0x0,%al
call   1030 <get_pwd@plt>
mov    -0x2070(%rbp),%rdi
mov    %rax,%rsi
call   1040 <strcpy@plt>
jmp    11e2 <cdmenu+0x82>
lea    -0x2060(%rbp),%rdi
movslq -0x2064(%rbp),%rax
mov    -0x2010(%rbp,%rax,8),%rsi
ff
call   1040 <strcpy@plt>
lea    -0x2010(%rbp),%rdi
mov    $0x0,%al
call   1070 <free_array@plt>
movslq -0x2064(%rbp),%rax
mov    -0x2010(%rbp,%rax,8),%rdi
ff
mov    $0x0,%al
call   1060 <chdir@plt>
mov    -0x4(%rbp),%eax
add    $0x2070,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cdmenu>:
push   %rbx
sub    $0x2000,%rsp
mov    %rdi,%rsi
mov    %rsp,%rbx
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <load_menus@plt>
mov    %rbx,%rdi
xor    %eax,%eax
call   1070 <make_select@plt>
mov    %eax,%ebx
cmp    $0x63,%eax
jne    1180 <cdmenu+0x30>
xor    %eax,%eax
call   1030 <get_pwd@plt>
mov    %rsp,%rdi
xor    %eax,%eax
call   1060 <free_array@plt>
movslq %ebx,%rax
mov    (%rsp,%rax,8),%rdi
xor    %eax,%eax
call   1050 <chdir@plt>
add    $0x2000,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define i32 @cdmenu(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca [1024 x i8*]
%5 = alloca [80 x i8]
%6 = alloca i32
store i8* %0, i8** %3
%7 = getelementptr inbounds [1024 x i8*], [1024 x i8*]* %4, i64 0, i64 0
%8 = load i8*, i8** %3
%9 = call i32 (i8**, i8*, ...) bitcast (i32 (...)* @load_menus to i32 (i8**, i8*, ...)*)(i8** %7, i8* %8)
%10 = getelementptr inbounds [1024 x i8*], [1024 x i8*]* %4, i64 0, i64 0
%11 = call i32 (i8**, ...) bitcast (i32 (...)* @make_select to i32 (i8**, ...)*)(i8** %10)
store i32 %11, i32* %6
%12 = icmp eq i32 %11, 99
br i1 %12, label %13, label %17
13: ; preds = %1
%14 = getelementptr inbounds [80 x i8], [80 x i8]* %5, i64 0, i64 0
%15 = call i8* (...) @get_pwd()
%16 = call i8* @strcpy(i8* %14, i8* %15)
br label %24
17: ; preds = %1
%18 = getelementptr inbounds [80 x i8], [80 x i8]* %5, i64 0, i64 0
%19 = load i32, i32* %6
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds [1024 x i8*], [1024 x i8*]* %4, i64 0, i64 %20
%22 = load i8*, i8** %21
%23 = call i8* @strcpy(i8* %18, i8* %22)
br label %24
24: ; preds = %17, %13
%25 = getelementptr inbounds [1024 x i8*], [1024 x i8*]* %4, i64 0, i64 0
%26 = call i32 (i8**, ...) bitcast (i32 (...)* @free_array to i32 (i8**, ...)*)(i8** %25)
%27 = load i32, i32* %6
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds [1024 x i8*], [1024 x i8*]* %4, i64 0, i64 %28
%30 = load i8*, i8** %29
%31 = call i32 (i8*, ...) bitcast (i32 (...)* @chdir to i32 (i8*, ...)*)(i8* %30)
%32 = load i32, i32* %2
ret i32 %32
}

LLVM IR (-O2):
define i32 @cdmenu(i8* %0) {
%2 = alloca [1024 x i8*]
%3 = bitcast [1024 x i8*]* %2 to i8*
%4 = getelementptr inbounds [1024 x i8*], [1024 x i8*]* %2, i64 0, i64 0
%5 = call i32 (i8**, i8*, ...) bitcast (i32 (...)* @load_menus to i32 (i8**, i8*, ...)*)(i8** %4, i8* %0)
%6 = call i32 (i8**, ...) bitcast (i32 (...)* @make_select to i32 (i8**, ...)*)(i8** %4)
%7 = icmp eq i32 %6, 99
br i1 %7, label %8, label %10
8: ; preds = %1
%9 = call i8* (...) @get_pwd()
br label %10
10: ; preds = %1, %8
%11 = call i32 (i8**, ...) bitcast (i32 (...)* @free_array to i32 (i8**, ...)*)(i8** %4)
%12 = sext i32 %6 to i64
%13 = getelementptr inbounds [1024 x i8*], [1024 x i8*]* %2, i64 0, i64 %12
%14 = load i8*, i8** %13
%15 = call i32 (i8*, ...) bitcast (i32 (...)* @chdir to i32 (i8*, ...)*)(i8* %14)
ret i32 undef
}