int save_buildroot() {
  char buildrootdir[512];
  char buildrootpackage[512];
  char buildrootproject[512];
  char directory[512];
  char commandstr[512];
  char project_name[512];
  int retval = 0;
  get_setting("project name", project_name);
  if (strlen(project_name) == 0)
    return -1;
  get_setting("directory", directory);
  sprintf(buildrootdir, "%s%c%s", directory, '/', "buildroot");
  if (directory_exists(buildrootdir) == 0) {
    sprintf(commandstr, "%s %s", "mkdir", buildrootdir);
    retval = system(commandstr);
  }
  sprintf(buildrootpackage, "%s%cpackage", buildrootdir, '/');
  if (directory_exists(buildrootpackage) == 0) {
    sprintf(commandstr, "%s %s", "mkdir", buildrootpackage);
    retval = system(commandstr);
  }
  sprintf(buildrootproject, "%s%c%s", buildrootpackage, '/', project_name);
  if (directory_exists(buildrootproject) == 0) {
    sprintf(commandstr, "%s %s", "mkdir", buildrootproject);
    retval = system(commandstr);
  }
  save_config_in(buildrootproject);
  save_makefile(buildrootproject);
  return retval;
}


x86 assembly (clang, -O0):
<save_buildroot>:
push   %rbp
mov    %rsp,%rbp
sub    $0xc20,%rsp
movl   $0x0,-0xc14(%rbp)
lea    -0xc10(%rbp),%rsi
lea    0xe6d(%rip),%rdi
mov    $0x0,%al
call   1060 <get_setting@plt>
lea    -0xc10(%rbp),%rdi
call   1030 <strlen@plt>
cmp    $0x0,%rax
jne    11bc <save_buildroot+0x4c>
movl   $0xffffffff,-0x4(%rbp)
jmp    1351 <save_buildroot+0x1e1>
lea    -0x810(%rbp),%rsi
lea    0xe43(%rip),%rdi
mov    $0x0,%al
call   1060 <get_setting@plt>
lea    -0x210(%rbp),%rdi
lea    -0x810(%rbp),%rdx
lea    0xe31(%rip),%rsi
mov    $0x2f,%ecx
lea    0xe2c(%rip),%r8
mov    $0x0,%al
call   1090 <sprintf@plt>
lea    -0x210(%rbp),%rdi
mov    $0x0,%al
call   1050 <directory_exists@plt>
cmp    $0x0,%eax
jne    1247 <save_buildroot+0xd7>
lea    -0xa10(%rbp),%rdi
lea    -0x210(%rbp),%rcx
lea    0xe03(%rip),%rsi
lea    0xe02(%rip),%rdx
mov    $0x0,%al
call   1090 <sprintf@plt>
lea    -0xa10(%rbp),%rdi
mov    $0x0,%al
call   1040 <system@plt>
mov    %eax,-0xc14(%rbp)
lea    -0x410(%rbp),%rdi
lea    -0x210(%rbp),%rdx
lea    0xdd8(%rip),%rsi
mov    $0x2f,%ecx
mov    $0x0,%al
call   1090 <sprintf@plt>
lea    -0x410(%rbp),%rdi
mov    $0x0,%al
call   1050 <directory_exists@plt>
cmp    $0x0,%eax
jne    12b6 <save_buildroot+0x146>
lea    -0xa10(%rbp),%rdi
lea    -0x410(%rbp),%rcx
lea    0xd94(%rip),%rsi
lea    0xd93(%rip),%rdx
mov    $0x0,%al
call   1090 <sprintf@plt>
lea    -0xa10(%rbp),%rdi
mov    $0x0,%al
call   1040 <system@plt>
mov    %eax,-0xc14(%rbp)
lea    -0x610(%rbp),%rdi
lea    -0x410(%rbp),%rdx
lea    -0xc10(%rbp),%r8
lea    0xd45(%rip),%rsi
mov    $0x2f,%ecx
mov    $0x0,%al
call   1090 <sprintf@plt>
lea    -0x610(%rbp),%rdi
mov    $0x0,%al
call   1050 <directory_exists@plt>
cmp    $0x0,%eax
jne    132c <save_buildroot+0x1bc>
lea    -0xa10(%rbp),%rdi
lea    -0x610(%rbp),%rcx
lea    0xd1e(%rip),%rsi
lea    0xd1d(%rip),%rdx
mov    $0x0,%al
call   1090 <sprintf@plt>
lea    -0xa10(%rbp),%rdi
mov    $0x0,%al
call   1040 <system@plt>
mov    %eax,-0xc14(%rbp)
lea    -0x610(%rbp),%rdi
mov    $0x0,%al
call   1070 <save_config_in@plt>
lea    -0x610(%rbp),%rdi
mov    $0x0,%al
call   1080 <save_makefile@plt>
mov    -0xc14(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0xc20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<save_buildroot>:
push   %rbp
push   %r14
push   %rbx
sub    $0xc00,%rsp
lea    0xe8e(%rip),%rdi
xor    %r14d,%r14d
mov    %rsp,%rsi
xor    %eax,%eax
call   1050 <get_setting@plt>
cmpb   $0x0,(%rsp)
je     1300 <save_buildroot+0x1a0>
lea    0xe7d(%rip),%rdi
lea    0xa00(%rsp),%rbx
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <get_setting@plt>
lea    0xe6e(%rip),%rsi
lea    0xe6e(%rip),%r8
lea    0x800(%rsp),%rbp
mov    %rbp,%rdi
mov    %rbx,%rdx
mov    $0x2f,%ecx
xor    %eax,%eax
call   1080 <sprintf@plt>
mov    %rbp,%rdi
xor    %eax,%eax
call   1040 <directory_exists@plt>
test   %eax,%eax
jne    120d <save_buildroot+0xad>
lea    0xe49(%rip),%rsi
lea    0xe48(%rip),%rdx
lea    0x200(%rsp),%rbx
lea    0x800(%rsp),%rcx
mov    %rbx,%rdi
xor    %eax,%eax
call   1080 <sprintf@plt>
mov    %rbx,%rdi
xor    %eax,%eax
call   1030 <system@plt>
mov    %eax,%r14d
lea    0xe20(%rip),%rsi
lea    0x600(%rsp),%rbx
lea    0x800(%rsp),%rdx
mov    %rbx,%rdi
mov    $0x2f,%ecx
xor    %eax,%eax
call   1080 <sprintf@plt>
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <directory_exists@plt>
test   %eax,%eax
jne    1276 <save_buildroot+0x116>
lea    0xde0(%rip),%rsi
lea    0xddf(%rip),%rdx
lea    0x200(%rsp),%rbx
lea    0x600(%rsp),%rcx
mov    %rbx,%rdi
xor    %eax,%eax
call   1080 <sprintf@plt>
mov    %rbx,%rdi
xor    %eax,%eax
call   1030 <system@plt>
mov    %eax,%r14d
lea    0xd9a(%rip),%rsi
lea    0x400(%rsp),%rbx
lea    0x600(%rsp),%rdx
mov    %rsp,%r8
mov    %rbx,%rdi
mov    $0x2f,%ecx
xor    %eax,%eax
call   1080 <sprintf@plt>
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <directory_exists@plt>
test   %eax,%eax
jne    12e2 <save_buildroot+0x182>
lea    0xd74(%rip),%rsi
lea    0xd73(%rip),%rdx
lea    0x200(%rsp),%rbx
lea    0x400(%rsp),%rcx
mov    %rbx,%rdi
xor    %eax,%eax
call   1080 <sprintf@plt>
mov    %rbx,%rdi
xor    %eax,%eax
call   1030 <system@plt>
mov    %eax,%r14d
lea    0x400(%rsp),%rbx
mov    %rbx,%rdi
xor    %eax,%eax
call   1060 <save_config_in@plt>
mov    %rbx,%rdi
xor    %eax,%eax
call   1070 <save_makefile@plt>
jmp    1306 <save_buildroot+0x1a6>
mov    $0xffffffff,%r14d
mov    %r14d,%eax
add    $0xc00,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [13 x i8] c"project name\00"
@.str.1 = [10 x i8] c"directory\00"
@.str.2 = [7 x i8] c"%s%c%s\00"
@.str.3 = [10 x i8] c"buildroot\00"
@.str.4 = [6 x i8] c"%s %s\00"
@.str.5 = [6 x i8] c"mkdir\00"
@.str.6 = [12 x i8] c"%s%cpackage\00"
define i32 @save_buildroot() {
%1 = alloca i32
%2 = alloca [512 x i8]
%3 = alloca [512 x i8]
%4 = alloca [512 x i8]
%5 = alloca [512 x i8]
%6 = alloca [512 x i8]
%7 = alloca [512 x i8]
%8 = alloca i32
store i32 0, i32* %8
%9 = getelementptr inbounds [512 x i8], [512 x i8]* %7, i64 0, i64 0
%10 = call i32 (i8*, i8*, ...) bitcast (i32 (...)* @get_setting to i32 (i8*, i8*, ...)*)(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* %9)
%11 = getelementptr inbounds [512 x i8], [512 x i8]* %7, i64 0, i64 0
%12 = call i64 @strlen(i8* %11)
%13 = icmp eq i64 %12, 0
br i1 %13, label %14, label %15
14: ; preds = %0
store i32 -1, i32* %1
br label %63
15: ; preds = %0
%16 = getelementptr inbounds [512 x i8], [512 x i8]* %5, i64 0, i64 0
%17 = call i32 (i8*, i8*, ...) bitcast (i32 (...)* @get_setting to i32 (i8*, i8*, ...)*)(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8* %16)
%18 = getelementptr inbounds [512 x i8], [512 x i8]* %2, i64 0, i64 0
%19 = getelementptr inbounds [512 x i8], [512 x i8]* %5, i64 0, i64 0
%20 = call i32 (i8*, i8*, ...) @sprintf(i8* %18, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i8* %19, i32 47, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0))
%21 = getelementptr inbounds [512 x i8], [512 x i8]* %2, i64 0, i64 0
%22 = call i32 (i8*, ...) bitcast (i32 (...)* @directory_exists to i32 (i8*, ...)*)(i8* %21)
%23 = icmp eq i32 %22, 0
br i1 %23, label %24, label %30
24: ; preds = %15
%25 = getelementptr inbounds [512 x i8], [512 x i8]* %6, i64 0, i64 0
%26 = getelementptr inbounds [512 x i8], [512 x i8]* %2, i64 0, i64 0
%27 = call i32 (i8*, i8*, ...) @sprintf(i8* %25, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0), i8* %26)
%28 = getelementptr inbounds [512 x i8], [512 x i8]* %6, i64 0, i64 0
%29 = call i32 (i8*, ...) bitcast (i32 (...)* @system to i32 (i8*, ...)*)(i8* %28)
store i32 %29, i32* %8
br label %30
30: ; preds = %24, %15
%31 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 0
%32 = getelementptr inbounds [512 x i8], [512 x i8]* %2, i64 0, i64 0
%33 = call i32 (i8*, i8*, ...) @sprintf(i8* %31, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.6, i64 0, i64 0), i8* %32, i32 47)
%34 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 0
%35 = call i32 (i8*, ...) bitcast (i32 (...)* @directory_exists to i32 (i8*, ...)*)(i8* %34)
%36 = icmp eq i32 %35, 0
br i1 %36, label %37, label %43
37: ; preds = %30
%38 = getelementptr inbounds [512 x i8], [512 x i8]* %6, i64 0, i64 0
%39 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 0
%40 = call i32 (i8*, i8*, ...) @sprintf(i8* %38, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0), i8* %39)
%41 = getelementptr inbounds [512 x i8], [512 x i8]* %6, i64 0, i64 0
%42 = call i32 (i8*, ...) bitcast (i32 (...)* @system to i32 (i8*, ...)*)(i8* %41)
store i32 %42, i32* %8
br label %43
43: ; preds = %37, %30
%44 = getelementptr inbounds [512 x i8], [512 x i8]* %4, i64 0, i64 0
%45 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 0
%46 = getelementptr inbounds [512 x i8], [512 x i8]* %7, i64 0, i64 0
%47 = call i32 (i8*, i8*, ...) @sprintf(i8* %44, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i8* %45, i32 47, i8* %46)
%48 = getelementptr inbounds [512 x i8], [512 x i8]* %4, i64 0, i64 0
%49 = call i32 (i8*, ...) bitcast (i32 (...)* @directory_exists to i32 (i8*, ...)*)(i8* %48)
%50 = icmp eq i32 %49, 0
br i1 %50, label %51, label %57
51: ; preds = %43
%52 = getelementptr inbounds [512 x i8], [512 x i8]* %6, i64 0, i64 0
%53 = getelementptr inbounds [512 x i8], [512 x i8]* %4, i64 0, i64 0
%54 = call i32 (i8*, i8*, ...) @sprintf(i8* %52, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0), i8* %53)
%55 = getelementptr inbounds [512 x i8], [512 x i8]* %6, i64 0, i64 0
%56 = call i32 (i8*, ...) bitcast (i32 (...)* @system to i32 (i8*, ...)*)(i8* %55)
store i32 %56, i32* %8
br label %57
57: ; preds = %51, %43
%58 = getelementptr inbounds [512 x i8], [512 x i8]* %4, i64 0, i64 0
%59 = call i32 (i8*, ...) bitcast (i32 (...)* @save_config_in to i32 (i8*, ...)*)(i8* %58)
%60 = getelementptr inbounds [512 x i8], [512 x i8]* %4, i64 0, i64 0
%61 = call i32 (i8*, ...) bitcast (i32 (...)* @save_makefile to i32 (i8*, ...)*)(i8* %60)
%62 = load i32, i32* %8
store i32 %62, i32* %1
br label %63
63: ; preds = %57, %14
%64 = load i32, i32* %1
ret i32 %64
}

