#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*/ err(int, char *);
int mkdir(char *, int);
int rename(char *, char *);
int main(int argc, char **argv) {
  if (mkdir("/mnt/0/dir", 0755) == -1) {
    err(1, "mkdir failed");
  }
  if (rename("/mnt/0/dir", "/mnt/0/dir/sub") == -1) {
    err(1, "rename failed");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xeb3(%rip),%rdi
mov    $0x1ed,%esi
call   1030 <mkdir@plt>
cmp    $0xffffffff,%eax
jne    1171 <main+0x41>
mov    $0x1,%edi
lea    0xe9f(%rip),%rsi
call   1040 <err@plt>
lea    0xe88(%rip),%rdi
lea    0xe99(%rip),%rsi
call   1050 <rename@plt>
cmp    $0xffffffff,%eax
jne    119e <main+0x6e>
mov    $0x1,%edi
lea    0xe8e(%rip),%rsi
call   1040 <err@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xec8(%rip),%rdi
mov    $0x1ed,%esi
call   1030 <mkdir@plt>
cmp    $0xffffffff,%eax
jne    1158 <main+0x28>
lea    0xebd(%rip),%rsi
mov    $0x1,%edi
call   1040 <err@plt>
lea    0xea1(%rip),%rdi
lea    0xeb2(%rip),%rsi
call   1050 <rename@plt>
cmp    $0xffffffff,%eax
jne    1181 <main+0x51>
lea    0xeb0(%rip),%rsi
mov    $0x1,%edi
call   1040 <err@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [11 x i8] c"/mnt/0/dir\00"
@.str.1 = [13 x i8] c"mkdir failed\00"
@.str.2 = [15 x i8] c"/mnt/0/dir/sub\00"
@.str.3 = [14 x i8] c"rename failed\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%6 = call i32 @mkdir(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 493)
%7 = icmp eq i32 %6, -1
br i1 %7, label %8, label %10
8: ; preds = %2
%9 = call i32 @err(i32 1, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0))
br label %10
10: ; preds = %8, %2
%11 = call i32 @rename(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0))
%12 = icmp eq i32 %11, -1
br i1 %12, label %13, label %15
13: ; preds = %10
%14 = call i32 @err(i32 1, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0))
br label %15
15: ; preds = %13, %10
ret i32 0
}

LLVM IR (-O2):
@.str = [11 x i8] c"/mnt/0/dir\00"
@.str.1 = [13 x i8] c"mkdir failed\00"
@.str.2 = [15 x i8] c"/mnt/0/dir/sub\00"
@.str.3 = [14 x i8] c"rename failed\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i32 @mkdir(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 493)
%4 = icmp eq i32 %3, -1
br i1 %4, label %5, label %7
5: ; preds = %2
%6 = tail call i32 @err(i32 1, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0))
br label %7
7: ; preds = %5, %2
%8 = tail call i32 @rename(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0))
%9 = icmp eq i32 %8, -1
br i1 %9, label %10, label %12
10: ; preds = %7
%11 = tail call i32 @err(i32 1, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0))
br label %12
12: ; preds = %10, %7
ret i32 0
}