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


x86 assembly (clang, -O0):
<eeprom_put_word>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %si,%ax
mov    %rdi,-0x8(%rbp)
mov    %ax,-0xa(%rbp)
movl   $0xf,-0x10(%rbp)
cmpl   $0x0,-0x10(%rbp)
jl     11d2 <eeprom_put_word+0xa2>
movzwl -0xa(%rbp),%eax
mov    -0x10(%rbp),%ecx
mov    $0x1,%edx
shl    %cl,%edx
mov    %edx,%ecx
and    %ecx,%eax
cmp    $0x0,%eax
je     1182 <eeprom_put_word+0x52>
mov    -0x8(%rbp),%rdi
mov    $0x1,%esi
call   1030 <set_sda_line@plt>
jmp    118d <eeprom_put_word+0x5d>
mov    -0x8(%rbp),%rdi
xor    %esi,%esi
call   1030 <set_sda_line@plt>
mov    $0x64,%edi
call   1040 <eeprom_delay@plt>
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
xor    %esi,%esi
call   1050 <set_scl_line@plt>
mov    $0x1f4,%edi
call   1040 <eeprom_delay@plt>
mov    -0x10(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x10(%rbp)
jmp    114a <eeprom_put_word+0x1a>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<eeprom_put_word>:
push   %rbp
push   %r14
push   %rbx
mov    %esi,%r14d
mov    %rdi,%rbx
mov    $0xf,%ebp
nop
mov    %r14d,%esi
mov    %ebp,%ecx
shr    %cl,%esi
and    $0x1,%esi
mov    %rbx,%rdi
call   1030 <set_sda_line@plt>
mov    $0x64,%edi
call   1040 <eeprom_delay@plt>
mov    %rbx,%rdi
mov    $0x1,%esi
call   1050 <set_scl_line@plt>
mov    $0x1f4,%edi
call   1040 <eeprom_delay@plt>
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_put_word+0x10>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define i32 @eeprom_put_word(i64 %0, i16 zeroext %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 = %30, %2
%7 = load i32, i32* %5
%8 = icmp sge i32 %7, 0
br i1 %8, label %9, label %33
9: ; preds = %6
%10 = load i16, i16* %4
%11 = zext i16 %10 to i32
%12 = load i32, i32* %5
%13 = shl i32 1, %12
%14 = and i32 %11, %13
%15 = icmp ne i32 %14, 0
br i1 %15, label %16, label %19
16: ; preds = %9
%17 = load i64, i64* %3
%18 = call i32 @set_sda_line(i64 %17, i32 1)
br label %22
19: ; preds = %9
%20 = load i64, i64* %3
%21 = call i32 @set_sda_line(i64 %20, i32 0)
br label %22
22: ; preds = %19, %16
%23 = call i32 @eeprom_delay(i32 100)
%24 = load i64, i64* %3
%25 = call i32 @set_scl_line(i64 %24, i32 1)
%26 = call i32 @eeprom_delay(i32 500)
%27 = load i64, i64* %3
%28 = call i32 @set_scl_line(i64 %27, i32 0)
%29 = call i32 @eeprom_delay(i32 500)
br label %30
30: ; preds = %22
%31 = load i32, i32* %5
%32 = add nsw i32 %31, -1
store i32 %32, i32* %5
br label %6
33: ; preds = %6
ret i32 0
}

LLVM IR (-O2):
define i32 @eeprom_put_word(i64 %0, i16 zeroext %1) {
%3 = zext i16 %1 to i32
br label %4
4: ; preds = %2, %4
%5 = phi i32 [ 15, %2 ], [ %14, %4 ]
%6 = lshr i32 %3, %5
%7 = and i32 %6, 1
%8 = tail call i32 @set_sda_line(i64 %0, i32 %7)
%9 = tail call i32 @eeprom_delay(i32 100)
%10 = tail call i32 @set_scl_line(i64 %0, i32 1)
%11 = tail call i32 @eeprom_delay(i32 500)
%12 = tail call i32 @set_scl_line(i64 %0, i32 0)
%13 = tail call i32 @eeprom_delay(i32 500)
%14 = add nsw i32 %5, -1
%15 = icmp eq i32 %5, 0
br i1 %15, label %16, label %4
16: ; preds = %4
ret i32 0
}