#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*/ xfclose(int /*<<< orphan*/ **);
int /*<<< orphan*/ *xfopen(char const *, char *);
int /*<<< orphan*/ xfwrite(char *, int, int, int /*<<< orphan*/ *);
extern int xfile_createFileWithSize(const char *fname, size_t bytes) {
  FILE *f;
  char nullData = 124;
  f = xfopen(fname, "wb");
  for (int i = 0; i < bytes; i++)
    xfwrite(&nullData, sizeof(char), 1, f);
  xfclose(&f);
  return 0;
}


x86 assembly (clang, -O0):
<xfile_createFileWithSize>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movb   $0x7c,-0x19(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xeb1(%rip),%rsi
call   1030 <xfopen@plt>
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x20(%rbp)
movslq -0x20(%rbp),%rax
cmp    -0x10(%rbp),%rax
jae    118f <xfile_createFileWithSize+0x5f>
mov    -0x18(%rbp),%rcx
lea    -0x19(%rbp),%rdi
mov    $0x1,%edx
mov    %edx,%esi
call   1040 <xfwrite@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    115f <xfile_createFileWithSize+0x2f>
lea    -0x18(%rbp),%rdi
call   1050 <xfclose@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<xfile_createFileWithSize>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%rbx
movb   $0x7c,0x7(%rsp)
lea    0xeb8(%rip),%rsi
call   1030 <xfopen@plt>
mov    %rax,0x8(%rsp)
test   %rbx,%rbx
je     117b <xfile_createFileWithSize+0x4b>
mov    %rax,%r14
lea    0x7(%rsp),%r15
nop
mov    %r15,%rdi
mov    $0x1,%esi
mov    $0x1,%edx
mov    %r14,%rcx
call   1040 <xfwrite@plt>
add    $0xffffffffffffffff,%rbx
jne    1160 <xfile_createFileWithSize+0x30>
lea    0x8(%rsp),%rdi
call   1050 <xfclose@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [3 x i8] c"wb\00"
define i32 @xfile_createFileWithSize(i8* %0, i64 %1) {
%3 = alloca i8*
%4 = alloca i64
%5 = alloca i32*
%6 = alloca i8
%7 = alloca i32
store i8* %0, i8** %3
store i64 %1, i64* %4
store i8 124, i8* %6
%8 = load i8*, i8** %3
%9 = call i32* @xfopen(i8* %8, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i32* %9, i32** %5
store i32 0, i32* %7
br label %10
10: ; preds = %18, %2
%11 = load i32, i32* %7
%12 = sext i32 %11 to i64
%13 = load i64, i64* %4
%14 = icmp ult i64 %12, %13
br i1 %14, label %15, label %21
15: ; preds = %10
%16 = load i32*, i32** %5
%17 = call i32 @xfwrite(i8* %6, i32 1, i32 1, i32* %16)
br label %18
18: ; preds = %15
%19 = load i32, i32* %7
%20 = add nsw i32 %19, 1
store i32 %20, i32* %7
br label %10
21: ; preds = %10
%22 = call i32 @xfclose(i32** %5)
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"wb\00"
define i32 @xfile_createFileWithSize(i8* %0, i64 %1) {
%3 = alloca i32*
%4 = alloca i8
%5 = bitcast i32** %3 to i8*
store i8 124, i8* %4
%6 = tail call i32* @xfopen(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
store i32* %6, i32** %3
%7 = icmp eq i64 %1, 0
br i1 %7, label %8, label %10
8: ; preds = %10, %2
%9 = call i32 @xfclose(i32** %3)
ret i32 0
10: ; preds = %2, %10
%11 = phi i64 [ %13, %10 ], [ 0, %2 ]
%12 = call i32 @xfwrite(i8* %4, i32 1, i32 1, i32* %6)
%13 = add nuw i64 %11, 1
%14 = icmp eq i64 %13, %1
br i1 %14, label %8, label %10
}