#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 DFMkdirIfAbsent(char *, char **);
int rmdir(char *);
int /*<<< orphan*/ utassert(int, char *);
void test_DFMkdirIfAbsent(void) {
  char *errmsg;
  int rc;
  rmdir("xxyz_testdir");
  rc = DFMkdirIfAbsent("xxyz_testdir", &errmsg);
  utassert((rc == 1), "Cannot create directory");
  rc = DFMkdirIfAbsent("xxyz_testdir", &errmsg);
  utassert((rc == 1), "Cannot use existing directory");
  rc = rmdir("xxyz_testdir");
  utassert((rc == 0), "did not create directory");
}


x86 assembly (clang, -O0):
<test_DFMkdirIfAbsent>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xec1(%rip),%rdi
call   1050 <rmdir@plt>
lea    0xeb5(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <DFMkdirIfAbsent@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0x1,-0xc(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
lea    0xea3(%rip),%rsi
call   1030 <utassert@plt>
lea    0xe8a(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <DFMkdirIfAbsent@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0x1,-0xc(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
lea    0xe90(%rip),%rsi
call   1030 <utassert@plt>
lea    0xe5f(%rip),%rdi
call   1050 <rmdir@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
lea    0xe87(%rip),%rsi
call   1030 <utassert@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_DFMkdirIfAbsent>:
push   %r14
push   %rbx
push   %rax
lea    0xec5(%rip),%rbx
mov    %rbx,%rdi
call   1050 <rmdir@plt>
mov    %rsp,%r14
mov    %rbx,%rdi
mov    %r14,%rsi
call   1040 <DFMkdirIfAbsent@plt>
xor    %edi,%edi
cmp    $0x1,%eax
sete   %dil
lea    0xeac(%rip),%rsi
call   1030 <utassert@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1040 <DFMkdirIfAbsent@plt>
xor    %edi,%edi
cmp    $0x1,%eax
sete   %dil
lea    0xea4(%rip),%rsi
call   1030 <utassert@plt>
mov    %rbx,%rdi
call   1050 <rmdir@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
lea    0xea6(%rip),%rsi
call   1030 <utassert@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [13 x i8] c"xxyz_testdir\00"
@.str.1 = [24 x i8] c"Cannot create directory\00"
@.str.2 = [30 x i8] c"Cannot use existing directory\00"
@.str.3 = [25 x i8] c"did not create directory\00"
define void @test_DFMkdirIfAbsent() {
%1 = alloca i8*
%2 = alloca i32
%3 = call i32 @rmdir(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @DFMkdirIfAbsent(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8** %1)
store i32 %4, i32* %2
%5 = load i32, i32* %2
%6 = icmp eq i32 %5, 1
%7 = zext i1 %6 to i32
%8 = call i32 @utassert(i32 %7, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0))
%9 = call i32 @DFMkdirIfAbsent(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8** %1)
store i32 %9, i32* %2
%10 = load i32, i32* %2
%11 = icmp eq i32 %10, 1
%12 = zext i1 %11 to i32
%13 = call i32 @utassert(i32 %12, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0))
%14 = call i32 @rmdir(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
store i32 %14, i32* %2
%15 = load i32, i32* %2
%16 = icmp eq i32 %15, 0
%17 = zext i1 %16 to i32
%18 = call i32 @utassert(i32 %17, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [13 x i8] c"xxyz_testdir\00"
@.str.1 = [24 x i8] c"Cannot create directory\00"
@.str.2 = [30 x i8] c"Cannot use existing directory\00"
@.str.3 = [25 x i8] c"did not create directory\00"
define void @test_DFMkdirIfAbsent() {
%1 = alloca i8*
%2 = bitcast i8** %1 to i8*
%3 = tail call i32 @rmdir(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @DFMkdirIfAbsent(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8** %1)
%5 = icmp eq i32 %4, 1
%6 = zext i1 %5 to i32
%7 = call i32 @utassert(i32 %6, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0))
%8 = call i32 @DFMkdirIfAbsent(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8** %1)
%9 = icmp eq i32 %8, 1
%10 = zext i1 %9 to i32
%11 = call i32 @utassert(i32 %10, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0))
%12 = call i32 @rmdir(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
%13 = icmp eq i32 %12, 0
%14 = zext i1 %13 to i32
%15 = call i32 @utassert(i32 %14, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0))
ret void
}