#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 */
unsigned char inb(unsigned short);
int /*<<< orphan*/ outb(int, unsigned short);
int /*<<< orphan*/ strcmp(char *, char *);
int /*<<< orphan*/ v_EepromCs76Read(unsigned short, unsigned short,
                                    unsigned short *);
int /*<<< orphan*/ v_EepromWaitBusy(unsigned short);
unsigned short w_EepromReadWord(unsigned short w_PCIBoardEepromAddress,
                                char *pc_PCIChipInformation,
                                unsigned short w_EepromStartAddress) {
  unsigned char b_Counter = 0;
  unsigned char b_ReadByte = 0;
  unsigned char b_ReadLowByte = 0;
  unsigned char b_ReadHighByte = 0;
  unsigned char b_SelectedAddressLow = 0;
  unsigned char b_SelectedAddressHigh = 0;
  unsigned short w_ReadWord = 0;
  if ((!strcmp(pc_PCIChipInformation, "S5920")) ||
      (!strcmp(pc_PCIChipInformation, "S5933"))) {
    for (b_Counter = 0; b_Counter < 2; b_Counter++) {
      b_SelectedAddressLow = (w_EepromStartAddress + b_Counter) % 256;
      b_SelectedAddressHigh = (w_EepromStartAddress + b_Counter) / 256;
      outb((0x4 << 5), w_PCIBoardEepromAddress + 0x3F);
      v_EepromWaitBusy(w_PCIBoardEepromAddress);
      outb(b_SelectedAddressLow, w_PCIBoardEepromAddress + 0x3E);
      v_EepromWaitBusy(w_PCIBoardEepromAddress);
      outb((0x5 << 5), w_PCIBoardEepromAddress + 0x3F);
      v_EepromWaitBusy(w_PCIBoardEepromAddress);
      outb(b_SelectedAddressHigh, w_PCIBoardEepromAddress + 0x3E);
      v_EepromWaitBusy(w_PCIBoardEepromAddress);
      outb((0x7 << 5), w_PCIBoardEepromAddress + 0x3F);
      v_EepromWaitBusy(w_PCIBoardEepromAddress);
      b_ReadByte = inb(w_PCIBoardEepromAddress + 0x3E);
      v_EepromWaitBusy(w_PCIBoardEepromAddress);
      if (b_Counter == 0) {
        b_ReadLowByte = b_ReadByte;
      } else {
        b_ReadHighByte = b_ReadByte;
      }
    }
    w_ReadWord = (b_ReadLowByte | (((unsigned short)b_ReadHighByte) * 256));
  }
  if (!strcmp(pc_PCIChipInformation, "93C76")) {
    v_EepromCs76Read(w_PCIBoardEepromAddress, w_EepromStartAddress,
                     &w_ReadWord);
  }
  return w_ReadWord;
}


