#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;
int /*<<< orphan*/ fread(unsigned char *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, int, int /*<<< orphan*/);
unsigned int spng_dec_read_size(FILE *fp, unsigned int *w, unsigned int *h) {
  unsigned char ptr[16];
  fseek(fp, 16, SEEK_SET);
  fread(ptr, 1, 4, fp);
  *w = (((ptr[0] << 8) + ptr[1] << 8) + ptr[2] << 8) + ptr[3];
  fread(ptr, 1, 4, fp);
  *h = (((ptr[0] << 8) + ptr[1] << 8) + ptr[2] << 8) + ptr[3];
  return 1;
}


x86 assembly (clang, -O0):
<spng_dec_read_size>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
mov    0x2ea1(%rip),%rax
mov    (%rax),%edx
mov    $0x10,%esi
call   1040 <fseek@plt>
lea    -0x30(%rbp),%rdi
mov    -0x8(%rbp),%rcx
mov    $0x1,%esi
mov    $0x4,%edx
call   1030 <fread@plt>
movzbl -0x30(%rbp),%ecx
shl    $0x8,%ecx
movzbl -0x2f(%rbp),%eax
add    %eax,%ecx
shl    $0x8,%ecx
movzbl -0x2e(%rbp),%eax
add    %eax,%ecx
shl    $0x8,%ecx
movzbl -0x2d(%rbp),%eax
add    %eax,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
lea    -0x30(%rbp),%rdi
mov    -0x8(%rbp),%rcx
mov    $0x1,%esi
mov    $0x4,%edx
call   1030 <fread@plt>
movzbl -0x30(%rbp),%ecx
shl    $0x8,%ecx
movzbl -0x2f(%rbp),%eax
add    %eax,%ecx
shl    $0x8,%ecx
movzbl -0x2e(%rbp),%eax
add    %eax,%ecx
shl    $0x8,%ecx
movzbl -0x2d(%rbp),%eax
add    %eax,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
mov    $0x1,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<spng_dec_read_size>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%rbx
mov    0x2ea5(%rip),%rax
mov    (%rax),%edx
mov    $0x10,%esi
call   1040 <fseek@plt>
mov    %rsp,%r12
mov    %r12,%rdi
mov    $0x1,%esi
mov    $0x4,%edx
mov    %rbx,%rcx
call   1030 <fread@plt>
mov    (%rsp),%eax
bswap  %eax
mov    %eax,(%r15)
mov    %r12,%rdi
mov    $0x1,%esi
mov    $0x4,%edx
mov    %rbx,%rcx
call   1030 <fread@plt>
mov    (%rsp),%eax
bswap  %eax
mov    %eax,(%r14)
mov    $0x1,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@SEEK_SET = global i32 0
define i32 @spng_dec_read_size(i32* %0, i32* %1, i32* %2) {
%4 = alloca i32*
%5 = alloca i32*
%6 = alloca i32*
%7 = alloca [16 x i8]
store i32* %0, i32** %4
store i32* %1, i32** %5
store i32* %2, i32** %6
%8 = load i32*, i32** %4
%9 = load i32, i32* @SEEK_SET
%10 = call i32 @fseek(i32* %8, i32 16, i32 %9)
%11 = getelementptr inbounds [16 x i8], [16 x i8]* %7, i64 0, i64 0
%12 = load i32*, i32** %4
%13 = call i32 @fread(i8* %11, i32 1, i32 4, i32* %12)
%14 = getelementptr inbounds [16 x i8], [16 x i8]* %7, i64 0, i64 0
%15 = load i8, i8* %14
%16 = zext i8 %15 to i32
%17 = shl i32 %16, 8
%18 = getelementptr inbounds [16 x i8], [16 x i8]* %7, i64 0, i64 1
%19 = load i8, i8* %18
%20 = zext i8 %19 to i32
%21 = add nsw i32 %17, %20
%22 = shl i32 %21, 8
%23 = getelementptr inbounds [16 x i8], [16 x i8]* %7, i64 0, i64 2
%24 = load i8, i8* %23
%25 = zext i8 %24 to i32
%26 = add nsw i32 %22, %25
%27 = shl i32 %26, 8
%28 = getelementptr inbounds [16 x i8], [16 x i8]* %7, i64 0, i64 3
%29 = load i8, i8* %28
%30 = zext i8 %29 to i32
%31 = add nsw i32 %27, %30
%32 = load i32*, i32** %5
store i32 %31, i32* %32
%33 = getelementptr inbounds [16 x i8], [16 x i8]* %7, i64 0, i64 0
%34 = load i32*, i32** %4
%35 = call i32 @fread(i8* %33, i32 1, i32 4, i32* %34)
%36 = getelementptr inbounds [16 x i8], [16 x i8]* %7, i64 0, i64 0
%37 = load i8, i8* %36
%38 = zext i8 %37 to i32
%39 = shl i32 %38, 8
%40 = getelementptr inbounds [16 x i8], [16 x i8]* %7, i64 0, i64 1
%41 = load i8, i8* %40
%42 = zext i8 %41 to i32
%43 = add nsw i32 %39, %42
%44 = shl i32 %43, 8
%45 = getelementptr inbounds [16 x i8], [16 x i8]* %7, i64 0, i64 2
%46 = load i8, i8* %45
%47 = zext i8 %46 to i32
%48 = add nsw i32 %44, %47
%49 = shl i32 %48, 8
%50 = getelementptr inbounds [16 x i8], [16 x i8]* %7, i64 0, i64 3
%51 = load i8, i8* %50
%52 = zext i8 %51 to i32
%53 = add nsw i32 %49, %52
%54 = load i32*, i32** %6
store i32 %53, i32* %54
ret i32 1
}

