#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 eeprom_send_addr(unsigned long, int);
int eeprom_send_start(unsigned long, int);
int eeprom_write_disable(unsigned long pci_base) {
  int status;
  (*(unsigned char *)(pci_base + 0x0e) |= (1 << 1));
  eeprom_delay(50);
  if (((status = eeprom_send_start(pci_base, 5)) != 0) ||
      ((status = eeprom_send_addr(pci_base, 0x00)) != 0))
    return (status);
  (*(unsigned char *)(pci_base + 0x0e) &= ~(1 << 1));
  eeprom_delay(100);
  return (0);
}


x86 assembly (clang, -O0):
<eeprom_write_disable>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movzbl 0xe(%rax),%ecx
or     $0x2,%ecx
mov    %cl,0xe(%rax)
mov    $0x32,%edi
call   1050 <eeprom_delay@plt>
mov    -0x10(%rbp),%rdi
mov    $0x5,%esi
call   1040 <eeprom_send_start@plt>
mov    %eax,-0x14(%rbp)
cmp    $0x0,%eax
jne    1185 <eeprom_write_disable+0x55>
mov    -0x10(%rbp),%rdi
xor    %esi,%esi
call   1030 <eeprom_send_addr@plt>
mov    %eax,-0x14(%rbp)
cmp    $0x0,%eax
je     1190 <eeprom_write_disable+0x60>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11af <eeprom_write_disable+0x7f>
mov    -0x10(%rbp),%rax
movzbl 0xe(%rax),%ecx
and    $0xfffffffd,%ecx
mov    %cl,0xe(%rax)
mov    $0x64,%edi
call   1050 <eeprom_delay@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<eeprom_write_disable>:
push   %rbx
mov    %rdi,%rbx
orb    $0x2,0xe(%rdi)
mov    $0x32,%edi
call   1050 <eeprom_delay@plt>
mov    %rbx,%rdi
mov    $0x5,%esi
call   1040 <eeprom_send_start@plt>
test   %eax,%eax
je     1155 <eeprom_write_disable+0x25>
pop    %rbx
ret
mov    %rbx,%rdi
xor    %esi,%esi
call   1030 <eeprom_send_addr@plt>
test   %eax,%eax
jne    1153 <eeprom_write_disable+0x23>
andb   $0xfd,0xe(%rbx)
mov    $0x64,%edi
call   1050 <eeprom_delay@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
define i32 @eeprom_write_disable(i64 %0) {
%2 = alloca i32
%3 = alloca i64
%4 = alloca i32
store i64 %0, i64* %3
%5 = load i64, i64* %3
%6 = add i64 %5, 14
%7 = inttoptr i64 %6 to i8*
%8 = load i8, i8* %7
%9 = zext i8 %8 to i32
%10 = or i32 %9, 2
%11 = trunc i32 %10 to i8
store i8 %11, i8* %7
%12 = call i32 @eeprom_delay(i32 50)
%13 = load i64, i64* %3
%14 = call i32 @eeprom_send_start(i64 %13, i32 5)
store i32 %14, i32* %4
%15 = icmp ne i32 %14, 0
br i1 %15, label %20, label %16
16: ; preds = %1
%17 = load i64, i64* %3
%18 = call i32 @eeprom_send_addr(i64 %17, i32 0)
store i32 %18, i32* %4
%19 = icmp ne i32 %18, 0
br i1 %19, label %20, label %22
20: ; preds = %16, %1
%21 = load i32, i32* %4
store i32 %21, i32* %2
br label %31
22: ; preds = %16
%23 = load i64, i64* %3
%24 = add i64 %23, 14
%25 = inttoptr i64 %24 to i8*
%26 = load i8, i8* %25
%27 = zext i8 %26 to i32
%28 = and i32 %27, -3
%29 = trunc i32 %28 to i8
store i8 %29, i8* %25
%30 = call i32 @eeprom_delay(i32 100)
store i32 0, i32* %2
br label %31
31: ; preds = %22, %20
%32 = load i32, i32* %2
ret i32 %32
}

LLVM IR (-O2):
define i32 @eeprom_write_disable(i64 %0) {
%2 = add i64 %0, 14
%3 = inttoptr i64 %2 to i8*
%4 = load i8, i8* %3
%5 = or i8 %4, 2
store i8 %5, i8* %3
%6 = tail call i32 @eeprom_delay(i32 50)
%7 = tail call i32 @eeprom_send_start(i64 %0, i32 5)
%8 = icmp eq i32 %7, 0
br i1 %8, label %9, label %16
9: ; preds = %1
%10 = tail call i32 @eeprom_send_addr(i64 %0, i32 0)
%11 = icmp eq i32 %10, 0
br i1 %11, label %12, label %16
12: ; preds = %9
%13 = load i8, i8* %3
%14 = and i8 %13, -3
store i8 %14, i8* %3
%15 = tail call i32 @eeprom_delay(i32 100)
br label %16
16: ; preds = %1, %9, %12
%17 = phi i32 [ 0, %12 ], [ %7, %1 ], [ %10, %9 ]
ret i32 %17
}