#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_RDWR;
int O_TRUNC;
int S_IREAD;
int S_IWRITE;
int /*<<< orphan*/ exit(int);
int open(char *, int, int);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ write_big_sparse_file(int);
int main(int argc, char *argv[]) {
  int handle;
  if (argc < 2) {
    printf("Gimme a file name!\n");
    exit(1);
  }
  handle = open(argv[1], O_CREAT | O_RDWR | O_TRUNC, S_IREAD | S_IWRITE);
  if (handle < 0) {
    perror("opening file");
    exit(1);
  }
  write_big_sparse_file(handle);
  printf("Job done\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    1186 <main+0x36>
lea    0xe89(%rip),%rdi
call   1030 <printf@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    0x2e63(%rip),%rax
mov    (%rax),%esi
mov    0x2e3a(%rip),%rax
or     (%rax),%esi
mov    0x2e49(%rip),%rax
or     (%rax),%esi
mov    0x2e10(%rip),%rax
mov    (%rax),%edx
mov    0x2e17(%rip),%rax
or     (%rax),%edx
call   1040 <open@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jge    11e3 <main+0x93>
lea    0xe40(%rip),%rdi
call   1050 <perror@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
mov    -0x14(%rbp),%edi
call   1060 <write_big_sparse_file@plt>
lea    0xe2f(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
cmp    $0x1,%edi
jle    11a7 <main+0x57>
mov    0x8(%rsi),%rdi
mov    0x2e97(%rip),%rax
mov    0x2e70(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
mov    0x2e7d(%rip),%rax
or     (%rax),%esi
mov    0x2e44(%rip),%rax
mov    0x2e4d(%rip),%rcx
mov    (%rcx),%edx
or     (%rax),%edx
call   1040 <open@plt>
test   %eax,%eax
js     11bd <main+0x6d>
mov    %eax,%edi
call   1060 <write_big_sparse_file@plt>
lea    0xe6f(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
pop    %rcx
ret
lea    0xe68(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%edi
call   1070 <exit@plt>
lea    0xe3c(%rip),%rdi
call   1050 <perror@plt>
mov    $0x1,%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@.str = [20 x i8] c"Gimme a file name!\0A\00"
@O_CREAT = global i32 0
@O_RDWR = global i32 0
@O_TRUNC = global i32 0
@S_IREAD = global i32 0
@S_IWRITE = global i32 0
@.str.1 = [13 x i8] c"opening file\00"
@.str.2 = [10 x i8] c"Job done\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = load i32, i32* %4
%8 = icmp slt i32 %7, 2
br i1 %8, label %9, label %12
9: ; preds = %2
%10 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
%11 = call i32 @exit(i32 1)
unreachable
12: ; preds = %2
%13 = load i8**, i8*** %5
%14 = getelementptr inbounds i8*, i8** %13, i64 1
%15 = load i8*, i8** %14
%16 = load i32, i32* @O_CREAT
%17 = load i32, i32* @O_RDWR
%18 = or i32 %16, %17
%19 = load i32, i32* @O_TRUNC
%20 = or i32 %18, %19
%21 = load i32, i32* @S_IREAD
%22 = load i32, i32* @S_IWRITE
%23 = or i32 %21, %22
%24 = call i32 @open(i8* %15, i32 %20, i32 %23)
store i32 %24, i32* %6
%25 = load i32, i32* %6
%26 = icmp slt i32 %25, 0
br i1 %26, label %27, label %30
27: ; preds = %12
%28 = call i32 @perror(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0))
%29 = call i32 @exit(i32 1)
unreachable
30: ; preds = %12
%31 = load i32, i32* %6
%32 = call i32 @write_big_sparse_file(i32 %31)
%33 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@O_CREAT = global i32 0
@O_RDWR = global i32 0
@O_TRUNC = global i32 0
@S_IREAD = global i32 0
@S_IWRITE = global i32 0
@.str.1 = [13 x i8] c"opening file\00"
@str = [9 x i8] c"Job done\00"
@str.3 = [19 x i8] c"Gimme a file name!\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp slt i32 %0, 2
br i1 %3, label %4, label %7
4: ; preds = %2
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str.3, i64 0, i64 0))
%6 = tail call i32 @exit(i32 1)
unreachable
7: ; preds = %2
%8 = getelementptr inbounds i8*, i8** %1, i64 1
%9 = load i8*, i8** %8
%10 = load i32, i32* @O_CREAT
%11 = load i32, i32* @O_RDWR
%12 = or i32 %11, %10
%13 = load i32, i32* @O_TRUNC
%14 = or i32 %12, %13
%15 = load i32, i32* @S_IREAD
%16 = load i32, i32* @S_IWRITE
%17 = or i32 %16, %15
%18 = tail call i32 @open(i8* %9, i32 %14, i32 %17)
%19 = icmp slt i32 %18, 0
br i1 %19, label %20, label %23
20: ; preds = %7
%21 = tail call i32 @perror(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0))
%22 = tail call i32 @exit(i32 1)
unreachable
23: ; preds = %7
%24 = tail call i32 @write_big_sparse_file(i32 %18)
%25 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @str, i64 0, i64 0))
ret i32 0
}