#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 EOF;
int getc(int /*<<< orphan*/ *);
int getlong(FILE *ttf) {
  int ch1 = getc(ttf);
  int ch2 = getc(ttf);
  int ch3 = getc(ttf);
  int ch4 = getc(ttf);
  if (ch4 == EOF)
    return (EOF);
  return ((ch1 << 24) | (ch2 << 16) | (ch3 << 8) | ch4);
}


x86 assembly (clang, -O0):
<getlong>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <getc@plt>
mov    %eax,-0x14(%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    -0x20(%rbp),%eax
mov    0x2e92(%rip),%rcx
cmp    (%rcx),%eax
jne    116f <getlong+0x5f>
mov    0x2e83(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    118b <getlong+0x7b>
mov    -0x14(%rbp),%eax
shl    $0x18,%eax
mov    -0x18(%rbp),%ecx
shl    $0x10,%ecx
or     %ecx,%eax
mov    -0x1c(%rbp),%ecx
shl    $0x8,%ecx
or     %ecx,%eax
or     -0x20(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getlong>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbp
call   1030 <getc@plt>
mov    %eax,%r14d
mov    %rbp,%rdi
call   1030 <getc@plt>
mov    %eax,%r15d
mov    %rbp,%rdi
call   1030 <getc@plt>
mov    %eax,%ebx
mov    %rbp,%rdi
call   1030 <getc@plt>
mov    0x2ea2(%rip),%rcx
cmp    (%rcx),%eax
je     115d <getlong+0x4d>
shl    $0x18,%r14d
shl    $0x10,%r15d
or     %r14d,%r15d
shl    $0x8,%ebx
or     %r15d,%ebx
or     %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@EOF = global i32 0
define i32 @getlong(i32* %0) {
%2 = alloca i32
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32* %0, i32** %3
%8 = load i32*, i32** %3
%9 = call i32 @getc(i32* %8)
store i32 %9, i32* %4
%10 = load i32*, i32** %3
%11 = call i32 @getc(i32* %10)
store i32 %11, i32* %5
%12 = load i32*, i32** %3
%13 = call i32 @getc(i32* %12)
store i32 %13, i32* %6
%14 = load i32*, i32** %3
%15 = call i32 @getc(i32* %14)
store i32 %15, i32* %7
%16 = load i32, i32* %7
%17 = load i32, i32* @EOF
%18 = icmp eq i32 %16, %17
br i1 %18, label %19, label %21
19: ; preds = %1
%20 = load i32, i32* @EOF
store i32 %20, i32* %2
br label %32
21: ; preds = %1
%22 = load i32, i32* %4
%23 = shl i32 %22, 24
%24 = load i32, i32* %5
%25 = shl i32 %24, 16
%26 = or i32 %23, %25
%27 = load i32, i32* %6
%28 = shl i32 %27, 8
%29 = or i32 %26, %28
%30 = load i32, i32* %7
%31 = or i32 %29, %30
store i32 %31, i32* %2
br label %32
32: ; preds = %21, %19
%33 = load i32, i32* %2
ret i32 %33
}

LLVM IR (-O2):
@EOF = global i32 0
define i32 @getlong(i32* nocapture %0) {
%2 = tail call i32 @getc(i32* %0)
%3 = tail call i32 @getc(i32* %0)
%4 = tail call i32 @getc(i32* %0)
%5 = tail call i32 @getc(i32* %0)
%6 = load i32, i32* @EOF
%7 = icmp eq i32 %5, %6
br i1 %7, label %15, label %8
8: ; preds = %1
%9 = shl i32 %2, 24
%10 = shl i32 %3, 16
%11 = or i32 %10, %9
%12 = shl i32 %4, 8
%13 = or i32 %11, %12
%14 = or i32 %13, %5
br label %15
15: ; preds = %1, %8
%16 = phi i32 [ %14, %8 ], [ %5, %1 ]
ret i32 %16
}