#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*/ *);
long getlong(FILE *f) {
  int ch1 = getc(f);
  int ch2 = getc(f);
  int ch3 = getc(f);
  int ch4 = getc(f);
  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    1171 <getlong+0x61>
mov    0x2e83(%rip),%rax
movslq (%rax),%rax
mov    %rax,-0x8(%rbp)
jmp    1190 <getlong+0x80>
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
cltq
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
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
cltq
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@EOF = global i32 0
define i64 @getlong(i32* %0) {
%2 = alloca i64
%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 %22
19: ; preds = %1
%20 = load i32, i32* @EOF
%21 = sext i32 %20 to i64
store i64 %21, i64* %2
br label %34
22: ; preds = %1
%23 = load i32, i32* %4
%24 = shl i32 %23, 24
%25 = load i32, i32* %5
%26 = shl i32 %25, 16
%27 = or i32 %24, %26
%28 = load i32, i32* %6
%29 = shl i32 %28, 8
%30 = or i32 %27, %29
%31 = load i32, i32* %7
%32 = or i32 %30, %31
%33 = sext i32 %32 to i64
store i64 %33, i64* %2
br label %34
34: ; preds = %22, %19
%35 = load i64, i64* %2
ret i64 %35
}

LLVM IR (-O2):
@EOF = global i32 0
define i64 @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 ]
%17 = sext i32 %16 to i64
ret i64 %17
}