#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 dirent {
  char *d_name;
};

/* Variables and functions */
int /*<<< orphan*/ printf(char *, ...);
void printfName(char *root, struct dirent *ep, int depth) {
  int i = 0;
  for (; i <= depth; i++) {
    printf("  ");
  }
  printf("%s\n", ep->d_name);
}


x86 assembly (clang, -O0):
<printfName>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jg     1152 <printfName+0x42>
lea    0xec3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    112a <printfName+0x1a>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xea3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printfName>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%r14
test   %edx,%edx
js     114f <printfName+0x2f>
mov    %edx,%ebp
add    $0x1,%ebp
lea    0xec9(%rip),%rbx
nopw   0x0(%rax,%rax,1)
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0xffffffff,%ebp
jne    1140 <printfName+0x20>
mov    (%r14),%rdi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1030 <puts@plt>

LLVM IR (-O0):
%struct.dirent = type { i8* }
@.str = [3 x i8] c" \00"
@.str.1 = [4 x i8] c"%s\0A\00"
define void @printfName(i8* %0, %struct.dirent* %1, i32 %2) {
%4 = alloca i8*
%5 = alloca %struct.dirent*
%6 = alloca i32
%7 = alloca i32
store i8* %0, i8** %4
store %struct.dirent* %1, %struct.dirent** %5
store i32 %2, i32* %6
store i32 0, i32* %7
br label %8
8: ; preds = %14, %3
%9 = load i32, i32* %7
%10 = load i32, i32* %6
%11 = icmp sle i32 %9, %10
br i1 %11, label %12, label %17
12: ; preds = %8
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
br label %14
14: ; preds = %12
%15 = load i32, i32* %7
%16 = add nsw i32 %15, 1
store i32 %16, i32* %7
br label %8
17: ; preds = %8
%18 = load %struct.dirent*, %struct.dirent** %5
%19 = getelementptr inbounds %struct.dirent, %struct.dirent* %18, i32 0, i32 0
%20 = load i8*, i8** %19
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %20)
ret void
}

LLVM IR (-O2):
%struct.dirent = type { i8* }
@.str = [3 x i8] c" \00"
define void @printfName(i8* nocapture readnone %0, %struct.dirent* nocapture %1, i32 %2) {
%4 = icmp slt i32 %2, 0
br i1 %4, label %10, label %5
5: ; preds = %3, %5
%6 = phi i32 [ %8, %5 ], [ 0, %3 ]
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%8 = add nuw i32 %6, 1
%9 = icmp eq i32 %6, %2
br i1 %9, label %10, label %5
10: ; preds = %5, %3
%11 = getelementptr inbounds %struct.dirent, %struct.dirent* %1, i64 0, i32 0
%12 = load i8*, i8** %11
%13 = tail call i32 @puts(i8* dereferenceable(1) %12)
ret void
}