#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 FPT_utilEEReadOrg(unsigned long, unsigned short);
unsigned short FPT_utilEERead(unsigned long p_port, unsigned short ee_addr) {
  unsigned short i, ee_data1, ee_data2;
  i = 0;
  ee_data1 = FPT_utilEEReadOrg(p_port, ee_addr);
  do {
    ee_data2 = FPT_utilEEReadOrg(p_port, ee_addr);
    if (ee_data1 == ee_data2)
      return ee_data1;
    ee_data1 = ee_data2;
    i++;
  } while (i < 4);
  return ee_data1;
}


x86 assembly (clang, -O0):
<FPT_utilEERead>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %si,%ax
mov    %rdi,-0x10(%rbp)
mov    %ax,-0x12(%rbp)
movw   $0x0,-0x14(%rbp)
mov    -0x10(%rbp),%rdi
movzwl -0x12(%rbp),%esi
call   1030 <FPT_utilEEReadOrg@plt>
mov    %ax,-0x16(%rbp)
mov    -0x10(%rbp),%rdi
movzwl -0x12(%rbp),%esi
call   1030 <FPT_utilEEReadOrg@plt>
mov    %ax,-0x18(%rbp)
movzwl -0x16(%rbp),%eax
movzwl -0x18(%rbp),%ecx
cmp    %ecx,%eax
jne    1168 <FPT_utilEERead+0x58>
mov    -0x16(%rbp),%ax
mov    %ax,-0x2(%rbp)
jmp    1191 <FPT_utilEERead+0x81>
mov    -0x18(%rbp),%ax
mov    %ax,-0x16(%rbp)
mov    -0x14(%rbp),%ax
add    $0x1,%ax
mov    %ax,-0x14(%rbp)
movzwl -0x14(%rbp),%eax
cmp    $0x4,%eax
jl     113a <FPT_utilEERead+0x2a>
mov    -0x16(%rbp),%ax
mov    %ax,-0x2(%rbp)
movzwl -0x2(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<FPT_utilEERead>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %esi,%ebp
mov    %rdi,%r14
call   1030 <FPT_utilEEReadOrg@plt>
mov    %eax,%ebx
mov    %r14,%rdi
mov    %ebp,%esi
call   1030 <FPT_utilEEReadOrg@plt>
cmp    %ax,%bx
je     1162 <FPT_utilEERead+0x52>
mov    %eax,%r15d
movzwl %bp,%r12d
mov    %r14,%rdi
mov    %r12d,%esi
call   1030 <FPT_utilEEReadOrg@plt>
mov    %r15d,%ebx
cmp    %ax,%r15w
je     1162 <FPT_utilEERead+0x52>
mov    %eax,%ebp
mov    %r14,%rdi
mov    %r12d,%esi
call   1030 <FPT_utilEEReadOrg@plt>
mov    %ebp,%ebx
cmp    %ax,%bp
jne    116d <FPT_utilEERead+0x5d>
mov    %ebx,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %r14,%rdi
mov    %r12d,%esi
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <FPT_utilEEReadOrg@plt>

LLVM IR (-O0):
define zeroext i16 @FPT_utilEERead(i64 %0, i16 zeroext %1) {
%3 = alloca i16
%4 = alloca i64
%5 = alloca i16
%6 = alloca i16
%7 = alloca i16
%8 = alloca i16
store i64 %0, i64* %4
store i16 %1, i16* %5
store i16 0, i16* %6
%9 = load i64, i64* %4
%10 = load i16, i16* %5
%11 = call zeroext i16 @FPT_utilEEReadOrg(i64 %9, i16 zeroext %10)
store i16 %11, i16* %7
br label %12
12: ; preds = %27, %2
%13 = load i64, i64* %4
%14 = load i16, i16* %5
%15 = call zeroext i16 @FPT_utilEEReadOrg(i64 %13, i16 zeroext %14)
store i16 %15, i16* %8
%16 = load i16, i16* %7
%17 = zext i16 %16 to i32
%18 = load i16, i16* %8
%19 = zext i16 %18 to i32
%20 = icmp eq i32 %17, %19
br i1 %20, label %21, label %23
21: ; preds = %12
%22 = load i16, i16* %7
store i16 %22, i16* %3
br label %33
23: ; preds = %12
%24 = load i16, i16* %8
store i16 %24, i16* %7
%25 = load i16, i16* %6
%26 = add i16 %25, 1
store i16 %26, i16* %6
br label %27
27: ; preds = %23
%28 = load i16, i16* %6
%29 = zext i16 %28 to i32
%30 = icmp slt i32 %29, 4
br i1 %30, label %12, label %31
31: ; preds = %27
%32 = load i16, i16* %7
store i16 %32, i16* %3
br label %33
33: ; preds = %31, %21
%34 = load i16, i16* %3
ret i16 %34
}

LLVM IR (-O2):
define zeroext i16 @FPT_utilEERead(i64 %0, i16 zeroext %1) {
%3 = tail call zeroext i16 @FPT_utilEEReadOrg(i64 %0, i16 zeroext %1)
%4 = tail call zeroext i16 @FPT_utilEEReadOrg(i64 %0, i16 zeroext %1)
%5 = icmp eq i16 %3, %4
br i1 %5, label %14, label %6
6: ; preds = %2
%7 = tail call zeroext i16 @FPT_utilEEReadOrg(i64 %0, i16 zeroext %1)
%8 = icmp eq i16 %4, %7
br i1 %8, label %14, label %9
9: ; preds = %6
%10 = tail call zeroext i16 @FPT_utilEEReadOrg(i64 %0, i16 zeroext %1)
%11 = icmp eq i16 %7, %10
br i1 %11, label %14, label %12
12: ; preds = %9
%13 = tail call zeroext i16 @FPT_utilEEReadOrg(i64 %0, i16 zeroext %1)
br label %14
14: ; preds = %12, %9, %6, %2
%15 = phi i16 [ %3, %2 ], [ %4, %6 ], [ %7, %9 ], [ %13, %12 ]
ret i16 %15
}