x86 assembly (clang, -O0):
<w_EepromReadWord>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %dx,%ax
mov    %di,%cx
mov    %cx,-0x2(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %ax,-0x12(%rbp)
movb   $0x0,-0x13(%rbp)
movb   $0x0,-0x14(%rbp)
movb   $0x0,-0x15(%rbp)
movb   $0x0,-0x16(%rbp)
movb   $0x0,-0x17(%rbp)
movb   $0x0,-0x18(%rbp)
movw   $0x0,-0x1a(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xe6d(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
je     11ba <w_EepromReadWord+0x6a>
mov    -0x10(%rbp),%rdi
lea    0xe5a(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    12e5 <w_EepromReadWord+0x195>
movb   $0x0,-0x13(%rbp)
movzbl -0x13(%rbp),%eax
cmp    $0x2,%eax
jge    12d1 <w_EepromReadWord+0x181>
movzwl -0x12(%rbp),%eax
movzbl -0x13(%rbp),%ecx
add    %ecx,%eax
mov    $0x100,%ecx
cltd
idiv   %ecx
mov    %dl,%al
mov    %al,-0x17(%rbp)
movzwl -0x12(%rbp),%eax
movzbl -0x13(%rbp),%ecx
add    %ecx,%eax
mov    $0x100,%ecx
cltd
idiv   %ecx
mov    %al,-0x18(%rbp)
movzwl -0x2(%rbp),%eax
add    $0x3f,%eax
mov    $0x80,%edi
movzwl %ax,%esi
call   1030 <outb@plt>
movzwl -0x2(%rbp),%edi
call   1070 <v_EepromWaitBusy@plt>
movzbl -0x17(%rbp),%edi
movzwl -0x2(%rbp),%eax
add    $0x3e,%eax
movzwl %ax,%esi
call   1030 <outb@plt>
movzwl -0x2(%rbp),%edi
call   1070 <v_EepromWaitBusy@plt>
movzwl -0x2(%rbp),%eax
add    $0x3f,%eax
mov    $0xa0,%edi
movzwl %ax,%esi
call   1030 <outb@plt>
movzwl -0x2(%rbp),%edi
call   1070 <v_EepromWaitBusy@plt>
movzbl -0x18(%rbp),%edi
movzwl -0x2(%rbp),%eax
add    $0x3e,%eax
movzwl %ax,%esi
call   1030 <outb@plt>
movzwl -0x2(%rbp),%edi
call   1070 <v_EepromWaitBusy@plt>
movzwl -0x2(%rbp),%eax
add    $0x3f,%eax
mov    $0xe0,%edi
movzwl %ax,%esi
call   1030 <outb@plt>
movzwl -0x2(%rbp),%edi
call   1070 <v_EepromWaitBusy@plt>
movzwl -0x2(%rbp),%eax
add    $0x3e,%eax
movzwl %ax,%edi
call   1050 <inb@plt>
mov    %al,-0x14(%rbp)
movzwl -0x2(%rbp),%edi
call   1070 <v_EepromWaitBusy@plt>
movzbl -0x13(%rbp),%eax
cmp    $0x0,%eax
jne    12b9 <w_EepromReadWord+0x169>
mov    -0x14(%rbp),%al
mov    %al,-0x15(%rbp)
jmp    12bf <w_EepromReadWord+0x16f>
mov    -0x14(%rbp),%al
mov    %al,-0x16(%rbp)
jmp    12c4 <w_EepromReadWord+0x174>
mov    -0x13(%rbp),%al
add    $0x1,%al
mov    %al,-0x13(%rbp)
jmp    11be <w_EepromReadWord+0x6e>
movzbl -0x15(%rbp),%eax
movzbl -0x16(%rbp),%ecx
movzwl %cx,%ecx
shl    $0x8,%ecx
or     %ecx,%eax
mov    %ax,-0x1a(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xd1c(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%eax
jne    1312 <w_EepromReadWord+0x1c2>
mov    -0x2(%rbp),%ax
lea    -0x1a(%rbp),%rdx
movzwl %ax,%edi
movzwl -0x12(%rbp),%esi
call   1060 <v_EepromCs76Read@plt>
movzwl -0x1a(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<w_EepromReadWord>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %edx,%ebx
mov    %rsi,%r15
mov    %edi,%ebp
movw   $0x0,0x4(%rsp)
lea    0xe90(%rip),%rsi
mov    %r15,%rdi
call   1040 <strcmp@plt>
movzwl %bx,%r14d
movzwl %bp,%ebx
test   %eax,%eax
je     119d <w_EepromReadWord+0x4d>
lea    0xe7c(%rip),%rsi
mov    %r15,%rdi
call   1040 <strcmp@plt>
test   %eax,%eax
je     119d <w_EepromReadWord+0x4d>
xor    %ebp,%ebp
jmp    12b1 <w_EepromReadWord+0x161>
lea    0x3f(%rbx),%eax
lea    0x3e(%rbx),%r13d
mov    %r14d,%ebp
shr    $0x8,%ebp
movzwl %ax,%r12d
mov    $0x80,%edi
mov    %r12d,%esi
call   1030 <outb@plt>
mov    %ebx,%edi
call   1070 <v_EepromWaitBusy@plt>
movzbl %r14b,%edi
movzwl %r13w,%r13d
mov    %r13d,%esi
call   1030 <outb@plt>
mov    %ebx,%edi
call   1070 <v_EepromWaitBusy@plt>
mov    $0xa0,%edi
mov    %r12d,%esi
call   1030 <outb@plt>
mov    %ebx,%edi
call   1070 <v_EepromWaitBusy@plt>
mov    %ebp,%edi
mov    %r13d,%esi
call   1030 <outb@plt>
mov    %ebx,%edi
call   1070 <v_EepromWaitBusy@plt>
mov    $0xe0,%edi
mov    %r12d,%esi
call   1030 <outb@plt>
mov    %ebx,%edi
call   1070 <v_EepromWaitBusy@plt>
mov    %r13d,%edi
call   1050 <inb@plt>
mov    %al,0x7(%rsp)
mov    %ebx,%edi
call   1070 <v_EepromWaitBusy@plt>
lea    0x1(%r14),%ebp
mov    $0x80,%edi
mov    %r12d,%esi
call   1030 <outb@plt>
mov    %ebx,%edi
call   1070 <v_EepromWaitBusy@plt>
movzbl %bpl,%edi
mov    %r13d,%esi
call   1030 <outb@plt>
mov    %ebx,%edi
call   1070 <v_EepromWaitBusy@plt>
mov    $0xa0,%edi
mov    %r12d,%esi
call   1030 <outb@plt>
mov    %ebx,%edi
call   1070 <v_EepromWaitBusy@plt>
mov    %ebp,%eax
movzbl %ah,%edi
mov    %r13d,%esi
call   1030 <outb@plt>
mov    %ebx,%edi
call   1070 <v_EepromWaitBusy@plt>
mov    $0xe0,%edi
mov    %r12d,%esi
call   1030 <outb@plt>
mov    %ebx,%edi
call   1070 <v_EepromWaitBusy@plt>
mov    %r13d,%edi
call   1050 <inb@plt>
mov    %eax,%r12d
mov    %ebx,%edi
call   1070 <v_EepromWaitBusy@plt>
movzbl 0x7(%rsp),%eax
movzbl %r12b,%ebp
shl    $0x8,%ebp
or     %eax,%ebp
mov    %bp,0x4(%rsp)
lea    0xd54(%rip),%rsi
mov    %r15,%rdi
call   1040 <strcmp@plt>
test   %eax,%eax
jne    12d8 <w_EepromReadWord+0x188>
lea    0x4(%rsp),%rdx
mov    %ebx,%edi
mov    %r14d,%esi
call   1060 <v_EepromCs76Read@plt>
movzwl 0x4(%rsp),%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [6 x i8] c"S5920\00"
@.str.1 = [6 x i8] c"S5933\00"
@.str.2 = [6 x i8] c"93C76\00"
define zeroext i16 @w_EepromReadWord(i16 zeroext %0, i8* %1, i16 zeroext %2) {
%4 = alloca i16
%5 = alloca i8*
%6 = alloca i16
%7 = alloca i8
%8 = alloca i8
%9 = alloca i8
%10 = alloca i8
%11 = alloca i8
%12 = alloca i8
%13 = alloca i16
store i16 %0, i16* %4
store i8* %1, i8** %5
store i16 %2, i16* %6
store i8 0, i8* %7
store i8 0, i8* %8
store i8 0, i8* %9
store i8 0, i8* %10
store i8 0, i8* %11
store i8 0, i8* %12
store i16 0, i16* %13
%14 = load i8*, i8** %5
%15 = call i32 @strcmp(i8* %14, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%16 = icmp ne i32 %15, 0
br i1 %16, label %17, label %21
17: ; preds = %3
%18 = load i8*, i8** %5
%19 = call i32 @strcmp(i8* %18, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%20 = icmp ne i32 %19, 0
br i1 %20, label %107, label %21
21: ; preds = %17, %3
store i8 0, i8* %7
br label %22
22: ; preds = %95, %21
%23 = load i8, i8* %7
%24 = zext i8 %23 to i32
%25 = icmp slt i32 %24, 2
br i1 %25, label %26, label %98
26: ; preds = %22
%27 = load i16, i16* %6
%28 = zext i16 %27 to i32
%29 = load i8, i8* %7
%30 = zext i8 %29 to i32
%31 = add nsw i32 %28, %30
%32 = srem i32 %31, 256
%33 = trunc i32 %32 to i8
store i8 %33, i8* %11
%34 = load i16, i16* %6
%35 = zext i16 %34 to i32
%36 = load i8, i8* %7
%37 = zext i8 %36 to i32
%38 = add nsw i32 %35, %37
%39 = sdiv i32 %38, 256
%40 = trunc i32 %39 to i8
store i8 %40, i8* %12
%41 = load i16, i16* %4
%42 = zext i16 %41 to i32
%43 = add nsw i32 %42, 63
%44 = trunc i32 %43 to i16
%45 = call i32 @outb(i32 128, i16 zeroext %44)
%46 = load i16, i16* %4
%47 = call i32 @v_EepromWaitBusy(i16 zeroext %46)
%48 = load i8, i8* %11
%49 = zext i8 %48 to i32
%50 = load i16, i16* %4
%51 = zext i16 %50 to i32
%52 = add nsw i32 %51, 62
%53 = trunc i32 %52 to i16
%54 = call i32 @outb(i32 %49, i16 zeroext %53)
%55 = load i16, i16* %4
%56 = call i32 @v_EepromWaitBusy(i16 zeroext %55)
%57 = load i16, i16* %4
%58 = zext i16 %57 to i32
%59 = add nsw i32 %58, 63
%60 = trunc i32 %59 to i16
%61 = call i32 @outb(i32 160, i16 zeroext %60)
%62 = load i16, i16* %4
%63 = call i32 @v_EepromWaitBusy(i16 zeroext %62)
%64 = load i8, i8* %12
%65 = zext i8 %64 to i32
%66 = load i16, i16* %4
%67 = zext i16 %66 to i32
%68 = add nsw i32 %67, 62
%69 = trunc i32 %68 to i16
%70 = call i32 @outb(i32 %65, i16 zeroext %69)
%71 = load i16, i16* %4
%72 = call i32 @v_EepromWaitBusy(i16 zeroext %71)
%73 = load i16, i16* %4
%74 = zext i16 %73 to i32
%75 = add nsw i32 %74, 63
%76 = trunc i32 %75 to i16
%77 = call i32 @outb(i32 224, i16 zeroext %76)
%78 = load i16, i16* %4
%79 = call i32 @v_EepromWaitBusy(i16 zeroext %78)
%80 = load i16, i16* %4
%81 = zext i16 %80 to i32
%82 = add nsw i32 %81, 62
%83 = trunc i32 %82 to i16
%84 = call zeroext i8 @inb(i16 zeroext %83)
store i8 %84, i8* %8
%85 = load i16, i16* %4
%86 = call i32 @v_EepromWaitBusy(i16 zeroext %85)
%87 = load i8, i8* %7
%88 = zext i8 %87 to i32
%89 = icmp eq i32 %88, 0
br i1 %89, label %90, label %92
90: ; preds = %26
%91 = load i8, i8* %8
store i8 %91, i8* %9
br label %94
92: ; preds = %26
%93 = load i8, i8* %8
store i8 %93, i8* %10
br label %94
94: ; preds = %92, %90
br label %95
95: ; preds = %94
%96 = load i8, i8* %7
%97 = add i8 %96, 1
store i8 %97, i8* %7
br label %22
98: ; preds = %22
%99 = load i8, i8* %9
%100 = zext i8 %99 to i32
%101 = load i8, i8* %10
%102 = zext i8 %101 to i16
%103 = zext i16 %102 to i32
%104 = mul nsw i32 %103, 256
%105 = or i32 %100, %104
%106 = trunc i32 %105 to i16
store i16 %106, i16* %13
br label %107
107: ; preds = %98, %17
%108 = load i8*, i8** %5
%109 = call i32 @strcmp(i8* %108, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%110 = icmp ne i32 %109, 0
br i1 %110, label %115, label %111
111: ; preds = %107
%112 = load i16, i16* %4
%113 = load i16, i16* %6
%114 = call i32 @v_EepromCs76Read(i16 zeroext %112, i16 zeroext %113, i16* %13)
br label %115
115: ; preds = %111, %107
%116 = load i16, i16* %13
ret i16 %116
}

LLVM IR (-O2):
@.str = [6 x i8] c"S5920\00"
@.str.1 = [6 x i8] c"S5933\00"
@.str.2 = [6 x i8] c"93C76\00"
define zeroext i16 @w_EepromReadWord(i16 zeroext %0, i8* nocapture %1, i16 zeroext %2) {
%4 = alloca i16
%5 = bitcast i16* %4 to i8*
store i16 0, i16* %4
%6 = tail call i32 @strcmp(i8* dereferenceable(1) %1, i8* dereferenceable(6) getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%7 = icmp eq i32 %6, 0
br i1 %7, label %11, label %8
8: ; preds = %3
%9 = tail call i32 @strcmp(i8* dereferenceable(1) %1, i8* dereferenceable(6) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%10 = icmp eq i32 %9, 0
br i1 %10, label %11, label %49
11: ; preds = %8, %3
%12 = zext i16 %2 to i32
%13 = add i16 %0, 63
%14 = add i16 %0, 62
%15 = lshr i32 %12, 8
%16 = tail call i32 @outb(i32 128, i16 zeroext %13)
%17 = tail call i32 @v_EepromWaitBusy(i16 zeroext %0)
%18 = and i32 %12, 255
%19 = tail call i32 @outb(i32 %18, i16 zeroext %14)
%20 = tail call i32 @v_EepromWaitBusy(i16 zeroext %0)
%21 = tail call i32 @outb(i32 160, i16 zeroext %13)
%22 = tail call i32 @v_EepromWaitBusy(i16 zeroext %0)
%23 = tail call i32 @outb(i32 %15, i16 zeroext %14)
%24 = tail call i32 @v_EepromWaitBusy(i16 zeroext %0)
%25 = tail call i32 @outb(i32 224, i16 zeroext %13)
%26 = tail call i32 @v_EepromWaitBusy(i16 zeroext %0)
%27 = tail call zeroext i8 @inb(i16 zeroext %14)
%28 = tail call i32 @v_EepromWaitBusy(i16 zeroext %0)
%29 = add nuw nsw i32 %12, 1
%30 = lshr i32 %29, 8
%31 = tail call i32 @outb(i32 128, i16 zeroext %13)
%32 = tail call i32 @v_EepromWaitBusy(i16 zeroext %0)
%33 = and i32 %29, 255
%34 = tail call i32 @outb(i32 %33, i16 zeroext %14)
%35 = tail call i32 @v_EepromWaitBusy(i16 zeroext %0)
%36 = tail call i32 @outb(i32 160, i16 zeroext %13)
%37 = tail call i32 @v_EepromWaitBusy(i16 zeroext %0)
%38 = and i32 %30, 255
%39 = tail call i32 @outb(i32 %38, i16 zeroext %14)
%40 = tail call i32 @v_EepromWaitBusy(i16 zeroext %0)
%41 = tail call i32 @outb(i32 224, i16 zeroext %13)
%42 = tail call i32 @v_EepromWaitBusy(i16 zeroext %0)
%43 = tail call zeroext i8 @inb(i16 zeroext %14)
%44 = tail call i32 @v_EepromWaitBusy(i16 zeroext %0)
%45 = zext i8 %27 to i16
%46 = zext i8 %43 to i16
%47 = shl nuw i16 %46, 8
%48 = or i16 %47, %45
store i16 %48, i16* %4
br label %49
49: ; preds = %11, %8
%50 = phi i16 [ %48, %11 ], [ 0, %8 ]
%51 = tail call i32 @strcmp(i8* dereferenceable(1) %1, i8* dereferenceable(6) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%52 = icmp eq i32 %51, 0
br i1 %52, label %53, label %56
53: ; preds = %49
%54 = call i32 @v_EepromCs76Read(i16 zeroext %0, i16 zeroext %2, i16* %4)
%55 = load i16, i16* %4
br label %56
56: ; preds = %53, %49
%57 = phi i16 [ %55, %53 ], [ %50, %49 ]
ret i16 %57
}