#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 EXIT_FAILURE;
int EXIT_SUCCESS;
int /*<<< orphan*/ exit(int);
int getopt(int, char **, char *);
int ls_lowmem(char const *);
int optind;
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdout;
int /*<<< orphan*/ usage(int /*<<< orphan*/, char *);
int main(int argc, char *argv[]) {
  int i, opt, fail = 0;
  const char *dirname;
  while ((opt = getopt(argc, argv, "hV")) != -1) {
    switch (opt) {
    case 'h':
      usage(stdout, argv[0]);
      exit(0);
    case 'V':
      printf("ls-lowmem (lowmem-tools) "
             "0.1.0"
             "\n");
      exit(0);
    default:
      usage(stderr, argv[0]);
      exit(1);
    }
  }
  if (optind == argc) {
    ls_lowmem(".");
  } else {
    for (i = optind; i < argc; ++i) {
      dirname = argv[i];
      if (argc > 2) {
        printf("%s:\n", dirname);
        ls_lowmem(dirname);
        printf("\n");
      } else {
        fail |= ls_lowmem(dirname);
      }
    }
  }
  exit(fail ? EXIT_FAILURE : EXIT_SUCCESS);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xe85(%rip),%rdx
call   1060 <getopt@plt>
mov    %eax,-0x18(%rbp)
cmp    $0xffffffff,%eax
je     1201 <main+0xb1>
mov    -0x18(%rbp),%eax
mov    %eax,-0x2c(%rbp)
sub    $0x56,%eax
je     11cd <main+0x7d>
jmp    11a0 <main+0x50>
mov    -0x2c(%rbp),%eax
sub    $0x68,%eax
jne    11e2 <main+0x92>
jmp    11b1 <main+0x61>
mov    0x2e10(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
call   1050 <usage@plt>
xor    %edi,%edi
call   1070 <exit@plt>
lea    0xe2f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %edi,%edi
call   1070 <exit@plt>
mov    0x2def(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
call   1050 <usage@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
mov    0x2de0(%rip),%rax
mov    (%rax),%eax
cmp    -0x8(%rbp),%eax
jne    1224 <main+0xd4>
lea    0xe09(%rip),%rdi
call   1030 <ls_lowmem@plt>
jmp    12ab <main+0x15b>
mov    0x2dbd(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    12a6 <main+0x156>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x28(%rbp)
cmpl   $0x2,-0x8(%rbp)
jle    1284 <main+0x134>
mov    -0x28(%rbp),%rsi
lea    0xdc4(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x28(%rbp),%rdi
call   1030 <ls_lowmem@plt>
lea    0xda9(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1293 <main+0x143>
mov    -0x28(%rbp),%rdi
call   1030 <ls_lowmem@plt>
or     -0x1c(%rbp),%eax
mov    %eax,-0x1c(%rbp)
jmp    1298 <main+0x148>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1230 <main+0xe0>
jmp    12ab <main+0x15b>
cmpl   $0x0,-0x1c(%rbp)
je     12c6 <main+0x176>
mov    0x2d14(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x30(%rbp)
jmp    12d2 <main+0x182>
mov    0x2cf3(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x30(%rbp)
mov    -0x30(%rbp),%edi
call   1070 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %edi,%r15d
lea    0xe78(%rip),%rdx
call   1080 <getopt@plt>
cmp    $0xffffffff,%eax
je     11c7 <main+0x57>
cmp    $0x56,%eax
je     11b4 <main+0x44>
cmp    $0x68,%eax
jne    11e7 <main+0x77>
mov    0x2e25(%rip),%rax
mov    (%rax),%edi
mov    (%r14),%rsi
call   1070 <usage@plt>
xor    %edi,%edi
call   1090 <exit@plt>
lea    0xe4f(%rip),%rdi
call   1050 <puts@plt>
xor    %edi,%edi
call   1090 <exit@plt>
mov    0x2e1a(%rip),%rax
movslq (%rax),%rax
cmp    %r15d,%eax
jne    1202 <main+0x92>
lea    0xe26(%rip),%rdi
call   1030 <ls_lowmem@plt>
jmp    1266 <main+0xf6>
mov    0x2dea(%rip),%rax
mov    (%rax),%edi
mov    (%r14),%rsi
call   1070 <usage@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
cmp    %r15d,%eax
jge    1266 <main+0xf6>
lea    (%r14,%rax,8),%r12
mov    %r15d,%r13d
sub    %eax,%r13d
xor    %r14d,%r14d
xor    %ebp,%ebp
jmp    1233 <main+0xc3>
nopl   0x0(%rax,%rax,1)
mov    %rbx,%rdi
call   1030 <ls_lowmem@plt>
or     %eax,%ebp
add    $0x1,%r14
cmp    %r14d,%r13d
je     1262 <main+0xf2>
mov    (%r12,%r14,8),%rbx
cmp    $0x3,%r15d
jl     1220 <main+0xb0>
lea    0xdc1(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %rbx,%rdi
call   1030 <ls_lowmem@plt>
mov    $0xa,%edi
call   1040 <putchar@plt>
jmp    122a <main+0xba>
test   %ebp,%ebp
jne    1274 <main+0x104>
mov    0x2d53(%rip),%rax
mov    (%rax),%edi
call   1090 <exit@plt>
mov    0x2d55(%rip),%rax
mov    (%rax),%edi
call   1090 <exit@plt>

LLVM IR (-O0):
@.str = [3 x i8] c"hV\00"
@stdout = global i32 0
@.str.1 = [32 x i8] c"ls-lowmem (lowmem-tools) 0.1.0\0A\00"
@stderr = global i32 0
@optind = global i32 0
@.str.2 = [2 x i8] c".\00"
@.str.3 = [5 x i8] c"%s:\0A\00"
@.str.4 = [2 x i8] c"\0A\00"
@EXIT_FAILURE = global i32 0
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %8
br label %10
10: ; preds = %2
%11 = load i32, i32* %4
%12 = load i8**, i8*** %5
%13 = call i32 @getopt(i32 %11, i8** %12, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i32 %13, i32* %7
%14 = icmp ne i32 %13, -1
br i1 %14, label %15, label %34
15: ; preds = %10
%16 = load i32, i32* %7
switch i32 %16, label %27 [
i32 104, label %17
i32 86, label %24
]
17: ; preds = %15
%18 = load i32, i32* @stdout
%19 = load i8**, i8*** %5
%20 = getelementptr inbounds i8*, i8** %19, i64 0
%21 = load i8*, i8** %20
%22 = call i32 @usage(i32 %18, i8* %21)
%23 = call i32 @exit(i32 0)
unreachable
24: ; preds = %15
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0))
%26 = call i32 @exit(i32 0)
unreachable
27: ; preds = %15
%28 = load i32, i32* @stderr
%29 = load i8**, i8*** %5
%30 = getelementptr inbounds i8*, i8** %29, i64 0
%31 = load i8*, i8** %30
%32 = call i32 @usage(i32 %28, i8* %31)
%33 = call i32 @exit(i32 1)
unreachable
34: ; preds = %10
%35 = load i32, i32* @optind
%36 = load i32, i32* %4
%37 = icmp eq i32 %35, %36
br i1 %37, label %38, label %40
38: ; preds = %34
%39 = call i32 @ls_lowmem(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %70
40: ; preds = %34
%41 = load i32, i32* @optind
store i32 %41, i32* %6
br label %42
42: ; preds = %66, %40
%43 = load i32, i32* %6
%44 = load i32, i32* %4
%45 = icmp slt i32 %43, %44
br i1 %45, label %46, label %69
46: ; preds = %42
%47 = load i8**, i8*** %5
%48 = load i32, i32* %6
%49 = sext i32 %48 to i64
%50 = getelementptr inbounds i8*, i8** %47, i64 %49
%51 = load i8*, i8** %50
store i8* %51, i8** %9
%52 = load i32, i32* %4
%53 = icmp sgt i32 %52, 2
br i1 %53, label %54, label %60
54: ; preds = %46
%55 = load i8*, i8** %9
%56 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i8* %55)
%57 = load i8*, i8** %9
%58 = call i32 @ls_lowmem(i8* %57)
%59 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
br label %65
60: ; preds = %46
%61 = load i8*, i8** %9
%62 = call i32 @ls_lowmem(i8* %61)
%63 = load i32, i32* %8
%64 = or i32 %63, %62
store i32 %64, i32* %8
br label %65
65: ; preds = %60, %54
br label %66
66: ; preds = %65
%67 = load i32, i32* %6
%68 = add nsw i32 %67, 1
store i32 %68, i32* %6
br label %42
69: ; preds = %42
br label %70
70: ; preds = %69, %38
%71 = load i32, i32* %8
%72 = icmp ne i32 %71, 0
br i1 %72, label %73, label %75
73: ; preds = %70
%74 = load i32, i32* @EXIT_FAILURE
br label %77
75: ; preds = %70
%76 = load i32, i32* @EXIT_SUCCESS
br label %77
77: ; preds = %75, %73
%78 = phi i32 [ %74, %73 ], [ %76, %75 ]
%79 = call i32 @exit(i32 %78)
unreachable
}

LLVM IR (-O2):
@.str = [3 x i8] c"hV\00"
@stdout = global i32 0
@stderr = global i32 0
@optind = global i32 0
@.str.2 = [2 x i8] c".\00"
@.str.3 = [5 x i8] c"%s:\0A\00"
@EXIT_FAILURE = global i32 0
@EXIT_SUCCESS = global i32 0
@str = [31 x i8] c"ls-lowmem (lowmem-tools) 0.1.0\00"
define i32 @main(i32 %0, i8** %1) {
%3 = tail call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
switch i32 %3, label %12 [
i32 -1, label %17
i32 104, label %4
i32 86, label %9
]
4: ; preds = %2
%5 = load i32, i32* @stdout
%6 = load i8*, i8** %1
%7 = tail call i32 @usage(i32 %5, i8* %6)
%8 = tail call i32 @exit(i32 0)
unreachable
9: ; preds = %2
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @str, i64 0, i64 0))
%11 = tail call i32 @exit(i32 0)
unreachable
12: ; preds = %2
%13 = load i32, i32* @stderr
%14 = load i8*, i8** %1
%15 = tail call i32 @usage(i32 %13, i8* %14)
%16 = tail call i32 @exit(i32 1)
unreachable
17: ; preds = %2
%18 = load i32, i32* @optind
%19 = icmp eq i32 %18, %0
br i1 %19, label %25, label %20
20: ; preds = %17
%21 = icmp slt i32 %18, %0
br i1 %21, label %22, label %46
22: ; preds = %20
%23 = icmp sgt i32 %0, 2
%24 = sext i32 %18 to i64
br label %27
25: ; preds = %17
%26 = tail call i32 @ls_lowmem(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %46
27: ; preds = %22, %39
%28 = phi i64 [ %24, %22 ], [ %41, %39 ]
%29 = phi i32 [ 0, %22 ], [ %40, %39 ]
%30 = getelementptr inbounds i8*, i8** %1, i64 %28
%31 = load i8*, i8** %30
br i1 %23, label %32, label %36
32: ; preds = %27
%33 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i8* %31)
%34 = tail call i32 @ls_lowmem(i8* %31)
%35 = tail call i32 @putchar(i32 10)
br label %39
36: ; preds = %27
%37 = tail call i32 @ls_lowmem(i8* %31)
%38 = or i32 %37, %29
br label %39
39: ; preds = %32, %36
%40 = phi i32 [ %29, %32 ], [ %38, %36 ]
%41 = add nsw i64 %28, 1
%42 = trunc i64 %41 to i32
%43 = icmp eq i32 %42, %0
br i1 %43, label %44, label %27
44: ; preds = %39
%45 = icmp eq i32 %40, 0
br i1 %45, label %46, label %47
46: ; preds = %20, %25, %44
br label %47
47: ; preds = %44, %46
%48 = phi i32* [ @EXIT_SUCCESS, %46 ], [ @EXIT_FAILURE, %44 ]
%49 = load i32, i32* %48
%50 = tail call i32 @exit(i32 %49)
unreachable
}