#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 int mv_reg_read(int);
int /*<<< orphan*/ mv_reg_write(int, unsigned int);
unsigned int mvEthRxCoalSet(unsigned int uSec) {
  unsigned int port = 0;
  unsigned int Tclk = 166000000;
  unsigned int coal = ((uSec * (Tclk / 1000000)) / 64);
  unsigned int portSdmaCfgReg;
  portSdmaCfgReg = mv_reg_read(((((port) == 0) ? 0x72000 : 0x82000) + 0x41c));
  portSdmaCfgReg &= ~(0x3fff << 7);
  portSdmaCfgReg |= ((((coal) << 7) & (0x3fff << 7)));
  mv_reg_write(((((port) == 0) ? 0x72000 : 0x82000) + 0x41c), portSdmaCfgReg);
  return coal;
}


x86 assembly (clang, -O0):
<mvEthRxCoalSet>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0x9e4f580,-0xc(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0xc(%rbp),%eax
mov    $0xf4240,%ecx
xor    %edx,%edx
div    %ecx
mov    %eax,%ecx
mov    -0x18(%rbp),%eax
imul   %ecx,%eax
shr    $0x6,%eax
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%ecx
mov    $0x82000,%edi
mov    $0x72000,%eax
cmp    $0x0,%ecx
cmove  %eax,%edi
add    $0x41c,%edi
call   1040 <mv_reg_read@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
and    $0xffe0007f,%eax
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%eax
shl    $0x7,%eax
and    $0x1fff80,%eax
or     -0x14(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%ecx
mov    $0x82000,%edi
mov    $0x72000,%eax
cmp    $0x0,%ecx
cmove  %eax,%edi
add    $0x41c,%edi
mov    -0x14(%rbp),%esi
call   1030 <mv_reg_write@plt>
mov    -0x10(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mvEthRxCoalSet>:
push   %rbp
push   %rbx
push   %rax
imul   $0xa6,%edi,%ebx
mov    %ebx,%ebp
shr    $0x6,%ebp
mov    $0x7241c,%edi
call   1040 <mv_reg_read@plt>
and    $0xffe0007f,%eax
and    $0xfffc0,%ebx
lea    (%rax,%rbx,2),%esi
mov    $0x7241c,%edi
call   1030 <mv_reg_write@plt>
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define i32 @mvEthRxCoalSet(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 %0, i32* %2
store i32 0, i32* %3
store i32 166000000, i32* %4
%7 = load i32, i32* %2
%8 = load i32, i32* %4
%9 = udiv i32 %8, 1000000
%10 = mul i32 %7, %9
%11 = udiv i32 %10, 64
store i32 %11, i32* %5
%12 = load i32, i32* %3
%13 = icmp eq i32 %12, 0
%14 = zext i1 %13 to i64
%15 = select i1 %13, i32 466944, i32 532480
%16 = add nsw i32 %15, 1052
%17 = call i32 @mv_reg_read(i32 %16)
store i32 %17, i32* %6
%18 = load i32, i32* %6
%19 = and i32 %18, -2097025
store i32 %19, i32* %6
%20 = load i32, i32* %5
%21 = shl i32 %20, 7
%22 = and i32 %21, 2097024
%23 = load i32, i32* %6
%24 = or i32 %23, %22
store i32 %24, i32* %6
%25 = load i32, i32* %3
%26 = icmp eq i32 %25, 0
%27 = zext i1 %26 to i64
%28 = select i1 %26, i32 466944, i32 532480
%29 = add nsw i32 %28, 1052
%30 = load i32, i32* %6
%31 = call i32 @mv_reg_write(i32 %29, i32 %30)
%32 = load i32, i32* %5
ret i32 %32
}

LLVM IR (-O2):
define i32 @mvEthRxCoalSet(i32 %0) {
%2 = mul i32 %0, 166
%3 = lshr i32 %2, 6
%4 = tail call i32 @mv_reg_read(i32 467996)
%5 = and i32 %4, -2097025
%6 = shl i32 %3, 7
%7 = and i32 %6, 2097024
%8 = or i32 %5, %7
%9 = tail call i32 @mv_reg_write(i32 467996, i32 %8)
ret i32 %3
}