#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 fwrite(unsigned char *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ sprintf(char *, char *, int);
int main(int argc, char *argv[]) {
  int j, i, k, m;
  char buf[80];
  unsigned char block[4096];
  FILE *dataFile;
  if (argc != 1) {
    printf("Usage: %s\n", argv[0]);
    return 1;
  }
  for (j = 0; j < 12; j++) {
    i = 1 << j;
    sprintf(buf, "0x%06X", i);
    printf("%s\n", buf);
    dataFile = fopen(buf, "wb");
    if (dataFile == NULL) {
      printf("Error: cannot open data file '%s'\n", buf);
      return 1;
    }
    for (m = 0; m < i; m++) {
      for (k = 0; k < 4096; k += 4) {
        block[k + 0] = m >> 24;
        block[k + 1] = m >> 16;
        block[k + 2] = m >> 8;
        block[k + 3] = m >> 0;
      }
      if (fwrite(block, 1, 4096, dataFile) != 4096) {
        printf("Error: cannot write data file '%s'\n", buf);
        return 1;
      }
    }
    fclose(dataFile);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1080,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x1,-0x8(%rbp)
je     1192 <main+0x42>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe7f(%rip),%rdi
call   1040 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    131d <main+0x1cd>
movl   $0x0,-0x14(%rbp)
cmpl   $0xc,-0x14(%rbp)
jge    1316 <main+0x1c6>
mov    -0x14(%rbp),%ecx
mov    $0x1,%eax
shl    %cl,%eax
mov    %eax,-0x18(%rbp)
lea    -0x70(%rbp),%rdi
mov    -0x18(%rbp),%edx
lea    0xe4d(%rip),%rsi
call   1060 <sprintf@plt>
lea    -0x70(%rbp),%rsi
lea    0xe39(%rip),%rdi
call   1040 <printf@plt>
lea    -0x70(%rbp),%rdi
lea    0xe34(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x1078(%rbp)
cmpq   $0x0,-0x1078(%rbp)
jne    1214 <main+0xc4>
lea    -0x70(%rbp),%rsi
lea    0xe12(%rip),%rdi
call   1040 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    131d <main+0x1cd>
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    12fc <main+0x1ac>
movl   $0x0,-0x1c(%rbp)
cmpl   $0x1000,-0x1c(%rbp)
jge    12a5 <main+0x155>
mov    -0x20(%rbp),%eax
sar    $0x18,%eax
mov    %al,%cl
mov    -0x1c(%rbp),%eax
add    $0x0,%eax
cltq
mov    %cl,-0x1070(%rbp,%rax,1)
mov    -0x20(%rbp),%eax
sar    $0x10,%eax
mov    %al,%cl
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
cltq
mov    %cl,-0x1070(%rbp,%rax,1)
mov    -0x20(%rbp),%eax
sar    $0x8,%eax
mov    %al,%cl
mov    -0x1c(%rbp),%eax
add    $0x2,%eax
cltq
mov    %cl,-0x1070(%rbp,%rax,1)
mov    -0x20(%rbp),%eax
sar    $0x0,%eax
mov    %al,%cl
mov    -0x1c(%rbp),%eax
add    $0x3,%eax
cltq
mov    %cl,-0x1070(%rbp,%rax,1)
mov    -0x1c(%rbp),%eax
add    $0x4,%eax
mov    %eax,-0x1c(%rbp)
jmp    122e <main+0xde>
lea    -0x1070(%rbp),%rdi
mov    -0x1078(%rbp),%rcx
mov    $0x1,%esi
mov    $0x1000,%edx
call   1070 <fwrite@plt>
cmp    $0x1000,%eax
je     12e9 <main+0x199>
lea    -0x70(%rbp),%rsi
lea    0xd60(%rip),%rdi
call   1040 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    131d <main+0x1cd>
jmp    12ee <main+0x19e>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    121b <main+0xcb>
mov    -0x1078(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1199 <main+0x49>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x1080,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x1068,%rsp
cmp    $0x1,%edi
jne    127f <main+0x12f>
xor    %ecx,%ecx
lea    0xe98(%rip),%r13
lea    0x10(%rsp),%rbx
lea    0xe88(%rip),%r12
lea    0xe8c(%rip),%rbp
lea    0x60(%rsp),%r15
mov    $0x1,%r14d
mov    %ecx,0xc(%rsp)
shl    %cl,%r14d
mov    %rbx,%rdi
mov    %r13,%rsi
mov    %r14d,%edx
call   1060 <sprintf@plt>
mov    %r12,%rdi
mov    %rbx,%rsi
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    %rbp,%rsi
call   1050 <fopen@plt>
test   %rax,%rax
je     12b3 <main+0x163>
mov    %rax,%r12
mov    %r13,%rbx
cmp    $0x2,%r14d
mov    $0x1,%eax
cmovl  %eax,%r14d
xor    %r13d,%r13d
nopl   0x0(%rax,%rax,1)
mov    %r13d,%eax
shr    $0x18,%eax
mov    %r13d,%ecx
shr    $0x10,%ecx
mov    %r13d,%edx
shr    $0x8,%edx
mov    $0xfffffffffffffffc,%rsi
nopl   0x0(%rax)
mov    %al,0x64(%rsp,%rsi,1)
mov    %cl,0x65(%rsp,%rsi,1)
mov    %dl,0x66(%rsp,%rsi,1)
mov    %r13b,0x67(%rsp,%rsi,1)
mov    %al,0x68(%rsp,%rsi,1)
mov    %cl,0x69(%rsp,%rsi,1)
mov    %dl,0x6a(%rsp,%rsi,1)
mov    %r13b,0x6b(%rsp,%rsi,1)
add    $0x8,%rsi
cmp    $0xffc,%rsi
jb     1200 <main+0xb0>
mov    %r15,%rdi
mov    $0x1,%esi
mov    $0x1000,%edx
mov    %r12,%rcx
call   1070 <fwrite@plt>
cmp    $0x1000,%eax
jne    128b <main+0x13b>
add    $0x1,%r13d
cmp    %r14d,%r13d
jne    11e0 <main+0x90>
mov    %r12,%rdi
call   1030 <fclose@plt>
mov    0xc(%rsp),%ecx
add    $0x1,%ecx
xor    %eax,%eax
cmp    $0xc,%ecx
mov    %rbx,%r13
lea    0x10(%rsp),%rbx
lea    0xd90(%rip),%r12
jne    118b <main+0x3b>
jmp    12a1 <main+0x151>
mov    (%rsi),%rsi
lea    0xd77(%rip),%rdi
jmp    1297 <main+0x147>
lea    0xda6(%rip),%rdi
lea    0x10(%rsp),%rsi
call   1040 <printf@plt>
mov    $0x1,%eax
add    $0x1068,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xd5b(%rip),%rdi
jmp    1292 <main+0x142>

LLVM IR (-O0):
@.str = [11 x i8] c"Usage: %s\0A\00"
@.str.1 = [7 x i8] c"0x%06X\00"
@.str.2 = [4 x i8] c"%s\0A\00"
@.str.3 = [3 x i8] c"wb\00"
@.str.4 = [35 x i8] c"Error: cannot open data file '%s'\0A\00"
@.str.5 = [36 x i8] c"Error: cannot write data file '%s'\0A\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
%10 = alloca [80 x i8]
%11 = alloca [4096 x i8]
%12 = alloca i32*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%13 = load i32, i32* %4
%14 = icmp ne i32 %13, 1
br i1 %14, label %15, label %20
15: ; preds = %2
%16 = load i8**, i8*** %5
%17 = getelementptr inbounds i8*, i8** %16, i64 0
%18 = load i8*, i8** %17
%19 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* %18)
store i32 1, i32* %3
br label %99
20: ; preds = %2
store i32 0, i32* %6
br label %21
21: ; preds = %95, %20
%22 = load i32, i32* %6
%23 = icmp slt i32 %22, 12
br i1 %23, label %24, label %98
24: ; preds = %21
%25 = load i32, i32* %6
%26 = shl i32 1, %25
store i32 %26, i32* %7
%27 = getelementptr inbounds [80 x i8], [80 x i8]* %10, i64 0, i64 0
%28 = load i32, i32* %7
%29 = call i32 @sprintf(i8* %27, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 %28)
%30 = getelementptr inbounds [80 x i8], [80 x i8]* %10, i64 0, i64 0
%31 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %30)
%32 = getelementptr inbounds [80 x i8], [80 x i8]* %10, i64 0, i64 0
%33 = call i32* @fopen(i8* %32, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
store i32* %33, i32** %12
%34 = load i32*, i32** %12
%35 = icmp eq i32* %34, null
br i1 %35, label %36, label %39
36: ; preds = %24
%37 = getelementptr inbounds [80 x i8], [80 x i8]* %10, i64 0, i64 0
%38 = call i32 @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.4, i64 0, i64 0), i8* %37)
store i32 1, i32* %3
br label %99
39: ; preds = %24
store i32 0, i32* %9
br label %40
40: ; preds = %89, %39
%41 = load i32, i32* %9
%42 = load i32, i32* %7
%43 = icmp slt i32 %41, %42
br i1 %43, label %44, label %92
44: ; preds = %40
store i32 0, i32* %8
br label %45
45: ; preds = %77, %44
%46 = load i32, i32* %8
%47 = icmp slt i32 %46, 4096
br i1 %47, label %48, label %80
48: ; preds = %45
%49 = load i32, i32* %9
%50 = ashr i32 %49, 24
%51 = trunc i32 %50 to i8
%52 = load i32, i32* %8
%53 = add nsw i32 %52, 0
%54 = sext i32 %53 to i64
%55 = getelementptr inbounds [4096 x i8], [4096 x i8]* %11, i64 0, i64 %54
store i8 %51, i8* %55
%56 = load i32, i32* %9
%57 = ashr i32 %56, 16
%58 = trunc i32 %57 to i8
%59 = load i32, i32* %8
%60 = add nsw i32 %59, 1
%61 = sext i32 %60 to i64
%62 = getelementptr inbounds [4096 x i8], [4096 x i8]* %11, i64 0, i64 %61
store i8 %58, i8* %62
%63 = load i32, i32* %9
%64 = ashr i32 %63, 8
%65 = trunc i32 %64 to i8
%66 = load i32, i32* %8
%67 = add nsw i32 %66, 2
%68 = sext i32 %67 to i64
%69 = getelementptr inbounds [4096 x i8], [4096 x i8]* %11, i64 0, i64 %68
store i8 %65, i8* %69
%70 = load i32, i32* %9
%71 = ashr i32 %70, 0
%72 = trunc i32 %71 to i8
%73 = load i32, i32* %8
%74 = add nsw i32 %73, 3
%75 = sext i32 %74 to i64
%76 = getelementptr inbounds [4096 x i8], [4096 x i8]* %11, i64 0, i64 %75
store i8 %72, i8* %76
br label %77
77: ; preds = %48
%78 = load i32, i32* %8
%79 = add nsw i32 %78, 4
store i32 %79, i32* %8
br label %45
80: ; preds = %45
%81 = getelementptr inbounds [4096 x i8], [4096 x i8]* %11, i64 0, i64 0
%82 = load i32*, i32** %12
%83 = call i32 @fwrite(i8* %81, i32 1, i32 4096, i32* %82)
%84 = icmp ne i32 %83, 4096
br i1 %84, label %85, label %88
85: ; preds = %80
%86 = getelementptr inbounds [80 x i8], [80 x i8]* %10, i64 0, i64 0
%87 = call i32 @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.5, i64 0, i64 0), i8* %86)
store i32 1, i32* %3
br label %99
88: ; preds = %80
br label %89
89: ; preds = %88
%90 = load i32, i32* %9
%91 = add nsw i32 %90, 1
store i32 %91, i32* %9
br label %40
92: ; preds = %40
%93 = load i32*, i32** %12
%94 = call i32 @fclose(i32* %93)
br label %95
95: ; preds = %92
%96 = load i32, i32* %6
%97 = add nsw i32 %96, 1
store i32 %97, i32* %6
br label %21
98: ; preds = %21
store i32 0, i32* %3
br label %99
99: ; preds = %98, %85, %36, %15
%100 = load i32, i32* %3
ret i32 %100
}

