#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*/ listdir(int, char *);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ printf_help();
int setoption(int, char **);
int main(int argv, char *argc[]) {
  char *pathname = "./";
  int options = 0;
  int i;
  if ((options = setoption(argv, argc)) < 0) {
    printf_help();
    return 0;
  }
  for (i = 1; i < argv; i++) {
    if (argc[i][0] != '-') {
      pathname = argc[i];
      printf("the dir %s :\n", pathname);
      listdir(options, pathname);
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xea3(%rip),%rax
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1030 <setoption@plt>
mov    %eax,-0x1c(%rbp)
cmp    $0x0,%eax
jge    1193 <main+0x53>
mov    $0x0,%al
call   1060 <printf_help@plt>
movl   $0x0,-0x4(%rbp)
jmp    1204 <main+0xc4>
movl   $0x1,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11fd <main+0xbd>
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movsbl (%rax),%eax
cmp    $0x2d,%eax
je     11ea <main+0xaa>
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rsi
lea    0xe2a(%rip),%rdi
call   1050 <printf@plt>
mov    -0x1c(%rbp),%edi
mov    -0x18(%rbp),%rsi
call   1040 <listdir@plt>
jmp    11ef <main+0xaf>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    119a <main+0x5a>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r12
mov    %edi,%r14d
call   1030 <setoption@plt>
test   %eax,%eax
js     11ab <main+0x6b>
cmp    $0x2,%r14d
jl     11b2 <main+0x72>
mov    %eax,%r15d
mov    %r14d,%r13d
mov    $0x1,%ebx
lea    0xe8e(%rip),%r14
jmp    1189 <main+0x49>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
add    $0x1,%rbx
cmp    %rbx,%r13
je     11b2 <main+0x72>
mov    (%r12,%rbx,8),%rbp
cmpb   $0x2d,0x0(%rbp)
je     1180 <main+0x40>
mov    %r14,%rdi
mov    %rbp,%rsi
call   1050 <printf@plt>
mov    %r15d,%edi
mov    %rbp,%rsi
call   1040 <listdir@plt>
jmp    1180 <main+0x40>
xor    %eax,%eax
call   1060 <printf_help@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"./\00"
@.str.1 = [14 x i8] c"the dir %s :\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8** %6
store i32 0, i32* %7
%9 = load i32, i32* %4
%10 = load i8**, i8*** %5
%11 = call i32 @setoption(i32 %9, i8** %10)
store i32 %11, i32* %7
%12 = icmp slt i32 %11, 0
br i1 %12, label %13, label %15
13: ; preds = %2
%14 = call i32 (...) @printf_help()
store i32 0, i32* %3
br label %46
15: ; preds = %2
store i32 1, i32* %8
br label %16
16: ; preds = %42, %15
%17 = load i32, i32* %8
%18 = load i32, i32* %4
%19 = icmp slt i32 %17, %18
br i1 %19, label %20, label %45
20: ; preds = %16
%21 = load i8**, i8*** %5
%22 = load i32, i32* %8
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds i8*, i8** %21, i64 %23
%25 = load i8*, i8** %24
%26 = getelementptr inbounds i8, i8* %25, i64 0
%27 = load i8, i8* %26
%28 = sext i8 %27 to i32
%29 = icmp ne i32 %28, 45
br i1 %29, label %30, label %41
30: ; preds = %20
%31 = load i8**, i8*** %5
%32 = load i32, i32* %8
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds i8*, i8** %31, i64 %33
%35 = load i8*, i8** %34
store i8* %35, i8** %6
%36 = load i8*, i8** %6
%37 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i8* %36)
%38 = load i32, i32* %7
%39 = load i8*, i8** %6
%40 = call i32 @listdir(i32 %38, i8* %39)
br label %41
41: ; preds = %30, %20
br label %42
42: ; preds = %41
%43 = load i32, i32* %8
%44 = add nsw i32 %43, 1
store i32 %44, i32* %8
br label %16
45: ; preds = %16
store i32 0, i32* %3
br label %46
46: ; preds = %45, %13
%47 = load i32, i32* %3
ret i32 %47
}

LLVM IR (-O2):
@.str.1 = [14 x i8] c"the dir %s :\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = tail call i32 @setoption(i32 %0, i8** %1)
%4 = icmp slt i32 %3, 0
br i1 %4, label %9, label %5
5: ; preds = %2
%6 = icmp sgt i32 %0, 1
br i1 %6, label %7, label %23
7: ; preds = %5
%8 = zext i32 %0 to i64
br label %11
9: ; preds = %2
%10 = tail call i32 (...) @printf_help()
br label %23
11: ; preds = %7, %20
%12 = phi i64 [ 1, %7 ], [ %21, %20 ]
%13 = getelementptr inbounds i8*, i8** %1, i64 %12
%14 = load i8*, i8** %13
%15 = load i8, i8* %14
%16 = icmp eq i8 %15, 45
br i1 %16, label %20, label %17
17: ; preds = %11
%18 = tail call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i8* %14)
%19 = tail call i32 @listdir(i32 %3, i8* %14)
br label %20
20: ; preds = %11, %17
%21 = add nuw nsw i64 %12, 1
%22 = icmp eq i64 %21, %8
br i1 %22, label %23, label %11
23: ; preds = %20, %5, %9
ret i32 0
}