#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 /*<<< orphan*/ SEEK_SET;
int /*<<< orphan*/ lseek(int, size_t, int /*<<< orphan*/);
int /*<<< orphan*/ write(int, char *, int);
void makerom_pad(int ifd, int ofd, size_t romsize, size_t makerom_padtosize) {
  int i;
  char c[1];
  c[0] = '\0';
  lseek(ofd, romsize, SEEK_SET);
  for (i = romsize; i < makerom_padtosize; i++) {
    write(ofd, c, 1);
  }
}


x86 assembly (clang, -O0):
<makerom_pad>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
mov    %rcx,-0x18(%rbp)
movb   $0x0,-0x1d(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    0x2e98(%rip),%rax
mov    (%rax),%edx
call   1040 <lseek@plt>
mov    -0x10(%rbp),%rax
mov    %eax,-0x1c(%rbp)
movslq -0x1c(%rbp),%rax
cmp    -0x18(%rbp),%rax
jae    1183 <makerom_pad+0x63>
mov    -0x8(%rbp),%edi
lea    -0x1d(%rbp),%rsi
mov    $0x1,%edx
call   1030 <write@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1156 <makerom_pad+0x36>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<makerom_pad>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rcx,%r15
mov    %rdx,%r14
mov    %esi,%ebp
movb   $0x0,0x7(%rsp)
mov    0x2ea5(%rip),%rax
mov    (%rax),%edx
mov    %esi,%edi
mov    %r14,%rsi
call   1040 <lseek@plt>
movslq %r14d,%rax
cmp    %r15,%rax
jae    1178 <makerom_pad+0x58>
movslq %r14d,%rbx
lea    0x7(%rsp),%r14
nopw   0x0(%rax,%rax,1)
mov    %ebp,%edi
mov    %r14,%rsi
mov    $0x1,%edx
call   1030 <write@plt>
add    $0x1,%rbx
cmp    %r15,%rbx
jb     1160 <makerom_pad+0x40>
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@SEEK_SET = global i32 0
define void @makerom_pad(i32 %0, i32 %1, i64 %2, i64 %3) {
%5 = alloca i32
%6 = alloca i32
%7 = alloca i64
%8 = alloca i64
%9 = alloca i32
%10 = alloca [1 x i8]
store i32 %0, i32* %5
store i32 %1, i32* %6
store i64 %2, i64* %7
store i64 %3, i64* %8
%11 = getelementptr inbounds [1 x i8], [1 x i8]* %10, i64 0, i64 0
store i8 0, i8* %11
%12 = load i32, i32* %6
%13 = load i64, i64* %7
%14 = load i32, i32* @SEEK_SET
%15 = call i32 @lseek(i32 %12, i64 %13, i32 %14)
%16 = load i64, i64* %7
%17 = trunc i64 %16 to i32
store i32 %17, i32* %9
br label %18
18: ; preds = %27, %4
%19 = load i32, i32* %9
%20 = sext i32 %19 to i64
%21 = load i64, i64* %8
%22 = icmp ult i64 %20, %21
br i1 %22, label %23, label %30
23: ; preds = %18
%24 = load i32, i32* %6
%25 = getelementptr inbounds [1 x i8], [1 x i8]* %10, i64 0, i64 0
%26 = call i32 @write(i32 %24, i8* %25, i32 1)
br label %27
27: ; preds = %23
%28 = load i32, i32* %9
%29 = add nsw i32 %28, 1
store i32 %29, i32* %9
br label %18
30: ; preds = %18
ret void
}

LLVM IR (-O2):
@SEEK_SET = global i32 0
define void @makerom_pad(i32 %0, i32 %1, i64 %2, i64 %3) {
%5 = alloca [1 x i8]
%6 = getelementptr inbounds [1 x i8], [1 x i8]* %5, i64 0, i64 0
store i8 0, i8* %6
%7 = load i32, i32* @SEEK_SET
%8 = tail call i32 @lseek(i32 %1, i64 %2, i32 %7)
%9 = shl i64 %2, 32
%10 = ashr exact i64 %9, 32
%11 = icmp ult i64 %10, %3
br i1 %11, label %12, label %20
12: ; preds = %4
%13 = shl i64 %2, 32
%14 = ashr exact i64 %13, 32
br label %15
15: ; preds = %12, %15
%16 = phi i64 [ %14, %12 ], [ %18, %15 ]
%17 = call i32 @write(i32 %1, i8* %6, i32 1)
%18 = add i64 %16, 1
%19 = icmp ult i64 %18, %3
br i1 %19, label %15, label %20
20: ; preds = %15, %4
ret void
}