#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 */
struct stat {
  long st_size;
};
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fwrite(unsigned char *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, char *);
scalar_t__ stat(char *, struct stat *);
long strtol(char *, int /*<<< orphan*/ *, int);
int /*<<< orphan*/ syntax();
int main(int argc, char **argv) {
  FILE *fp;
  long int i = 0L, padsize = 0L;
  unsigned char data = 0xff;
  struct stat fileinfo;
  if (argc < 3) {
    syntax();
    exit(1);
  }
  if ((fp = fopen(argv[2], "a")) == NULL) {
    printf("error opening %s.\n", argv[2]);
    exit(1);
  }
  if (stat(argv[2], &fileinfo) != 0) {
    printf("error in stat of %s.\n", argv[2]);
    exit(1);
  }
  padsize = strtol(argv[1], NULL, 10) - fileinfo.st_size;
  for (i = 0; i < padsize; i++) {
    fwrite(&data, 1, 1, fp);
  }
  fclose(fp);
  return (0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
movb   $0xff,-0x29(%rbp)
cmpl   $0x3,-0x8(%rbp)
jge    11c5 <main+0x45>
mov    $0x0,%al
call   1070 <syntax@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xe2c(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jne    1205 <main+0x85>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rsi
lea    0xe0c(%rip),%rdi
call   1040 <printf@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    -0x38(%rbp),%rsi
call   1050 <stat@plt>
cmp    $0x0,%rax
je     123e <main+0xbe>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rsi
lea    0xde6(%rip),%rdi
call   1040 <printf@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0xa,%edx
call   1060 <strtol@plt>
sub    -0x38(%rbp),%rax
mov    %rax,-0x28(%rbp)
movq   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%rax
cmp    -0x28(%rbp),%rax
jge    1297 <main+0x117>
mov    -0x18(%rbp),%rcx
lea    -0x29(%rbp),%rdi
mov    $0x1,%edx
mov    %edx,%esi
call   10a0 <fwrite@plt>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    1264 <main+0xe4>
mov    -0x18(%rbp),%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
cmp    $0x2,%edi
jle    1207 <main+0x87>
mov    %rsi,%r14
mov    0x10(%rsi),%rdi
lea    0xe64(%rip),%rsi
call   1090 <fopen@plt>
mov    %rax,%r15
mov    0x10(%r14),%rax
test   %r15,%r15
je     1218 <main+0x98>
lea    0x8(%rsp),%rsi
mov    %rax,%rdi
call   1060 <stat@plt>
test   %rax,%rax
jne    1224 <main+0xa4>
mov    0x8(%r14),%rdi
xor    %esi,%esi
mov    $0xa,%edx
call   1070 <strtol@plt>
mov    %rax,%rbx
sub    0x8(%rsp),%rbx
test   %rbx,%rbx
jle    11f3 <main+0x73>
nopl   0x0(%rax)
mov    $0xffffffff,%edi
mov    %r15,%rsi
call   1050 <fputc@plt>
add    $0xffffffffffffffff,%rbx
jne    11e0 <main+0x60>
mov    %r15,%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret
xor    %eax,%eax
call   1080 <syntax@plt>
mov    $0x1,%edi
call   10a0 <exit@plt>
lea    0xde3(%rip),%rdi
mov    %rax,%rsi
jmp    122f <main+0xaf>
mov    0x10(%r14),%rsi
lea    0xde6(%rip),%rdi
call   1040 <printf@plt>
mov    $0x1,%edi
call   10a0 <exit@plt>

LLVM IR (-O0):
%struct.stat = type { i64 }
@.str = [2 x i8] c"a\00"
@.str.1 = [19 x i8] c"error opening %s.\0A\00"
@.str.2 = [22 x i8] c"error in stat of %s.\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca i64
%8 = alloca i64
%9 = alloca i8
%10 = alloca %struct.stat
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i64 0, i64* %7
store i64 0, i64* %8
store i8 -1, i8* %9
%11 = load i32, i32* %4
%12 = icmp slt i32 %11, 3
br i1 %12, label %13, label %16
13: ; preds = %2
%14 = call i32 (...) @syntax()
%15 = call i32 @exit(i32 1)
unreachable
16: ; preds = %2
%17 = load i8**, i8*** %5
%18 = getelementptr inbounds i8*, i8** %17, i64 2
%19 = load i8*, i8** %18
%20 = call i32* @fopen(i8* %19, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %20, i32** %6
%21 = icmp eq i32* %20, null
br i1 %21, label %22, label %28
22: ; preds = %16
%23 = load i8**, i8*** %5
%24 = getelementptr inbounds i8*, i8** %23, i64 2
%25 = load i8*, i8** %24
%26 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i8* %25)
%27 = call i32 @exit(i32 1)
unreachable
28: ; preds = %16
%29 = load i8**, i8*** %5
%30 = getelementptr inbounds i8*, i8** %29, i64 2
%31 = load i8*, i8** %30
%32 = call i64 @stat(i8* %31, %struct.stat* %10)
%33 = icmp ne i64 %32, 0
br i1 %33, label %34, label %40
34: ; preds = %28
%35 = load i8**, i8*** %5
%36 = getelementptr inbounds i8*, i8** %35, i64 2
%37 = load i8*, i8** %36
%38 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0), i8* %37)
%39 = call i32 @exit(i32 1)
unreachable
40: ; preds = %28
%41 = load i8**, i8*** %5
%42 = getelementptr inbounds i8*, i8** %41, i64 1
%43 = load i8*, i8** %42
%44 = call i64 @strtol(i8* %43, i32* null, i32 10)
%45 = getelementptr inbounds %struct.stat, %struct.stat* %10, i32 0, i32 0
%46 = load i64, i64* %45
%47 = sub nsw i64 %44, %46
store i64 %47, i64* %8
store i64 0, i64* %7
br label %48
48: ; preds = %55, %40
%49 = load i64, i64* %7
%50 = load i64, i64* %8
%51 = icmp slt i64 %49, %50
br i1 %51, label %52, label %58
52: ; preds = %48
%53 = load i32*, i32** %6
%54 = call i32 @fwrite(i8* %9, i32 1, i32 1, i32* %53)
br label %55
55: ; preds = %52
%56 = load i64, i64* %7
%57 = add nsw i64 %56, 1
store i64 %57, i64* %7
br label %48
58: ; preds = %48
%59 = load i32*, i32** %6
%60 = call i32 @fclose(i32* %59)
ret i32 0
}

