#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*/ assert(int);
int errno;
int /*<<< orphan*/ mkdir(char *, int);
int /*<<< orphan*/ opendir(char *);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ rmdir(char *);
int main() {
  mkdir("testmakedir", 077);
  printf("errno:%d \n", errno);
  assert(errno == 0);
  mkdir("testmakedir2", 077);
  printf("errno:%d \n", errno);
  assert(errno == 0);
  opendir("testmakedir");
  printf("errno:%d \n", errno);
  assert(errno == 0);
  opendir("testmakedir2");
  printf("errno:%d \n", errno);
  assert(errno == 0);
  rmdir("testmakedir");
  assert(errno == 0);
  rmdir("testmakedir2");
  assert(errno == 0);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe9a(%rip),%rdi
mov    $0x3f,%esi
call   1030 <mkdir@plt>
mov    0x2e69(%rip),%rax
mov    (%rax),%esi
lea    0xe8c(%rip),%rdi
call   1060 <printf@plt>
mov    0x2e54(%rip),%rax
cmpl   $0x0,(%rax)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1070 <assert@plt>
lea    0xe74(%rip),%rdi
mov    $0x3f,%esi
call   1030 <mkdir@plt>
mov    0x2e2c(%rip),%rax
mov    (%rax),%esi
lea    0xe4f(%rip),%rdi
call   1060 <printf@plt>
mov    0x2e17(%rip),%rax
cmpl   $0x0,(%rax)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1070 <assert@plt>
lea    0xe20(%rip),%rdi
call   1040 <opendir@plt>
mov    0x2df4(%rip),%rax
mov    (%rax),%esi
lea    0xe17(%rip),%rdi
call   1060 <printf@plt>
mov    0x2ddf(%rip),%rax
cmpl   $0x0,(%rax)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1070 <assert@plt>
lea    0xdff(%rip),%rdi
call   1040 <opendir@plt>
mov    0x2dbc(%rip),%rax
mov    (%rax),%esi
lea    0xddf(%rip),%rdi
call   1060 <printf@plt>
mov    0x2da7(%rip),%rax
cmpl   $0x0,(%rax)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1070 <assert@plt>
lea    0xdb0(%rip),%rdi
call   1050 <rmdir@plt>
mov    0x2d84(%rip),%rax
cmpl   $0x0,(%rax)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1070 <assert@plt>
lea    0xda4(%rip),%rdi
call   1050 <rmdir@plt>
mov    0x2d61(%rip),%rax
cmpl   $0x0,(%rax)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1070 <assert@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
lea    0xea1(%rip),%r14
mov    %r14,%rdi
mov    $0x3f,%esi
call   1030 <mkdir@plt>
mov    0x2e6d(%rip),%rbx
mov    (%rbx),%esi
lea    0xe90(%rip),%r12
mov    %r12,%rdi
call   1060 <printf@plt>
xor    %edi,%edi
cmpl   $0x0,(%rbx)
sete   %dil
call   1070 <assert@plt>
lea    0xe7e(%rip),%r15
mov    %r15,%rdi
mov    $0x3f,%esi
call   1030 <mkdir@plt>
mov    (%rbx),%esi
mov    %r12,%rdi
call   1060 <printf@plt>
xor    %edi,%edi
cmpl   $0x0,(%rbx)
sete   %dil
call   1070 <assert@plt>
mov    %r14,%rdi
call   1040 <opendir@plt>
mov    (%rbx),%esi
mov    %r12,%rdi
call   1060 <printf@plt>
xor    %edi,%edi
cmpl   $0x0,(%rbx)
sete   %dil
call   1070 <assert@plt>
mov    %r15,%rdi
call   1040 <opendir@plt>
mov    (%rbx),%esi
mov    %r12,%rdi
call   1060 <printf@plt>
xor    %edi,%edi
cmpl   $0x0,(%rbx)
sete   %dil
call   1070 <assert@plt>
mov    %r14,%rdi
call   1050 <rmdir@plt>
xor    %edi,%edi
cmpl   $0x0,(%rbx)
sete   %dil
call   1070 <assert@plt>
mov    %r15,%rdi
call   1050 <rmdir@plt>
xor    %edi,%edi
cmpl   $0x0,(%rbx)
sete   %dil
call   1070 <assert@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [12 x i8] c"testmakedir\00"
@.str.1 = [11 x i8] c"errno:%d \0A\00"
@errno = global i32 0
@.str.2 = [13 x i8] c"testmakedir2\00"
define i32 @main() {
%1 = alloca i32
store i32 0, i32* %1
%2 = call i32 @mkdir(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 63)
%3 = load i32, i32* @errno
%4 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i32 %3)
%5 = load i32, i32* @errno
%6 = icmp eq i32 %5, 0
%7 = zext i1 %6 to i32
%8 = call i32 @assert(i32 %7)
%9 = call i32 @mkdir(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i32 63)
%10 = load i32, i32* @errno
%11 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i32 %10)
%12 = load i32, i32* @errno
%13 = icmp eq i32 %12, 0
%14 = zext i1 %13 to i32
%15 = call i32 @assert(i32 %14)
%16 = call i32 @opendir(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
%17 = load i32, i32* @errno
%18 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i32 %17)
%19 = load i32, i32* @errno
%20 = icmp eq i32 %19, 0
%21 = zext i1 %20 to i32
%22 = call i32 @assert(i32 %21)
%23 = call i32 @opendir(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0))
%24 = load i32, i32* @errno
%25 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i32 %24)
%26 = load i32, i32* @errno
%27 = icmp eq i32 %26, 0
%28 = zext i1 %27 to i32
%29 = call i32 @assert(i32 %28)
%30 = call i32 @rmdir(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
%31 = load i32, i32* @errno
%32 = icmp eq i32 %31, 0
%33 = zext i1 %32 to i32
%34 = call i32 @assert(i32 %33)
%35 = call i32 @rmdir(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0))
%36 = load i32, i32* @errno
%37 = icmp eq i32 %36, 0
%38 = zext i1 %37 to i32
%39 = call i32 @assert(i32 %38)
ret i32 0
}

