#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 uint8_t;

/* Variables and functions */
int /*<<< orphan*/ printf(char *, int);
uint8_t *read_file_header(uint8_t *buf) {
  printf("FIXED_FILE_HEADER_II_2BYTES | 0x%x\n", (buf[0] << 8) | buf[1]);
  printf("FIXED_FILE_HEADER_0XBC_BYTE | 0x%x\n", buf[2]);
  printf("FILE_VERSION_ID             | %d\n", buf[3]);
  printf("FIRST_IFD_OFFSET            | %d\n",
         (buf[7] << 24) | (buf[6] << 16) | (buf[5] << 8) | buf[4]);
  return buf + 8;
}


x86 assembly (clang, -O0):
<read_file_header>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%esi
shl    $0x8,%esi
mov    -0x8(%rbp),%rax
or     0x4(%rax),%esi
lea    0xecd(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%esi
lea    0xede(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%rax
mov    0xc(%rax),%esi
lea    0xeef(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%rax
mov    0x1c(%rax),%esi
shl    $0x18,%esi
mov    -0x8(%rbp),%rax
mov    0x18(%rax),%eax
shl    $0x10,%eax
or     %eax,%esi
mov    -0x8(%rbp),%rax
mov    0x14(%rax),%eax
shl    $0x8,%eax
or     %eax,%esi
mov    -0x8(%rbp),%rax
or     0x10(%rax),%esi
lea    0xedc(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%rax
add    $0x20,%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_file_header>:
push   %rbx
mov    %rdi,%rbx
mov    (%rdi),%esi
shl    $0x8,%esi
or     0x4(%rdi),%esi
lea    0xedd(%rip),%rdi
call   1030 <printf@plt>
mov    0x8(%rbx),%esi
lea    0xef2(%rip),%rdi
call   1030 <printf@plt>
mov    0xc(%rbx),%esi
lea    0xf07(%rip),%rdi
call   1030 <printf@plt>
mov    0x1c(%rbx),%eax
shl    $0x18,%eax
mov    0x14(%rbx),%esi
mov    0x18(%rbx),%ecx
shl    $0x10,%ecx
or     %eax,%ecx
shl    $0x8,%esi
or     %ecx,%esi
or     0x10(%rbx),%esi
lea    0xf04(%rip),%rdi
call   1030 <printf@plt>
add    $0x20,%rbx
mov    %rbx,%rax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [36 x i8] c"FIXED_FILE_HEADER_II_2BYTES | 0x%x\0A\00"
@.str.1 = [36 x i8] c"FIXED_FILE_HEADER_0XBC_BYTE | 0x%x\0A\00"
@.str.2 = [34 x i8] c"FILE_VERSION_ID | %d\0A\00"
@.str.3 = [34 x i8] c"FIRST_IFD_OFFSET | %d\0A\00"
define i32* @read_file_header(i32* %0) {
%2 = alloca i32*
store i32* %0, i32** %2
%3 = load i32*, i32** %2
%4 = getelementptr inbounds i32, i32* %3, i64 0
%5 = load i32, i32* %4
%6 = shl i32 %5, 8
%7 = load i32*, i32** %2
%8 = getelementptr inbounds i32, i32* %7, i64 1
%9 = load i32, i32* %8
%10 = or i32 %6, %9
%11 = call i32 @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0), i32 %10)
%12 = load i32*, i32** %2
%13 = getelementptr inbounds i32, i32* %12, i64 2
%14 = load i32, i32* %13
%15 = call i32 @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.1, i64 0, i64 0), i32 %14)
%16 = load i32*, i32** %2
%17 = getelementptr inbounds i32, i32* %16, i64 3
%18 = load i32, i32* %17
%19 = call i32 @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.2, i64 0, i64 0), i32 %18)
%20 = load i32*, i32** %2
%21 = getelementptr inbounds i32, i32* %20, i64 7
%22 = load i32, i32* %21
%23 = shl i32 %22, 24
%24 = load i32*, i32** %2
%25 = getelementptr inbounds i32, i32* %24, i64 6
%26 = load i32, i32* %25
%27 = shl i32 %26, 16
%28 = or i32 %23, %27
%29 = load i32*, i32** %2
%30 = getelementptr inbounds i32, i32* %29, i64 5
%31 = load i32, i32* %30
%32 = shl i32 %31, 8
%33 = or i32 %28, %32
%34 = load i32*, i32** %2
%35 = getelementptr inbounds i32, i32* %34, i64 4
%36 = load i32, i32* %35
%37 = or i32 %33, %36
%38 = call i32 @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.3, i64 0, i64 0), i32 %37)
%39 = load i32*, i32** %2
%40 = getelementptr inbounds i32, i32* %39, i64 8
ret i32* %40
}

LLVM IR (-O2):
@.str = [36 x i8] c"FIXED_FILE_HEADER_II_2BYTES | 0x%x\0A\00"
@.str.1 = [36 x i8] c"FIXED_FILE_HEADER_0XBC_BYTE | 0x%x\0A\00"
@.str.2 = [34 x i8] c"FILE_VERSION_ID | %d\0A\00"
@.str.3 = [34 x i8] c"FIRST_IFD_OFFSET | %d\0A\00"
define i32* @read_file_header(i32* %0) {
%2 = load i32, i32* %0
%3 = shl i32 %2, 8
%4 = getelementptr inbounds i32, i32* %0, i64 1
%5 = load i32, i32* %4
%6 = or i32 %3, %5
%7 = tail call i32 @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0), i32 %6)
%8 = getelementptr inbounds i32, i32* %0, i64 2
%9 = load i32, i32* %8
%10 = tail call i32 @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.1, i64 0, i64 0), i32 %9)
%11 = getelementptr inbounds i32, i32* %0, i64 3
%12 = load i32, i32* %11
%13 = tail call i32 @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.2, i64 0, i64 0), i32 %12)
%14 = getelementptr inbounds i32, i32* %0, i64 7
%15 = load i32, i32* %14
%16 = shl i32 %15, 24
%17 = getelementptr inbounds i32, i32* %0, i64 6
%18 = load i32, i32* %17
%19 = shl i32 %18, 16
%20 = or i32 %19, %16
%21 = getelementptr inbounds i32, i32* %0, i64 5
%22 = load i32, i32* %21
%23 = shl i32 %22, 8
%24 = or i32 %20, %23
%25 = getelementptr inbounds i32, i32* %0, i64 4
%26 = load i32, i32* %25
%27 = or i32 %24, %26
%28 = tail call i32 @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.3, i64 0, i64 0), i32 %27)
%29 = getelementptr inbounds i32, i32* %0, i64 8
ret i32* %29
}