#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*/ addi_eeprom_clk_93c76(unsigned long, unsigned int);
int /*<<< orphan*/ outl(unsigned int, unsigned long);
int /*<<< orphan*/ udelay(int);
unsigned int addi_eeprom_cmd_93c76(unsigned long iobase, unsigned int cmd,
                                   unsigned char len) {
  unsigned int val = (1 << 1);
  int i;
  outl(val, iobase);
  udelay(100);
  for (i = (len - 1); i >= 0; i--) {
    if (cmd & (1 << i))
      val |= (1 << 2);
    else
      val &= ~(1 << 2);
    outl(val, iobase);
    udelay(100);
    addi_eeprom_clk_93c76(iobase, val);
  }
  return val;
}


x86 assembly (clang, -O0):
<addi_eeprom_cmd_93c76>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %dl,%al
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %al,-0xd(%rbp)
movl   $0x2,-0x14(%rbp)
mov    -0x14(%rbp),%edi
mov    -0x8(%rbp),%rsi
call   1040 <outl@plt>
mov    $0x64,%edi
call   1050 <udelay@plt>
movzbl -0xd(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
jl     11d6 <addi_eeprom_cmd_93c76+0xa6>
mov    -0xc(%rbp),%eax
mov    -0x18(%rbp),%ecx
mov    $0x1,%edx
shl    %cl,%edx
mov    %edx,%ecx
and    %ecx,%eax
cmp    $0x0,%eax
je     119d <addi_eeprom_cmd_93c76+0x6d>
mov    -0x14(%rbp),%eax
or     $0x4,%eax
mov    %eax,-0x14(%rbp)
jmp    11a6 <addi_eeprom_cmd_93c76+0x76>
mov    -0x14(%rbp),%eax
and    $0xfffffffb,%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%edi
mov    -0x8(%rbp),%rsi
call   1040 <outl@plt>
mov    $0x64,%edi
call   1050 <udelay@plt>
mov    -0x8(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1030 <addi_eeprom_clk_93c76@plt>
mov    -0x18(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x18(%rbp)
jmp    116b <addi_eeprom_cmd_93c76+0x3b>
mov    -0x14(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<addi_eeprom_cmd_93c76>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %edx,%r15d
mov    %esi,%r14d
mov    %rdi,%r12
mov    $0x2,%ebp
mov    $0x2,%edi
mov    %r12,%rsi
call   1040 <outl@plt>
mov    $0x64,%edi
call   1050 <udelay@plt>
test   %r15d,%r15d
je     11ac <addi_eeprom_cmd_93c76+0x7c>
movzbl %r15b,%ebx
add    $0x1,%ebx
mov    $0x2,%ebp
xchg   %ax,%ax
lea    -0x2(%rbx),%eax
movzbl %al,%eax
xor    %ecx,%ecx
bt     %eax,%r14d
setb   %cl
and    $0xfffffffb,%ebp
lea    0x0(%rbp,%rcx,4),%ebp
mov    %ebp,%edi
mov    %r12,%rsi
call   1040 <outl@plt>
mov    $0x64,%edi
call   1050 <udelay@plt>
mov    %r12,%rdi
mov    %ebp,%esi
call   1030 <addi_eeprom_clk_93c76@plt>
add    $0xffffffff,%ebx
cmp    $0x1,%ebx
ja     1170 <addi_eeprom_cmd_93c76+0x40>
mov    %ebp,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @addi_eeprom_cmd_93c76(i64 %0, i32 %1, i8 zeroext %2) {
%4 = alloca i64
%5 = alloca i32
%6 = alloca i8
%7 = alloca i32
%8 = alloca i32
store i64 %0, i64* %4
store i32 %1, i32* %5
store i8 %2, i8* %6
store i32 2, i32* %7
%9 = load i32, i32* %7
%10 = load i64, i64* %4
%11 = call i32 @outl(i32 %9, i64 %10)
%12 = call i32 @udelay(i32 100)
%13 = load i8, i8* %6
%14 = zext i8 %13 to i32
%15 = sub nsw i32 %14, 1
store i32 %15, i32* %8
br label %16
16: ; preds = %39, %3
%17 = load i32, i32* %8
%18 = icmp sge i32 %17, 0
br i1 %18, label %19, label %42
19: ; preds = %16
%20 = load i32, i32* %5
%21 = load i32, i32* %8
%22 = shl i32 1, %21
%23 = and i32 %20, %22
%24 = icmp ne i32 %23, 0
br i1 %24, label %25, label %28
25: ; preds = %19
%26 = load i32, i32* %7
%27 = or i32 %26, 4
store i32 %27, i32* %7
br label %31
28: ; preds = %19
%29 = load i32, i32* %7
%30 = and i32 %29, -5
store i32 %30, i32* %7
br label %31
31: ; preds = %28, %25
%32 = load i32, i32* %7
%33 = load i64, i64* %4
%34 = call i32 @outl(i32 %32, i64 %33)
%35 = call i32 @udelay(i32 100)
%36 = load i64, i64* %4
%37 = load i32, i32* %7
%38 = call i32 @addi_eeprom_clk_93c76(i64 %36, i32 %37)
br label %39
39: ; preds = %31
%40 = load i32, i32* %8
%41 = add nsw i32 %40, -1
store i32 %41, i32* %8
br label %16
42: ; preds = %16
%43 = load i32, i32* %7
ret i32 %43
}

LLVM IR (-O2):
define i32 @addi_eeprom_cmd_93c76(i64 %0, i32 %1, i8 zeroext %2) {
%4 = tail call i32 @outl(i32 2, i64 %0)
%5 = tail call i32 @udelay(i32 100)
%6 = icmp eq i8 %2, 0
br i1 %6, label %23, label %7
7: ; preds = %3
%8 = zext i8 %2 to i32
br label %9
9: ; preds = %7, %9
%10 = phi i32 [ %12, %9 ], [ %8, %7 ]
%11 = phi i32 [ %18, %9 ], [ 2, %7 ]
%12 = add nsw i32 %10, -1
%13 = shl nuw i32 1, %12
%14 = and i32 %13, %1
%15 = icmp eq i32 %14, 0
%16 = and i32 %11, -5
%17 = select i1 %15, i32 0, i32 4
%18 = or i32 %17, %16
%19 = tail call i32 @outl(i32 %18, i64 %0)
%20 = tail call i32 @udelay(i32 100)
%21 = tail call i32 @addi_eeprom_clk_93c76(i64 %0, i32 %18)
%22 = icmp ugt i32 %10, 1
br i1 %22, label %9, label %23
23: ; preds = %9, %3
%24 = phi i32 [ 2, %3 ], [ %18, %9 ]
ret i32 %24
}