#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*/ createFile();
int /*<<< orphan*/ failExclFileCreation();
int /*<<< orphan*/ failOpenNonexistingFile();
int /*<<< orphan*/ openFile();
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ sleep(int);
int /*<<< orphan*/ system(char *);
int /*<<< orphan*/ truncateFile();
int main(int argc, char **argv) {
  createFile();
  system("ls -l newfile");
  printf("\n");
  sleep(2);
  createFile();
  system("ls -l newfile");
  printf("\n");
  sleep(2);
  failExclFileCreation();
  printf("\n");
  sleep(2);
  openFile();
  printf("\n");
  sleep(2);
  failOpenNonexistingFile();
  printf("\n");
  sleep(2);
  system("cp openex.c newfile");
  system("ls -l newfile");
  truncateFile();
  system("ls -l newfile");
  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)
mov    $0x0,%al
call   1060 <createFile@plt>
lea    0xe5c(%rip),%rdi
call   1040 <system@plt>
lea    0xe5e(%rip),%rdi
call   1050 <printf@plt>
mov    $0x2,%edi
call   10a0 <sleep@plt>
mov    $0x0,%al
call   1060 <createFile@plt>
lea    0xe33(%rip),%rdi
call   1040 <system@plt>
lea    0xe35(%rip),%rdi
call   1050 <printf@plt>
mov    $0x2,%edi
call   10a0 <sleep@plt>
mov    $0x0,%al
call   1070 <failExclFileCreation@plt>
lea    0xe18(%rip),%rdi
call   1050 <printf@plt>
mov    $0x2,%edi
call   10a0 <sleep@plt>
mov    $0x0,%al
call   1030 <openFile@plt>
lea    0xdfb(%rip),%rdi
call   1050 <printf@plt>
mov    $0x2,%edi
call   10a0 <sleep@plt>
mov    $0x0,%al
call   1080 <failOpenNonexistingFile@plt>
lea    0xdde(%rip),%rdi
call   1050 <printf@plt>
mov    $0x2,%edi
call   10a0 <sleep@plt>
lea    0xdca(%rip),%rdi
call   1040 <system@plt>
lea    0xdae(%rip),%rdi
call   1040 <system@plt>
mov    $0x0,%al
call   1090 <truncateFile@plt>
lea    0xd9b(%rip),%rdi
call   1040 <system@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
xor    %eax,%eax
call   1060 <createFile@plt>
lea    0xe71(%rip),%rbx
mov    %rbx,%rdi
call   1050 <system@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    $0x2,%edi
call   10a0 <sleep@plt>
xor    %eax,%eax
call   1060 <createFile@plt>
mov    %rbx,%rdi
call   1050 <system@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    $0x2,%edi
call   10a0 <sleep@plt>
xor    %eax,%eax
call   1070 <failExclFileCreation@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    $0x2,%edi
call   10a0 <sleep@plt>
xor    %eax,%eax
call   1040 <openFile@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    $0x2,%edi
call   10a0 <sleep@plt>
xor    %eax,%eax
call   1080 <failOpenNonexistingFile@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    $0x2,%edi
call   10a0 <sleep@plt>
lea    0xde8(%rip),%rdi
call   1050 <system@plt>
mov    %rbx,%rdi
call   1050 <system@plt>
xor    %eax,%eax
call   1090 <truncateFile@plt>
mov    %rbx,%rdi
call   1050 <system@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [14 x i8] c"ls -l newfile\00"
@.str.1 = [2 x i8] c"\0A\00"
@.str.2 = [20 x i8] c"cp openex.c newfile\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 (...) @createFile()
%7 = call i32 @system(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
%8 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%9 = call i32 @sleep(i32 2)
%10 = call i32 (...) @createFile()
%11 = call i32 @system(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
%12 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%13 = call i32 @sleep(i32 2)
%14 = call i32 (...) @failExclFileCreation()
%15 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%16 = call i32 @sleep(i32 2)
%17 = call i32 (...) @openFile()
%18 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%19 = call i32 @sleep(i32 2)
%20 = call i32 (...) @failOpenNonexistingFile()
%21 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%22 = call i32 @sleep(i32 2)
%23 = call i32 @system(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0))
%24 = call i32 @system(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
%25 = call i32 (...) @truncateFile()
%26 = call i32 @system(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str = [14 x i8] c"ls -l newfile\00"
@.str.2 = [20 x i8] c"cp openex.c newfile\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i32 (...) @createFile()
%4 = tail call i32 @system(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
%5 = tail call i32 @putchar(i32 10)
%6 = tail call i32 @sleep(i32 2)
%7 = tail call i32 (...) @createFile()
%8 = tail call i32 @system(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
%9 = tail call i32 @putchar(i32 10)
%10 = tail call i32 @sleep(i32 2)
%11 = tail call i32 (...) @failExclFileCreation()
%12 = tail call i32 @putchar(i32 10)
%13 = tail call i32 @sleep(i32 2)
%14 = tail call i32 (...) @openFile()
%15 = tail call i32 @putchar(i32 10)
%16 = tail call i32 @sleep(i32 2)
%17 = tail call i32 (...) @failOpenNonexistingFile()
%18 = tail call i32 @putchar(i32 10)
%19 = tail call i32 @sleep(i32 2)
%20 = tail call i32 @system(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0))
%21 = tail call i32 @system(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
%22 = tail call i32 (...) @truncateFile()
%23 = tail call i32 @system(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
ret i32 0
}