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


x86 assembly (clang, -O0):
<getWidth>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
mov    0x2e99(%rip),%rax
mov    (%rax),%edx
mov    $0x12,%esi
call   1050 <fseek@plt>
movl   $0x0,-0xc(%rbp)
movb   $0x0,-0xd(%rbp)
movsbl -0xd(%rbp),%eax
cmp    $0x3,%eax
jg     1193 <getWidth+0x63>
mov    -0x8(%rbp),%rdi
call   1040 <fgetc@plt>
movsbl %al,%eax
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 <getWidth+0x2e>
mov    -0x8(%rbp),%rdi
call   1030 <rewind@plt>
mov    -0xc(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getWidth>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r15
mov    0x2e9f(%rip),%rax
mov    (%rax),%edx
mov    $0x12,%esi
call   1050 <fseek@plt>
mov    %r15,%rdi
call   1040 <fgetc@plt>
movsbl %al,%r14d
mov    %r15,%rdi
call   1040 <fgetc@plt>
movsbl %al,%ebp
shl    $0x8,%ebp
add    %r14d,%ebp
mov    %r15,%rdi
call   1040 <fgetc@plt>
movsbl %al,%ebx
shl    $0x10,%ebx
add    %ebp,%ebx
mov    %r15,%rdi
call   1040 <fgetc@plt>
movzbl %al,%ebp
shl    $0x18,%ebp
add    %ebx,%ebp
mov    %r15,%rdi
call   1030 <rewind@plt>
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@SEEK_SET = global i32 0
define i32 @getWidth(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 18, 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 signext i8 @fgetc(i32* %13)
%15 = sext i8 %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 @getWidth(i32* nocapture %0) {
%2 = load i32, i32* @SEEK_SET
%3 = tail call i32 @fseek(i32* %0, i32 18, i32 %2)
%4 = tail call signext i8 @fgetc(i32* %0)
%5 = sext i8 %4 to i32
%6 = tail call signext i8 @fgetc(i32* %0)
%7 = sext i8 %6 to i32
%8 = shl nsw i32 %7, 8
%9 = add nsw i32 %8, %5
%10 = tail call signext i8 @fgetc(i32* %0)
%11 = sext i8 %10 to i32
%12 = shl nsw i32 %11, 16
%13 = add nsw i32 %12, %9
%14 = tail call signext i8 @fgetc(i32* %0)
%15 = zext i8 %14 to i32
%16 = shl nuw i32 %15, 24
%17 = add nsw i32 %16, %13
%18 = tail call i32 @rewind(i32* %0)
ret i32 %17
}