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

/* Variables and functions */
int /*<<< orphan*/ printf(char *, char *);
struct dirent *readdir(int /*<<< orphan*/ *);
void list_items(DIR *directory, bool show_all) {
  struct dirent *item;
  while ((item = readdir(directory))) {
    char *item_name = item->d_name;
    if (item_name[0] == '.' && show_all) {
      printf("%s  ", item_name);
    } else if (item_name[0] != '.') {
      printf("%s  ", item_name);
    }
  }
}


x86 assembly (clang, -O0):
<list_items>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <readdir@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
je     11aa <list_items+0x8a>
mov    -0x18(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2e,%eax
jne    1180 <list_items+0x60>
cmpl   $0x0,-0xc(%rbp)
je     1180 <list_items+0x60>
mov    -0x20(%rbp),%rsi
lea    0xe8a(%rip),%rdi
call   1030 <printf@plt>
jmp    11a5 <list_items+0x85>
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x2e,%eax
je     11a0 <list_items+0x80>
mov    -0x20(%rbp),%rsi
lea    0xe65(%rip),%rdi
call   1030 <printf@plt>
jmp    11a5 <list_items+0x85>
jmp    112f <list_items+0xf>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<list_items>:
push   %rbp
push   %r14
push   %rbx
mov    %esi,%ebp
mov    %rdi,%rbx
call   1040 <readdir@plt>
test   %rax,%rax
je     1163 <list_items+0x43>
lea    0xec6(%rip),%r14
jmp    1155 <list_items+0x35>
nopl   0x0(%rax)
mov    %r14,%rdi
call   1030 <printf@plt>
mov    %rbx,%rdi
call   1040 <readdir@plt>
test   %rax,%rax
je     1163 <list_items+0x43>
mov    (%rax),%rsi
cmpb   $0x2e,(%rsi)
jne    1140 <list_items+0x20>
test   %ebp,%ebp
je     1148 <list_items+0x28>
jmp    1140 <list_items+0x20>
pop    %rbx
pop    %r14
pop    %rbp
ret

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

LLVM IR (-O2):
%struct.dirent = type { i8* }
@.str = [5 x i8] c"%s \00"
define void @list_items(i32* %0, i32 %1) {
%3 = tail call %struct.dirent* @readdir(i32* %0)
%4 = icmp eq %struct.dirent* %3, null
br i1 %4, label %19, label %5
5: ; preds = %2
%6 = icmp eq i32 %1, 0
br label %7
7: ; preds = %5, %16
%8 = phi %struct.dirent* [ %3, %5 ], [ %17, %16 ]
%9 = getelementptr inbounds %struct.dirent, %struct.dirent* %8, i64 0, i32 0
%10 = load i8*, i8** %9
%11 = load i8, i8* %10
%12 = icmp eq i8 %11, 46
%13 = and i1 %12, %6
br i1 %13, label %16, label %14
14: ; preds = %7
%15 = tail call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %10)
br label %16
16: ; preds = %7, %14
%17 = tail call %struct.dirent* @readdir(i32* %0)
%18 = icmp eq %struct.dirent* %17, null
br i1 %18, label %19, label %7
19: ; preds = %16, %2
ret void
}