LLVM IR (-O2):
@.str = [13 x i8] c"project name\00"
@.str.1 = [10 x i8] c"directory\00"
@.str.2 = [7 x i8] c"%s%c%s\00"
@.str.3 = [10 x i8] c"buildroot\00"
@.str.4 = [6 x i8] c"%s %s\00"
@.str.5 = [6 x i8] c"mkdir\00"
@.str.6 = [12 x i8] c"%s%cpackage\00"
define i32 @save_buildroot() {
%1 = alloca [512 x i8]
%2 = alloca [512 x i8]
%3 = alloca [512 x i8]
%4 = alloca [512 x i8]
%5 = alloca [512 x i8]
%6 = alloca [512 x i8]
%7 = getelementptr inbounds [512 x i8], [512 x i8]* %1, i64 0, i64 0
%8 = getelementptr inbounds [512 x i8], [512 x i8]* %2, i64 0, i64 0
%9 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 0
%10 = getelementptr inbounds [512 x i8], [512 x i8]* %4, i64 0, i64 0
%11 = getelementptr inbounds [512 x i8], [512 x i8]* %5, i64 0, i64 0
%12 = getelementptr inbounds [512 x i8], [512 x i8]* %6, i64 0, i64 0
%13 = call i32 (i8*, i8*, ...) bitcast (i32 (...)* @get_setting to i32 (i8*, i8*, ...)*)(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8* %12)
%14 = load i8, i8* %12
%15 = icmp eq i8 %14, 0
br i1 %15, label %44, label %16
16: ; preds = %0
%17 = call i32 (i8*, i8*, ...) bitcast (i32 (...)* @get_setting to i32 (i8*, i8*, ...)*)(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8* %10)
%18 = call i32 (i8*, i8*, ...) @sprintf(i8* %7, i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i8* %10, i32 47, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0))
%19 = call i32 (i8*, ...) bitcast (i32 (...)* @directory_exists to i32 (i8*, ...)*)(i8* %7)
%20 = icmp eq i32 %19, 0
br i1 %20, label %21, label %24
21: ; preds = %16
%22 = call i32 (i8*, i8*, ...) @sprintf(i8* %11, i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0), i8* %7)
%23 = call i32 (i8*, ...) bitcast (i32 (...)* @system to i32 (i8*, ...)*)(i8* %11)
br label %24
24: ; preds = %21, %16
%25 = phi i32 [ %23, %21 ], [ 0, %16 ]
%26 = call i32 (i8*, i8*, ...) @sprintf(i8* %8, i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.6, i64 0, i64 0), i8* %7, i32 47)
%27 = call i32 (i8*, ...) bitcast (i32 (...)* @directory_exists to i32 (i8*, ...)*)(i8* %8)
%28 = icmp eq i32 %27, 0
br i1 %28, label %29, label %32
29: ; preds = %24
%30 = call i32 (i8*, i8*, ...) @sprintf(i8* %11, i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0), i8* %8)
%31 = call i32 (i8*, ...) bitcast (i32 (...)* @system to i32 (i8*, ...)*)(i8* %11)
br label %32
32: ; preds = %29, %24
%33 = phi i32 [ %31, %29 ], [ %25, %24 ]
%34 = call i32 (i8*, i8*, ...) @sprintf(i8* %9, i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i8* %8, i32 47, i8* %12)
%35 = call i32 (i8*, ...) bitcast (i32 (...)* @directory_exists to i32 (i8*, ...)*)(i8* %9)
%36 = icmp eq i32 %35, 0
br i1 %36, label %37, label %40
37: ; preds = %32
%38 = call i32 (i8*, i8*, ...) @sprintf(i8* %11, i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0), i8* %9)
%39 = call i32 (i8*, ...) bitcast (i32 (...)* @system to i32 (i8*, ...)*)(i8* %11)
br label %40
40: ; preds = %37, %32
%41 = phi i32 [ %39, %37 ], [ %33, %32 ]
%42 = call i32 (i8*, ...) bitcast (i32 (...)* @save_config_in to i32 (i8*, ...)*)(i8* %9)
%43 = call i32 (i8*, ...) bitcast (i32 (...)* @save_makefile to i32 (i8*, ...)*)(i8* %9)
br label %44
44: ; preds = %0, %40
%45 = phi i32 [ %41, %40 ], [ -1, %0 ]
ret i32 %45
}