#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 O_CREAT;
int O_WRONLY;
int /*<<< orphan*/ mkdir(char *, int);
int /*<<< orphan*/ open(char *, int, int);
int /*<<< orphan*/ rename(char *, char *);
int main() {
  open("tmp/useless", O_WRONLY | O_CREAT, 0666);
  mkdir("tmp/subdirnew.temporary", 0777);
  mkdir("tmp/subdirnew.temporary/subsub", 0777);
  open("tmp/subdirnew.temporary/subfile", O_WRONLY | O_CREAT, 0666);
  rename("tmp/subdirnew.temporary", "tmp/subdirnew");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2e8a(%rip),%rax
mov    (%rax),%esi
mov    0x2ea9(%rip),%rax
or     (%rax),%esi
lea    0xea8(%rip),%rdi
mov    $0x1b6,%edx
call   1040 <open@plt>
lea    0xea3(%rip),%rdi
mov    $0x1ff,%esi
call   1030 <mkdir@plt>
lea    0xeaa(%rip),%rdi
mov    $0x1ff,%esi
call   1030 <mkdir@plt>
mov    0x2e45(%rip),%rax
mov    (%rax),%esi
mov    0x2e64(%rip),%rax
or     (%rax),%esi
lea    0xea6(%rip),%rdi
mov    $0x1b6,%edx
call   1040 <open@plt>
lea    0xe5e(%rip),%rdi
lea    0xeae(%rip),%rsi
call   1050 <rename@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
mov    0x2e94(%rip),%r14
mov    0x2eb5(%rip),%r15
mov    (%r15),%esi
or     (%r14),%esi
lea    0xeb0(%rip),%rdi
mov    $0x1b6,%edx
call   1040 <open@plt>
lea    0xeab(%rip),%rbx
mov    %rbx,%rdi
mov    $0x1ff,%esi
call   1030 <mkdir@plt>
lea    0xeaf(%rip),%rdi
mov    $0x1ff,%esi
call   1030 <mkdir@plt>
mov    (%r15),%esi
or     (%r14),%esi
lea    0xeb7(%rip),%rdi
mov    $0x1b6,%edx
call   1040 <open@plt>
lea    0xec6(%rip),%rsi
mov    %rbx,%rdi
call   1050 <rename@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [12 x i8] c"tmp/useless\00"
@O_WRONLY = global i32 0
@O_CREAT = global i32 0
@.str.1 = [24 x i8] c"tmp/subdirnew.temporary\00"
@.str.2 = [31 x i8] c"tmp/subdirnew.temporary/subsub\00"
@.str.3 = [32 x i8] c"tmp/subdirnew.temporary/subfile\00"
@.str.4 = [14 x i8] c"tmp/subdirnew\00"
define i32 @main() {
%1 = alloca i32
store i32 0, i32* %1
%2 = load i32, i32* @O_WRONLY
%3 = load i32, i32* @O_CREAT
%4 = or i32 %2, %3
%5 = call i32 @open(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 %4, i32 438)
%6 = call i32 @mkdir(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), i32 511)
%7 = call i32 @mkdir(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0), i32 511)
%8 = load i32, i32* @O_WRONLY
%9 = load i32, i32* @O_CREAT
%10 = or i32 %8, %9
%11 = call i32 @open(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.3, i64 0, i64 0), i32 %10, i32 438)
%12 = call i32 @rename(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str = [12 x i8] c"tmp/useless\00"
@O_WRONLY = global i32 0
@O_CREAT = global i32 0
@.str.1 = [24 x i8] c"tmp/subdirnew.temporary\00"
@.str.2 = [31 x i8] c"tmp/subdirnew.temporary/subsub\00"
@.str.3 = [32 x i8] c"tmp/subdirnew.temporary/subfile\00"
@.str.4 = [14 x i8] c"tmp/subdirnew\00"
define i32 @main() {
%1 = load i32, i32* @O_WRONLY
%2 = load i32, i32* @O_CREAT
%3 = or i32 %2, %1
%4 = tail call i32 @open(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 %3, i32 438)
%5 = tail call i32 @mkdir(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), i32 511)
%6 = tail call i32 @mkdir(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0), i32 511)
%7 = load i32, i32* @O_WRONLY
%8 = load i32, i32* @O_CREAT
%9 = or i32 %8, %7
%10 = tail call i32 @open(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.3, i64 0, i64 0), i32 %9, i32 438)
%11 = tail call i32 @rename(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0))
ret i32 0
}