#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_send_start(unsigned long pci_base, int command) {
  int op_code[2];
  switch (command) {
  case 1:
    op_code[0] = 0;
    op_code[1] = 1;
    break;
  case 2:
    op_code[0] = 1;
    op_code[1] = 0;
    break;
  case 3:
    op_code[0] = 1;
    op_code[1] = 1;
    break;
  case 4:
  case 5:
    op_code[0] = 0;
    op_code[1] = 0;
    break;
  default:
    return (4);
  }
  set_scl_line(pci_base, 0);
  set_sda_line(pci_base, 1);
  eeprom_delay(100);
  set_scl_line(pci_base, 1);
  eeprom_delay(500);
  set_scl_line(pci_base, 0);
  eeprom_delay(500);
  set_sda_line(pci_base, op_code[0]);
  eeprom_delay(100);
  set_scl_line(pci_base, 1);
  eeprom_delay(500);
  set_scl_line(pci_base, 0);
  eeprom_delay(500);
  set_sda_line(pci_base, op_code[1]);
  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_send_start>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    -0x14(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x28(%rbp)
sub    $0x4,%eax
ja     11b4 <eeprom_send_start+0x84>
mov    -0x28(%rbp),%rax
lea    0xea1(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movl   $0x0,-0x1c(%rbp)
movl   $0x1,-0x18(%rbp)
jmp    11c0 <eeprom_send_start+0x90>
movl   $0x1,-0x1c(%rbp)
movl   $0x0,-0x18(%rbp)
jmp    11c0 <eeprom_send_start+0x90>
movl   $0x1,-0x1c(%rbp)
movl   $0x1,-0x18(%rbp)
jmp    11c0 <eeprom_send_start+0x90>
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x18(%rbp)
jmp    11c0 <eeprom_send_start+0x90>
movl   $0x4,-0x4(%rbp)
jmp    129d <eeprom_send_start+0x16d>
mov    -0x10(%rbp),%rdi
xor    %esi,%esi
call   1050 <set_scl_line@plt>
mov    -0x10(%rbp),%rdi
mov    $0x1,%esi
call   1030 <set_sda_line@plt>
mov    $0x64,%edi
call   1040 <eeprom_delay@plt>
mov    -0x10(%rbp),%rdi
mov    $0x1,%esi
call   1050 <set_scl_line@plt>
mov    $0x1f4,%edi
call   1040 <eeprom_delay@plt>
mov    -0x10(%rbp),%rdi
xor    %esi,%esi
call   1050 <set_scl_line@plt>
mov    $0x1f4,%edi
call   1040 <eeprom_delay@plt>
mov    -0x10(%rbp),%rdi
mov    -0x1c(%rbp),%esi
call   1030 <set_sda_line@plt>
mov    $0x64,%edi
call   1040 <eeprom_delay@plt>
mov    -0x10(%rbp),%rdi
mov    $0x1,%esi
call   1050 <set_scl_line@plt>
mov    $0x1f4,%edi
call   1040 <eeprom_delay@plt>
mov    -0x10(%rbp),%rdi
xor    %esi,%esi
call   1050 <set_scl_line@plt>
mov    $0x1f4,%edi
call   1040 <eeprom_delay@plt>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%esi
call   1030 <set_sda_line@plt>
mov    $0x64,%edi
call   1040 <eeprom_delay@plt>
mov    -0x10(%rbp),%rdi
mov    $0x1,%esi
call   1050 <set_scl_line@plt>
mov    $0x1f4,%edi
call   1040 <eeprom_delay@plt>
mov    -0x10(%rbp),%rdi
xor    %esi,%esi
call   1050 <set_scl_line@plt>
mov    $0x1f4,%edi
call   1040 <eeprom_delay@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<eeprom_send_start>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
add    $0xffffffff,%esi
mov    $0x4,%ebp
cmp    $0x4,%esi
ja     122f <eeprom_send_start+0xff>
mov    %rdi,%rbx
movslq %esi,%rax
lea    0xeab(%rip),%rcx
mov    (%rcx,%rax,4),%r14d
lea    0xeb4(%rip),%rcx
mov    (%rcx,%rax,4),%r15d
xor    %ebp,%ebp
xor    %esi,%esi
call   1050 <set_scl_line@plt>
mov    %rbx,%rdi
mov    $0x1,%esi
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>
mov    %rbx,%rdi
mov    %r15d,%esi
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>
mov    %rbx,%rdi
mov    %r14d,%esi
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>
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @eeprom_send_start(i64 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i64
%5 = alloca i32
%6 = alloca [2 x i32]
store i64 %0, i64* %4
store i32 %1, i32* %5
%7 = load i32, i32* %5
switch i32 %7, label %20 [
i32 1, label %8
i32 2, label %11
i32 3, label %14
i32 4, label %17
i32 5, label %17
]
8: ; preds = %2
%9 = getelementptr inbounds [2 x i32], [2 x i32]* %6, i64 0, i64 0
store i32 0, i32* %9
%10 = getelementptr inbounds [2 x i32], [2 x i32]* %6, i64 0, i64 1
store i32 1, i32* %10
br label %21
11: ; preds = %2
%12 = getelementptr inbounds [2 x i32], [2 x i32]* %6, i64 0, i64 0
store i32 1, i32* %12
%13 = getelementptr inbounds [2 x i32], [2 x i32]* %6, i64 0, i64 1
store i32 0, i32* %13
br label %21
14: ; preds = %2
%15 = getelementptr inbounds [2 x i32], [2 x i32]* %6, i64 0, i64 0
store i32 1, i32* %15
%16 = getelementptr inbounds [2 x i32], [2 x i32]* %6, i64 0, i64 1
store i32 1, i32* %16
br label %21
17: ; preds = %2, %2
%18 = getelementptr inbounds [2 x i32], [2 x i32]* %6, i64 0, i64 0
store i32 0, i32* %18
%19 = getelementptr inbounds [2 x i32], [2 x i32]* %6, i64 0, i64 1
store i32 0, i32* %19
br label %21
20: ; preds = %2
store i32 4, i32* %3
br label %55
21: ; preds = %17, %14, %11, %8
%22 = load i64, i64* %4
%23 = call i32 @set_scl_line(i64 %22, i32 0)
%24 = load i64, i64* %4
%25 = call i32 @set_sda_line(i64 %24, i32 1)
%26 = call i32 @eeprom_delay(i32 100)
%27 = load i64, i64* %4
%28 = call i32 @set_scl_line(i64 %27, i32 1)
%29 = call i32 @eeprom_delay(i32 500)
%30 = load i64, i64* %4
%31 = call i32 @set_scl_line(i64 %30, i32 0)
%32 = call i32 @eeprom_delay(i32 500)
%33 = load i64, i64* %4
%34 = getelementptr inbounds [2 x i32], [2 x i32]* %6, i64 0, i64 0
%35 = load i32, i32* %34
%36 = call i32 @set_sda_line(i64 %33, i32 %35)
%37 = call i32 @eeprom_delay(i32 100)
%38 = load i64, i64* %4
%39 = call i32 @set_scl_line(i64 %38, i32 1)
%40 = call i32 @eeprom_delay(i32 500)
%41 = load i64, i64* %4
%42 = call i32 @set_scl_line(i64 %41, i32 0)
%43 = call i32 @eeprom_delay(i32 500)
%44 = load i64, i64* %4
%45 = getelementptr inbounds [2 x i32], [2 x i32]* %6, i64 0, i64 1
%46 = load i32, i32* %45
%47 = call i32 @set_sda_line(i64 %44, i32 %46)
%48 = call i32 @eeprom_delay(i32 100)
%49 = load i64, i64* %4
%50 = call i32 @set_scl_line(i64 %49, i32 1)
%51 = call i32 @eeprom_delay(i32 500)
%52 = load i64, i64* %4
%53 = call i32 @set_scl_line(i64 %52, i32 0)
%54 = call i32 @eeprom_delay(i32 500)
store i32 0, i32* %3
br label %55
55: ; preds = %21, %20
%56 = load i32, i32* %3
ret i32 %56
}

LLVM IR (-O2):
@switch.table.eeprom_send_start = [5 x i32] [i32 1, i32 0, i32 1, i32 0, i32 0]
@switch.table.eeprom_send_start.1 = [5 x i32] [i32 0, i32 1, i32 1, i32 0, i32 0]
define i32 @eeprom_send_start(i64 %0, i32 %1) {
%3 = add i32 %1, -1
%4 = icmp ult i32 %3, 5
br i1 %4, label %5, label %31
5: ; preds = %2
%6 = sext i32 %3 to i64
%7 = getelementptr inbounds [5 x i32], [5 x i32]* @switch.table.eeprom_send_start, i64 0, i64 %6
%8 = load i32, i32* %7
%9 = sext i32 %3 to i64
%10 = getelementptr inbounds [5 x i32], [5 x i32]* @switch.table.eeprom_send_start.1, i64 0, i64 %9
%11 = load i32, i32* %10
%12 = tail call i32 @set_scl_line(i64 %0, i32 0)
%13 = tail call i32 @set_sda_line(i64 %0, i32 1)
%14 = tail call i32 @eeprom_delay(i32 100)
%15 = tail call i32 @set_scl_line(i64 %0, i32 1)
%16 = tail call i32 @eeprom_delay(i32 500)
%17 = tail call i32 @set_scl_line(i64 %0, i32 0)
%18 = tail call i32 @eeprom_delay(i32 500)
%19 = tail call i32 @set_sda_line(i64 %0, i32 %11)
%20 = tail call i32 @eeprom_delay(i32 100)
%21 = tail call i32 @set_scl_line(i64 %0, i32 1)
%22 = tail call i32 @eeprom_delay(i32 500)
%23 = tail call i32 @set_scl_line(i64 %0, i32 0)
%24 = tail call i32 @eeprom_delay(i32 500)
%25 = tail call i32 @set_sda_line(i64 %0, i32 %8)
%26 = tail call i32 @eeprom_delay(i32 100)
%27 = tail call i32 @set_scl_line(i64 %0, i32 1)
%28 = tail call i32 @eeprom_delay(i32 500)
%29 = tail call i32 @set_scl_line(i64 %0, i32 0)
%30 = tail call i32 @eeprom_delay(i32 500)
br label %31
31: ; preds = %2, %5
%32 = phi i32 [ 0, %5 ], [ 4, %2 ]
ret i32 %32
}