#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 */

/* Variables and functions */
char **dir_list(char *, int /*<<< orphan*/ *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ paths_free(char **);
int /*<<< orphan*/ stderr;
int test_empty_dir(void) {
  int ret;
  char **paths;
  paths = dir_list("data/empty_dir", NULL);
  ret = 0;
  if (paths) {
    if (*paths) {
      ret = 1;
      fprintf(stderr, "ERROR: list not empty %s\n", *paths);
    }
    paths_free(paths);
  }
  return ret;
}


x86 assembly (clang, -O0):
<test_empty_dir>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xec1(%rip),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1050 <dir_list@plt>
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x4(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     1198 <test_empty_dir+0x68>
mov    -0x10(%rbp),%rax
cmpq   $0x0,(%rax)
je     118f <test_empty_dir+0x5f>
movl   $0x1,-0x4(%rbp)
mov    0x2e66(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
lea    0xe85(%rip),%rsi
call   1040 <fprintf@plt>
mov    -0x10(%rbp),%rdi
call   1030 <paths_free@plt>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_empty_dir>:
push   %r14
push   %rbx
push   %rax
lea    0xec5(%rip),%rdi
xor    %r14d,%r14d
xor    %esi,%esi
call   1050 <dir_list@plt>
test   %rax,%rax
je     117d <test_empty_dir+0x4d>
mov    %rax,%rbx
mov    (%rax),%rdx
test   %rdx,%rdx
je     1172 <test_empty_dir+0x42>
mov    0x2e84(%rip),%rax
mov    (%rax),%edi
lea    0xeaa(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0x1,%r14d
jmp    1175 <test_empty_dir+0x45>
xor    %r14d,%r14d
mov    %rbx,%rdi
call   1030 <paths_free@plt>
mov    %r14d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [15 x i8] c"data/empty_dir\00"
@stderr = global i32 0
@.str.1 = [26 x i8] c"ERROR: list not empty %s\0A\00"
define i32 @test_empty_dir() {
%1 = alloca i32
%2 = alloca i8**
%3 = call i8** @dir_list(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i32* null)
store i8** %3, i8*** %2
store i32 0, i32* %1
%4 = load i8**, i8*** %2
%5 = icmp ne i8** %4, null
br i1 %5, label %6, label %18
6: ; preds = %0
%7 = load i8**, i8*** %2
%8 = load i8*, i8** %7
%9 = icmp ne i8* %8, null
br i1 %9, label %10, label %15
10: ; preds = %6
store i32 1, i32* %1
%11 = load i32, i32* @stderr
%12 = load i8**, i8*** %2
%13 = load i8*, i8** %12
%14 = call i32 @fprintf(i32 %11, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0), i8* %13)
br label %15
15: ; preds = %10, %6
%16 = load i8**, i8*** %2
%17 = call i32 @paths_free(i8** %16)
br label %18
18: ; preds = %15, %0
%19 = load i32, i32* %1
ret i32 %19
}

LLVM IR (-O2):
@.str = [15 x i8] c"data/empty_dir\00"
@stderr = global i32 0
@.str.1 = [26 x i8] c"ERROR: list not empty %s\0A\00"
define i32 @test_empty_dir() {
%1 = tail call i8** @dir_list(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i32* null)
%2 = icmp eq i8** %1, null
br i1 %2, label %12, label %3
3: ; preds = %0
%4 = load i8*, i8** %1
%5 = icmp eq i8* %4, null
br i1 %5, label %9, label %6
6: ; preds = %3
%7 = load i32, i32* @stderr
%8 = tail call i32 @fprintf(i32 %7, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0), i8* %4)
br label %9
9: ; preds = %6, %3
%10 = phi i32 [ 1, %6 ], [ 0, %3 ]
%11 = tail call i32 @paths_free(i8** %1)
br label %12
12: ; preds = %9, %0
%13 = phi i32 [ %10, %9 ], [ 0, %0 ]
ret i32 %13
}