#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 */
struct stat {
  scalar_t__ st_size;
};

/* Variables and functions */
int /*<<< orphan*/ PrintToString(long long);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ readDirRec(char *);
int /*<<< orphan*/ stat(char *, struct stat *);
int main(int argc, char **argv) {
  char *startDir;
  if (argc == 1) {
    startDir = ".";
  } else {
    startDir = *++argv;
  }
  struct stat statbuf;
  stat(startDir, &statbuf);
  PrintToString((long long)statbuf.st_size);
  printf(" %s\n", startDir);
  if (startDir != NULL) {
    readDirRec(startDir);
  } else {
    perror("Directory could not be openend\n");
  }
  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)
cmpl   $0x1,-0x8(%rbp)
jne    1180 <main+0x30>
lea    0xe89(%rip),%rax
mov    %rax,-0x18(%rbp)
jmp    1197 <main+0x47>
mov    -0x10(%rbp),%rax
mov    %rax,%rcx
add    $0x8,%rcx
mov    %rcx,-0x10(%rbp)
mov    0x8(%rax),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
lea    -0x20(%rbp),%rsi
call   1050 <stat@plt>
mov    -0x20(%rbp),%rdi
call   1040 <PrintToString@plt>
mov    -0x18(%rbp),%rsi
lea    0xe4a(%rip),%rdi
call   1030 <printf@plt>
cmpq   $0x0,-0x18(%rbp)
je     11d6 <main+0x86>
mov    -0x18(%rbp),%rdi
call   1060 <readDirRec@plt>
jmp    11e2 <main+0x92>
lea    0xe2a(%rip),%rdi
call   1070 <perror@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
cmp    $0x1,%edi
jne    1163 <main+0x13>
lea    0xe9f(%rip),%rbx
jmp    1167 <main+0x17>
mov    0x8(%rsi),%rbx
lea    0x8(%rsp),%rsi
mov    %rbx,%rdi
call   1050 <stat@plt>
mov    0x8(%rsp),%rdi
call   1040 <PrintToString@plt>
lea    0xe7d(%rip),%rdi
mov    %rbx,%rsi
call   1030 <printf@plt>
test   %rbx,%rbx
je     11a2 <main+0x52>
mov    %rbx,%rdi
call   1060 <readDirRec@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret
lea    0xe5e(%rip),%rdi
call   1070 <perror@plt>
jmp    119a <main+0x4a>

LLVM IR (-O0):
%struct.stat = type { i64 }
@.str = [2 x i8] c".\00"
@.str.1 = [5 x i8] c" %s\0A\00"
@.str.2 = [32 x i8] c"Directory could not be openend\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca %struct.stat
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = load i32, i32* %4
%9 = icmp eq i32 %8, 1
br i1 %9, label %10, label %11
10: ; preds = %2
store i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i8** %6
br label %15
11: ; preds = %2
%12 = load i8**, i8*** %5
%13 = getelementptr inbounds i8*, i8** %12, i32 1
store i8** %13, i8*** %5
%14 = load i8*, i8** %13
store i8* %14, i8** %6
br label %15
15: ; preds = %11, %10
%16 = load i8*, i8** %6
%17 = call i32 @stat(i8* %16, %struct.stat* %7)
%18 = getelementptr inbounds %struct.stat, %struct.stat* %7, i32 0, i32 0
%19 = load i64, i64* %18
%20 = call i32 @PrintToString(i64 %19)
%21 = load i8*, i8** %6
%22 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* %21)
%23 = load i8*, i8** %6
%24 = icmp ne i8* %23, null
br i1 %24, label %25, label %28
25: ; preds = %15
%26 = load i8*, i8** %6
%27 = call i32 @readDirRec(i8* %26)
br label %30
28: ; preds = %15
%29 = call i32 @perror(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0))
br label %30
30: ; preds = %28, %25
ret i32 0
}

LLVM IR (-O2):
%struct.stat = type { i64 }
@.str = [2 x i8] c".\00"
@.str.1 = [5 x i8] c" %s\0A\00"
@.str.2 = [32 x i8] c"Directory could not be openend\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca %struct.stat
%4 = icmp eq i32 %0, 1
br i1 %4, label %8, label %5
5: ; preds = %2
%6 = getelementptr inbounds i8*, i8** %1, i64 1
%7 = load i8*, i8** %6
br label %8
8: ; preds = %2, %5
%9 = phi i8* [ %7, %5 ], [ getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), %2 ]
%10 = bitcast %struct.stat* %3 to i8*
%11 = call i32 @stat(i8* %9, %struct.stat* %3)
%12 = getelementptr inbounds %struct.stat, %struct.stat* %3, i64 0, i32 0
%13 = load i64, i64* %12
%14 = tail call i32 @PrintToString(i64 %13)
%15 = tail call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* %9)
%16 = icmp eq i8* %9, null
br i1 %16, label %19, label %17
17: ; preds = %8
%18 = tail call i32 @readDirRec(i8* %9)
br label %21
19: ; preds = %8
%20 = tail call i32 @perror(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0))
br label %21
21: ; preds = %19, %17
ret i32 0
}