#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 */
unsigned int atoi(char *);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fputc(int /*<<< orphan*/, int /*<<< orphan*/ *);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, int /*<<< orphan*/, int);
unsigned int ftell(int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, unsigned int);
int /*<<< orphan*/ srand(int /*<<< orphan*/);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int main(int argc, char **argv) {
  if (argc != 3)
    return -1;
  srand(time(NULL));
  FILE *pf = fopen(argv[1], "rb+");
  unsigned int size = atoi(argv[2]);
  printf("%d bytes\n", size);
  fseek(pf, 0, 2);
  while (ftell(pf) < size)
    fputc(0, pf);
  fclose(pf);
  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   $0x3,-0x8(%rbp)
je     11bc <main+0x2c>
movl   $0xffffffff,-0x4(%rbp)
jmp    1245 <main+0xb5>
xor    %eax,%eax
mov    %eax,%edi
call   1080 <time@plt>
mov    %eax,%edi
call   1060 <srand@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe25(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   10b0 <atoi@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%esi
lea    0xe06(%rip),%rdi
call   1040 <printf@plt>
mov    -0x18(%rbp),%rdi
xor    %esi,%esi
mov    $0x2,%edx
call   1090 <fseek@plt>
mov    -0x18(%rbp),%rdi
call   1070 <ftell@plt>
cmp    -0x1c(%rbp),%eax
jae    1235 <main+0xa5>
mov    -0x18(%rbp),%rsi
xor    %edi,%edi
call   1050 <fputc@plt>
jmp    1213 <main+0x83>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
mov    $0xffffffff,%r14d
cmp    $0x3,%edi
jne    1210 <main+0x80>
mov    %rsi,%rbp
xor    %r14d,%r14d
xor    %edi,%edi
call   1080 <time@plt>
mov    %eax,%edi
call   1060 <srand@plt>
mov    0x8(%rbp),%rdi
lea    0xe42(%rip),%rsi
call   10a0 <fopen@plt>
mov    %rax,%rbx
mov    0x10(%rbp),%rdi
call   10b0 <atoi@plt>
mov    %eax,%ebp
lea    0xe2c(%rip),%rdi
mov    %eax,%esi
call   1040 <printf@plt>
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x2,%edx
call   1090 <fseek@plt>
xchg   %ax,%ax
mov    %rbx,%rdi
call   1070 <ftell@plt>
cmp    %ebp,%eax
jae    1208 <main+0x78>
xor    %edi,%edi
mov    %rbx,%rsi
call   1050 <fputc@plt>
jmp    11f0 <main+0x60>
mov    %rbx,%rdi
call   1030 <fclose@plt>
mov    %r14d,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [4 x i8] c"rb+\00"
@.str.1 = [10 x i8] c"%d bytes\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = load i32, i32* %4
%9 = icmp ne i32 %8, 3
br i1 %9, label %10, label %11
10: ; preds = %2
store i32 -1, i32* %3
br label %37
11: ; preds = %2
%12 = call i32 @time(i32* null)
%13 = call i32 @srand(i32 %12)
%14 = load i8**, i8*** %5
%15 = getelementptr inbounds i8*, i8** %14, i64 1
%16 = load i8*, i8** %15
%17 = call i32* @fopen(i8* %16, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
store i32* %17, i32** %6
%18 = load i8**, i8*** %5
%19 = getelementptr inbounds i8*, i8** %18, i64 2
%20 = load i8*, i8** %19
%21 = call i32 @atoi(i8* %20)
store i32 %21, i32* %7
%22 = load i32, i32* %7
%23 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i32 %22)
%24 = load i32*, i32** %6
%25 = call i32 @fseek(i32* %24, i32 0, i32 2)
br label %26
26: ; preds = %31, %11
%27 = load i32*, i32** %6
%28 = call i32 @ftell(i32* %27)
%29 = load i32, i32* %7
%30 = icmp ult i32 %28, %29
br i1 %30, label %31, label %34
31: ; preds = %26
%32 = load i32*, i32** %6
%33 = call i32 @fputc(i32 0, i32* %32)
br label %26
34: ; preds = %26
%35 = load i32*, i32** %6
%36 = call i32 @fclose(i32* %35)
store i32 0, i32* %3
br label %37
37: ; preds = %34, %10
%38 = load i32, i32* %3
ret i32 %38
}

LLVM IR (-O2):
@.str = [4 x i8] c"rb+\00"
@.str.1 = [10 x i8] c"%d bytes\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 3
br i1 %3, label %4, label %23
4: ; preds = %2
%5 = tail call i32 @time(i32* null)
%6 = tail call i32 @srand(i32 %5)
%7 = getelementptr inbounds i8*, i8** %1, i64 1
%8 = load i8*, i8** %7
%9 = tail call i32* @fopen(i8* %8, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%10 = getelementptr inbounds i8*, i8** %1, i64 2
%11 = load i8*, i8** %10
%12 = tail call i32 @atoi(i8* %11)
%13 = tail call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i32 %12)
%14 = tail call i32 @fseek(i32* %9, i32 0, i32 2)
%15 = tail call i32 @ftell(i32* %9)
%16 = icmp ult i32 %15, %12
br i1 %16, label %17, label %21
17: ; preds = %4, %17
%18 = tail call i32 @fputc(i32 0, i32* %9)
%19 = tail call i32 @ftell(i32* %9)
%20 = icmp ult i32 %19, %12
br i1 %20, label %17, label %21
21: ; preds = %17, %4
%22 = tail call i32 @fclose(i32* %9)
br label %23
23: ; preds = %2, %21
%24 = phi i32 [ 0, %21 ], [ -1, %2 ]
ret i32 %24
}