#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 */
typedef int /*<<< orphan*/ mode_t;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int EEXIST;
int /*<<< orphan*/ errno;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, int);
int mkdir(char *, int /*<<< orphan*/);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ stderr;
void untar_create_directory_(char *fullpath, mode_t mode, int filesize,
                             FILE *fp) {
  int result = mkdir(fullpath, mode);
  if (result != 0) {
    if (!errno == EEXIST)
      fprintf(stderr, "Could not create directory %s (%d)\n", fullpath, result);
    perror("having trouble creating directory");
    return;
  }
}


x86 assembly (clang, -O0):
<untar_create_directory_>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %rcx,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
call   1030 <mkdir@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
je     11aa <untar_create_directory_+0x7a>
mov    0x2e6a(%rip),%rax
cmpl   $0x0,(%rax)
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%eax
mov    0x2e66(%rip),%rcx
cmp    (%rcx),%eax
jne    119e <untar_create_directory_+0x6e>
mov    0x2e4f(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
mov    -0x1c(%rbp),%ecx
lea    0xe67(%rip),%rsi
call   1040 <fprintf@plt>
lea    0xe7f(%rip),%rdi
call   1050 <perror@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<untar_create_directory_>:
push   %rbx
mov    %rdi,%rbx
call   1030 <mkdir@plt>
test   %eax,%eax
jne    113f <untar_create_directory_+0xf>
pop    %rbx
ret
mov    0x2e8a(%rip),%rcx
xor    %edx,%edx
cmpl   $0x0,(%rcx)
sete   %dl
mov    0x2e8b(%rip),%rcx
cmp    %edx,(%rcx)
jne    1173 <untar_create_directory_+0x43>
mov    0x2e78(%rip),%rcx
mov    (%rcx),%edi
lea    0xe97(%rip),%rsi
mov    %rbx,%rdx
mov    %eax,%ecx
call   1040 <fprintf@plt>
lea    0xeaa(%rip),%rdi
pop    %rbx
jmp    1050 <perror@plt>

LLVM IR (-O0):
@errno = global i32 0
@EEXIST = global i32 0
@stderr = global i32 0
@.str = [36 x i8] c"Could not create directory %s (%d)\0A\00"
@.str.1 = [34 x i8] c"having trouble creating directory\00"
define void @untar_create_directory_(i8* %0, i32 %1, i32 %2, i32* %3) {
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32*
%9 = alloca i32
store i8* %0, i8** %5
store i32 %1, i32* %6
store i32 %2, i32* %7
store i32* %3, i32** %8
%10 = load i8*, i8** %5
%11 = load i32, i32* %6
%12 = call i32 @mkdir(i8* %10, i32 %11)
store i32 %12, i32* %9
%13 = load i32, i32* %9
%14 = icmp ne i32 %13, 0
br i1 %14, label %15, label %29
15: ; preds = %4
%16 = load i32, i32* @errno
%17 = icmp ne i32 %16, 0
%18 = xor i1 %17, true
%19 = zext i1 %18 to i32
%20 = load i32, i32* @EEXIST
%21 = icmp eq i32 %19, %20
br i1 %21, label %22, label %27
22: ; preds = %15
%23 = load i32, i32* @stderr
%24 = load i8*, i8** %5
%25 = load i32, i32* %9
%26 = call i32 @fprintf(i32 %23, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0), i8* %24, i32 %25)
br label %27
27: ; preds = %22, %15
%28 = call i32 @perror(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0))
br label %29
29: ; preds = %27, %4
ret void
}

LLVM IR (-O2):
@errno = global i32 0
@EEXIST = global i32 0
@stderr = global i32 0
@.str = [36 x i8] c"Could not create directory %s (%d)\0A\00"
@.str.1 = [34 x i8] c"having trouble creating directory\00"
define void @untar_create_directory_(i8* %0, i32 %1, i32 %2, i32* nocapture readnone %3) {
%5 = tail call i32 @mkdir(i8* %0, i32 %1)
%6 = icmp eq i32 %5, 0
br i1 %6, label %18, label %7
7: ; preds = %4
%8 = load i32, i32* @errno
%9 = icmp eq i32 %8, 0
%10 = zext i1 %9 to i32
%11 = load i32, i32* @EEXIST
%12 = icmp eq i32 %11, %10
br i1 %12, label %13, label %16
13: ; preds = %7
%14 = load i32, i32* @stderr
%15 = tail call i32 @fprintf(i32 %14, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0), i8* %0, i32 %5)
br label %16
16: ; preds = %13, %7
%17 = tail call i32 @perror(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0))
br label %18
18: ; preds = %4, %16
ret void
}