#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 */
char *concat_strings(char *, char *);
char *enquote_string(char const *);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ printf(char *, char const *);
int system(char *);
int create_folder(const char *folder) {
  char *quoted = enquote_string(folder);
  char *cmd = concat_strings("mkdir ", quoted);
  int err = system(cmd);
  free(cmd);
  free(quoted);
  if (!err)
    printf("Folder '%s' created.\n", folder);
  return err;
}


x86 assembly (clang, -O0):
<create_folder>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <enquote_string@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rsi
lea    0xe8c(%rip),%rdi
call   1070 <concat_strings@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1050 <system@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
cmpl   $0x0,-0x1c(%rbp)
jne    11b5 <create_folder+0x65>
mov    -0x8(%rbp),%rsi
lea    0xe57(%rip),%rdi
call   1060 <printf@plt>
mov    -0x1c(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<create_folder>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
call   1040 <enquote_string@plt>
mov    %rax,%rbx
lea    0xe97(%rip),%rdi
mov    %rax,%rsi
call   1070 <concat_strings@plt>
mov    %rax,%rbp
mov    %rax,%rdi
call   1050 <system@plt>
mov    %eax,%r15d
mov    %rbp,%rdi
call   1030 <free@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
test   %r15d,%r15d
jne    11a3 <create_folder+0x53>
lea    0xe6c(%rip),%rdi
mov    %r14,%rsi
call   1060 <printf@plt>
mov    %r15d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [7 x i8] c"mkdir \00"
@.str.1 = [22 x i8] c"Folder '%s' created.\0A\00"
define i32 @create_folder(i8* %0) {
%2 = tail call i8* @enquote_string(i8* %0)
%3 = tail call i8* @concat_strings(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* %2)
%4 = tail call i32 @system(i8* %3)
%5 = tail call i32 @free(i8* %3)
%6 = tail call i32 @free(i8* %2)
%7 = icmp eq i32 %4, 0
br i1 %7, label %8, label %10
8: ; preds = %1
%9 = tail call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i8* %0)
br label %10
10: ; preds = %8, %1
ret i32 %4
}