#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char const *const, char *);
int /*<<< orphan*/ fputc(int /*<<< orphan*/, int /*<<< orphan*/ *);
bool CheckCreateBlankFile(const char *const srcfile, const char *const dstfile,
                          const long Pointer, const int length) {
  FILE *src = fopen(srcfile, "rb");
  if (src != NULL) {
    fclose(src);
    return false;
  }
  FILE *dst = fopen(dstfile, "wb");
  for (int i = 0; i < Pointer + length; ++i)
    fputc(0, dst);
  fclose(dst);
  return true;
}


x86 assembly (clang, -O0):
<CheckCreateBlankFile>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %ecx,-0x24(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xeae(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
je     117b <CheckCreateBlankFile+0x4b>
mov    -0x30(%rbp),%rdi
call   1030 <fclose@plt>
movl   $0x0,-0x4(%rbp)
jmp    11d7 <CheckCreateBlankFile+0xa7>
mov    -0x18(%rbp),%rdi
lea    0xe7d(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x38(%rbp)
movl   $0x0,-0x3c(%rbp)
movslq -0x3c(%rbp),%rax
mov    -0x20(%rbp),%rcx
movslq -0x24(%rbp),%rdx
add    %rdx,%rcx
cmp    %rcx,%rax
jge    11c7 <CheckCreateBlankFile+0x97>
mov    -0x38(%rbp),%rsi
xor    %edi,%edi
call   1040 <fputc@plt>
mov    -0x3c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3c(%rbp)
jmp    1196 <CheckCreateBlankFile+0x66>
mov    -0x38(%rbp),%rdi
call   1030 <fclose@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<CheckCreateBlankFile>:
push   %rbp
push   %r14
push   %rbx
mov    %ecx,%ebp
mov    %rdx,%r14
mov    %rsi,%rbx
lea    0xebd(%rip),%rsi
call   1050 <fopen@plt>
test   %rax,%rax
je     1159 <CheckCreateBlankFile+0x29>
mov    %rax,%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
jmp    119d <CheckCreateBlankFile+0x6d>
lea    0xea3(%rip),%rsi
mov    %rbx,%rdi
call   1050 <fopen@plt>
mov    %rax,%rbx
movslq %ebp,%rbp
add    %r14,%rbp
test   %rbp,%rbp
jle    1190 <CheckCreateBlankFile+0x60>
cs nopw 0x0(%rax,%rax,1)
xor    %edi,%edi
mov    %rbx,%rsi
call   1040 <fputc@plt>
add    $0xffffffffffffffff,%rbp
jne    1180 <CheckCreateBlankFile+0x50>
mov    %rbx,%rdi
call   1030 <fclose@plt>
mov    $0x1,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"rb\00"
@.str.1 = [3 x i8] c"wb\00"
define i32 @CheckCreateBlankFile(i8* %0, i8* %1, i64 %2, i32 %3) {
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i64
%9 = alloca i32
%10 = alloca i32*
%11 = alloca i32*
%12 = alloca i32
store i8* %0, i8** %6
store i8* %1, i8** %7
store i64 %2, i64* %8
store i32 %3, i32* %9
%13 = load i8*, i8** %6
%14 = call i32* @fopen(i8* %13, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i32* %14, i32** %10
%15 = load i32*, i32** %10
%16 = icmp ne i32* %15, null
br i1 %16, label %17, label %20
17: ; preds = %4
%18 = load i32*, i32** %10
%19 = call i32 @fclose(i32* %18)
store i32 0, i32* %5
br label %40
20: ; preds = %4
%21 = load i8*, i8** %7
%22 = call i32* @fopen(i8* %21, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %22, i32** %11
store i32 0, i32* %12
br label %23
23: ; preds = %34, %20
%24 = load i32, i32* %12
%25 = sext i32 %24 to i64
%26 = load i64, i64* %8
%27 = load i32, i32* %9
%28 = sext i32 %27 to i64
%29 = add nsw i64 %26, %28
%30 = icmp slt i64 %25, %29
br i1 %30, label %31, label %37
31: ; preds = %23
%32 = load i32*, i32** %11
%33 = call i32 @fputc(i32 0, i32* %32)
br label %34
34: ; preds = %31
%35 = load i32, i32* %12
%36 = add nsw i32 %35, 1
store i32 %36, i32* %12
br label %23
37: ; preds = %23
%38 = load i32*, i32** %11
%39 = call i32 @fclose(i32* %38)
store i32 1, i32* %5
br label %40
40: ; preds = %37, %17
%41 = load i32, i32* %5
ret i32 %41
}

LLVM IR (-O2):
@.str = [3 x i8] c"rb\00"
@.str.1 = [3 x i8] c"wb\00"
define i32 @CheckCreateBlankFile(i8* nocapture %0, i8* nocapture %1, i64 %2, i32 %3) {
%5 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%6 = icmp eq i32* %5, null
br i1 %6, label %9, label %7
7: ; preds = %4
%8 = tail call i32 @fclose(i32* %5)
br label %21
9: ; preds = %4
%10 = tail call i32* @fopen(i8* %1, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%11 = sext i32 %3 to i64
%12 = add i64 %11, %2
%13 = icmp sgt i64 %12, 0
br i1 %13, label %16, label %14
14: ; preds = %16, %9
%15 = tail call i32 @fclose(i32* %10)
br label %21
16: ; preds = %9, %16
%17 = phi i64 [ %19, %16 ], [ 0, %9 ]
%18 = tail call i32 @fputc(i32 0, i32* %10)
%19 = add nuw nsw i64 %17, 1
%20 = icmp eq i64 %19, %12
br i1 %20, label %14, label %16
21: ; preds = %14, %7
%22 = phi i32 [ 0, %7 ], [ 1, %14 ]
ret i32 %22
}