#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);
scalar_t__ get_sda_line(unsigned long);
int /*<<< orphan*/ set_scl_line(unsigned long, int);
int /*<<< orphan*/ set_sda_line(unsigned long, int);
int eeprom_send_addr(unsigned long pci_base, unsigned char eeprom_addr) {
  register int i;
  for (i = 5; i >= 0; i--) {
    if (eeprom_addr & (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);
    if (get_sda_line(pci_base) == 0)
      break;
  }
  return (0);
}


x86 assembly (clang, -O0):
<eeprom_send_addr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %sil,%al
mov    %rdi,-0x8(%rbp)
mov    %al,-0x9(%rbp)
movl   $0x5,-0x10(%rbp)
cmpl   $0x0,-0x10(%rbp)
jl     11fe <eeprom_send_addr+0xbe>
movzbl -0x9(%rbp),%eax
mov    -0x10(%rbp),%ecx
mov    $0x1,%edx
shl    %cl,%edx
mov    %edx,%ecx
and    %ecx,%eax
cmp    $0x0,%eax
je     1191 <eeprom_send_addr+0x51>
mov    -0x8(%rbp),%rdi
mov    $0x1,%esi
call   1030 <set_sda_line@plt>
jmp    119c <eeprom_send_addr+0x5c>
mov    -0x8(%rbp),%rdi
xor    %esi,%esi
call   1030 <set_sda_line@plt>
mov    $0x64,%edi
call   1050 <eeprom_delay@plt>
mov    -0x8(%rbp),%rdi
mov    $0x1,%esi
call   1060 <set_scl_line@plt>
mov    $0x1f4,%edi
call   1050 <eeprom_delay@plt>
mov    -0x8(%rbp),%rdi
xor    %esi,%esi
call   1060 <set_scl_line@plt>
mov    $0x1f4,%edi
call   1050 <eeprom_delay@plt>
mov    -0x8(%rbp),%rdi
call   1040 <get_sda_line@plt>
cmp    $0x0,%rax
jne    11eb <eeprom_send_addr+0xab>
jmp    11fe <eeprom_send_addr+0xbe>
jmp    11f0 <eeprom_send_addr+0xb0>
mov    -0x10(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x10(%rbp)
jmp    1159 <eeprom_send_addr+0x19>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<eeprom_send_addr>:
push   %rbp
push   %r14
push   %rbx
mov    %esi,%r14d
mov    %rdi,%rbx
mov    $0x5,%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   1050 <eeprom_delay@plt>
mov    %rbx,%rdi
mov    $0x1,%esi
call   1060 <set_scl_line@plt>
mov    $0x1f4,%edi
call   1050 <eeprom_delay@plt>
mov    %rbx,%rdi
xor    %esi,%esi
call   1060 <set_scl_line@plt>
mov    $0x1f4,%edi
call   1050 <eeprom_delay@plt>
mov    %rbx,%rdi
call   1040 <get_sda_line@plt>
sub    $0x1,%ebp
setb   %cl
test   %rax,%rax
je     11ae <eeprom_send_addr+0x6e>
test   %cl,%cl
je     1150 <eeprom_send_addr+0x10>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define i32 @eeprom_send_addr(i64 %0, i8 zeroext %1) {
%3 = alloca i64
%4 = alloca i8
%5 = alloca i32
store i64 %0, i64* %3
store i8 %1, i8* %4
store i32 5, i32* %5
br label %6
6: ; preds = %35, %2
%7 = load i32, i32* %5
%8 = icmp sge i32 %7, 0
br i1 %8, label %9, label %38
9: ; preds = %6
%10 = load i8, i8* %4
%11 = zext i8 %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)
%30 = load i64, i64* %3
%31 = call i64 @get_sda_line(i64 %30)
%32 = icmp eq i64 %31, 0
br i1 %32, label %33, label %34
33: ; preds = %22
br label %38
34: ; preds = %22
br label %35
35: ; preds = %34
%36 = load i32, i32* %5
%37 = add nsw i32 %36, -1
store i32 %37, i32* %5
br label %6
38: ; preds = %33, %6
ret i32 0
}

LLVM IR (-O2):
define i32 @eeprom_send_addr(i64 %0, i8 zeroext %1) {
%3 = zext i8 %1 to i32
br label %4
4: ; preds = %4, %2
%5 = phi i32 [ 5, %2 ], [ %16, %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 = tail call i64 @get_sda_line(i64 %0)
%15 = icmp eq i64 %14, 0
%16 = add nsw i32 %5, -1
%17 = icmp eq i32 %5, 0
%18 = select i1 %15, i1 true, i1 %17
br i1 %18, label %19, label %4
19: ; preds = %4
ret i32 0
}