LLVM IR (-O2):
@.str = [12 x i8] c"testmakedir\00"
@.str.1 = [11 x i8] c"errno:%d \0A\00"
@errno = global i32 0
@.str.2 = [13 x i8] c"testmakedir2\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 = load i32, i32* @errno
%3 = tail call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i32 %2)
%4 = load i32, i32* @errno
%5 = icmp eq i32 %4, 0
%6 = zext i1 %5 to i32
%7 = tail call i32 @assert(i32 %6)
%8 = tail call i32 @mkdir(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0), i32 63)
%9 = load i32, i32* @errno
%10 = tail call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i32 %9)
%11 = load i32, i32* @errno
%12 = icmp eq i32 %11, 0
%13 = zext i1 %12 to i32
%14 = tail call i32 @assert(i32 %13)
%15 = tail call i32 @opendir(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
%16 = load i32, i32* @errno
%17 = tail call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i32 %16)
%18 = load i32, i32* @errno
%19 = icmp eq i32 %18, 0
%20 = zext i1 %19 to i32
%21 = tail call i32 @assert(i32 %20)
%22 = tail call i32 @opendir(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0))
%23 = load i32, i32* @errno
%24 = tail call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i32 %23)
%25 = load i32, i32* @errno
%26 = icmp eq i32 %25, 0
%27 = zext i1 %26 to i32
%28 = tail call i32 @assert(i32 %27)
%29 = tail call i32 @rmdir(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
%30 = load i32, i32* @errno
%31 = icmp eq i32 %30, 0
%32 = zext i1 %31 to i32
%33 = tail call i32 @assert(i32 %32)
%34 = tail call i32 @rmdir(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0))
%35 = load i32, i32* @errno
%36 = icmp eq i32 %35, 0
%37 = zext i1 %36 to i32
%38 = tail call i32 @assert(i32 %37)
ret i32 0
}