#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 char uint8_t;
typedef int /*<<< orphan*/ uint32_t;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ __simplePNG__write_chunk(int /*<<< orphan*/ *, char *,
                                            char *, int);
int /*<<< orphan*/ __simplePNG_to_bendian(int /*<<< orphan*/ *, int);
void __simplePNG_write_IHDR(FILE *f, uint32_t width, uint32_t height,
                            uint8_t const *rgb_image) {
  uint8_t chunk_type[4];
  uint32_t *u32_ptr;
  chunk_type[0] = 'I';
  chunk_type[1] = 'H';
  chunk_type[2] = 'D';
  chunk_type[3] = 'R';
  uint8_t ihdr_chunk[(sizeof(uint32_t) * 2 + sizeof(uint8_t) * 5)];
  uint32_t w = width;
  uint32_t h = height;
  __simplePNG_to_bendian(&w, 4);
  __simplePNG_to_bendian(&h, 4);
  uint8_t depth = 8;
  uint8_t color = 2;
  uint8_t compression = 0;
  uint8_t filter = 0;
  uint8_t interlace = 0;
  u32_ptr = (uint32_t *)(ihdr_chunk);
  u32_ptr[0] = w;
  u32_ptr[1] = h;
  ihdr_chunk[8] = depth;
  ihdr_chunk[9] = color;
  ihdr_chunk[10] = compression;
  ihdr_chunk[11] = filter;
  ihdr_chunk[12] = interlace;
  __simplePNG__write_chunk(f, chunk_type, ihdr_chunk,
                           (sizeof(uint32_t) * 2 + sizeof(uint8_t) * 5));
}


