#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 mkdir(char *, int);
int /*<<< orphan*/ puts(char *);
int rmdir(char *);
int main() {
  int result;
  result = mkdir("rmdir_test", 0776);
  if (result == -1) {
    puts("error");
    return result;
  }
  puts("make directory");
  result = rmdir("rmdir_test");
  if (result == -1) {
    puts("error");
    return result;
  }
  puts("success");
  return result;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeba(%rip),%rdi
mov    $0x1fe,%esi
call   1030 <mkdir@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0xffffffff,-0x8(%rbp)
jne    1174 <main+0x44>
lea    0xea7(%rip),%rdi
call   1040 <puts@plt>
mov    -0x8(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11c2 <main+0x92>
lea    0xe96(%rip),%rdi
call   1040 <puts@plt>
lea    0xe79(%rip),%rdi
call   1050 <rmdir@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0xffffffff,-0x8(%rbp)
jne    11b0 <main+0x80>
lea    0xe6b(%rip),%rdi
call   1040 <puts@plt>
mov    -0x8(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11c2 <main+0x92>
lea    0xe69(%rip),%rdi
call   1040 <puts@plt>
mov    -0x8(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
lea    0xec8(%rip),%rdi
mov    $0x1fe,%esi
call   1030 <mkdir@plt>
cmp    $0xffffffff,%eax
je     1178 <main+0x48>
lea    0xec3(%rip),%rdi
call   1040 <puts@plt>
lea    0xea6(%rip),%rdi
call   1050 <rmdir@plt>
mov    %eax,%ebx
cmp    $0xffffffff,%eax
lea    0xea0(%rip),%rax
lea    0xeae(%rip),%rdi
cmove  %rax,%rdi
jmp    1184 <main+0x54>
mov    $0xffffffff,%ebx
lea    0xe87(%rip),%rdi
call   1040 <puts@plt>
mov    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [11 x i8] c"rmdir_test\00"
@.str.1 = [6 x i8] c"error\00"
@.str.2 = [15 x i8] c"make directory\00"
@.str.3 = [8 x i8] c"success\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 %9
6: ; preds = %0
%7 = call i32 @puts(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%8 = load i32, i32* %2
store i32 %8, i32* %1
br label %20
9: ; preds = %0
%10 = call i32 @puts(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0))
%11 = call i32 @rmdir(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
store i32 %11, i32* %2
%12 = load i32, i32* %2
%13 = icmp eq i32 %12, -1
br i1 %13, label %14, label %17
14: ; preds = %9
%15 = call i32 @puts(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%16 = load i32, i32* %2
store i32 %16, i32* %1
br label %20
17: ; preds = %9
%18 = call i32 @puts(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0))
%19 = load i32, i32* %2
store i32 %19, i32* %1
br label %20
20: ; preds = %17, %14, %6
%21 = load i32, i32* %1
ret i32 %21
}

LLVM IR (-O2):
@.str = [11 x i8] c"rmdir_test\00"
@.str.1 = [6 x i8] c"error\00"
@.str.2 = [15 x i8] c"make directory\00"
@.str.3 = [8 x i8] c"success\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 %8, label %3
3: ; preds = %0
%4 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0))
%5 = tail call i32 @rmdir(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%6 = icmp eq i32 %5, -1
%7 = select i1 %6, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0)
br label %8
8: ; preds = %3, %0
%9 = phi i8* [ getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), %0 ], [ %7, %3 ]
%10 = phi i32 [ -1, %0 ], [ %5, %3 ]
%11 = tail call i32 @puts(i8* dereferenceable(1) %9)
ret i32 %10
}