#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 */
typedef int /*<<< orphan*/ cwd;

/* Variables and functions */
int /*<<< orphan*/ dig(char const *);
int /*<<< orphan*/ *getcwd(char *, int);
int /*<<< orphan*/ perror(char *);
int main(const int argc, const char *argv[]) {
  int i = 1;
  char cwd[1024];
  if (argc < 2) {
    if (getcwd(cwd, sizeof(cwd)) != NULL)
      dig(cwd);
    else
      perror("getcwd() error");
  } else {
    for (; i < argc; i++) {
      dig(argv[i]);
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x420,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x1,-0x14(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    1197 <main+0x67>
lea    -0x420(%rbp),%rdi
mov    $0x400,%esi
call   1030 <getcwd@plt>
cmp    $0x0,%rax
je     1186 <main+0x56>
lea    -0x420(%rbp),%rdi
call   1040 <dig@plt>
jmp    1192 <main+0x62>
lea    0xe73(%rip),%rdi
call   1050 <perror@plt>
jmp    11cc <main+0x9c>
jmp    119c <main+0x6c>
mov    -0x14(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11c7 <main+0x97>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1040 <dig@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    119c <main+0x6c>
jmp    11cc <main+0x9c>
xor    %eax,%eax
add    $0x420,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x400,%rsp
cmp    $0x2,%edi
jge    115d <main+0x2d>
mov    %rsp,%rdi
mov    $0x400,%esi
call   1030 <getcwd@plt>
test   %rax,%rax
je     1191 <main+0x61>
mov    %rsp,%rdi
call   1040 <dig@plt>
jmp    1182 <main+0x52>
mov    %rsi,%r14
mov    %edi,%r15d
mov    $0x1,%ebx
nopl   0x0(%rax,%rax,1)
mov    (%r14,%rbx,8),%rdi
call   1040 <dig@plt>
add    $0x1,%rbx
cmp    %rbx,%r15
jne    1170 <main+0x40>
xor    %eax,%eax
add    $0x400,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret
lea    0xe68(%rip),%rdi
call   1050 <perror@plt>
jmp    1182 <main+0x52>

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

LLVM IR (-O2):
@.str = [15 x i8] c"getcwd() error\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [1024 x i8]
%4 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%5 = icmp slt i32 %0, 2
br i1 %5, label %8, label %6
6: ; preds = %2
%7 = zext i32 %0 to i64
br label %15
8: ; preds = %2
%9 = call i32* @getcwd(i8* %4, i32 1024)
%10 = icmp eq i32* %9, null
br i1 %10, label %13, label %11
11: ; preds = %8
%12 = call i32 @dig(i8* %4)
br label %22
13: ; preds = %8
%14 = call i32 @perror(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
br label %22
15: ; preds = %6, %15
%16 = phi i64 [ 1, %6 ], [ %20, %15 ]
%17 = getelementptr inbounds i8*, i8** %1, i64 %16
%18 = load i8*, i8** %17
%19 = tail call i32 @dig(i8* %18)
%20 = add nuw nsw i64 %16, 1
%21 = icmp eq i64 %20, %7
br i1 %21, label %22, label %15
22: ; preds = %15, %11, %13
ret i32 0
}