#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 */
int atoi(char *);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fputc(int /*<<< orphan*/, int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *);
int main(int argc, char **argv) {
  if (argc != 3) {
    printf("Usage: make_empty_disk bytes_per_block nblocks\n");
    return 0;
  }
  int bytes_per_block = atoi(argv[1]);
  int nblocks = atoi(argv[2]);
  FILE *dev_fd = fopen("./disk.sfs", "w");
  int i;
  for (i = 0; i < nblocks * bytes_per_block; i++) {
    fputc(0, dev_fd);
  }
  fclose(dev_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)
cmpl   $0x3,-0x8(%rbp)
je     1188 <main+0x38>
lea    0xe89(%rip),%rdi
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1201 <main+0xb1>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1070 <atoi@plt>
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1070 <atoi@plt>
mov    %eax,-0x18(%rbp)
lea    0xe81(%rip),%rdi
lea    0xe85(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
mov    -0x18(%rbp),%ecx
imul   -0x14(%rbp),%ecx
cmp    %ecx,%eax
jge    11f1 <main+0xa1>
mov    -0x20(%rbp),%rsi
xor    %edi,%edi
call   1050 <fputc@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    11c6 <main+0x76>
mov    -0x20(%rbp),%rdi
call   1030 <fclose@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
cmp    $0x3,%edi
jne    11a9 <main+0x59>
mov    %rsi,%rbx
mov    0x8(%rsi),%rdi
call   1070 <atoi@plt>
mov    %eax,%ebp
mov    0x10(%rbx),%rdi
call   1070 <atoi@plt>
mov    %eax,%ebx
lea    0xe87(%rip),%rdi
lea    0xe8b(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,%r14
imul   %ebp,%ebx
test   %ebx,%ebx
jle    119f <main+0x4f>
nop
xor    %edi,%edi
mov    %r14,%rsi
call   1050 <fputc@plt>
add    $0xffffffff,%ebx
jne    1190 <main+0x40>
mov    %r14,%rdi
call   1040 <fclose@plt>
jmp    11b5 <main+0x65>
lea    0xe5d(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [48 x i8] c"Usage: make_empty_disk bytes_per_block nblocks\0A\00"
@.str.1 = [11 x i8] c"./disk.sfs\00"
@.str.2 = [2 x i8] c"w\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32*
%9 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = load i32, i32* %4
%11 = icmp ne i32 %10, 3
br i1 %11, label %12, label %14
12: ; preds = %2
%13 = call i32 @printf(i8* getelementptr inbounds ([48 x i8], [48 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %3
br label %39
14: ; preds = %2
%15 = load i8**, i8*** %5
%16 = getelementptr inbounds i8*, i8** %15, i64 1
%17 = load i8*, i8** %16
%18 = call i32 @atoi(i8* %17)
store i32 %18, i32* %6
%19 = load i8**, i8*** %5
%20 = getelementptr inbounds i8*, i8** %19, i64 2
%21 = load i8*, i8** %20
%22 = call i32 @atoi(i8* %21)
store i32 %22, i32* %7
%23 = call i32* @fopen(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32* %23, i32** %8
store i32 0, i32* %9
br label %24
24: ; preds = %33, %14
%25 = load i32, i32* %9
%26 = load i32, i32* %7
%27 = load i32, i32* %6
%28 = mul nsw i32 %26, %27
%29 = icmp slt i32 %25, %28
br i1 %29, label %30, label %36
30: ; preds = %24
%31 = load i32*, i32** %8
%32 = call i32 @fputc(i32 0, i32* %31)
br label %33
33: ; preds = %30
%34 = load i32, i32* %9
%35 = add nsw i32 %34, 1
store i32 %35, i32* %9
br label %24
36: ; preds = %24
%37 = load i32*, i32** %8
%38 = call i32 @fclose(i32* %37)
store i32 0, i32* %3
br label %39
39: ; preds = %36, %12
%40 = load i32, i32* %3
ret i32 %40
}

LLVM IR (-O2):
@.str.1 = [11 x i8] c"./disk.sfs\00"
@.str.2 = [2 x i8] c"w\00"
@str = [47 x i8] c"Usage: make_empty_disk bytes_per_block nblocks\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 3
br i1 %3, label %6, label %4
4: ; preds = %2
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([47 x i8], [47 x i8]* @str, i64 0, i64 0))
br label %23
6: ; preds = %2
%7 = getelementptr inbounds i8*, i8** %1, i64 1
%8 = load i8*, i8** %7
%9 = tail call i32 @atoi(i8* %8)
%10 = getelementptr inbounds i8*, i8** %1, i64 2
%11 = load i8*, i8** %10
%12 = tail call i32 @atoi(i8* %11)
%13 = tail call i32* @fopen(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%14 = mul i32 %12, %9
%15 = icmp sgt i32 %14, 0
br i1 %15, label %16, label %21
16: ; preds = %6, %16
%17 = phi i32 [ %19, %16 ], [ 0, %6 ]
%18 = tail call i32 @fputc(i32 0, i32* %13)
%19 = add nuw nsw i32 %17, 1
%20 = icmp eq i32 %19, %14
br i1 %20, label %21, label %16
21: ; preds = %16, %6
%22 = tail call i32 @fclose(i32* %13)
br label %23
23: ; preds = %21, %4
ret i32 0
}