#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 */
scalar_t__ EEXIST;
scalar_t__ errno;
int mkdir(char *, int);
int /*<<< orphan*/ puts(char *);
int main() {
  int result;
  result = mkdir("mkdir_test", 0776);
  if ((result == -1) && (errno != EEXIST)) {
    puts("error");
    return -1;
  }
  puts("sucess");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
mov    $0x1fe,%esi
call   1030 <mkdir@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0xffffffff,-0x8(%rbp)
jne    117f <main+0x5f>
mov    0x2e84(%rip),%rax
mov    (%rax),%rax
mov    0x2e82(%rip),%rcx
cmp    (%rcx),%rax
je     117f <main+0x5f>
lea    0xe9d(%rip),%rdi
call   1040 <puts@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1192 <main+0x72>
lea    0xe8b(%rip),%rdi
call   1040 <puts@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
lea    0xed8(%rip),%rdi
mov    $0x1fe,%esi
call   1030 <mkdir@plt>
cmp    $0xffffffff,%eax
jne    114d <main+0x2d>
mov    0x2e9a(%rip),%rax
mov    (%rax),%rax
mov    0x2e98(%rip),%rcx
cmp    (%rcx),%rax
jne    1158 <main+0x38>
xor    %ebx,%ebx
lea    0xebb(%rip),%rdi
jmp    1164 <main+0x44>
mov    $0xffffffff,%ebx
lea    0xea7(%rip),%rdi
call   1040 <puts@plt>
mov    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [11 x i8] c"mkdir_test\00"
@errno = global i64 0
@EEXIST = global i64 0
@.str.1 = [6 x i8] c"error\00"
@.str.2 = [7 x i8] c"sucess\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
store i32 0, i32* %1
%3 = call i32 @mkdir(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 510)
store i32 %3, i32* %2
%4 = load i32, i32* %2
%5 = icmp eq i32 %4, -1
br i1 %5, label %6, label %12
6: ; preds = %0
%7 = load i64, i64* @errno
%8 = load i64, i64* @EEXIST
%9 = icmp ne i64 %7, %8
br i1 %9, label %10, label %12
10: ; preds = %6
%11 = call i32 @puts(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
store i32 -1, i32* %1
br label %14
12: ; preds = %6, %0
%13 = call i32 @puts(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %1
br label %14
14: ; preds = %12, %10
%15 = load i32, i32* %1
ret i32 %15
}

LLVM IR (-O2):
@.str = [11 x i8] c"mkdir_test\00"
@errno = global i64 0
@EEXIST = global i64 0
@.str.1 = [6 x i8] c"error\00"
@.str.2 = [7 x i8] c"sucess\00"
define i32 @main() {
%1 = tail call i32 @mkdir(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 510)
%2 = icmp eq i32 %1, -1
br i1 %2, label %3, label %7
3: ; preds = %0
%4 = load i64, i64* @errno
%5 = load i64, i64* @EEXIST
%6 = icmp eq i64 %4, %5
br i1 %6, label %7, label %8
7: ; preds = %3, %0
br label %8
8: ; preds = %3, %7
%9 = phi i8* [ getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), %7 ], [ getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), %3 ]
%10 = phi i32 [ 0, %7 ], [ -1, %3 ]
%11 = tail call i32 @puts(i8* dereferenceable(1) %9)
ret i32 %10
}