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

/* Variables and functions */
int getc(int /*<<< orphan*/ *);
void freadulong(uint32_t *ptr, FILE *fd) {
  uint32_t tmp;
  uint8_t t1, t2, t3, t4;
  t1 = getc(fd);
  t2 = getc(fd);
  t3 = getc(fd);
  t4 = getc(fd);
  tmp = t4;
  tmp = tmp * 256 + t3;
  tmp = tmp * 256 + t2;
  tmp = tmp * 256 + t1;
  *ptr = tmp;
}


x86 assembly (clang, -O0):
<freadulong>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <getc@plt>
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <getc@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <getc@plt>
mov    %eax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <getc@plt>
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
shl    $0x8,%eax
add    -0x20(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
shl    $0x8,%eax
add    -0x1c(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
shl    $0x8,%eax
add    -0x18(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,(%rax)
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<freadulong>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rsi,%rbx
mov    %rdi,%r14
mov    %rsi,%rdi
call   1030 <getc@plt>
mov    %eax,%r15d
mov    %rbx,%rdi
call   1030 <getc@plt>
mov    %eax,%r12d
mov    %rbx,%rdi
call   1030 <getc@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1030 <getc@plt>
shl    $0x8,%eax
add    %ebp,%eax
shl    $0x8,%eax
add    %r12d,%eax
shl    $0x8,%eax
add    %r15d,%eax
mov    %eax,(%r14)
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @freadulong(i32* %0, i32* %1) {
%3 = alloca i32*
%4 = alloca i32*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i32* %0, i32** %3
store i32* %1, i32** %4
%10 = load i32*, i32** %4
%11 = call i32 @getc(i32* %10)
store i32 %11, i32* %6
%12 = load i32*, i32** %4
%13 = call i32 @getc(i32* %12)
store i32 %13, i32* %7
%14 = load i32*, i32** %4
%15 = call i32 @getc(i32* %14)
store i32 %15, i32* %8
%16 = load i32*, i32** %4
%17 = call i32 @getc(i32* %16)
store i32 %17, i32* %9
%18 = load i32, i32* %9
store i32 %18, i32* %5
%19 = load i32, i32* %5
%20 = mul nsw i32 %19, 256
%21 = load i32, i32* %8
%22 = add nsw i32 %20, %21
store i32 %22, i32* %5
%23 = load i32, i32* %5
%24 = mul nsw i32 %23, 256
%25 = load i32, i32* %7
%26 = add nsw i32 %24, %25
store i32 %26, i32* %5
%27 = load i32, i32* %5
%28 = mul nsw i32 %27, 256
%29 = load i32, i32* %6
%30 = add nsw i32 %28, %29
store i32 %30, i32* %5
%31 = load i32, i32* %5
%32 = load i32*, i32** %3
store i32 %31, i32* %32
ret void
}

LLVM IR (-O2):
define void @freadulong(i32* nocapture writeonly %0, i32* nocapture %1) {
%3 = tail call i32 @getc(i32* %1)
%4 = tail call i32 @getc(i32* %1)
%5 = tail call i32 @getc(i32* %1)
%6 = tail call i32 @getc(i32* %1)
%7 = shl nsw i32 %6, 8
%8 = add nsw i32 %7, %5
%9 = shl nsw i32 %8, 8
%10 = add nsw i32 %9, %4
%11 = shl nsw i32 %10, 8
%12 = add nsw i32 %11, %3
store i32 %12, i32* %0
ret void
}