#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*/ SEEK_SET;
scalar_t__ fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, int, int /*<<< orphan*/);
int /*<<< orphan*/ rewind(int /*<<< orphan*/ *);
signed int getHeight(FILE *myFile) {
  fseek(myFile, 0x16, SEEK_SET);
  signed int height = 0;
  char i;
  for (i = 0; i <= 3; i++) {
    height += (signed int)fgetc(myFile) << (i * 8);
  }
  rewind(myFile);
  return height;
}


x86 assembly (clang, -O0):
<getHeight>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
mov    0x2e99(%rip),%rax
mov    (%rax),%edx
mov    $0x16,%esi
call   1050 <fseek@plt>
movl   $0x0,-0xc(%rbp)
movb   $0x0,-0xd(%rbp)
movsbl -0xd(%rbp),%eax
cmp    $0x3,%eax
jg     1190 <getHeight+0x60>
mov    -0x8(%rbp),%rdi
call   1040 <fgetc@plt>
movsbl -0xd(%rbp),%ecx
shl    $0x3,%ecx
shl    %cl,%eax
add    -0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0xd(%rbp),%al
add    $0x1,%al
mov    %al,-0xd(%rbp)
jmp    115e <getHeight+0x2e>
mov    -0x8(%rbp),%rdi
call   1030 <rewind@plt>
mov    -0xc(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getHeight>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%r15
mov    0x2ea1(%rip),%rax
mov    (%rax),%edx
mov    $0x16,%esi
call   1050 <fseek@plt>
mov    %r15,%rdi
call   1040 <fgetc@plt>
mov    %rax,%r14
mov    %r15,%rdi
call   1040 <fgetc@plt>
mov    %rax,%rbx
shl    $0x8,%ebx
add    %r14d,%ebx
mov    %r15,%rdi
call   1040 <fgetc@plt>
mov    %rax,%r14
shl    $0x10,%r14d
add    %ebx,%r14d
mov    %r15,%rdi
call   1040 <fgetc@plt>
mov    %rax,%rbx
shl    $0x18,%ebx
add    %r14d,%ebx
mov    %r15,%rdi
call   1030 <rewind@plt>
mov    %ebx,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@SEEK_SET = global i32 0
define i32 @getHeight(i32* %0) {
%2 = alloca i32*
%3 = alloca i32
%4 = alloca i8
store i32* %0, i32** %2
%5 = load i32*, i32** %2
%6 = load i32, i32* @SEEK_SET
%7 = call i32 @fseek(i32* %5, i32 22, i32 %6)
store i32 0, i32* %3
store i8 0, i8* %4
br label %8
8: ; preds = %22, %1
%9 = load i8, i8* %4
%10 = sext i8 %9 to i32
%11 = icmp sle i32 %10, 3
br i1 %11, label %12, label %25
12: ; preds = %8
%13 = load i32*, i32** %2
%14 = call i64 @fgetc(i32* %13)
%15 = trunc i64 %14 to i32
%16 = load i8, i8* %4
%17 = sext i8 %16 to i32
%18 = mul nsw i32 %17, 8
%19 = shl i32 %15, %18
%20 = load i32, i32* %3
%21 = add nsw i32 %20, %19
store i32 %21, i32* %3
br label %22
22: ; preds = %12
%23 = load i8, i8* %4
%24 = add i8 %23, 1
store i8 %24, i8* %4
br label %8
25: ; preds = %8
%26 = load i32*, i32** %2
%27 = call i32 @rewind(i32* %26)
%28 = load i32, i32* %3
ret i32 %28
}

LLVM IR (-O2):
@SEEK_SET = global i32 0
define i32 @getHeight(i32* nocapture %0) {
%2 = load i32, i32* @SEEK_SET
%3 = tail call i32 @fseek(i32* %0, i32 22, i32 %2)
%4 = tail call i64 @fgetc(i32* %0)
%5 = trunc i64 %4 to i32
%6 = tail call i64 @fgetc(i32* %0)
%7 = trunc i64 %6 to i32
%8 = shl i32 %7, 8
%9 = add nsw i32 %8, %5
%10 = tail call i64 @fgetc(i32* %0)
%11 = trunc i64 %10 to i32
%12 = shl i32 %11, 16
%13 = add nsw i32 %12, %9
%14 = tail call i64 @fgetc(i32* %0)
%15 = trunc i64 %14 to i32
%16 = shl i32 %15, 24
%17 = add nsw i32 %16, %13
%18 = tail call i32 @rewind(i32* %0)
ret i32 %17
}