#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 */
char EOF;
unsigned long long atoll(char *);
scalar_t__ errno;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, int);
char getopt(int, char **, char *);
int list_directory(char *, unsigned long long, unsigned long long);
int /*<<< orphan*/ stderr;
int main(int argc, char *argv[]) {
  extern int optind, optopt;
  extern char *optarg;
  char c;
  unsigned long long offset = 0, nfiles = 0;
  int ii, rv;
  errno = 0;
  while ((c = getopt(argc, argv, "n:o:")) != EOF) {
    switch (c) {
    case 'n':
      nfiles = atoll(optarg);
      break;
    case 'o':
      offset = atoll(optarg);
      break;
    default:
      fprintf(stderr, "Unrecognized option: -%c\n", optopt);
      return (-1);
    }
  }
  if (argc == optind) {
    rv = list_directory(".", offset, nfiles);
  } else {
    for (ii = optind; ii < argc; ii++) {
      if ((rv = list_directory(argv[ii], offset, nfiles)) != 0)
        break;
    }
  }
  return (rv);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
mov    0x2e53(%rip),%rax
movq   $0x0,(%rax)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xe7e(%rip),%rdx
call   1060 <getopt@plt>
mov    %al,-0x11(%rbp)
movsbl %al,%eax
mov    0x2e54(%rip),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
je     1224 <main+0xe4>
movsbl -0x11(%rbp),%eax
mov    %eax,-0x34(%rbp)
sub    $0x6e,%eax
je     11c5 <main+0x85>
jmp    11b4 <main+0x74>
mov    -0x34(%rbp),%eax
sub    $0x6f,%eax
je     11dd <main+0x9d>
jmp    11f5 <main+0xb5>
mov    0x2e04(%rip),%rax
mov    (%rax),%rdi
call   1030 <atoll@plt>
mov    %rax,-0x28(%rbp)
jmp    121f <main+0xdf>
mov    0x2dec(%rip),%rax
mov    (%rax),%rdi
call   1030 <atoll@plt>
mov    %rax,-0x20(%rbp)
jmp    121f <main+0xdf>
mov    0x2dcc(%rip),%rax
mov    (%rax),%edi
mov    0x2ddb(%rip),%rax
mov    (%rax),%edx
lea    0xdf7(%rip),%rsi
call   1050 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    12b2 <main+0x172>
jmp    1174 <main+0x34>
mov    -0x8(%rbp),%eax
mov    0x2d8a(%rip),%rcx
cmp    (%rcx),%eax
jne    1252 <main+0x112>
mov    -0x20(%rbp),%rsi
mov    -0x28(%rbp),%rdx
lea    0xdda(%rip),%rdi
call   1040 <list_directory@plt>
mov    %eax,-0x30(%rbp)
jmp    12ac <main+0x16c>
mov    0x2d5f(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    12a7 <main+0x167>
mov    -0x10(%rbp),%rax
movslq -0x2c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x28(%rbp),%rdx
call   1040 <list_directory@plt>
mov    %eax,-0x30(%rbp)
cmp    $0x0,%eax
je     1294 <main+0x154>
jmp    12a7 <main+0x167>
jmp    1299 <main+0x159>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    125e <main+0x11e>
jmp    12ac <main+0x16c>
mov    -0x30(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%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,%ebx
mov    0x2e69(%rip),%rax
movq   $0x0,(%rax)
lea    0xe9b(%rip),%rdx
call   1060 <getopt@plt>
mov    0x2e77(%rip),%rbp
cmp    0x0(%rbp),%al
jne    11aa <main+0x6a>
xor    %r15d,%r15d
xor    %r14d,%r14d
mov    0x2e35(%rip),%rax
movslq (%rax),%rcx
cmp    %ebx,%ecx
jne    1205 <main+0xc5>
lea    0xe8e(%rip),%rdi
mov    %r15,%rsi
mov    %r14,%rdx
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <list_directory@plt>
xor    %r14d,%r14d
lea    0xe4c(%rip),%r13
xor    %r15d,%r15d
jmp    11e4 <main+0xa4>
nopl   0x0(%rax)
mov    0x2e09(%rip),%rax
mov    (%rax),%rdi
call   1030 <atoll@plt>
mov    %rax,%r15
mov    %ebx,%edi
mov    %r12,%rsi
mov    %r13,%rdx
call   1060 <getopt@plt>
cmp    0x0(%rbp),%al
je     117c <main+0x3c>
movsbl %al,%eax
cmp    $0x6f,%eax
je     11c0 <main+0x80>
cmp    $0x6e,%eax
jne    123f <main+0xff>
mov    0x2dd8(%rip),%rax
mov    (%rax),%rdi
call   1030 <atoll@plt>
mov    %rax,%r14
jmp    11d2 <main+0x92>
xor    %eax,%eax
cmp    %ebx,%ecx
jge    1262 <main+0x122>
lea    (%r12,%rcx,8),%r12
sub    %ecx,%ebx
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    (%r12,%rbp,8),%rdi
mov    %r15,%rsi
mov    %r14,%rdx
call   1040 <list_directory@plt>
test   %eax,%eax
jne    1262 <main+0x122>
add    $0x1,%rbp
cmp    %ebp,%ebx
jne    1220 <main+0xe0>
xor    %eax,%eax
jmp    1262 <main+0x122>
mov    0x2d82(%rip),%rax
mov    (%rax),%edi
mov    0x2d91(%rip),%rax
mov    (%rax),%edx
lea    0xdad(%rip),%rsi
call   1050 <fprintf@plt>
mov    $0xffffffff,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@errno = global i64 0
@.str = [5 x i8] c"n:o:\00"
@EOF = global i8 0
@optarg = external global i8*
@stderr = global i32 0
@.str.1 = [26 x i8] c"Unrecognized option: -%c\0A\00"
@optopt = external global i32
@optind = external global i32
@.str.2 = [2 x i8] c".\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8
%7 = alloca i64
%8 = alloca i64
%9 = alloca i32
%10 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i64 0, i64* %7
store i64 0, i64* %8
store i64 0, i64* @errno
br label %11
11: ; preds = %32, %2
%12 = load i32, i32* %4
%13 = load i8**, i8*** %5
%14 = call signext i8 @getopt(i32 %12, i8** %13, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
store i8 %14, i8* %6
%15 = sext i8 %14 to i32
%16 = load i8, i8* @EOF
%17 = sext i8 %16 to i32
%18 = icmp ne i32 %15, %17
br i1 %18, label %19, label %33
19: ; preds = %11
%20 = load i8, i8* %6
%21 = sext i8 %20 to i32
switch i32 %21, label %28 [
i32 110, label %22
i32 111, label %25
]
22: ; preds = %19
%23 = load i8*, i8** @optarg
%24 = call i64 @atoll(i8* %23)
store i64 %24, i64* %8
br label %32
25: ; preds = %19
%26 = load i8*, i8** @optarg
%27 = call i64 @atoll(i8* %26)
store i64 %27, i64* %7
br label %32
28: ; preds = %19
%29 = load i32, i32* @stderr
%30 = load i32, i32* @optopt
%31 = call i32 @fprintf(i32 %29, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0), i32 %30)
store i32 -1, i32* %3
br label %65
32: ; preds = %25, %22
br label %11
33: ; preds = %11
%34 = load i32, i32* %4
%35 = load i32, i32* @optind
%36 = icmp eq i32 %34, %35
br i1 %36, label %37, label %41
37: ; preds = %33
%38 = load i64, i64* %7
%39 = load i64, i64* %8
%40 = call i32 @list_directory(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), i64 %38, i64 %39)
store i32 %40, i32* %10
br label %63
41: ; preds = %33
%42 = load i32, i32* @optind
store i32 %42, i32* %9
br label %43
43: ; preds = %59, %41
%44 = load i32, i32* %9
%45 = load i32, i32* %4
%46 = icmp slt i32 %44, %45
br i1 %46, label %47, label %62
47: ; preds = %43
%48 = load i8**, i8*** %5
%49 = load i32, i32* %9
%50 = sext i32 %49 to i64
%51 = getelementptr inbounds i8*, i8** %48, i64 %50
%52 = load i8*, i8** %51
%53 = load i64, i64* %7
%54 = load i64, i64* %8
%55 = call i32 @list_directory(i8* %52, i64 %53, i64 %54)
store i32 %55, i32* %10
%56 = icmp ne i32 %55, 0
br i1 %56, label %57, label %58
57: ; preds = %47
br label %62
58: ; preds = %47
br label %59
59: ; preds = %58
%60 = load i32, i32* %9
%61 = add nsw i32 %60, 1
store i32 %61, i32* %9
br label %43
62: ; preds = %57, %43
br label %63
63: ; preds = %62, %37
%64 = load i32, i32* %10
store i32 %64, i32* %3
br label %65
65: ; preds = %63, %28
%66 = load i32, i32* %3
ret i32 %66
}

LLVM IR (-O2):
@errno = global i64 0
@.str = [5 x i8] c"n:o:\00"
@EOF = global i8 0
@optarg = external global i8*
@stderr = global i32 0
@.str.1 = [26 x i8] c"Unrecognized option: -%c\0A\00"
@optopt = external global i32
@optind = external global i32
@.str.2 = [2 x i8] c".\00"
define i32 @main(i32 %0, i8** %1) {
store i64 0, i64* @errno
%3 = tail call signext i8 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%4 = load i8, i8* @EOF
%5 = icmp eq i8 %3, %4
br i1 %5, label %27, label %6
6: ; preds = %2, %21
%7 = phi i8 [ %24, %21 ], [ %3, %2 ]
%8 = phi i64 [ %23, %21 ], [ 0, %2 ]
%9 = phi i64 [ %22, %21 ], [ 0, %2 ]
%10 = sext i8 %7 to i32
switch i32 %10, label %17 [
i32 110, label %11
i32 111, label %14
]
11: ; preds = %6
%12 = load i8*, i8** @optarg
%13 = tail call i64 @atoll(i8* %12)
br label %21
14: ; preds = %6
%15 = load i8*, i8** @optarg
%16 = tail call i64 @atoll(i8* %15)
br label %21
17: ; preds = %6
%18 = load i32, i32* @stderr
%19 = load i32, i32* @optopt
%20 = tail call i32 @fprintf(i32 %18, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0), i32 %19)
br label %48
21: ; preds = %14, %11
%22 = phi i64 [ %16, %14 ], [ %9, %11 ]
%23 = phi i64 [ %8, %14 ], [ %13, %11 ]
%24 = tail call signext i8 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%25 = load i8, i8* @EOF
%26 = icmp eq i8 %24, %25
br i1 %26, label %27, label %6
27: ; preds = %21, %2
%28 = phi i64 [ 0, %2 ], [ %22, %21 ]
%29 = phi i64 [ 0, %2 ], [ %23, %21 ]
%30 = load i32, i32* @optind
%31 = icmp eq i32 %30, %0
br i1 %31, label %36, label %32
32: ; preds = %27
%33 = icmp slt i32 %30, %0
br i1 %33, label %34, label %48
34: ; preds = %32
%35 = sext i32 %30 to i64
br label %41
36: ; preds = %27
%37 = tail call i32 @list_directory(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0), i64 %28, i64 %29)
br label %48
38: ; preds = %41
%39 = trunc i64 %47 to i32
%40 = icmp eq i32 %39, %0
br i1 %40, label %48, label %41
41: ; preds = %34, %38
%42 = phi i64 [ %35, %34 ], [ %47, %38 ]
%43 = getelementptr inbounds i8*, i8** %1, i64 %42
%44 = load i8*, i8** %43
%45 = tail call i32 @list_directory(i8* %44, i64 %28, i64 %29)
%46 = icmp eq i32 %45, 0
%47 = add nsw i64 %42, 1
br i1 %46, label %38, label %48
48: ; preds = %38, %41, %32, %36, %17
%49 = phi i32 [ -1, %17 ], [ %37, %36 ], [ 0, %32 ], [ 0, %38 ], [ %45, %41 ]
ret i32 %49
}