#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*/ STDOUT_FILENO;
int /*<<< orphan*/ free(void *);
int isatty(int /*<<< orphan*/);
int /*<<< orphan*/ iterate_files(char const *, long const *, long, long, int);
long *ls_my_files(char const *, long, long);
int parse_args(char *, int, char **, long *, long *, char const **);
int main(int argc, char **argv) {
  long start_at, end_at;
  const char *path;
  const long *files;
  int progress;
  int rc;
  rc = parse_args("read", argc, argv, &start_at, &end_at, &path);
  if (rc)
    return rc;
  files = ls_my_files(path, start_at, end_at);
  progress = isatty(STDOUT_FILENO);
  iterate_files(path, files, start_at, end_at, progress);
  free((void *)files);
  return 0;
}


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)
mov    -0x8(%rbp),%esi
mov    -0x10(%rbp),%rdx
lea    0xe8c(%rip),%rdi
lea    -0x18(%rbp),%rcx
lea    -0x20(%rbp),%r8
lea    -0x28(%rbp),%r9
call   1060 <parse_args@plt>
mov    %eax,-0x38(%rbp)
cmpl   $0x0,-0x38(%rbp)
je     119d <main+0x4d>
mov    -0x38(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11ec <main+0x9c>
mov    -0x28(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
call   1050 <ls_my_files@plt>
mov    %rax,-0x30(%rbp)
mov    0x2e37(%rip),%rax
mov    (%rax),%edi
call   1040 <isatty@plt>
mov    %eax,-0x34(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x30(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rcx
mov    -0x34(%rbp),%r8d
call   1070 <iterate_files@plt>
mov    -0x30(%rbp),%rdi
call   1030 <free@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%rdx
mov    %edi,%esi
lea    0xe9d(%rip),%rdi
lea    0x10(%rsp),%rcx
lea    0x8(%rsp),%r8
mov    %rsp,%r9
call   1060 <parse_args@plt>
mov    %eax,%ebx
test   %eax,%eax
jne    11c0 <main+0x70>
mov    (%rsp),%rdi
mov    0x10(%rsp),%rsi
mov    0x8(%rsp),%rdx
call   1050 <ls_my_files@plt>
mov    %rax,%r14
mov    0x2e58(%rip),%rax
mov    (%rax),%edi
call   1040 <isatty@plt>
mov    (%rsp),%rdi
mov    0x10(%rsp),%rdx
mov    0x8(%rsp),%rcx
mov    %r14,%rsi
mov    %eax,%r8d
call   1070 <iterate_files@plt>
mov    %r14,%rdi
call   1030 <free@plt>
mov    %ebx,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [5 x i8] c"read\00"
@STDOUT_FILENO = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i64
%7 = alloca i64
%8 = alloca i8*
%9 = alloca i64*
%10 = alloca i32
%11 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%12 = load i32, i32* %4
%13 = load i8**, i8*** %5
%14 = call i32 @parse_args(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %12, i8** %13, i64* %6, i64* %7, i8** %8)
store i32 %14, i32* %11
%15 = load i32, i32* %11
%16 = icmp ne i32 %15, 0
br i1 %16, label %17, label %19
17: ; preds = %2
%18 = load i32, i32* %11
store i32 %18, i32* %3
br label %35
19: ; preds = %2
%20 = load i8*, i8** %8
%21 = load i64, i64* %6
%22 = load i64, i64* %7
%23 = call i64* @ls_my_files(i8* %20, i64 %21, i64 %22)
store i64* %23, i64** %9
%24 = load i32, i32* @STDOUT_FILENO
%25 = call i32 @isatty(i32 %24)
store i32 %25, i32* %10
%26 = load i8*, i8** %8
%27 = load i64*, i64** %9
%28 = load i64, i64* %6
%29 = load i64, i64* %7
%30 = load i32, i32* %10
%31 = call i32 @iterate_files(i8* %26, i64* %27, i64 %28, i64 %29, i32 %30)
%32 = load i64*, i64** %9
%33 = bitcast i64* %32 to i8*
%34 = call i32 @free(i8* %33)
store i32 0, i32* %3
br label %35
35: ; preds = %19, %17
%36 = load i32, i32* %3
ret i32 %36
}

LLVM IR (-O2):
@.str = [5 x i8] c"read\00"
@STDOUT_FILENO = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i64
%4 = alloca i64
%5 = alloca i8*
%6 = bitcast i64* %3 to i8*
%7 = bitcast i64* %4 to i8*
%8 = bitcast i8** %5 to i8*
%9 = call i32 @parse_args(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32 %0, i8** %1, i64* %3, i64* %4, i8** %5)
%10 = icmp eq i32 %9, 0
br i1 %10, label %11, label %24
11: ; preds = %2
%12 = load i8*, i8** %5
%13 = load i64, i64* %3
%14 = load i64, i64* %4
%15 = call i64* @ls_my_files(i8* %12, i64 %13, i64 %14)
%16 = load i32, i32* @STDOUT_FILENO
%17 = call i32 @isatty(i32 %16)
%18 = load i8*, i8** %5
%19 = load i64, i64* %3
%20 = load i64, i64* %4
%21 = call i32 @iterate_files(i8* %18, i64* %15, i64 %19, i64 %20, i32 %17)
%22 = bitcast i64* %15 to i8*
%23 = call i32 @free(i8* %22)
br label %24
24: ; preds = %2, %11
ret i32 %9
}