#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*/ uint32_t;

/* Variables and functions */
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fputs(char *, int /*<<< orphan*/);
int fwrite(int /*<<< orphan*/ *, int, int, int /*<<< orphan*/);
int /*<<< orphan*/ htonl(int /*<<< orphan*/);
int /*<<< orphan*/ stdout;
void write_header(uint32_t width, uint32_t height) {
  uint32_t tmp;
  fputs("farbfeld", stdout);
  tmp = htonl(width);
  if (fwrite(&tmp, sizeof(uint32_t), 1, stdout) != 1)
    exit(1);
  tmp = htonl(height);
  if (fwrite(&tmp, sizeof(uint32_t), 1, stdout) != 1)
    exit(1);
}


x86 assembly (clang, -O0):
<write_header>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    0x2e8b(%rip),%rax
mov    (%rax),%esi
lea    0xea2(%rip),%rdi
call   1030 <fputs@plt>
mov    -0x4(%rbp),%edi
call   1040 <htonl@plt>
mov    %eax,-0xc(%rbp)
mov    0x2e6b(%rip),%rax
mov    (%rax),%ecx
lea    -0xc(%rbp),%rdi
mov    $0x4,%esi
mov    $0x1,%edx
call   1060 <fwrite@plt>
cmp    $0x1,%eax
je     119d <write_header+0x5d>
mov    $0x1,%edi
call   1050 <exit@plt>
mov    -0x8(%rbp),%edi
call   1040 <htonl@plt>
mov    %eax,-0xc(%rbp)
mov    0x2e31(%rip),%rax
mov    (%rax),%ecx
lea    -0xc(%rbp),%rdi
mov    $0x4,%esi
mov    $0x1,%edx
call   1060 <fwrite@plt>
cmp    $0x1,%eax
je     11d7 <write_header+0x97>
mov    $0x1,%edi
call   1050 <exit@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<write_header>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %esi,%ebx
mov    %edi,%ebp
mov    0x2e8d(%rip),%r14
mov    (%r14),%esi
lea    0xea3(%rip),%rdi
call   1030 <fputs@plt>
mov    %ebp,%edi
call   1040 <htonl@plt>
mov    %eax,0xc(%rsp)
mov    (%r14),%ecx
lea    0xc(%rsp),%rdi
mov    $0x4,%esi
mov    $0x1,%edx
call   1060 <fwrite@plt>
cmp    $0x1,%eax
jne    11b9 <write_header+0x79>
mov    %ebx,%edi
call   1040 <htonl@plt>
mov    %eax,0xc(%rsp)
mov    (%r14),%ecx
lea    0xc(%rsp),%rdi
mov    $0x4,%esi
mov    $0x1,%edx
call   1060 <fwrite@plt>
cmp    $0x1,%eax
jne    11b9 <write_header+0x79>
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret
mov    $0x1,%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@.str = [9 x i8] c"farbfeld\00"
@stdout = global i32 0
define void @write_header(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
%6 = load i32, i32* @stdout
%7 = call i32 @fputs(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 %6)
%8 = load i32, i32* %3
%9 = call i32 @htonl(i32 %8)
store i32 %9, i32* %5
%10 = load i32, i32* @stdout
%11 = call i32 @fwrite(i32* %5, i32 4, i32 1, i32 %10)
%12 = icmp ne i32 %11, 1
br i1 %12, label %13, label %15
13: ; preds = %2
%14 = call i32 @exit(i32 1)
unreachable
15: ; preds = %2
%16 = load i32, i32* %4
%17 = call i32 @htonl(i32 %16)
store i32 %17, i32* %5
%18 = load i32, i32* @stdout
%19 = call i32 @fwrite(i32* %5, i32 4, i32 1, i32 %18)
%20 = icmp ne i32 %19, 1
br i1 %20, label %21, label %23
21: ; preds = %15
%22 = call i32 @exit(i32 1)
unreachable
23: ; preds = %15
ret void
}

LLVM IR (-O2):
@.str = [9 x i8] c"farbfeld\00"
@stdout = global i32 0
define void @write_header(i32 %0, i32 %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
%5 = load i32, i32* @stdout
%6 = tail call i32 @fputs(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 %5)
%7 = tail call i32 @htonl(i32 %0)
store i32 %7, i32* %3
%8 = load i32, i32* @stdout
%9 = call i32 @fwrite(i32* %3, i32 4, i32 1, i32 %8)
%10 = icmp eq i32 %9, 1
br i1 %10, label %13, label %11
11: ; preds = %2
%12 = call i32 @exit(i32 1)
unreachable
13: ; preds = %2
%14 = call i32 @htonl(i32 %1)
store i32 %14, i32* %3
%15 = load i32, i32* @stdout
%16 = call i32 @fwrite(i32* %3, i32 4, i32 1, i32 %15)
%17 = icmp eq i32 %16, 1
br i1 %17, label %20, label %18
18: ; preds = %13
%19 = call i32 @exit(i32 1)
unreachable
20: ; preds = %13
ret void
}