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

/* Variables and functions */
scalar_t__ DT_DIR;
int /*<<< orphan*/ add_user(char *, int /*<<< orphan*/ *);
int /*<<< orphan*/ closedir(int /*<<< orphan*/ *);
int /*<<< orphan*/ load_friend();
int /*<<< orphan*/ *opendir(char *);
struct dirent *readdir(int /*<<< orphan*/ *);
void load_user(void) {
  DIR *dir;
  struct dirent *ent;
  if (!(dir = opendir("./user/")))
    return;
  while ((ent = readdir(dir))) {
    if (ent->d_name[0] == '.')
      continue;
    if (ent->d_type != DT_DIR)
      continue;
    add_user(ent->d_name, NULL);
  }
  closedir(dir);
  load_friend();
}


x86 assembly (clang, -O0):
<load_user>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xea1(%rip),%rdi
call   1030 <opendir@plt>
mov    %rax,-0x8(%rbp)
cmp    $0x0,%rax
jne    1177 <load_user+0x27>
jmp    11ed <load_user+0x9d>
jmp    117c <load_user+0x2c>
mov    -0x8(%rbp),%rdi
call   1060 <readdir@plt>
mov    %rax,-0x10(%rbp)
cmp    $0x0,%rax
je     11dd <load_user+0x8d>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
movsbl (%rax),%eax
cmp    $0x2e,%eax
jne    11ab <load_user+0x5b>
jmp    117c <load_user+0x2c>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    0x2e26(%rip),%rcx
cmp    (%rcx),%rax
je     11c8 <load_user+0x78>
jmp    117c <load_user+0x2c>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1050 <add_user@plt>
jmp    117c <load_user+0x2c>
mov    -0x8(%rbp),%rdi
call   1040 <closedir@plt>
mov    $0x0,%al
call   1070 <load_friend@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<load_user>:
push   %r14
push   %rbx
push   %rax
lea    0xea5(%rip),%rdi
call   1030 <opendir@plt>
test   %rax,%rax
je     11bd <load_user+0x6d>
mov    %rax,%rbx
mov    %rax,%rdi
call   1060 <readdir@plt>
test   %rax,%rax
je     11a7 <load_user+0x57>
mov    0x2e64(%rip),%r14
jmp    118d <load_user+0x3d>
xchg   %ax,%ax
mov    %rbx,%rdi
call   1060 <readdir@plt>
test   %rax,%rax
je     11a7 <load_user+0x57>
mov    (%rax),%rdi
cmpb   $0x2e,(%rdi)
je     1180 <load_user+0x30>
mov    0x8(%rax),%rax
cmp    (%r14),%rax
jne    1180 <load_user+0x30>
xor    %esi,%esi
call   1050 <add_user@plt>
jmp    1180 <load_user+0x30>
mov    %rbx,%rdi
call   1040 <closedir@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1070 <load_friend@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
%struct.dirent = type { i8*, i64 }
@.str = [8 x i8] c"./user/\00"
@DT_DIR = global i64 0
define void @load_user() {
%1 = tail call i32* @opendir(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%2 = icmp eq i32* %1, null
br i1 %2, label %25, label %3
3: ; preds = %0
%4 = tail call %struct.dirent* @readdir(i32* %1)
%5 = icmp eq %struct.dirent* %4, null
br i1 %5, label %22, label %6
6: ; preds = %3, %19
%7 = phi %struct.dirent* [ %20, %19 ], [ %4, %3 ]
%8 = getelementptr inbounds %struct.dirent, %struct.dirent* %7, i64 0, i32 0
%9 = load i8*, i8** %8
%10 = load i8, i8* %9
%11 = icmp eq i8 %10, 46
br i1 %11, label %19, label %12
12: ; preds = %6
%13 = getelementptr inbounds %struct.dirent, %struct.dirent* %7, i64 0, i32 1
%14 = load i64, i64* %13
%15 = load i64, i64* @DT_DIR
%16 = icmp eq i64 %14, %15
br i1 %16, label %17, label %19
17: ; preds = %12
%18 = tail call i32 @add_user(i8* %9, i32* null)
br label %19
19: ; preds = %17, %6, %12
%20 = tail call %struct.dirent* @readdir(i32* %1)
%21 = icmp eq %struct.dirent* %20, null
br i1 %21, label %22, label %6
22: ; preds = %19, %3
%23 = tail call i32 @closedir(i32* %1)
%24 = tail call i32 (...) @load_friend()
br label %25
25: ; preds = %0, %22
ret void
}