#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 short addi_eeprom_readw_93c76(unsigned long, unsigned short);
unsigned short addi_eeprom_readw_nvram(unsigned long, unsigned short);
int /*<<< orphan*/ strcmp(char *, char *);
unsigned short addi_eeprom_readw(unsigned long iobase, char *type,
                                 unsigned short addr) {
  unsigned short val = 0;
  addr += 0x100;
  if (!strcmp(type, "S5920") || !strcmp(type, "S5933"))
    val = addi_eeprom_readw_nvram(iobase, addr);
  if (!strcmp(type, "93C76"))
    val = addi_eeprom_readw_93c76(iobase, addr);
  return val;
}


x86 assembly (clang, -O0):
<addi_eeprom_readw>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %dx,%ax
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %ax,-0x12(%rbp)
movw   $0x0,-0x14(%rbp)
movzwl -0x12(%rbp),%eax
add    $0x100,%eax
mov    %ax,-0x12(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xe9b(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%eax
je     118c <addi_eeprom_readw+0x5c>
mov    -0x10(%rbp),%rdi
lea    0xe88(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%eax
jne    119d <addi_eeprom_readw+0x6d>
mov    -0x8(%rbp),%rdi
movzwl -0x12(%rbp),%esi
call   1040 <addi_eeprom_readw_nvram@plt>
mov    %ax,-0x14(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xe64(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%eax
jne    11c7 <addi_eeprom_readw+0x97>
mov    -0x8(%rbp),%rdi
movzwl -0x12(%rbp),%esi
call   1050 <addi_eeprom_readw_93c76@plt>
mov    %ax,-0x14(%rbp)
movzwl -0x14(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<addi_eeprom_readw>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %edx,%ebp
mov    %rsi,%rbx
mov    %rdi,%r14
add    $0x100,%ebp
lea    0xeb4(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %eax,%eax
je     1170 <addi_eeprom_readw+0x40>
lea    0xea7(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %eax,%eax
je     1170 <addi_eeprom_readw+0x40>
xor    %r15d,%r15d
jmp    117e <addi_eeprom_readw+0x4e>
movzwl %bp,%esi
mov    %r14,%rdi
call   1040 <addi_eeprom_readw_nvram@plt>
mov    %eax,%r15d
lea    0xe87(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %eax,%eax
je     119f <addi_eeprom_readw+0x6f>
mov    %r15d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
movzwl %bp,%esi
mov    %r14,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1050 <addi_eeprom_readw_93c76@plt>

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 @addi_eeprom_readw(i64 %0, i8* %1, i16 zeroext %2) {
%4 = alloca i64
%5 = alloca i8*
%6 = alloca i16
%7 = alloca i16
store i64 %0, i64* %4
store i8* %1, i8** %5
store i16 %2, i16* %6
store i16 0, i16* %7
%8 = load i16, i16* %6
%9 = zext i16 %8 to i32
%10 = add nsw i32 %9, 256
%11 = trunc i32 %10 to i16
store i16 %11, i16* %6
%12 = load i8*, i8** %5
%13 = call i32 @strcmp(i8* %12, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%14 = icmp ne i32 %13, 0
br i1 %14, label %15, label %19
15: ; preds = %3
%16 = load i8*, i8** %5
%17 = call i32 @strcmp(i8* %16, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%18 = icmp ne i32 %17, 0
br i1 %18, label %23, label %19
19: ; preds = %15, %3
%20 = load i64, i64* %4
%21 = load i16, i16* %6
%22 = call zeroext i16 @addi_eeprom_readw_nvram(i64 %20, i16 zeroext %21)
store i16 %22, i16* %7
br label %23
23: ; preds = %19, %15
%24 = load i8*, i8** %5
%25 = call i32 @strcmp(i8* %24, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%26 = icmp ne i32 %25, 0
br i1 %26, label %31, label %27
27: ; preds = %23
%28 = load i64, i64* %4
%29 = load i16, i16* %6
%30 = call zeroext i16 @addi_eeprom_readw_93c76(i64 %28, i16 zeroext %29)
store i16 %30, i16* %7
br label %31
31: ; preds = %27, %23
%32 = load i16, i16* %7
ret i16 %32
}

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 @addi_eeprom_readw(i64 %0, i8* nocapture %1, i16 zeroext %2) {
%4 = add i16 %2, 256
%5 = tail call i32 @strcmp(i8* dereferenceable(1) %1, i8* dereferenceable(6) getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%6 = icmp eq i32 %5, 0
br i1 %6, label %10, label %7
7: ; preds = %3
%8 = 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))
%9 = icmp eq i32 %8, 0
br i1 %9, label %10, label %12
10: ; preds = %7, %3
%11 = tail call zeroext i16 @addi_eeprom_readw_nvram(i64 %0, i16 zeroext %4)
br label %12
12: ; preds = %10, %7
%13 = phi i16 [ 0, %7 ], [ %11, %10 ]
%14 = 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))
%15 = icmp eq i32 %14, 0
br i1 %15, label %16, label %18
16: ; preds = %12
%17 = tail call zeroext i16 @addi_eeprom_readw_93c76(i64 %0, i16 zeroext %4)
br label %18
18: ; preds = %16, %12
%19 = phi i16 [ %13, %12 ], [ %17, %16 ]
ret i16 %19
}