#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 stat {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ S_IRWXU;
scalar_t__ mkdir(char *, int /*<<< orphan*/);
int /*<<< orphan*/ s_free(char *);
char *sosc_get_config_directory();
int /*<<< orphan*/ stat(char *, struct stat *);
int sosc_config_create_directory() {
  struct stat buf[1];
  char *cdir;
  cdir = sosc_get_config_directory();
  if (!stat(cdir, buf))
    return 0;
  if (mkdir(cdir, S_IRWXU))
    goto err_mkdir;
  s_free(cdir);
  return 0;
err_mkdir:
  s_free(cdir);
  return 1;
}


x86 assembly (clang, -O0):
<sosc_config_create_directory>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x0,%al
call   1060 <sosc_get_config_directory@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x8(%rbp),%rsi
call   1050 <stat@plt>
cmp    $0x0,%eax
jne    1175 <sosc_config_create_directory+0x35>
movl   $0x0,-0x4(%rbp)
jmp    11bb <sosc_config_create_directory+0x7b>
mov    -0x10(%rbp),%rdi
mov    0x2e68(%rip),%rax
mov    (%rax),%esi
call   1040 <mkdir@plt>
cmp    $0x0,%rax
je     1196 <sosc_config_create_directory+0x56>
jmp    11ab <sosc_config_create_directory+0x6b>
mov    -0x10(%rbp),%rdi
call   1030 <s_free@plt>
movl   $0x0,-0x4(%rbp)
jmp    11bb <sosc_config_create_directory+0x7b>
mov    -0x10(%rbp),%rdi
call   1030 <s_free@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sosc_config_create_directory>:
push   %r14
push   %rbx
push   %rax
xor    %ebx,%ebx
xor    %eax,%eax
call   1060 <sosc_get_config_directory@plt>
mov    %rax,%r14
mov    %rsp,%rsi
mov    %rax,%rdi
call   1050 <stat@plt>
test   %eax,%eax
je     1180 <sosc_config_create_directory+0x40>
mov    0x2e82(%rip),%rax
mov    (%rax),%esi
mov    %r14,%rdi
call   1040 <mkdir@plt>
xor    %ebx,%ebx
test   %rax,%rax
setne  %bl
mov    %r14,%rdi
call   1030 <s_free@plt>
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.stat = type { i32 }
@S_IRWXU = global i32 0
define i32 @sosc_config_create_directory() {
%1 = alloca i32
%2 = alloca [1 x %struct.stat]
%3 = alloca i8*
%4 = call i8* (...) @sosc_get_config_directory()
store i8* %4, i8** %3
%5 = load i8*, i8** %3
%6 = getelementptr inbounds [1 x %struct.stat], [1 x %struct.stat]* %2, i64 0, i64 0
%7 = call i32 @stat(i8* %5, %struct.stat* %6)
%8 = icmp ne i32 %7, 0
br i1 %8, label %10, label %9
9: ; preds = %0
store i32 0, i32* %1
br label %22
10: ; preds = %0
%11 = load i8*, i8** %3
%12 = load i32, i32* @S_IRWXU
%13 = call i64 @mkdir(i8* %11, i32 %12)
%14 = icmp ne i64 %13, 0
br i1 %14, label %15, label %16
15: ; preds = %10
br label %19
16: ; preds = %10
%17 = load i8*, i8** %3
%18 = call i32 @s_free(i8* %17)
store i32 0, i32* %1
br label %22
19: ; preds = %15
%20 = load i8*, i8** %3
%21 = call i32 @s_free(i8* %20)
store i32 1, i32* %1
br label %22
22: ; preds = %19, %16, %9
%23 = load i32, i32* %1
ret i32 %23
}

LLVM IR (-O2):
%struct.stat = type { i32 }
@S_IRWXU = global i32 0
define i32 @sosc_config_create_directory() {
%1 = alloca [1 x %struct.stat]
%2 = bitcast [1 x %struct.stat]* %1 to i8*
%3 = tail call i8* (...) @sosc_get_config_directory()
%4 = getelementptr inbounds [1 x %struct.stat], [1 x %struct.stat]* %1, i64 0, i64 0
%5 = call i32 @stat(i8* %3, %struct.stat* %4)
%6 = icmp eq i32 %5, 0
br i1 %6, label %13, label %7
7: ; preds = %0
%8 = load i32, i32* @S_IRWXU
%9 = tail call i64 @mkdir(i8* %3, i32 %8)
%10 = icmp ne i64 %9, 0
%11 = tail call i32 @s_free(i8* %3)
%12 = zext i1 %10 to i32
br label %13
13: ; preds = %7, %0
%14 = phi i32 [ 0, %0 ], [ %12, %7 ]
ret i32 %14
}