#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 O_CREAT;
int O_TRUNC;
int O_WRONLY;
int /*<<< orphan*/ SEEK_CUR;
int /*<<< orphan*/ S_IRWXU;
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ lseek(int, int, int /*<<< orphan*/);
int open(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ write(int, char *, int);
int create_sparse(char *f_name, int size) {
  int file_des = open(f_name, O_WRONLY | O_TRUNC | O_CREAT, S_IRWXU);
  if (file_des == -1) {
    printf("Error! Can't open or create file: %s", f_name);
    return 1;
  }
  write(file_des, "Start sparse file!\n", 19);
  lseek(file_des, size, SEEK_CUR);
  write(file_des, "End sparse file!\n", 17);
  close(file_des);
  return 0;
}


x86 assembly (clang, -O0):
<create_sparse>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    -0x10(%rbp),%rdi
mov    0x2e4e(%rip),%rax
mov    (%rax),%esi
mov    0x2e7d(%rip),%rax
or     (%rax),%esi
mov    0x2e7c(%rip),%rax
or     (%rax),%esi
mov    0x2e53(%rip),%rax
mov    (%rax),%edx
call   1070 <open@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0xffffffff,-0x18(%rbp)
jne    11b5 <create_sparse+0x65>
mov    -0x10(%rbp),%rsi
lea    0xe5c(%rip),%rdi
call   1040 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1200 <create_sparse+0xb0>
mov    -0x18(%rbp),%edi
lea    0xe66(%rip),%rsi
mov    $0x13,%edx
call   1030 <write@plt>
mov    -0x18(%rbp),%edi
mov    -0x14(%rbp),%esi
mov    0x2dfa(%rip),%rax
mov    (%rax),%edx
call   1050 <lseek@plt>
mov    -0x18(%rbp),%edi
lea    0xe52(%rip),%rsi
mov    $0x11,%edx
call   1030 <write@plt>
mov    -0x18(%rbp),%edi
call   1060 <close@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<create_sparse>:
push   %rbp
push   %r14
push   %rbx
mov    %esi,%r14d
mov    %rdi,%rbx
mov    0x2e57(%rip),%rax
mov    0x2e88(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
mov    0x2e85(%rip),%rax
or     (%rax),%esi
mov    0x2e5c(%rip),%rax
mov    (%rax),%edx
call   1070 <open@plt>
cmp    $0xffffffff,%eax
je     11ce <create_sparse+0x7e>
mov    %eax,%ebp
lea    0xe94(%rip),%rsi
mov    %eax,%edi
mov    $0x13,%edx
call   1030 <write@plt>
mov    0x2e2c(%rip),%rax
mov    (%rax),%edx
mov    %ebp,%edi
mov    %r14d,%esi
call   1050 <lseek@plt>
lea    0xe82(%rip),%rsi
mov    %ebp,%edi
mov    $0x11,%edx
call   1030 <write@plt>
mov    %ebp,%edi
call   1060 <close@plt>
xor    %eax,%eax
jmp    11e2 <create_sparse+0x92>
lea    0xe2b(%rip),%rdi
mov    %rbx,%rsi
call   1040 <printf@plt>
mov    $0x1,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@O_WRONLY = global i32 0
@O_TRUNC = global i32 0
@O_CREAT = global i32 0
@S_IRWXU = global i32 0
@.str = [37 x i8] c"Error! Can't open or create file: %s\00"
@.str.1 = [20 x i8] c"Start sparse file!\0A\00"
@SEEK_CUR = global i32 0
@.str.2 = [18 x i8] c"End sparse file!\0A\00"
define i32 @create_sparse(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 = load i32, i32* @O_WRONLY
%9 = load i32, i32* @O_TRUNC
%10 = or i32 %8, %9
%11 = load i32, i32* @O_CREAT
%12 = or i32 %10, %11
%13 = load i32, i32* @S_IRWXU
%14 = call i32 @open(i8* %7, i32 %12, i32 %13)
store i32 %14, i32* %6
%15 = load i32, i32* %6
%16 = icmp eq i32 %15, -1
br i1 %16, label %17, label %20
17: ; preds = %2
%18 = load i8*, i8** %4
%19 = call i32 @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0), i8* %18)
store i32 1, i32* %3
br label %31
20: ; preds = %2
%21 = load i32, i32* %6
%22 = call i32 @write(i32 %21, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i32 19)
%23 = load i32, i32* %6
%24 = load i32, i32* %5
%25 = load i32, i32* @SEEK_CUR
%26 = call i32 @lseek(i32 %23, i32 %24, i32 %25)
%27 = load i32, i32* %6
%28 = call i32 @write(i32 %27, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i32 17)
%29 = load i32, i32* %6
%30 = call i32 @close(i32 %29)
store i32 0, i32* %3
br label %31
31: ; preds = %20, %17
%32 = load i32, i32* %3
ret i32 %32
}

LLVM IR (-O2):
@O_WRONLY = global i32 0
@O_TRUNC = global i32 0
@O_CREAT = global i32 0
@S_IRWXU = global i32 0
@.str = [37 x i8] c"Error! Can't open or create file: %s\00"
@.str.1 = [20 x i8] c"Start sparse file!\0A\00"
@SEEK_CUR = global i32 0
@.str.2 = [18 x i8] c"End sparse file!\0A\00"
define i32 @create_sparse(i8* %0, i32 %1) {
%3 = load i32, i32* @O_WRONLY
%4 = load i32, i32* @O_TRUNC
%5 = or i32 %4, %3
%6 = load i32, i32* @O_CREAT
%7 = or i32 %5, %6
%8 = load i32, i32* @S_IRWXU
%9 = tail call i32 @open(i8* %0, i32 %7, i32 %8)
%10 = icmp eq i32 %9, -1
br i1 %10, label %11, label %13
11: ; preds = %2
%12 = tail call i32 @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0), i8* %0)
br label %19
13: ; preds = %2
%14 = tail call i32 @write(i32 %9, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i32 19)
%15 = load i32, i32* @SEEK_CUR
%16 = tail call i32 @lseek(i32 %9, i32 %1, i32 %15)
%17 = tail call i32 @write(i32 %9, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i32 17)
%18 = tail call i32 @close(i32 %9)
br label %19
19: ; preds = %13, %11
%20 = phi i32 [ 1, %11 ], [ 0, %13 ]
ret i32 %20
}