#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 */

/* Variables and functions */
unsigned short asix88796_eeprom_getbit(int);
unsigned short asix88796_eeprom_get(int ioaddr) {
  unsigned short value = 0;
  int i;
  asix88796_eeprom_getbit(ioaddr);
  for (i = 0; i < 16; i++) {
    value <<= 1;
    value |= asix88796_eeprom_getbit(ioaddr);
  }
  return value;
}


x86 assembly (clang, -O0):
<asix88796_eeprom_get>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
movw   $0x0,-0x6(%rbp)
mov    -0x4(%rbp),%edi
call   1030 <asix88796_eeprom_getbit@plt>
movl   $0x0,-0xc(%rbp)
cmpl   $0x10,-0xc(%rbp)
jge    1168 <asix88796_eeprom_get+0x58>
movzwl -0x6(%rbp),%eax
shl    $0x1,%eax
mov    %ax,-0x6(%rbp)
mov    -0x4(%rbp),%edi
call   1030 <asix88796_eeprom_getbit@plt>
movzwl %ax,%ecx
movzwl -0x6(%rbp),%eax
or     %ecx,%eax
mov    %ax,-0x6(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1130 <asix88796_eeprom_get+0x20>
movzwl -0x6(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<asix88796_eeprom_get>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %edi,%r14d
call   1030 <asix88796_eeprom_getbit@plt>
mov    %r14d,%edi
call   1030 <asix88796_eeprom_getbit@plt>
mov    %eax,%ebp
mov    %r14d,%edi
call   1030 <asix88796_eeprom_getbit@plt>
mov    %eax,%ebx
shl    $0x2,%ebp
add    %ebx,%ebx
or     %ebp,%ebx
mov    %r14d,%edi
call   1030 <asix88796_eeprom_getbit@plt>
mov    %eax,%ebp
or     %ebx,%ebp
mov    %r14d,%edi
call   1030 <asix88796_eeprom_getbit@plt>
mov    %eax,%r15d
shl    $0x2,%ebp
add    %r15d,%r15d
mov    %r14d,%edi
call   1030 <asix88796_eeprom_getbit@plt>
mov    %eax,%ebx
or     %r15d,%ebx
or     %ebp,%ebx
mov    %r14d,%edi
call   1030 <asix88796_eeprom_getbit@plt>
mov    %eax,%r15d
shl    $0x2,%ebx
add    %r15d,%r15d
mov    %r14d,%edi
call   1030 <asix88796_eeprom_getbit@plt>
mov    %eax,%ebp
or     %r15d,%ebp
or     %ebx,%ebp
mov    %r14d,%edi
call   1030 <asix88796_eeprom_getbit@plt>
mov    %eax,%r15d
shl    $0x2,%ebp
add    %r15d,%r15d
mov    %r14d,%edi
call   1030 <asix88796_eeprom_getbit@plt>
mov    %eax,%ebx
or     %r15d,%ebx
or     %ebp,%ebx
mov    %r14d,%edi
call   1030 <asix88796_eeprom_getbit@plt>
mov    %eax,%r15d
shl    $0x2,%ebx
add    %r15d,%r15d
mov    %r14d,%edi
call   1030 <asix88796_eeprom_getbit@plt>
mov    %eax,%ebp
or     %r15d,%ebp
or     %ebx,%ebp
mov    %r14d,%edi
call   1030 <asix88796_eeprom_getbit@plt>
mov    %eax,%r15d
shl    $0x2,%ebp
add    %r15d,%r15d
mov    %r14d,%edi
call   1030 <asix88796_eeprom_getbit@plt>
mov    %eax,%ebx
or     %r15d,%ebx
or     %ebp,%ebx
mov    %r14d,%edi
call   1030 <asix88796_eeprom_getbit@plt>
mov    %eax,%r15d
shl    $0x2,%ebx
add    %r15d,%r15d
mov    %r14d,%edi
call   1030 <asix88796_eeprom_getbit@plt>
mov    %eax,%ebp
or     %r15d,%ebp
or     %ebx,%ebp
add    %ebp,%ebp
mov    %r14d,%edi
call   1030 <asix88796_eeprom_getbit@plt>
or     %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define zeroext i16 @asix88796_eeprom_get(i32 %0) {
%2 = alloca i32
%3 = alloca i16
%4 = alloca i32
store i32 %0, i32* %2
store i16 0, i16* %3
%5 = load i32, i32* %2
%6 = call zeroext i16 @asix88796_eeprom_getbit(i32 %5)
store i32 0, i32* %4
br label %7
7: ; preds = %22, %1
%8 = load i32, i32* %4
%9 = icmp slt i32 %8, 16
br i1 %9, label %10, label %25
10: ; preds = %7
%11 = load i16, i16* %3
%12 = zext i16 %11 to i32
%13 = shl i32 %12, 1
%14 = trunc i32 %13 to i16
store i16 %14, i16* %3
%15 = load i32, i32* %2
%16 = call zeroext i16 @asix88796_eeprom_getbit(i32 %15)
%17 = zext i16 %16 to i32
%18 = load i16, i16* %3
%19 = zext i16 %18 to i32
%20 = or i32 %19, %17
%21 = trunc i32 %20 to i16
store i16 %21, i16* %3
br label %22
22: ; preds = %10
%23 = load i32, i32* %4
%24 = add nsw i32 %23, 1
store i32 %24, i32* %4
br label %7
25: ; preds = %7
%26 = load i16, i16* %3
ret i16 %26
}

LLVM IR (-O2):
define zeroext i16 @asix88796_eeprom_get(i32 %0) {
%2 = tail call zeroext i16 @asix88796_eeprom_getbit(i32 %0)
%3 = tail call zeroext i16 @asix88796_eeprom_getbit(i32 %0)
%4 = tail call zeroext i16 @asix88796_eeprom_getbit(i32 %0)
%5 = shl i16 %3, 2
%6 = shl i16 %4, 1
%7 = or i16 %5, %6
%8 = tail call zeroext i16 @asix88796_eeprom_getbit(i32 %0)
%9 = or i16 %8, %7
%10 = tail call zeroext i16 @asix88796_eeprom_getbit(i32 %0)
%11 = shl i16 %9, 2
%12 = shl i16 %10, 1
%13 = or i16 %11, %12
%14 = tail call zeroext i16 @asix88796_eeprom_getbit(i32 %0)
%15 = or i16 %14, %13
%16 = tail call zeroext i16 @asix88796_eeprom_getbit(i32 %0)
%17 = shl i16 %15, 2
%18 = shl i16 %16, 1
%19 = or i16 %17, %18
%20 = tail call zeroext i16 @asix88796_eeprom_getbit(i32 %0)
%21 = or i16 %20, %19
%22 = tail call zeroext i16 @asix88796_eeprom_getbit(i32 %0)
%23 = shl i16 %21, 2
%24 = shl i16 %22, 1
%25 = or i16 %23, %24
%26 = tail call zeroext i16 @asix88796_eeprom_getbit(i32 %0)
%27 = or i16 %26, %25
%28 = tail call zeroext i16 @asix88796_eeprom_getbit(i32 %0)
%29 = shl i16 %27, 2
%30 = shl i16 %28, 1
%31 = or i16 %29, %30
%32 = tail call zeroext i16 @asix88796_eeprom_getbit(i32 %0)
%33 = or i16 %32, %31
%34 = tail call zeroext i16 @asix88796_eeprom_getbit(i32 %0)
%35 = shl i16 %33, 2
%36 = shl i16 %34, 1
%37 = or i16 %35, %36
%38 = tail call zeroext i16 @asix88796_eeprom_getbit(i32 %0)
%39 = or i16 %38, %37
%40 = tail call zeroext i16 @asix88796_eeprom_getbit(i32 %0)
%41 = shl i16 %39, 2
%42 = shl i16 %40, 1
%43 = or i16 %41, %42
%44 = tail call zeroext i16 @asix88796_eeprom_getbit(i32 %0)
%45 = or i16 %44, %43
%46 = shl i16 %45, 1
%47 = tail call zeroext i16 @asix88796_eeprom_getbit(i32 %0)
%48 = or i16 %47, %46
ret i16 %48
}