x86 assembly (clang, -O0):
<__simplePNG_write_IHDR>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %rcx,-0x18(%rbp)
movb   $0x49,-0x1c(%rbp)
movb   $0x48,-0x1b(%rbp)
movb   $0x44,-0x1a(%rbp)
movb   $0x52,-0x19(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x3c(%rbp)
mov    -0x10(%rbp),%eax
mov    %eax,-0x40(%rbp)
lea    -0x3c(%rbp),%rdi
mov    $0x4,%esi
call   1030 <__simplePNG_to_bendian@plt>
lea    -0x40(%rbp),%rdi
mov    $0x4,%esi
call   1030 <__simplePNG_to_bendian@plt>
movb   $0x8,-0x41(%rbp)
movb   $0x2,-0x42(%rbp)
movb   $0x0,-0x43(%rbp)
movb   $0x0,-0x44(%rbp)
movb   $0x0,-0x45(%rbp)
lea    -0x35(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x3c(%rbp),%ecx
mov    -0x28(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x40(%rbp),%ecx
mov    -0x28(%rbp),%rax
mov    %ecx,0x4(%rax)
mov    -0x41(%rbp),%al
mov    %al,-0x2d(%rbp)
mov    -0x42(%rbp),%al
mov    %al,-0x2c(%rbp)
mov    -0x43(%rbp),%al
mov    %al,-0x2b(%rbp)
mov    -0x44(%rbp),%al
mov    %al,-0x2a(%rbp)
mov    -0x45(%rbp),%al
mov    %al,-0x29(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0x1c(%rbp),%rsi
lea    -0x35(%rbp),%rdx
mov    $0xd,%ecx
call   1040 <__simplePNG__write_chunk@plt>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<__simplePNG_write_IHDR>:
push   %rbx
sub    $0x20,%rsp
mov    %rdi,%rbx
movl   $0x52444849,0xc(%rsp)
52
mov    %esi,0x8(%rsp)
mov    %edx,0x4(%rsp)
lea    0x8(%rsp),%rdi
mov    $0x4,%esi
call   1030 <__simplePNG_to_bendian@plt>
lea    0x4(%rsp),%rdi
mov    $0x4,%esi
call   1030 <__simplePNG_to_bendian@plt>
mov    0x8(%rsp),%eax
mov    %eax,0x10(%rsp)
mov    0x4(%rsp),%eax
mov    %eax,0x14(%rsp)
movl   $0x208,0x18(%rsp)
movb   $0x0,0x1c(%rsp)
lea    0xc(%rsp),%rsi
lea    0x10(%rsp),%rdx
mov    %rbx,%rdi
mov    $0xd,%ecx
call   1040 <__simplePNG__write_chunk@plt>
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define void @__simplePNG_write_IHDR(i32* %0, i32 %1, i32 %2, i8* %3) {
%5 = alloca i32*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i8*
%9 = alloca [4 x i8]
%10 = alloca i32*
%11 = alloca [13 x i8]
%12 = alloca i32
%13 = alloca i32
%14 = alloca i8
%15 = alloca i8
%16 = alloca i8
%17 = alloca i8
%18 = alloca i8
store i32* %0, i32** %5
store i32 %1, i32* %6
store i32 %2, i32* %7
store i8* %3, i8** %8
%19 = getelementptr inbounds [4 x i8], [4 x i8]* %9, i64 0, i64 0
store i8 73, i8* %19
%20 = getelementptr inbounds [4 x i8], [4 x i8]* %9, i64 0, i64 1
store i8 72, i8* %20
%21 = getelementptr inbounds [4 x i8], [4 x i8]* %9, i64 0, i64 2
store i8 68, i8* %21
%22 = getelementptr inbounds [4 x i8], [4 x i8]* %9, i64 0, i64 3
store i8 82, i8* %22
%23 = load i32, i32* %6
store i32 %23, i32* %12
%24 = load i32, i32* %7
store i32 %24, i32* %13
%25 = call i32 @__simplePNG_to_bendian(i32* %12, i32 4)
%26 = call i32 @__simplePNG_to_bendian(i32* %13, i32 4)
store i8 8, i8* %14
store i8 2, i8* %15
store i8 0, i8* %16
store i8 0, i8* %17
store i8 0, i8* %18
%27 = getelementptr inbounds [13 x i8], [13 x i8]* %11, i64 0, i64 0
%28 = bitcast i8* %27 to i32*
store i32* %28, i32** %10
%29 = load i32, i32* %12
%30 = load i32*, i32** %10
%31 = getelementptr inbounds i32, i32* %30, i64 0
store i32 %29, i32* %31
%32 = load i32, i32* %13
%33 = load i32*, i32** %10
%34 = getelementptr inbounds i32, i32* %33, i64 1
store i32 %32, i32* %34
%35 = load i8, i8* %14
%36 = getelementptr inbounds [13 x i8], [13 x i8]* %11, i64 0, i64 8
store i8 %35, i8* %36
%37 = load i8, i8* %15
%38 = getelementptr inbounds [13 x i8], [13 x i8]* %11, i64 0, i64 9
store i8 %37, i8* %38
%39 = load i8, i8* %16
%40 = getelementptr inbounds [13 x i8], [13 x i8]* %11, i64 0, i64 10
store i8 %39, i8* %40
%41 = load i8, i8* %17
%42 = getelementptr inbounds [13 x i8], [13 x i8]* %11, i64 0, i64 11
store i8 %41, i8* %42
%43 = load i8, i8* %18
%44 = getelementptr inbounds [13 x i8], [13 x i8]* %11, i64 0, i64 12
store i8 %43, i8* %44
%45 = load i32*, i32** %5
%46 = getelementptr inbounds [4 x i8], [4 x i8]* %9, i64 0, i64 0
%47 = getelementptr inbounds [13 x i8], [13 x i8]* %11, i64 0, i64 0
%48 = call i32 @__simplePNG__write_chunk(i32* %45, i8* %46, i8* %47, i32 13)
ret void
}

LLVM IR (-O2):
define void @__simplePNG_write_IHDR(i32* %0, i32 %1, i32 %2, i8* nocapture readnone %3) {
%5 = alloca [4 x i8]
%6 = alloca [13 x i8]
%7 = alloca i32
%8 = alloca i32
%9 = getelementptr inbounds [4 x i8], [4 x i8]* %5, i64 0, i64 0
store i8 73, i8* %9
%10 = getelementptr inbounds [4 x i8], [4 x i8]* %5, i64 0, i64 1
store i8 72, i8* %10
%11 = getelementptr inbounds [4 x i8], [4 x i8]* %5, i64 0, i64 2
store i8 68, i8* %11
%12 = getelementptr inbounds [4 x i8], [4 x i8]* %5, i64 0, i64 3
store i8 82, i8* %12
%13 = getelementptr inbounds [13 x i8], [13 x i8]* %6, i64 0, i64 0
%14 = bitcast i32* %7 to i8*
store i32 %1, i32* %7
%15 = bitcast i32* %8 to i8*
store i32 %2, i32* %8
%16 = call i32 @__simplePNG_to_bendian(i32* %7, i32 4)
%17 = call i32 @__simplePNG_to_bendian(i32* %8, i32 4)
%18 = bitcast [13 x i8]* %6 to i32*
%19 = load i32, i32* %7
store i32 %19, i32* %18
%20 = load i32, i32* %8
%21 = getelementptr inbounds [13 x i8], [13 x i8]* %6, i64 0, i64 4
%22 = bitcast i8* %21 to i32*
store i32 %20, i32* %22
%23 = getelementptr inbounds [13 x i8], [13 x i8]* %6, i64 0, i64 8
store i8 8, i8* %23
%24 = getelementptr inbounds [13 x i8], [13 x i8]* %6, i64 0, i64 9
store i8 2, i8* %24
%25 = getelementptr inbounds [13 x i8], [13 x i8]* %6, i64 0, i64 10
store i8 0, i8* %25
%26 = getelementptr inbounds [13 x i8], [13 x i8]* %6, i64 0, i64 11
store i8 0, i8* %26
%27 = getelementptr inbounds [13 x i8], [13 x i8]* %6, i64 0, i64 12
store i8 0, i8* %27
%28 = call i32 @__simplePNG__write_chunk(i32* %0, i8* %9, i8* %13, i32 13)
ret void
}