#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;

/* Variables and functions */
int access(char const *, int /*<<< orphan*/);
int mkdir(char const *, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, char const *);
void create_folder(const char *foldername, mode_t mode) {
  int is_exist = access(foldername, 0);
  if (is_exist == -1) {
    int success = mkdir(foldername, mode);
    if (success == -1) {
      printf("Error - can't create folder: %s\n", foldername);
    }
  }
}


x86 assembly (clang, -O0):
<create_folder>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
xor    %esi,%esi
call   1050 <access@plt>
mov    %eax,-0x10(%rbp)
cmpl   $0xffffffff,-0x10(%rbp)
jne    1185 <create_folder+0x55>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
call   1030 <mkdir@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0xffffffff,-0x14(%rbp)
jne    1180 <create_folder+0x50>
mov    -0x8(%rbp),%rsi
lea    0xe85(%rip),%rdi
call   1040 <printf@plt>
jmp    1185 <create_folder+0x55>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<create_folder>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebp
mov    %rdi,%rbx
xor    %esi,%esi
call   1050 <access@plt>
cmp    $0xffffffff,%eax
jne    1153 <create_folder+0x23>
mov    %rbx,%rdi
mov    %ebp,%esi
call   1030 <mkdir@plt>
cmp    $0xffffffff,%eax
je     115a <create_folder+0x2a>
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret
lea    0xe9f(%rip),%rdi
mov    %rbx,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1040 <printf@plt>

LLVM IR (-O0):
@.str = [33 x i8] c"Error - can't create folder: %s\0A\00"
define void @create_folder(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i8* %0, i8** %3
store i32 %1, i32* %4
%7 = load i8*, i8** %3
%8 = call i32 @access(i8* %7, i32 0)
store i32 %8, i32* %5
%9 = load i32, i32* %5
%10 = icmp eq i32 %9, -1
br i1 %10, label %11, label %21
11: ; preds = %2
%12 = load i8*, i8** %3
%13 = load i32, i32* %4
%14 = call i32 @mkdir(i8* %12, i32 %13)
store i32 %14, i32* %6
%15 = load i32, i32* %6
%16 = icmp eq i32 %15, -1
br i1 %16, label %17, label %20
17: ; preds = %11
%18 = load i8*, i8** %3
%19 = call i32 @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), i8* %18)
br label %20
20: ; preds = %17, %11
br label %21
21: ; preds = %20, %2
ret void
}

LLVM IR (-O2):
@.str = [33 x i8] c"Error - can't create folder: %s\0A\00"
define void @create_folder(i8* %0, i32 %1) {
%3 = tail call i32 @access(i8* %0, i32 0)
%4 = icmp eq i32 %3, -1
br i1 %4, label %5, label %10
5: ; preds = %2
%6 = tail call i32 @mkdir(i8* %0, i32 %1)
%7 = icmp eq i32 %6, -1
br i1 %7, label %8, label %10
8: ; preds = %5
%9 = tail call i32 @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), i8* %0)
br label %10
10: ; preds = %5, %8, %2
ret void
}