#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_EXCL;
int O_WRONLY;
int /*<<< orphan*/ SEEK_SET;
scalar_t__ atoi(char *);
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ lseek(int, size_t, int /*<<< orphan*/);
int open(char *, int, int);
int /*<<< orphan*/ write(int, int *, int);
int main(int argc, char *argv[]) {
  int zero = 0;
  const int megabyte = 1024 * 1024;
  char *filename = argv[1];
  size_t length = (size_t)atoi(argv[2]) * megabyte;
  int fd = open(filename, O_WRONLY | O_CREAT | O_EXCL, 0666);
  lseek(fd, length - 1, SEEK_SET);
  write(fd, &zero, 1);
  close(fd);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x100000,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1070 <atoi@plt>
shl    $0x14,%rax
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rdi
mov    0x2e20(%rip),%rax
mov    (%rax),%esi
mov    0x2e4f(%rip),%rax
or     (%rax),%esi
mov    0x2e26(%rip),%rax
or     (%rax),%esi
mov    $0x1b6,%edx
call   1060 <open@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x2c(%rbp),%edi
mov    -0x28(%rbp),%rsi
sub    $0x1,%rsi
mov    0x2dfd(%rip),%rax
mov    (%rax),%edx
call   1040 <lseek@plt>
mov    -0x2c(%rbp),%edi
lea    -0x14(%rbp),%rsi
mov    $0x1,%edx
call   1030 <write@plt>
mov    -0x2c(%rbp),%edi
call   1050 <close@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
movl   $0x0,0xc(%rsp)
mov    0x8(%rsi),%r14
mov    0x10(%rsi),%rdi
call   1070 <atoi@plt>
mov    %rax,%rbx
mov    0x2e49(%rip),%rax
mov    0x2e7a(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
shl    $0x14,%rbx
mov    0x2e4b(%rip),%rax
or     (%rax),%esi
mov    %r14,%rdi
mov    $0x1b6,%edx
call   1060 <open@plt>
mov    %eax,%ebp
add    $0xffffffffffffffff,%rbx
mov    0x2e27(%rip),%rax
mov    (%rax),%edx
mov    %ebp,%edi
mov    %rbx,%rsi
call   1040 <lseek@plt>
lea    0xc(%rsp),%rsi
mov    %ebp,%edi
mov    $0x1,%edx
call   1030 <write@plt>
mov    %ebp,%edi
call   1050 <close@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@O_WRONLY = global i32 0
@O_CREAT = global i32 0
@O_EXCL = global i32 0
@SEEK_SET = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i64
%10 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %6
store i32 1048576, i32* %7
%11 = load i8**, i8*** %5
%12 = getelementptr inbounds i8*, i8** %11, i64 1
%13 = load i8*, i8** %12
store i8* %13, i8** %8
%14 = load i8**, i8*** %5
%15 = getelementptr inbounds i8*, i8** %14, i64 2
%16 = load i8*, i8** %15
%17 = call i64 @atoi(i8* %16)
%18 = mul i64 %17, 1048576
store i64 %18, i64* %9
%19 = load i8*, i8** %8
%20 = load i32, i32* @O_WRONLY
%21 = load i32, i32* @O_CREAT
%22 = or i32 %20, %21
%23 = load i32, i32* @O_EXCL
%24 = or i32 %22, %23
%25 = call i32 @open(i8* %19, i32 %24, i32 438)
store i32 %25, i32* %10
%26 = load i32, i32* %10
%27 = load i64, i64* %9
%28 = sub i64 %27, 1
%29 = load i32, i32* @SEEK_SET
%30 = call i32 @lseek(i32 %26, i64 %28, i32 %29)
%31 = load i32, i32* %10
%32 = call i32 @write(i32 %31, i32* %6, i32 1)
%33 = load i32, i32* %10
%34 = call i32 @close(i32 %33)
ret i32 0
}

LLVM IR (-O2):
@O_WRONLY = global i32 0
@O_CREAT = global i32 0
@O_EXCL = global i32 0
@SEEK_SET = global i32 0
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
store i32 0, i32* %3
%5 = getelementptr inbounds i8*, i8** %1, i64 1
%6 = load i8*, i8** %5
%7 = getelementptr inbounds i8*, i8** %1, i64 2
%8 = load i8*, i8** %7
%9 = tail call i64 @atoi(i8* %8)
%10 = shl i64 %9, 20
%11 = load i32, i32* @O_WRONLY
%12 = load i32, i32* @O_CREAT
%13 = or i32 %12, %11
%14 = load i32, i32* @O_EXCL
%15 = or i32 %13, %14
%16 = tail call i32 @open(i8* %6, i32 %15, i32 438)
%17 = add i64 %10, -1
%18 = load i32, i32* @SEEK_SET
%19 = tail call i32 @lseek(i32 %16, i64 %17, i32 %18)
%20 = call i32 @write(i32 %16, i32* %3, i32 1)
%21 = tail call i32 @close(i32 %16)
ret i32 0
}