#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 errno;
int mkdir(char *, int);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ rmdir(char *);
int main() {
  int x = mkdir("testmakedir", 077);
  if (x != 0)
    printf("mkdir1 failed with error no:%d ", errno);
  int y = mkdir("testmakedir2", 077);
  if (y != 0)
    printf("mkdir2 failed with error no:%d ", errno);
  rmdir("testmakedir");
  rmdir("testmakedir2");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeba(%rip),%rdi
mov    $0x3f,%esi
call   1030 <mkdir@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
je     1172 <main+0x42>
mov    0x2e7c(%rip),%rax
mov    (%rax),%esi
lea    0xe9f(%rip),%rdi
call   1050 <printf@plt>
lea    0xeb3(%rip),%rdi
mov    $0x3f,%esi
call   1030 <mkdir@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
je     11a5 <main+0x75>
mov    0x2e49(%rip),%rax
mov    (%rax),%esi
lea    0xe99(%rip),%rdi
call   1050 <printf@plt>
lea    0xe54(%rip),%rdi
call   1040 <rmdir@plt>
lea    0xe74(%rip),%rdi
call   1040 <rmdir@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xec8(%rip),%rdi
mov    $0x3f,%esi
call   1030 <mkdir@plt>
test   %eax,%eax
je     115b <main+0x2b>
mov    0x2e93(%rip),%rax
mov    (%rax),%esi
lea    0xeb6(%rip),%rdi
call   1050 <printf@plt>
lea    0xeca(%rip),%rdi
mov    $0x3f,%esi
call   1030 <mkdir@plt>
test   %eax,%eax
je     1185 <main+0x55>
mov    0x2e69(%rip),%rax
mov    (%rax),%esi
lea    0xeb9(%rip),%rdi
call   1050 <printf@plt>
lea    0xe74(%rip),%rdi
call   1040 <rmdir@plt>
lea    0xe94(%rip),%rdi
call   1040 <rmdir@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [12 x i8] c"testmakedir\00"
@.str.1 = [32 x i8] c"mkdir1 failed with error no:%d \00"
@errno = global i32 0
@.str.2 = [13 x i8] c"testmakedir2\00"
@.str.3 = [32 x i8] c"mkdir2 failed with error no:%d \00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
store i32 0, i32* %1
%4 = call i32 @mkdir(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 63)
store i32 %4, i32* %2
%5 = load i32, i32* %2
%6 = icmp ne i32 %5, 0
br i1 %6, label %7, label %10
7: ; preds = %0
%8 = load i32, i32* @errno
%9 = call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0), i32 %8)
br label %10
10: ; preds = %7, %0
%11 = call i32 @mkdir(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i32 63)
store i32 %11, i32* %3
%12 = load i32, i32* %3
%13 = icmp ne i32 %12, 0
br i1 %13, label %14, label %17
14: ; preds = %10
%15 = load i32, i32* @errno
%16 = call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.3, i64 0, i64 0), i32 %15)
br label %17
17: ; preds = %14, %10
%18 = call i32 @rmdir(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
%19 = call i32 @rmdir(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str = [12 x i8] c"testmakedir\00"
@.str.1 = [32 x i8] c"mkdir1 failed with error no:%d \00"
@errno = global i32 0
@.str.2 = [13 x i8] c"testmakedir2\00"
@.str.3 = [32 x i8] c"mkdir2 failed with error no:%d \00"
define i32 @main() {
%1 = tail call i32 @mkdir(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 63)
%2 = icmp eq i32 %1, 0
br i1 %2, label %6, label %3
3: ; preds = %0
%4 = load i32, i32* @errno
%5 = tail call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.1, i64 0, i64 0), i32 %4)
br label %6
6: ; preds = %3, %0
%7 = tail call i32 @mkdir(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i32 63)
%8 = icmp eq i32 %7, 0
br i1 %8, label %12, label %9
9: ; preds = %6
%10 = load i32, i32* @errno
%11 = tail call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.3, i64 0, i64 0), i32 %10)
br label %12
12: ; preds = %9, %6
%13 = tail call i32 @rmdir(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
%14 = tail call i32 @rmdir(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0))
ret i32 0
}