#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_WRONLY;
int /*<<< orphan*/ SEEK_SET;
int /*<<< orphan*/ close(int);
int errno;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int lseek(int, int, int /*<<< orphan*/);
int open(char *, int);
int /*<<< orphan*/ printf(char *, int, int);
int /*<<< orphan*/ strlen(char *);
int /*<<< orphan*/ write(int, char *, int /*<<< orphan*/);
int main() {
  int fd;
  fd = open("dummy.data", O_CREAT | O_WRONLY);
  int offset = lseek(fd, 20000000000, SEEK_SET);
  if (offset < 0) {
    printf("Cannot create a 20 GB sparse file, offset %d, errno %d\n", offset,
           errno);
    exit(0);
  }
  write(fd, "simple_string", strlen("simple_string"));
  close(fd);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2e72(%rip),%rax
mov    (%rax),%esi
mov    0x2e31(%rip),%rax
or     (%rax),%esi
lea    0xe68(%rip),%rdi
call   1080 <open@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%edi
mov    0x2e26(%rip),%rax
mov    (%rax),%edx
mov    $0xa817c800,%esi
call   1060 <lseek@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jge    11e2 <main+0x72>
mov    -0xc(%rbp),%esi
mov    0x2e0b(%rip),%rax
mov    (%rax),%edx
lea    0xe35(%rip),%rdi
call   1050 <printf@plt>
xor    %edi,%edi
call   1090 <exit@plt>
mov    -0x8(%rbp),%eax
mov    %eax,-0x10(%rbp)
lea    0xe54(%rip),%rdi
call   1040 <strlen@plt>
mov    -0x10(%rbp),%edi
mov    %eax,%edx
lea    0xe43(%rip),%rsi
call   1030 <write@plt>
mov    -0x8(%rbp),%edi
call   1070 <close@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
mov    0x2e7d(%rip),%rax
mov    0x2e3e(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
lea    0xe73(%rip),%rdi
call   1080 <open@plt>
mov    %eax,%ebx
mov    0x2e35(%rip),%rax
mov    (%rax),%edx
mov    %ebx,%edi
mov    $0xa817c800,%esi
call   1060 <lseek@plt>
test   %eax,%eax
js     11d9 <main+0x69>
lea    0xe8f(%rip),%r14
mov    %r14,%rdi
call   1040 <strlen@plt>
mov    %ebx,%edi
mov    %r14,%rsi
mov    %eax,%edx
call   1030 <write@plt>
mov    %ebx,%edi
call   1070 <close@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
mov    0x2df8(%rip),%rcx
mov    (%rcx),%edx
lea    0xe22(%rip),%rdi
mov    %eax,%esi
call   1050 <printf@plt>
xor    %edi,%edi
call   1090 <exit@plt>

LLVM IR (-O0):
@.str = [11 x i8] c"dummy.data\00"
@O_CREAT = global i32 0
@O_WRONLY = global i32 0
@SEEK_SET = global i32 0
@.str.1 = [56 x i8] c"Cannot create a 20 GB sparse file, offset %d, errno %d\0A\00"
@errno = global i32 0
@.str.2 = [14 x i8] c"simple_string\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
store i32 0, i32* %1
%4 = load i32, i32* @O_CREAT
%5 = load i32, i32* @O_WRONLY
%6 = or i32 %4, %5
%7 = call i32 @open(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 %6)
store i32 %7, i32* %2
%8 = load i32, i32* %2
%9 = load i32, i32* @SEEK_SET
%10 = call i32 @lseek(i32 %8, i32 -1474836480, i32 %9)
store i32 %10, i32* %3
%11 = load i32, i32* %3
%12 = icmp slt i32 %11, 0
br i1 %12, label %13, label %18
13: ; preds = %0
%14 = load i32, i32* %3
%15 = load i32, i32* @errno
%16 = call i32 @printf(i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.1, i64 0, i64 0), i32 %14, i32 %15)
%17 = call i32 @exit(i32 0)
unreachable
18: ; preds = %0
%19 = load i32, i32* %2
%20 = call i32 @strlen(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0))
%21 = call i32 @write(i32 %19, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i32 %20)
%22 = load i32, i32* %2
%23 = call i32 @close(i32 %22)
ret i32 0
}

LLVM IR (-O2):
@.str = [11 x i8] c"dummy.data\00"
@O_CREAT = global i32 0
@O_WRONLY = global i32 0
@SEEK_SET = global i32 0
@.str.1 = [56 x i8] c"Cannot create a 20 GB sparse file, offset %d, errno %d\0A\00"
@errno = global i32 0
@.str.2 = [14 x i8] c"simple_string\00"
define i32 @main() {
%1 = load i32, i32* @O_CREAT
%2 = load i32, i32* @O_WRONLY
%3 = or i32 %2, %1
%4 = tail call i32 @open(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 %3)
%5 = load i32, i32* @SEEK_SET
%6 = tail call i32 @lseek(i32 %4, i32 -1474836480, i32 %5)
%7 = icmp slt i32 %6, 0
br i1 %7, label %8, label %12
8: ; preds = %0
%9 = load i32, i32* @errno
%10 = tail call i32 @printf(i8* getelementptr inbounds ([56 x i8], [56 x i8]* @.str.1, i64 0, i64 0), i32 %6, i32 %9)
%11 = tail call i32 @exit(i32 0)
unreachable
12: ; preds = %0
%13 = tail call i32 @strlen(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0))
%14 = tail call i32 @write(i32 %4, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i32 %13)
%15 = tail call i32 @close(i32 %4)
ret i32 0
}