main(argc, argv) int argc;
char **argv;
{
  if (argc == 2) {
    if (strcmp(argv[1], "-a") == 0) {
      put_current_directory_at_top();
    } else {
      cdmenu(argv[1]);
    }
  } else {
    cdmenu("");
  }
  execl("/bin/ksh", *argv, (char *)0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
jne    119d <main+0x5d>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe91(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    1189 <main+0x49>
mov    $0x0,%al
call   1050 <put_current_directory_at_top@plt>
jmp    1198 <main+0x58>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    $0x0,%al
call   1030 <cdmenu@plt>
jmp    11ab <main+0x6b>
lea    0xe5e(%rip),%rdi
mov    $0x0,%al
call   1030 <cdmenu@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe4a(%rip),%rdi
xor    %eax,%eax
mov    %eax,%edx
mov    $0x0,%al
call   1060 <execl@plt>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
cmp    $0x2,%edi
jne    1168 <main+0x28>
mov    0x8(%rbx),%r14
lea    0xea9(%rip),%rsi
mov    %r14,%rdi
call   1040 <strcmp@plt>
test   %eax,%eax
je     1178 <main+0x38>
mov    %r14,%rdi
jmp    116f <main+0x2f>
lea    0xe93(%rip),%rdi
xor    %eax,%eax
call   1030 <cdmenu@plt>
jmp    117f <main+0x3f>
xor    %eax,%eax
call   1050 <put_current_directory_at_top@plt>
mov    (%rbx),%rsi
lea    0xe7a(%rip),%rdi
xor    %edx,%edx
xor    %eax,%eax
call   1060 <execl@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [3 x i8] c"-a\00"
@.str.1 = [1 x i8] zeroinitializer
@.str.2 = [9 x i8] c"/bin/ksh\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%6 = load i32, i32* %4
%7 = icmp eq i32 %6, 2
br i1 %7, label %8, label %22
8: ; preds = %2
%9 = load i8**, i8*** %5
%10 = getelementptr inbounds i8*, i8** %9, i64 1
%11 = load i8*, i8** %10
%12 = call i32 @strcmp(i8* %11, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%13 = icmp eq i32 %12, 0
br i1 %13, label %14, label %16
14: ; preds = %8
%15 = call i32 (...) @put_current_directory_at_top()
br label %21
16: ; preds = %8
%17 = load i8**, i8*** %5
%18 = getelementptr inbounds i8*, i8** %17, i64 1
%19 = load i8*, i8** %18
%20 = call i32 (i8*, ...) bitcast (i32 (...)* @cdmenu to i32 (i8*, ...)*)(i8* %19)
br label %21
21: ; preds = %16, %14
br label %24
22: ; preds = %2
%23 = call i32 (i8*, ...) bitcast (i32 (...)* @cdmenu to i32 (i8*, ...)*)(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0))
br label %24
24: ; preds = %22, %21
%25 = load i8**, i8*** %5
%26 = load i8*, i8** %25
%27 = call i32 (i8*, i8*, i8*, ...) bitcast (i32 (...)* @execl to i32 (i8*, i8*, i8*, ...)*)(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8* %26, i8* null)
%28 = load i32, i32* %3
ret i32 %28
}

LLVM IR (-O2):
@.str = [3 x i8] c"-a\00"
@.str.1 = [1 x i8] zeroinitializer
@.str.2 = [9 x i8] c"/bin/ksh\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 2
br i1 %3, label %4, label %13
4: ; preds = %2
%5 = getelementptr inbounds i8*, i8** %1, i64 1
%6 = load i8*, i8** %5
%7 = tail call i32 @strcmp(i8* dereferenceable(1) %6, i8* dereferenceable(3) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%8 = icmp eq i32 %7, 0
br i1 %8, label %9, label %11
9: ; preds = %4
%10 = tail call i32 (...) @put_current_directory_at_top()
br label %15
11: ; preds = %4
%12 = tail call i32 (i8*, ...) bitcast (i32 (...)* @cdmenu to i32 (i8*, ...)*)(i8* %6)
br label %15
13: ; preds = %2
%14 = tail call i32 (i8*, ...) bitcast (i32 (...)* @cdmenu to i32 (i8*, ...)*)(i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0))
br label %15
15: ; preds = %9, %11, %13
%16 = load i8*, i8** %1
%17 = tail call i32 (i8*, i8*, i8*, ...) bitcast (i32 (...)* @execl to i32 (i8*, i8*, i8*, ...)*)(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0), i8* %16, i8* null)
ret i32 0
}