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

/* Variables and functions */
int unzlocal_getByte(int /*<<< orphan*/ *, int *);
int unzlocal_getShort(FILE *fin, uLong *pX) {
  uLong x;
  int i = 0;
  int err;
  err = unzlocal_getByte(fin, &i);
  x = (uLong)i;
  if (err == (0))
    err = unzlocal_getByte(fin, &i);
  x += ((uLong)i) << 8;
  if (err == (0))
    *pX = x;
  else
    *pX = 0;
  return err;
}


x86 assembly (clang, -O0):
<unzlocal_getShort>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0x18(%rbp),%rsi
call   1030 <unzlocal_getByte@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%eax
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jne    1157 <unzlocal_getShort+0x47>
mov    -0x8(%rbp),%rdi
lea    -0x18(%rbp),%rsi
call   1030 <unzlocal_getByte@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%eax
shl    $0x8,%eax
add    -0x14(%rbp),%eax
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jne    117b <unzlocal_getShort+0x6b>
mov    -0x14(%rbp),%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
jmp    1185 <unzlocal_getShort+0x75>
mov    -0x10(%rbp),%rax
movl   $0x0,(%rax)
mov    -0x1c(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<unzlocal_getShort>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%r14
mov    %rdi,%rbx
movl   $0x0,0xc(%rsp)
lea    0xc(%rsp),%rsi
call   1030 <unzlocal_getByte@plt>
mov    0xc(%rsp),%ebp
mov    %ebp,%ecx
test   %eax,%eax
jne    114b <unzlocal_getShort+0x3b>
lea    0xc(%rsp),%rsi
mov    %rbx,%rdi
call   1030 <unzlocal_getByte@plt>
mov    0xc(%rsp),%ecx
shl    $0x8,%ecx
add    %ebp,%ecx
xor    %edx,%edx
test   %eax,%eax
cmove  %ecx,%edx
mov    %edx,(%r14)
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

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

LLVM IR (-O2):
define i32 @unzlocal_getShort(i32* %0, i32* nocapture writeonly %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
store i32 0, i32* %3
%5 = call i32 @unzlocal_getByte(i32* %0, i32* %3)
%6 = load i32, i32* %3
%7 = icmp eq i32 %5, 0
br i1 %7, label %8, label %11
8: ; preds = %2
%9 = call i32 @unzlocal_getByte(i32* %0, i32* %3)
%10 = load i32, i32* %3
br label %11
11: ; preds = %8, %2
%12 = phi i32 [ %10, %8 ], [ %6, %2 ]
%13 = phi i32 [ %9, %8 ], [ %5, %2 ]
%14 = icmp eq i32 %13, 0
%15 = shl i32 %12, 8
%16 = add nsw i32 %15, %6
%17 = select i1 %14, i32 %16, i32 0
store i32 %17, i32* %1
ret i32 %13
}