#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 read_long(FILE *stream) {
  int c;
  long word;
  c = getc(stream);
  if (c == EOF)
    return -1;
  word = c;
  c = getc(stream);
  if (c == EOF)
    return -1;
  word = word << 8 | c;
  c = getc(stream);
  if (c == EOF)
    return -1;
  word = word << 8 | c;
  c = getc(stream);
  if (c == EOF)
    return -1;
  return word << 8 | c;
}


x86 assembly (clang, -O0):
<read_long>:
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    -0x14(%rbp),%eax
mov    0x2eb6(%rip),%rcx
cmp    (%rcx),%eax
jne    1147 <read_long+0x37>
movq   $0xffffffffffffffff,-0x8(%rbp)
ff
jmp    1209 <read_long+0xf9>
movslq -0x14(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <getc@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    0x2e83(%rip),%rcx
cmp    (%rcx),%eax
jne    117a <read_long+0x6a>
movq   $0xffffffffffffffff,-0x8(%rbp)
ff
jmp    1209 <read_long+0xf9>
mov    -0x20(%rbp),%rax
shl    $0x8,%rax
movslq -0x14(%rbp),%rcx
or     %rcx,%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <getc@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    0x2e45(%rip),%rcx
cmp    (%rcx),%eax
jne    11b8 <read_long+0xa8>
movq   $0xffffffffffffffff,-0x8(%rbp)
ff
jmp    1209 <read_long+0xf9>
mov    -0x20(%rbp),%rax
shl    $0x8,%rax
movslq -0x14(%rbp),%rcx
or     %rcx,%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <getc@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    0x2e07(%rip),%rcx
cmp    (%rcx),%eax
jne    11f6 <read_long+0xe6>
movq   $0xffffffffffffffff,-0x8(%rbp)
ff
jmp    1209 <read_long+0xf9>
mov    -0x20(%rbp),%rax
shl    $0x8,%rax
movslq -0x14(%rbp),%rcx
or     %rcx,%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_long>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdi,%rbx
call   1030 <getc@plt>
mov    0x2ebe(%rip),%r13
mov    $0xffffffffffffffff,%r14
cmp    0x0(%r13),%eax
je     118a <read_long+0x7a>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1030 <getc@plt>
cmp    0x0(%r13),%eax
je     118a <read_long+0x7a>
mov    %eax,%r15d
mov    %rbx,%rdi
call   1030 <getc@plt>
cmp    0x0(%r13),%eax
je     118a <read_long+0x7a>
mov    %eax,%r12d
mov    %rbx,%rdi
call   1030 <getc@plt>
cmp    0x0(%r13),%eax
je     118a <read_long+0x7a>
movslq %ebp,%rcx
shl    $0x10,%rcx
movslq %r15d,%rdx
shl    $0x8,%rdx
or     %rcx,%rdx
movslq %r12d,%rcx
or     %rdx,%rcx
shl    $0x8,%rcx
movslq %eax,%r14
or     %rcx,%r14
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@EOF = global i32 0
define i64 @read_long(i32* %0) {
%2 = alloca i64
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i64
store i32* %0, i32** %3
%6 = load i32*, i32** %3
%7 = call i32 @getc(i32* %6)
store i32 %7, i32* %4
%8 = load i32, i32* %4
%9 = load i32, i32* @EOF
%10 = icmp eq i32 %8, %9
br i1 %10, label %11, label %12
11: ; preds = %1
store i64 -1, i64* %2
br label %51
12: ; preds = %1
%13 = load i32, i32* %4
%14 = sext i32 %13 to i64
store i64 %14, i64* %5
%15 = load i32*, i32** %3
%16 = call i32 @getc(i32* %15)
store i32 %16, i32* %4
%17 = load i32, i32* %4
%18 = load i32, i32* @EOF
%19 = icmp eq i32 %17, %18
br i1 %19, label %20, label %21
20: ; preds = %12
store i64 -1, i64* %2
br label %51
21: ; preds = %12
%22 = load i64, i64* %5
%23 = shl i64 %22, 8
%24 = load i32, i32* %4
%25 = sext i32 %24 to i64
%26 = or i64 %23, %25
store i64 %26, i64* %5
%27 = load i32*, i32** %3
%28 = call i32 @getc(i32* %27)
store i32 %28, i32* %4
%29 = load i32, i32* %4
%30 = load i32, i32* @EOF
%31 = icmp eq i32 %29, %30
br i1 %31, label %32, label %33
32: ; preds = %21
store i64 -1, i64* %2
br label %51
33: ; preds = %21
%34 = load i64, i64* %5
%35 = shl i64 %34, 8
%36 = load i32, i32* %4
%37 = sext i32 %36 to i64
%38 = or i64 %35, %37
store i64 %38, i64* %5
%39 = load i32*, i32** %3
%40 = call i32 @getc(i32* %39)
store i32 %40, i32* %4
%41 = load i32, i32* %4
%42 = load i32, i32* @EOF
%43 = icmp eq i32 %41, %42
br i1 %43, label %44, label %45
44: ; preds = %33
store i64 -1, i64* %2
br label %51
45: ; preds = %33
%46 = load i64, i64* %5
%47 = shl i64 %46, 8
%48 = load i32, i32* %4
%49 = sext i32 %48 to i64
%50 = or i64 %47, %49
store i64 %50, i64* %2
br label %51
51: ; preds = %45, %44, %32, %20, %11
%52 = load i64, i64* %2
ret i64 %52
}

LLVM IR (-O2):
@EOF = global i32 0
define i64 @read_long(i32* nocapture %0) {
%2 = tail call i32 @getc(i32* %0)
%3 = load i32, i32* @EOF
%4 = icmp eq i32 %2, %3
br i1 %4, label %28, label %5
5: ; preds = %1
%6 = tail call i32 @getc(i32* %0)
%7 = load i32, i32* @EOF
%8 = icmp eq i32 %6, %7
br i1 %8, label %28, label %9
9: ; preds = %5
%10 = tail call i32 @getc(i32* %0)
%11 = load i32, i32* @EOF
%12 = icmp eq i32 %10, %11
br i1 %12, label %28, label %13
13: ; preds = %9
%14 = tail call i32 @getc(i32* %0)
%15 = load i32, i32* @EOF
%16 = icmp eq i32 %14, %15
br i1 %16, label %28, label %17
17: ; preds = %13
%18 = sext i32 %2 to i64
%19 = shl nsw i64 %18, 16
%20 = sext i32 %6 to i64
%21 = shl nsw i64 %20, 8
%22 = or i64 %21, %19
%23 = sext i32 %10 to i64
%24 = or i64 %22, %23
%25 = shl nsw i64 %24, 8
%26 = sext i32 %14 to i64
%27 = or i64 %25, %26
br label %28
28: ; preds = %13, %9, %5, %1, %17
%29 = phi i64 [ %27, %17 ], [ -1, %1 ], [ -1, %5 ], [ -1, %9 ], [ -1, %13 ]
ret i64 %29
}