#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*/ putc(char, int /*<<< orphan*/ *);
int main(void) {
  FILE *f;
  long i;
  char l, h;
  f = fopen("lhhl.bin", "wb");
  for (i = 0; i < 65536; i += 4) {
    l = i & 255;
    h = i >> 8;
    putc(l, f);
    putc(h, f);
    putc(h, f);
    putc(l + 3, f);
  }
  fclose(f);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeba(%rip),%rdi
lea    0xebc(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
cmpq   $0x10000,-0x18(%rbp)
jge    11d5 <main+0xa5>
mov    -0x18(%rbp),%rax
and    $0xff,%rax
mov    %al,-0x19(%rbp)
mov    -0x18(%rbp),%rax
sar    $0x8,%rax
mov    %al,-0x1a(%rbp)
mov    -0x19(%rbp),%al
mov    -0x10(%rbp),%rsi
movsbl %al,%edi
call   1040 <putc@plt>
mov    -0x1a(%rbp),%al
mov    -0x10(%rbp),%rsi
movsbl %al,%edi
call   1040 <putc@plt>
mov    -0x1a(%rbp),%al
mov    -0x10(%rbp),%rsi
movsbl %al,%edi
call   1040 <putc@plt>
movsbl -0x19(%rbp),%eax
add    $0x3,%eax
mov    -0x10(%rbp),%rsi
movsbl %al,%edi
call   1040 <putc@plt>
mov    -0x18(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x18(%rbp)
jmp    115e <main+0x2e>
mov    -0x10(%rbp),%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
lea    0xec5(%rip),%rdi
lea    0xec7(%rip),%rsi
call   1050 <fopen@plt>
mov    %rax,%r14
xor    %ebx,%ebx
nopl   0x0(%rax)
mov    %ebx,%ebp
shr    $0x8,%ebp
movsbl %bl,%edi
mov    %r14,%rsi
call   1040 <putc@plt>
movsbl %bpl,%ebp
mov    %ebp,%edi
mov    %r14,%rsi
call   1040 <putc@plt>
mov    %ebp,%edi
mov    %r14,%rsi
call   1040 <putc@plt>
lea    0x3(%rbx),%eax
movsbl %al,%edi
mov    %r14,%rsi
call   1040 <putc@plt>
lea    0x4(%rbx),%rax
cmp    $0xfffc,%rbx
mov    %rax,%rbx
jb     1150 <main+0x20>
mov    %r14,%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [9 x i8] c"lhhl.bin\00"
@.str.1 = [3 x i8] c"wb\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca i64
%4 = alloca i8
%5 = alloca i8
store i32 0, i32* %1
%6 = call i32* @fopen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
store i32* %6, i32** %2
store i64 0, i64* %3
br label %7
7: ; preds = %32, %0
%8 = load i64, i64* %3
%9 = icmp slt i64 %8, 65536
br i1 %9, label %10, label %35
10: ; preds = %7
%11 = load i64, i64* %3
%12 = and i64 %11, 255
%13 = trunc i64 %12 to i8
store i8 %13, i8* %4
%14 = load i64, i64* %3
%15 = ashr i64 %14, 8
%16 = trunc i64 %15 to i8
store i8 %16, i8* %5
%17 = load i8, i8* %4
%18 = load i32*, i32** %2
%19 = call i32 @putc(i8 signext %17, i32* %18)
%20 = load i8, i8* %5
%21 = load i32*, i32** %2
%22 = call i32 @putc(i8 signext %20, i32* %21)
%23 = load i8, i8* %5
%24 = load i32*, i32** %2
%25 = call i32 @putc(i8 signext %23, i32* %24)
%26 = load i8, i8* %4
%27 = sext i8 %26 to i32
%28 = add nsw i32 %27, 3
%29 = trunc i32 %28 to i8
%30 = load i32*, i32** %2
%31 = call i32 @putc(i8 signext %29, i32* %30)
br label %32
32: ; preds = %10
%33 = load i64, i64* %3
%34 = add nsw i64 %33, 4
store i64 %34, i64* %3
br label %7
35: ; preds = %7
%36 = load i32*, i32** %2
%37 = call i32 @fclose(i32* %36)
ret i32 0
}

LLVM IR (-O2):
@.str = [9 x i8] c"lhhl.bin\00"
@.str.1 = [3 x i8] c"wb\00"
define i32 @main() {
%1 = tail call i32* @fopen(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
br label %2
2: ; preds = %0, %2
%3 = phi i64 [ 0, %0 ], [ %12, %2 ]
%4 = trunc i64 %3 to i8
%5 = lshr i64 %3, 8
%6 = trunc i64 %5 to i8
%7 = tail call i32 @putc(i8 signext %4, i32* %1)
%8 = tail call i32 @putc(i8 signext %6, i32* %1)
%9 = tail call i32 @putc(i8 signext %6, i32* %1)
%10 = or i8 %4, 3
%11 = tail call i32 @putc(i8 signext %10, i32* %1)
%12 = add nuw nsw i64 %3, 4
%13 = icmp ult i64 %3, 65532
br i1 %13, label %2, label %14
14: ; preds = %2
%15 = tail call i32 @fclose(i32* %1)
ret i32 0
}