#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 gdGetWord(int *result, FILE *in) {
  int r;
  r = getc(in);
  if (r == EOF) {
    return 0;
  }
  *result = r << 8;
  r = getc(in);
  if (r == EOF) {
    return 0;
  }
  *result += r;
  return 1;
}


x86 assembly (clang, -O0):
<gdGetWord>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <getc@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    0x2eb2(%rip),%rcx
cmp    (%rcx),%eax
jne    114a <gdGetWord+0x3a>
movl   $0x0,-0x4(%rbp)
jmp    1192 <gdGetWord+0x82>
mov    -0x1c(%rbp),%ecx
shl    $0x8,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x18(%rbp),%rdi
call   1030 <getc@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    0x2e7c(%rip),%rcx
cmp    (%rcx),%eax
jne    1180 <gdGetWord+0x70>
movl   $0x0,-0x4(%rbp)
jmp    1192 <gdGetWord+0x82>
mov    -0x1c(%rbp),%ecx
mov    -0x10(%rbp),%rax
add    (%rax),%ecx
mov    %ecx,(%rax)
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gdGetWord>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %rdi,%r14
mov    %rsi,%rdi
call   1030 <getc@plt>
mov    0x2ebc(%rip),%r15
xor    %ebp,%ebp
cmp    (%r15),%eax
je     114e <gdGetWord+0x3e>
shl    $0x8,%eax
mov    %eax,(%r14)
mov    %rbx,%rdi
call   1030 <getc@plt>
cmp    (%r15),%eax
je     114e <gdGetWord+0x3e>
add    %eax,(%r14)
mov    $0x1,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

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