LLVM IR (-O2):
@SEEK_SET = global i32 0
define i32 @spng_dec_read_size(i32* nocapture %0, i32* nocapture writeonly %1, i32* nocapture writeonly %2) {
%4 = alloca [16 x i8]
%5 = getelementptr inbounds [16 x i8], [16 x i8]* %4, i64 0, i64 0
%6 = load i32, i32* @SEEK_SET
%7 = tail call i32 @fseek(i32* %0, i32 16, i32 %6)
%8 = call i32 @fread(i8* %5, i32 1, i32 4, i32* %0)
%9 = load i8, i8* %5
%10 = zext i8 %9 to i32
%11 = getelementptr inbounds [16 x i8], [16 x i8]* %4, i64 0, i64 1
%12 = load i8, i8* %11
%13 = zext i8 %12 to i32
%14 = shl nuw nsw i32 %10, 16
%15 = shl nuw nsw i32 %13, 8
%16 = or i32 %15, %14
%17 = getelementptr inbounds [16 x i8], [16 x i8]* %4, i64 0, i64 2
%18 = load i8, i8* %17
%19 = zext i8 %18 to i32
%20 = or i32 %16, %19
%21 = shl nuw i32 %20, 8
%22 = getelementptr inbounds [16 x i8], [16 x i8]* %4, i64 0, i64 3
%23 = load i8, i8* %22
%24 = zext i8 %23 to i32
%25 = or i32 %21, %24
store i32 %25, i32* %1
%26 = call i32 @fread(i8* %5, i32 1, i32 4, i32* %0)
%27 = load i8, i8* %5
%28 = zext i8 %27 to i32
%29 = load i8, i8* %11
%30 = zext i8 %29 to i32
%31 = shl nuw nsw i32 %28, 16
%32 = shl nuw nsw i32 %30, 8
%33 = or i32 %32, %31
%34 = load i8, i8* %17
%35 = zext i8 %34 to i32
%36 = or i32 %33, %35
%37 = shl nuw i32 %36, 8
%38 = load i8, i8* %22
%39 = zext i8 %38 to i32
%40 = or i32 %37, %39
store i32 %40, i32* %2
ret i32 1
}