#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 */
int /*<<< orphan*/ assert(int);
int directory_exists(char *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ run_shell_command(char *);
int /*<<< orphan*/ sprintf(char *, char *, char *);
void test_directory_exists() {
  char *test_directory = "/tmp/scalam_test_directory_exists";
  char cmdstr[256];
  printf("test_directory_exists...");
  sprintf(cmdstr, "mkdir -p %s", test_directory);
  run_shell_command(cmdstr);
  assert(directory_exists(test_directory));
  sprintf(cmdstr, "rm -rf %s", test_directory);
  run_shell_command(cmdstr);
  assert(!directory_exists(test_directory));
  printf("Ok\n");
}


x86 assembly (clang, -O0):
<test_directory_exists>:
push   %rbp
mov    %rsp,%rbp
sub    $0x110,%rsp
lea    0xe9e(%rip),%rax
mov    %rax,-0x8(%rbp)
lea    0xeb5(%rip),%rdi
call   1040 <printf@plt>
lea    -0x110(%rbp),%rdi
mov    -0x8(%rbp),%rdx
lea    0xeb7(%rip),%rsi
call   1070 <sprintf@plt>
lea    -0x110(%rbp),%rdi
call   1030 <run_shell_command@plt>
mov    -0x8(%rbp),%rdi
call   1050 <directory_exists@plt>
mov    %eax,%edi
call   1060 <assert@plt>
lea    -0x110(%rbp),%rdi
mov    -0x8(%rbp),%rdx
lea    0xe90(%rip),%rsi
call   1070 <sprintf@plt>
lea    -0x110(%rbp),%rdi
call   1030 <run_shell_command@plt>
mov    -0x8(%rbp),%rdi
call   1050 <directory_exists@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
lea    0xe67(%rip),%rdi
call   1040 <printf@plt>
add    $0x110,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_directory_exists>:
push   %r14
push   %rbx
sub    $0x108,%rsp
lea    0xeb1(%rip),%rdi
call   1050 <printf@plt>
lea    0xebe(%rip),%rsi
lea    0xe7c(%rip),%r14
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    %r14,%rdx
call   1080 <sprintf@plt>
mov    %rbx,%rdi
call   1040 <run_shell_command@plt>
mov    %r14,%rdi
call   1060 <directory_exists@plt>
mov    %eax,%edi
call   1070 <assert@plt>
lea    0xe97(%rip),%rsi
mov    %rbx,%rdi
mov    %r14,%rdx
call   1080 <sprintf@plt>
mov    %rbx,%rdi
call   1040 <run_shell_command@plt>
mov    %r14,%rdi
call   1060 <directory_exists@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
call   1070 <assert@plt>
lea    0xe72(%rip),%rdi
call   1030 <puts@plt>
add    $0x108,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [34 x i8] c"/tmp/scalam_test_directory_exists\00"
@.str.1 = [25 x i8] c"test_directory_exists...\00"
@.str.2 = [12 x i8] c"mkdir -p %s\00"
@.str.3 = [10 x i8] c"rm -rf %s\00"
@.str.4 = [4 x i8] c"Ok\0A\00"
define void @test_directory_exists() {
%1 = alloca i8*
%2 = alloca [256 x i8]
store i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0), i8** %1
%3 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0))
%4 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
%5 = load i8*, i8** %1
%6 = call i32 @sprintf(i8* %4, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i8* %5)
%7 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
%8 = call i32 @run_shell_command(i8* %7)
%9 = load i8*, i8** %1
%10 = call i32 @directory_exists(i8* %9)
%11 = call i32 @assert(i32 %10)
%12 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
%13 = load i8*, i8** %1
%14 = call i32 @sprintf(i8* %12, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i8* %13)
%15 = getelementptr inbounds [256 x i8], [256 x i8]* %2, i64 0, i64 0
%16 = call i32 @run_shell_command(i8* %15)
%17 = load i8*, i8** %1
%18 = call i32 @directory_exists(i8* %17)
%19 = icmp ne i32 %18, 0
%20 = xor i1 %19, true
%21 = zext i1 %20 to i32
%22 = call i32 @assert(i32 %21)
%23 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [34 x i8] c"/tmp/scalam_test_directory_exists\00"
@.str.1 = [25 x i8] c"test_directory_exists...\00"
@.str.2 = [12 x i8] c"mkdir -p %s\00"
@.str.3 = [10 x i8] c"rm -rf %s\00"
@str = [3 x i8] c"Ok\00"
define void @test_directory_exists() {
%1 = alloca [256 x i8]
%2 = getelementptr inbounds [256 x i8], [256 x i8]* %1, i64 0, i64 0
%3 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0))
%4 = call i32 @sprintf(i8* %2, i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0))
%5 = call i32 @run_shell_command(i8* %2)
%6 = call i32 @directory_exists(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0))
%7 = call i32 @assert(i32 %6)
%8 = call i32 @sprintf(i8* %2, i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0))
%9 = call i32 @run_shell_command(i8* %2)
%10 = call i32 @directory_exists(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0))
%11 = icmp eq i32 %10, 0
%12 = zext i1 %11 to i32
%13 = call i32 @assert(i32 %12)
%14 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @str, i64 0, i64 0))
ret void
}