LLVM IR (-O2):
%struct.stat = type { i64 }
@.str = [2 x i8] c"a\00"
@.str.1 = [19 x i8] c"error opening %s.\0A\00"
@.str.2 = [22 x i8] c"error in stat of %s.\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca %struct.stat
%4 = bitcast %struct.stat* %3 to i8*
%5 = icmp slt i32 %0, 3
br i1 %5, label %6, label %9
6: ; preds = %2
%7 = tail call i32 (...) @syntax()
%8 = tail call i32 @exit(i32 1)
unreachable
9: ; preds = %2
%10 = getelementptr inbounds i8*, i8** %1, i64 2
%11 = load i8*, i8** %10
%12 = tail call i32* @fopen(i8* %11, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%13 = icmp eq i32* %12, null
%14 = load i8*, i8** %10
br i1 %13, label %15, label %18
15: ; preds = %9
%16 = tail call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0), i8* %14)
%17 = tail call i32 @exit(i32 1)
unreachable
18: ; preds = %9
%19 = call i64 @stat(i8* %14, %struct.stat* %3)
%20 = icmp eq i64 %19, 0
br i1 %20, label %25, label %21
21: ; preds = %18
%22 = load i8*, i8** %10
%23 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0), i8* %22)
%24 = call i32 @exit(i32 1)
unreachable
25: ; preds = %18
%26 = getelementptr inbounds i8*, i8** %1, i64 1
%27 = load i8*, i8** %26
%28 = call i64 @strtol(i8* nocapture %27, i32* null, i32 10)
%29 = getelementptr inbounds %struct.stat, %struct.stat* %3, i64 0, i32 0
%30 = load i64, i64* %29
%31 = sub i64 %28, %30
%32 = icmp sgt i64 %31, 0
br i1 %32, label %33, label %38
33: ; preds = %25, %33
%34 = phi i64 [ %36, %33 ], [ 0, %25 ]
%35 = call i32 @fputc(i32 -1, i32* %12)
%36 = add nuw nsw i64 %34, 1
%37 = icmp eq i64 %36, %31
br i1 %37, label %38, label %33
38: ; preds = %33, %25
%39 = call i32 @fclose(i32* %12)
ret i32 0
}