#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*/ EXIT_FAILURE;
int O_CREAT;
int O_EXCL;
int O_WRONLY;
int close(int);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int open(char const *, int, int);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ stderr;
void CreateFile(const char *path) {
  int handle;
  if ((handle = open(path, O_CREAT | O_WRONLY | O_EXCL, 0666)) == -1) {
    fprintf(stderr, "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
                    "outputs/2022-01-22/02-19-57/repos/Ansahmadiba/bazel/refs/"
                    "heads/master/src/main/tools/namespace-sandbox.c"
                    ":"
                    "291"
                    ": ");
    perror("handle = open(path, O_CREAT | O_WRONLY | O_EXCL, 0666)");
    exit(EXIT_FAILURE);
  };
  if ((close(handle)) == -1) {
    fprintf(stderr, "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
                    "outputs/2022-01-22/02-19-57/repos/Ansahmadiba/bazel/refs/"
                    "heads/master/src/main/tools/namespace-sandbox.c"
                    ":"
                    "292"
                    ": ");
    perror("close(handle)");
    exit(EXIT_FAILURE);
  };
}


x86 assembly (clang, -O0):
<CreateFile>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
mov    0x2e91(%rip),%rax
mov    (%rax),%esi
mov    0x2e48(%rip),%rax
or     (%rax),%esi
mov    0x2e57(%rip),%rax
or     (%rax),%esi
mov    $0x1b6,%edx
call   1050 <open@plt>
mov    %eax,-0xc(%rbp)
cmp    $0xffffffff,%eax
jne    11c0 <CreateFile+0x70>
mov    0x2e40(%rip),%rax
mov    (%rax),%edi
lea    0xe5f(%rip),%rsi
call   1040 <fprintf@plt>
lea    0xefa(%rip),%rdi
call   1060 <perror@plt>
mov    0x2e0f(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>
mov    -0xc(%rbp),%edi
call   1030 <close@plt>
cmp    $0xffffffff,%eax
jne    1200 <CreateFile+0xb0>
mov    0x2e00(%rip),%rax
mov    (%rax),%edi
lea    0xefd(%rip),%rsi
call   1040 <fprintf@plt>
lea    0xf98(%rip),%rdi
call   1060 <perror@plt>
mov    0x2dcf(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<CreateFile>:
push   %rax
mov    0x2ea0(%rip),%rax
mov    0x2e59(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
mov    0x2e66(%rip),%rax
or     (%rax),%esi
mov    $0x1b6,%edx
call   1050 <open@plt>
cmp    $0xffffffff,%eax
je     1189 <CreateFile+0x39>
mov    %eax,%edi
call   1030 <close@plt>
cmp    $0xffffffff,%eax
je     11a7 <CreateFile+0x57>
pop    %rax
ret
mov    0x2e48(%rip),%rax
mov    (%rax),%edi
lea    0xe67(%rip),%rsi
call   1040 <fprintf@plt>
lea    0xf02(%rip),%rdi
jmp    11c3 <CreateFile+0x73>
mov    0x2e2a(%rip),%rax
mov    (%rax),%edi
lea    0xf27(%rip),%rsi
call   1040 <fprintf@plt>
lea    0xfc2(%rip),%rdi
call   1060 <perror@plt>
mov    0x2df9(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@O_CREAT = global i32 0
@O_WRONLY = global i32 0
@O_EXCL = global i32 0
@stderr = global i32 0
@.str = [167 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/Ansahmadiba/bazel/refs/heads/master/src/main/tools/namespace-sandbox.c:291: \00"
@.str.1 = [55 x i8] c"handle = open(path, O_CREAT | O_WRONLY | O_EXCL, 0666)\00"
@EXIT_FAILURE = global i32 0
@.str.2 = [167 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/Ansahmadiba/bazel/refs/heads/master/src/main/tools/namespace-sandbox.c:292: \00"
@.str.3 = [14 x i8] c"close(handle)\00"
define void @CreateFile(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
store i8* %0, i8** %2
%4 = load i8*, i8** %2
%5 = load i32, i32* @O_CREAT
%6 = load i32, i32* @O_WRONLY
%7 = or i32 %5, %6
%8 = load i32, i32* @O_EXCL
%9 = or i32 %7, %8
%10 = call i32 @open(i8* %4, i32 %9, i32 438)
store i32 %10, i32* %3
%11 = icmp eq i32 %10, -1
br i1 %11, label %12, label %18
12: ; preds = %1
%13 = load i32, i32* @stderr
%14 = call i32 @fprintf(i32 %13, i8* getelementptr inbounds ([167 x i8], [167 x i8]* @.str, i64 0, i64 0))
%15 = call i32 @perror(i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str.1, i64 0, i64 0))
%16 = load i32, i32* @EXIT_FAILURE
%17 = call i32 @exit(i32 %16)
unreachable
18: ; preds = %1
%19 = load i32, i32* %3
%20 = call i32 @close(i32 %19)
%21 = icmp eq i32 %20, -1
br i1 %21, label %22, label %28
22: ; preds = %18
%23 = load i32, i32* @stderr
%24 = call i32 @fprintf(i32 %23, i8* getelementptr inbounds ([167 x i8], [167 x i8]* @.str.2, i64 0, i64 0))
%25 = call i32 @perror(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0))
%26 = load i32, i32* @EXIT_FAILURE
%27 = call i32 @exit(i32 %26)
unreachable
28: ; preds = %18
ret void
}

LLVM IR (-O2):
@O_CREAT = global i32 0
@O_WRONLY = global i32 0
@O_EXCL = global i32 0
@stderr = global i32 0
@.str = [167 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/Ansahmadiba/bazel/refs/heads/master/src/main/tools/namespace-sandbox.c:291: \00"
@.str.1 = [55 x i8] c"handle = open(path, O_CREAT | O_WRONLY | O_EXCL, 0666)\00"
@EXIT_FAILURE = global i32 0
@.str.2 = [167 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/Ansahmadiba/bazel/refs/heads/master/src/main/tools/namespace-sandbox.c:292: \00"
@.str.3 = [14 x i8] c"close(handle)\00"
define void @CreateFile(i8* nocapture %0) {
%2 = load i32, i32* @O_CREAT
%3 = load i32, i32* @O_WRONLY
%4 = or i32 %3, %2
%5 = load i32, i32* @O_EXCL
%6 = or i32 %4, %5
%7 = tail call i32 @open(i8* %0, i32 %6, i32 438)
%8 = icmp eq i32 %7, -1
br i1 %8, label %9, label %15
9: ; preds = %1
%10 = load i32, i32* @stderr
%11 = tail call i32 @fprintf(i32 %10, i8* getelementptr inbounds ([167 x i8], [167 x i8]* @.str, i64 0, i64 0))
%12 = tail call i32 @perror(i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str.1, i64 0, i64 0))
%13 = load i32, i32* @EXIT_FAILURE
%14 = tail call i32 @exit(i32 %13)
unreachable
15: ; preds = %1
%16 = tail call i32 @close(i32 %7)
%17 = icmp eq i32 %16, -1
br i1 %17, label %18, label %24
18: ; preds = %15
%19 = load i32, i32* @stderr
%20 = tail call i32 @fprintf(i32 %19, i8* getelementptr inbounds ([167 x i8], [167 x i8]* @.str.2, i64 0, i64 0))
%21 = tail call i32 @perror(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0))
%22 = load i32, i32* @EXIT_FAILURE
%23 = tail call i32 @exit(i32 %22)
unreachable
24: ; preds = %15
ret void
}