#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 {
  int st_mode;
};

/* Variables and functions */
int FTW_D;
int FTW_F;
int FTW_NS;
int /*<<< orphan*/ get_chunk_id(char const *);
int /*<<< orphan*/ printf(char *, int, char const *);
scalar_t__ strcmp(char *, char const *);
int list(const char *name, const struct stat *status, int type) {
  if (type == FTW_NS)
    return 0;
  if (type == FTW_F)
    printf("0%3o\t%s\n", status->st_mode & 0777, name);
  get_chunk_id(name);
  if (type == FTW_D && strcmp(".", name) != 0)
    printf("0%3o\t%s/\n", status->st_mode & 0777, name);
  return 0;
}


x86 assembly (clang, -O0):
<list>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    0x2e7b(%rip),%rcx
cmp    (%rcx),%eax
jne    1161 <list+0x31>
movl   $0x0,-0x4(%rbp)
jmp    11e7 <list+0xb7>
mov    -0x1c(%rbp),%eax
mov    0x2e75(%rip),%rcx
cmp    (%rcx),%eax
jne    118f <list+0x5f>
mov    -0x18(%rbp),%rax
mov    (%rax),%esi
and    $0x1ff,%esi
mov    -0x10(%rbp),%rdx
lea    0xe76(%rip),%rdi
call   1030 <printf@plt>
mov    -0x10(%rbp),%rdi
call   1050 <get_chunk_id@plt>
mov    -0x1c(%rbp),%eax
mov    0x2e46(%rip),%rcx
cmp    (%rcx),%eax
jne    11e0 <list+0xb0>
mov    -0x10(%rbp),%rsi
lea    0xe54(%rip),%rdi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
je     11e0 <list+0xb0>
mov    -0x18(%rbp),%rax
mov    (%rax),%esi
and    $0x1ff,%esi
mov    -0x10(%rbp),%rdx
lea    0xe30(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<list>:
push   %rbp
push   %r14
push   %rbx
mov    0x2e8d(%rip),%rax
cmp    %edx,(%rax)
je     11a7 <list+0x77>
mov    %edx,%ebp
mov    %rsi,%r14
mov    %rdi,%rbx
mov    0x2e92(%rip),%rax
cmp    %edx,(%rax)
jne    1169 <list+0x39>
mov    $0x1ff,%esi
and    (%r14),%esi
lea    0xe9f(%rip),%rdi
mov    %rbx,%rdx
call   1030 <printf@plt>
mov    %rbx,%rdi
call   1050 <get_chunk_id@plt>
mov    0x2e70(%rip),%rax
cmp    %ebp,(%rax)
jne    11a7 <list+0x77>
lea    0xe86(%rip),%rdi
mov    %rbx,%rsi
call   1040 <strcmp@plt>
test   %rax,%rax
je     11a7 <list+0x77>
mov    $0x1ff,%esi
and    (%r14),%esi
lea    0xe6c(%rip),%rdi
mov    %rbx,%rdx
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
%struct.stat = type { i32 }
@FTW_NS = global i32 0
@FTW_F = global i32 0
@.str = [9 x i8] c"0%3o\09%s\0A\00"
@FTW_D = global i32 0
@.str.1 = [2 x i8] c".\00"
@.str.2 = [10 x i8] c"0%3o\09%s/\0A\00"
define i32 @list(i8* %0, %struct.stat* %1, i32 %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca %struct.stat*
%7 = alloca i32
store i8* %0, i8** %5
store %struct.stat* %1, %struct.stat** %6
store i32 %2, i32* %7
%8 = load i32, i32* %7
%9 = load i32, i32* @FTW_NS
%10 = icmp eq i32 %8, %9
br i1 %10, label %11, label %12
11: ; preds = %3
store i32 0, i32* %4
br label %41
12: ; preds = %3
%13 = load i32, i32* %7
%14 = load i32, i32* @FTW_F
%15 = icmp eq i32 %13, %14
br i1 %15, label %16, label %23
16: ; preds = %12
%17 = load %struct.stat*, %struct.stat** %6
%18 = getelementptr inbounds %struct.stat, %struct.stat* %17, i32 0, i32 0
%19 = load i32, i32* %18
%20 = and i32 %19, 511
%21 = load i8*, i8** %5
%22 = call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 %20, i8* %21)
br label %23
23: ; preds = %16, %12
%24 = load i8*, i8** %5
%25 = call i32 @get_chunk_id(i8* %24)
%26 = load i32, i32* %7
%27 = load i32, i32* @FTW_D
%28 = icmp eq i32 %26, %27
br i1 %28, label %29, label %40
29: ; preds = %23
%30 = load i8*, i8** %5
%31 = call i64 @strcmp(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i8* %30)
%32 = icmp ne i64 %31, 0
br i1 %32, label %33, label %40
33: ; preds = %29
%34 = load %struct.stat*, %struct.stat** %6
%35 = getelementptr inbounds %struct.stat, %struct.stat* %34, i32 0, i32 0
%36 = load i32, i32* %35
%37 = and i32 %36, 511
%38 = load i8*, i8** %5
%39 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i32 %37, i8* %38)
br label %40
40: ; preds = %33, %29, %23
store i32 0, i32* %4
br label %41
41: ; preds = %40, %11
%42 = load i32, i32* %4
ret i32 %42
}

LLVM IR (-O2):
%struct.stat = type { i32 }
@FTW_NS = global i32 0
@FTW_F = global i32 0
@.str = [9 x i8] c"0%3o\09%s\0A\00"
@FTW_D = global i32 0
@.str.1 = [2 x i8] c".\00"
@.str.2 = [10 x i8] c"0%3o\09%s/\0A\00"
define i32 @list(i8* %0, %struct.stat* nocapture %1, i32 %2) {
%4 = load i32, i32* @FTW_NS
%5 = icmp eq i32 %4, %2
br i1 %5, label %26, label %6
6: ; preds = %3
%7 = load i32, i32* @FTW_F
%8 = icmp eq i32 %7, %2
br i1 %8, label %9, label %14
9: ; preds = %6
%10 = getelementptr inbounds %struct.stat, %struct.stat* %1, i64 0, i32 0
%11 = load i32, i32* %10
%12 = and i32 %11, 511
%13 = tail call i32 @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 %12, i8* %0)
br label %14
14: ; preds = %9, %6
%15 = tail call i32 @get_chunk_id(i8* %0)
%16 = load i32, i32* @FTW_D
%17 = icmp eq i32 %16, %2
br i1 %17, label %18, label %26
18: ; preds = %14
%19 = tail call i64 @strcmp(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i8* %0)
%20 = icmp eq i64 %19, 0
br i1 %20, label %26, label %21
21: ; preds = %18
%22 = getelementptr inbounds %struct.stat, %struct.stat* %1, i64 0, i32 0
%23 = load i32, i32* %22
%24 = and i32 %23, 511
%25 = tail call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i32 %24, i8* %0)
br label %26
26: ; preds = %14, %18, %21, %3
ret i32 0
}