#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 /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fputc(unsigned int, int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, ...);
int main(int argc, char **argv) {
  if (argc < 2) {
    printf("Bad command args\n");
    return 1;
  }
  printf("Creating %s\n", argv[1]);
  FILE *hex = fopen(argv[1], "wb");
  unsigned i;
  unsigned j;
  for (j = 0; j <= 255; ++j)
    for (i = 0; i <= 255; ++i)
      fputc(i, hex);
  fclose(hex);
  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   $0x2,-0x8(%rbp)
jge    117a <main+0x3a>
lea    0xe99(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    120d <main+0xcd>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xe89(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe80(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x20(%rbp)
cmpl   $0xff,-0x20(%rbp)
ja     11fd <main+0xbd>
movl   $0x0,-0x1c(%rbp)
cmpl   $0xff,-0x1c(%rbp)
ja     11ea <main+0xaa>
mov    -0x1c(%rbp),%edi
mov    -0x18(%rbp),%rsi
call   1050 <fputc@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11c3 <main+0x83>
jmp    11ef <main+0xaf>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    11af <main+0x6f>
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
cmp    $0x1,%edi
jg     116c <main+0x1c>
lea    0xeb0(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%eax
jmp    11dc <main+0x8c>
mov    %rsi,%rbx
mov    0x8(%rsi),%rsi
lea    0xe86(%rip),%rdi
xor    %r14d,%r14d
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x8(%rbx),%rdi
lea    0xe7e(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,%rbx
nopw   0x0(%rax,%rax,1)
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %ebp,%edi
mov    %rbx,%rsi
call   1060 <fputc@plt>
add    $0x1,%ebp
cmp    $0x100,%ebp
jne    11b0 <main+0x60>
add    $0x1,%r14d
cmp    $0x100,%r14d
jne    11a0 <main+0x50>
mov    %rbx,%rdi
call   1040 <fclose@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [18 x i8] c"Bad command args\0A\00"
@.str.1 = [13 x i8] c"Creating %s\0A\00"
@.str.2 = [3 x i8] c"wb\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
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = load i32, i32* %4
%10 = icmp slt i32 %9, 2
br i1 %10, label %11, label %13
11: ; preds = %2
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %3
br label %43
13: ; preds = %2
%14 = load i8**, i8*** %5
%15 = getelementptr inbounds i8*, i8** %14, i64 1
%16 = load i8*, i8** %15
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i8* %16)
%18 = load i8**, i8*** %5
%19 = getelementptr inbounds i8*, i8** %18, i64 1
%20 = load i8*, i8** %19
%21 = call i32* @fopen(i8* %20, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
store i32* %21, i32** %6
store i32 0, i32* %8
br label %22
22: ; preds = %37, %13
%23 = load i32, i32* %8
%24 = icmp ule i32 %23, 255
br i1 %24, label %25, label %40
25: ; preds = %22
store i32 0, i32* %7
br label %26
26: ; preds = %33, %25
%27 = load i32, i32* %7
%28 = icmp ule i32 %27, 255
br i1 %28, label %29, label %36
29: ; preds = %26
%30 = load i32, i32* %7
%31 = load i32*, i32** %6
%32 = call i32 @fputc(i32 %30, i32* %31)
br label %33
33: ; preds = %29
%34 = load i32, i32* %7
%35 = add i32 %34, 1
store i32 %35, i32* %7
br label %26
36: ; preds = %26
br label %37
37: ; preds = %36
%38 = load i32, i32* %8
%39 = add i32 %38, 1
store i32 %39, i32* %8
br label %22
40: ; preds = %22
%41 = load i32*, i32** %6
%42 = call i32 @fclose(i32* %41)
store i32 0, i32* %3
br label %43
43: ; preds = %40, %11
%44 = load i32, i32* %3
ret i32 %44
}

LLVM IR (-O2):
@.str.1 = [13 x i8] c"Creating %s\0A\00"
@.str.2 = [3 x i8] c"wb\00"
@str = [17 x i8] c"Bad command args\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp slt i32 %0, 2
br i1 %3, label %4, label %6
4: ; preds = %2
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str, i64 0, i64 0))
br label %24
6: ; preds = %2
%7 = getelementptr inbounds i8*, i8** %1, i64 1
%8 = load i8*, i8** %7
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i8* %8)
%10 = load i8*, i8** %7
%11 = tail call i32* @fopen(i8* %10, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
br label %12
12: ; preds = %6, %19
%13 = phi i32 [ 0, %6 ], [ %20, %19 ]
br label %14
14: ; preds = %12, %14
%15 = phi i32 [ 0, %12 ], [ %17, %14 ]
%16 = tail call i32 @fputc(i32 %15, i32* %11)
%17 = add nuw nsw i32 %15, 1
%18 = icmp eq i32 %17, 256
br i1 %18, label %19, label %14
19: ; preds = %14
%20 = add nuw nsw i32 %13, 1
%21 = icmp eq i32 %20, 256
br i1 %21, label %22, label %12
22: ; preds = %19
%23 = tail call i32 @fclose(i32* %11)
br label %24
24: ; preds = %22, %4
%25 = phi i32 [ 1, %4 ], [ 0, %22 ]
ret i32 %25
}