#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 */
int /*<<< orphan*/ eeprom_delay(int);
int get_sda_line(unsigned long);
int /*<<< orphan*/ set_scl_line(unsigned long, int);
int eeprom_get_word(unsigned long pci_base, unsigned short *word_addr) {
  register int i;
  for (i = 15; i >= 0; i--) {
    set_scl_line(pci_base, 1);
    eeprom_delay(500);
    if (get_sda_line(pci_base) == 1)
      *word_addr |= (1 << i);
    else
      *word_addr &= ~(1 << i);
    set_scl_line(pci_base, 0);
    eeprom_delay(500);
  }
  return (0);
}


x86 assembly (clang, -O0):
<eeprom_get_word>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0xf,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jl     11d2 <eeprom_get_word+0xa2>
mov    -0x8(%rbp),%rdi
mov    $0x1,%esi
call   1050 <set_scl_line@plt>
mov    $0x1f4,%edi
call   1040 <eeprom_delay@plt>
mov    -0x8(%rbp),%rdi
call   1030 <get_sda_line@plt>
cmp    $0x1,%eax
jne    1196 <eeprom_get_word+0x66>
mov    -0x14(%rbp),%ecx
mov    $0x1,%edx
shl    %cl,%edx
mov    -0x10(%rbp),%rax
movzwl (%rax),%ecx
or     %edx,%ecx
mov    %cx,(%rax)
jmp    11af <eeprom_get_word+0x7f>
mov    -0x14(%rbp),%ecx
mov    $0x1,%edx
shl    %cl,%edx
xor    $0xffffffff,%edx
mov    -0x10(%rbp),%rax
movzwl (%rax),%ecx
and    %edx,%ecx
mov    %cx,(%rax)
mov    -0x8(%rbp),%rdi
xor    %esi,%esi
call   1050 <set_scl_line@plt>
mov    $0x1f4,%edi
call   1040 <eeprom_delay@plt>
mov    -0x14(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x14(%rbp)
jmp    1147 <eeprom_get_word+0x17>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<eeprom_get_word>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %rdi,%rbx
mov    $0xf,%ebp
nop
mov    %rbx,%rdi
mov    $0x1,%esi
call   1050 <set_scl_line@plt>
mov    $0x1f4,%edi
call   1040 <eeprom_delay@plt>
mov    %rbx,%rdi
call   1030 <get_sda_line@plt>
movzwl (%r14),%ecx
mov    %ecx,%edx
btr    %ebp,%edx
bts    %ebp,%ecx
cmp    $0x1,%eax
cmovne %edx,%ecx
mov    %cx,(%r14)
mov    %rbx,%rdi
xor    %esi,%esi
call   1050 <set_scl_line@plt>
mov    $0x1f4,%edi
call   1040 <eeprom_delay@plt>
add    $0xffffffff,%ebp
jb     1140 <eeprom_get_word+0x10>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define i32 @eeprom_get_word(i64 %0, i16* %1) {
%3 = alloca i64
%4 = alloca i16*
%5 = alloca i32
store i64 %0, i64* %3
store i16* %1, i16** %4
store i32 15, i32* %5
br label %6
6: ; preds = %37, %2
%7 = load i32, i32* %5
%8 = icmp sge i32 %7, 0
br i1 %8, label %9, label %40
9: ; preds = %6
%10 = load i64, i64* %3
%11 = call i32 @set_scl_line(i64 %10, i32 1)
%12 = call i32 @eeprom_delay(i32 500)
%13 = load i64, i64* %3
%14 = call i32 @get_sda_line(i64 %13)
%15 = icmp eq i32 %14, 1
br i1 %15, label %16, label %24
16: ; preds = %9
%17 = load i32, i32* %5
%18 = shl i32 1, %17
%19 = load i16*, i16** %4
%20 = load i16, i16* %19
%21 = zext i16 %20 to i32
%22 = or i32 %21, %18
%23 = trunc i32 %22 to i16
store i16 %23, i16* %19
br label %33
24: ; preds = %9
%25 = load i32, i32* %5
%26 = shl i32 1, %25
%27 = xor i32 %26, -1
%28 = load i16*, i16** %4
%29 = load i16, i16* %28
%30 = zext i16 %29 to i32
%31 = and i32 %30, %27
%32 = trunc i32 %31 to i16
store i16 %32, i16* %28
br label %33
33: ; preds = %24, %16
%34 = load i64, i64* %3
%35 = call i32 @set_scl_line(i64 %34, i32 0)
%36 = call i32 @eeprom_delay(i32 500)
br label %37
37: ; preds = %33
%38 = load i32, i32* %5
%39 = add nsw i32 %38, -1
store i32 %39, i32* %5
br label %6
40: ; preds = %6
ret i32 0
}

LLVM IR (-O2):
define i32 @eeprom_get_word(i64 %0, i16* nocapture %1) {
br label %3
3: ; preds = %2, %3
%4 = phi i32 [ 15, %2 ], [ %18, %3 ]
%5 = tail call i32 @set_scl_line(i64 %0, i32 1)
%6 = tail call i32 @eeprom_delay(i32 500)
%7 = tail call i32 @get_sda_line(i64 %0)
%8 = icmp eq i32 %7, 1
%9 = shl nuw i32 1, %4
%10 = load i16, i16* %1
%11 = trunc i32 %9 to i16
%12 = xor i16 %11, -1
%13 = and i16 %10, %12
%14 = or i16 %10, %11
%15 = select i1 %8, i16 %14, i16 %13
store i16 %15, i16* %1
%16 = tail call i32 @set_scl_line(i64 %0, i32 0)
%17 = tail call i32 @eeprom_delay(i32 500)
%18 = add nsw i32 %4, -1
%19 = icmp eq i32 %4, 0
br i1 %19, label %20, label %3
20: ; preds = %3
ret i32 0
}