LLVM IR (-O2):
@.str = [11 x i8] c"Usage: %s\0A\00"
@.str.1 = [7 x i8] c"0x%06X\00"
@.str.2 = [4 x i8] c"%s\0A\00"
@.str.3 = [3 x i8] c"wb\00"
@.str.4 = [35 x i8] c"Error: cannot open data file '%s'\0A\00"
@.str.5 = [36 x i8] c"Error: cannot write data file '%s'\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [80 x i8]
%4 = alloca [4096 x i8]
%5 = getelementptr inbounds [80 x i8], [80 x i8]* %3, i64 0, i64 0
%6 = getelementptr inbounds [4096 x i8], [4096 x i8]* %4, i64 0, i64 0
%7 = icmp eq i32 %0, 1
br i1 %7, label %11, label %8
8: ; preds = %2
%9 = load i8*, i8** %1
%10 = tail call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* %9)
br label %62
11: ; preds = %2, %58
%12 = phi i32 [ %60, %58 ], [ 0, %2 ]
%13 = shl nuw nsw i32 1, %12
%14 = call i32 @sprintf(i8* %5, i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32 %13)
%15 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %5)
%16 = call i32* @fopen(i8* %5, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%17 = icmp eq i32* %16, null
br i1 %17, label %20, label %18
18: ; preds = %11
%19 = call i32 @llvm.smax.i32(i32 %13, i32 1)
br label %24
20: ; preds = %11
%21 = call i32 @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.4, i64 0, i64 0), i8* %5)
br label %62
22: ; preds = %52
%23 = icmp eq i32 %55, %19
br i1 %23, label %58, label %24
24: ; preds = %18, %22
%25 = phi i32 [ %55, %22 ], [ 0, %18 ]
%26 = lshr i32 %25, 24
%27 = trunc i32 %26 to i8
%28 = lshr i32 %25, 16
%29 = trunc i32 %28 to i8
%30 = lshr i32 %25, 8
%31 = trunc i32 %30 to i8
%32 = trunc i32 %25 to i8
br label %33
33: ; preds = %33, %24
%34 = phi i64 [ 0, %24 ], [ %50, %33 ]
%35 = getelementptr inbounds [4096 x i8], [4096 x i8]* %4, i64 0, i64 %34
store i8 %27, i8* %35
%36 = or i64 %34, 1
%37 = getelementptr inbounds [4096 x i8], [4096 x i8]* %4, i64 0, i64 %36
store i8 %29, i8* %37
%38 = or i64 %34, 2
%39 = getelementptr inbounds [4096 x i8], [4096 x i8]* %4, i64 0, i64 %38
store i8 %31, i8* %39
%40 = or i64 %34, 3
%41 = getelementptr inbounds [4096 x i8], [4096 x i8]* %4, i64 0, i64 %40
store i8 %32, i8* %41
%42 = or i64 %34, 4
%43 = getelementptr inbounds [4096 x i8], [4096 x i8]* %4, i64 0, i64 %42
store i8 %27, i8* %43
%44 = or i64 %34, 5
%45 = getelementptr inbounds [4096 x i8], [4096 x i8]* %4, i64 0, i64 %44
store i8 %29, i8* %45
%46 = or i64 %34, 6
%47 = getelementptr inbounds [4096 x i8], [4096 x i8]* %4, i64 0, i64 %46
store i8 %31, i8* %47
%48 = or i64 %34, 7
%49 = getelementptr inbounds [4096 x i8], [4096 x i8]* %4, i64 0, i64 %48
store i8 %32, i8* %49
%50 = add nuw nsw i64 %34, 8
%51 = icmp ult i64 %42, 4092
br i1 %51, label %33, label %52
52: ; preds = %33
%53 = call i32 @fwrite(i8* %6, i32 1, i32 4096, i32* %16)
%54 = icmp eq i32 %53, 4096
%55 = add nuw nsw i32 %25, 1
br i1 %54, label %22, label %56
56: ; preds = %52
%57 = call i32 @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.5, i64 0, i64 0), i8* %5)
br label %62
58: ; preds = %22
%59 = call i32 @fclose(i32* %16)
%60 = add nuw nsw i32 %12, 1
%61 = icmp eq i32 %60, 12
br i1 %61, label %62, label %11
62: ; preds = %58, %56, %20, %8
%63 = phi i32 [ 1, %8 ], [ 1, %20 ], [ 1, %56 ], [ 0, %58 ]
ret i32 %63
}