#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*/ File_Close(int);
scalar_t__ File_Exist(char const *);
int File_Open(char const *);
scalar_t__ truncate(char const *, int);
int File_Create(const char *FileName, int size) {
  int fd;
  if (File_Exist(FileName))
    return 0;
  if ((fd = File_Open(FileName)) < 0)
    return -1;
  File_Close(fd);
  if (truncate(FileName, size) < 0)
    return -1;
  return 0;
}


x86 assembly (clang, -O0):
<File_Create>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <File_Exist@plt>
cmp    $0x0,%rax
je     116e <File_Create+0x2e>
movl   $0x0,-0x4(%rbp)
jmp    11c0 <File_Create+0x80>
mov    -0x10(%rbp),%rdi
call   1050 <File_Open@plt>
mov    %eax,-0x18(%rbp)
cmp    $0x0,%eax
jge    118f <File_Create+0x4f>
movl   $0xffffffff,-0x4(%rbp)
jmp    11c0 <File_Create+0x80>
mov    -0x18(%rbp),%edi
call   1060 <File_Close@plt>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1040 <truncate@plt>
cmp    $0x0,%rax
jge    11b9 <File_Create+0x79>
movl   $0xffffffff,-0x4(%rbp)
jmp    11c0 <File_Create+0x80>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<File_Create>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebp
mov    %rdi,%rbx
call   1030 <File_Exist@plt>
mov    %rax,%rcx
xor    %eax,%eax
test   %rcx,%rcx
jne    117f <File_Create+0x3f>
mov    %rbx,%rdi
call   1050 <File_Open@plt>
test   %eax,%eax
js     117a <File_Create+0x3a>
mov    %eax,%edi
call   1060 <File_Close@plt>
mov    %rbx,%rdi
mov    %ebp,%esi
call   1040 <truncate@plt>
sar    $0x3f,%rax
jmp    117f <File_Create+0x3f>
mov    $0xffffffff,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define i32 @File_Create(i8* %0, i32 %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
store i8* %0, i8** %4
store i32 %1, i32* %5
%7 = load i8*, i8** %4
%8 = call i64 @File_Exist(i8* %7)
%9 = icmp ne i64 %8, 0
br i1 %9, label %10, label %11
10: ; preds = %2
store i32 0, i32* %3
br label %25
11: ; preds = %2
%12 = load i8*, i8** %4
%13 = call i32 @File_Open(i8* %12)
store i32 %13, i32* %6
%14 = icmp slt i32 %13, 0
br i1 %14, label %15, label %16
15: ; preds = %11
store i32 -1, i32* %3
br label %25
16: ; preds = %11
%17 = load i32, i32* %6
%18 = call i32 @File_Close(i32 %17)
%19 = load i8*, i8** %4
%20 = load i32, i32* %5
%21 = call i64 @truncate(i8* %19, i32 %20)
%22 = icmp slt i64 %21, 0
br i1 %22, label %23, label %24
23: ; preds = %16
store i32 -1, i32* %3
br label %25
24: ; preds = %16
store i32 0, i32* %3
br label %25
25: ; preds = %24, %23, %15, %10
%26 = load i32, i32* %3
ret i32 %26
}

LLVM IR (-O2):
define i32 @File_Create(i8* %0, i32 %1) {
%3 = tail call i64 @File_Exist(i8* %0)
%4 = icmp eq i64 %3, 0
br i1 %4, label %5, label %13
5: ; preds = %2
%6 = tail call i32 @File_Open(i8* %0)
%7 = icmp slt i32 %6, 0
br i1 %7, label %13, label %8
8: ; preds = %5
%9 = tail call i32 @File_Close(i32 %6)
%10 = tail call i64 @truncate(i8* %0, i32 %1)
%11 = ashr i64 %10, 63
%12 = trunc i64 %11 to i32
br label %13
13: ; preds = %8, %5, %2
%14 = phi i32 [ 0, %2 ], [ -1, %5 ], [ %12, %8 ]
ret i32 %14
}