#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*/ g_chmod_hex(char *, int);
int /*<<< orphan*/ g_create_dir(char *);
int /*<<< orphan*/ g_directory_exist(char *);
int /*<<< orphan*/ printf(char *);
int g_mk_temp_dir(const char *app_name) {
  if (!g_directory_exist("/tmp/.xrdp")) {
    if (!g_create_dir("/tmp/.xrdp")) {
      if (!g_directory_exist("/tmp/.xrdp")) {
        printf("g_mk_temp_dir: g_create_dir failed\n");
        return 1;
      }
    }
    g_chmod_hex("/tmp/.xrdp", 0x1777);
  }
  return 0;
}


x86 assembly (clang, -O0):
<g_mk_temp_dir>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x10(%rbp)
lea    0xead(%rip),%rdi
call   1040 <g_directory_exist@plt>
cmp    $0x0,%eax
jne    11b9 <g_mk_temp_dir+0x79>
lea    0xe98(%rip),%rdi
call   1030 <g_create_dir@plt>
cmp    $0x0,%eax
jne    11a8 <g_mk_temp_dir+0x68>
lea    0xe83(%rip),%rdi
call   1040 <g_directory_exist@plt>
cmp    $0x0,%eax
jne    11a3 <g_mk_temp_dir+0x63>
lea    0xe79(%rip),%rdi
call   1050 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    11c0 <g_mk_temp_dir+0x80>
jmp    11a8 <g_mk_temp_dir+0x68>
lea    0xe51(%rip),%rdi
mov    $0x1777,%esi
call   1060 <g_chmod_hex@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<g_mk_temp_dir>:
push   %rbx
lea    0xeb8(%rip),%rdi
call   1050 <g_directory_exist@plt>
xor    %ebx,%ebx
test   %eax,%eax
jne    1184 <g_mk_temp_dir+0x44>
lea    0xea6(%rip),%rdi
call   1040 <g_create_dir@plt>
test   %eax,%eax
jne    1173 <g_mk_temp_dir+0x33>
lea    0xe96(%rip),%rdi
call   1050 <g_directory_exist@plt>
test   %eax,%eax
je     1188 <g_mk_temp_dir+0x48>
lea    0xe86(%rip),%rdi
mov    $0x1777,%esi
call   1060 <g_chmod_hex@plt>
mov    %ebx,%eax
pop    %rbx
ret
lea    0xe7c(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%ebx
jmp    1184 <g_mk_temp_dir+0x44>

LLVM IR (-O0):
@.str = [11 x i8] c"/tmp/.xrdp\00"
@.str.1 = [36 x i8] c"g_mk_temp_dir: g_create_dir failed\0A\00"
define i32 @g_mk_temp_dir(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
store i8* %0, i8** %3
%4 = call i32 @g_directory_exist(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%5 = icmp ne i32 %4, 0
br i1 %5, label %17, label %6
6: ; preds = %1
%7 = call i32 @g_create_dir(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%8 = icmp ne i32 %7, 0
br i1 %8, label %15, label %9
9: ; preds = %6
%10 = call i32 @g_directory_exist(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%11 = icmp ne i32 %10, 0
br i1 %11, label %14, label %12
12: ; preds = %9
%13 = call i32 @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.1, i64 0, i64 0))
store i32 1, i32* %2
br label %18
14: ; preds = %9
br label %15
15: ; preds = %14, %6
%16 = call i32 @g_chmod_hex(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 6007)
br label %17
17: ; preds = %15, %1
store i32 0, i32* %2
br label %18
18: ; preds = %17, %12
%19 = load i32, i32* %2
ret i32 %19
}

LLVM IR (-O2):
@.str = [11 x i8] c"/tmp/.xrdp\00"
@str = [35 x i8] c"g_mk_temp_dir: g_create_dir failed\00"
define i32 @g_mk_temp_dir(i8* nocapture readnone %0) {
%2 = tail call i32 @g_directory_exist(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%3 = icmp eq i32 %2, 0
br i1 %3, label %4, label %14
4: ; preds = %1
%5 = tail call i32 @g_create_dir(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%6 = icmp eq i32 %5, 0
br i1 %6, label %7, label %12
7: ; preds = %4
%8 = tail call i32 @g_directory_exist(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%9 = icmp eq i32 %8, 0
br i1 %9, label %10, label %12
10: ; preds = %7
%11 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @str, i64 0, i64 0))
br label %14
12: ; preds = %7, %4
%13 = tail call i32 @g_chmod_hex(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 6007)
br label %14
14: ; preds = %1, %12, %10
%15 = phi i32 [ 1, %10 ], [ 0, %12 ], [ 0, %1 ]
ret i32 %15
}