#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 */
typedef int uint32_t;

/* Variables and functions */
int /*<<< orphan*/ I2CMasterEnable(int);
void I2CMasterInitExpClk(uint32_t ui32Base, uint32_t ui32I2CClk, bool bFast) {
  uint32_t ui32SCLFreq;
  uint32_t ui32TPR;
  ;
  I2CMasterEnable(ui32Base);
  if (bFast == true) {
    ui32SCLFreq = 400000;
  } else {
    ui32SCLFreq = 100000;
  }
  ui32TPR =
      ((ui32I2CClk + (2 * 10 * ui32SCLFreq) - 1) / (2 * 10 * ui32SCLFreq)) - 1;
  (*((volatile uint32_t *)(ui32Base + 0x0000000C))) = ui32TPR;
  if ((*((volatile uint32_t *)(ui32Base + 0x00000FC0))) & 0x00000001) {
    ui32TPR = ((ui32I2CClk + (2 * 3 * 3400000) - 1) / (2 * 3 * 3400000)) - 1;
    (*((volatile uint32_t *)(ui32Base + 0x0000000C))) = 0x00000080 | ui32TPR;
  }
}


x86 assembly (clang, -O0):
<I2CMasterInitExpClk>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    -0x4(%rbp),%edi
call   1030 <I2CMasterEnable@plt>
cmpl   $0x1,-0xc(%rbp)
jne    113f <I2CMasterInitExpClk+0x2f>
movl   $0x61a80,-0x10(%rbp)
jmp    1146 <I2CMasterInitExpClk+0x36>
movl   $0x186a0,-0x10(%rbp)
mov    -0x8(%rbp),%eax
imul   $0x14,-0x10(%rbp),%ecx
add    %ecx,%eax
sub    $0x1,%eax
imul   $0x14,-0x10(%rbp),%ecx
cltd
idiv   %ecx
sub    $0x1,%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%ecx
mov    -0x4(%rbp),%eax
add    $0xc,%eax
cltq
mov    %ecx,(%rax)
mov    -0x4(%rbp),%eax
add    $0xfc0,%eax
cltq
mov    (%rax),%eax
and    $0x1,%eax
cmp    $0x0,%eax
je     11b0 <I2CMasterInitExpClk+0xa0>
mov    -0x8(%rbp),%eax
add    $0x1374780,%eax
sub    $0x1,%eax
mov    $0x1374780,%ecx
cltd
idiv   %ecx
sub    $0x1,%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%ecx
or     $0x80,%ecx
mov    -0x4(%rbp),%eax
add    $0xc,%eax
cltq
mov    %ecx,(%rax)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<I2CMasterInitExpClk>:
push   %rbp
push   %r14
push   %rbx
mov    %edx,%r14d
mov    %esi,%ebx
mov    %edi,%ebp
call   1030 <I2CMasterEnable@plt>
cmp    $0x1,%r14d
mov    $0x7a1200,%eax
mov    $0x1e8480,%ecx
cmove  %eax,%ecx
lea    (%rbx,%rcx,1),%eax
add    $0xffffffff,%eax
cltd
idiv   %ecx
add    $0xffffffff,%eax
movslq %ebp,%rcx
mov    %eax,0xc(%rcx)
testl  $0x1,0xfc0(%rcx)
je     1177 <I2CMasterInitExpClk+0x67>
add    $0x137477f,%ebx
movslq %ebx,%rax
imul   $0x6944d07d,%rax,%rax
mov    %rax,%rdx
sar    $0x37,%rdx
shr    $0x3f,%rax
add    %edx,%eax
add    $0xffffffff,%eax
or     $0x80,%eax
mov    %eax,0xc(%rcx)
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define void @I2CMasterInitExpClk(i32 %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%9 = load i32, i32* %4
%10 = call i32 @I2CMasterEnable(i32 %9)
%11 = load i32, i32* %6
%12 = icmp eq i32 %11, 1
br i1 %12, label %13, label %14
13: ; preds = %3
store i32 400000, i32* %7
br label %15
14: ; preds = %3
store i32 100000, i32* %7
br label %15
15: ; preds = %14, %13
%16 = load i32, i32* %5
%17 = load i32, i32* %7
%18 = mul nsw i32 20, %17
%19 = add nsw i32 %16, %18
%20 = sub nsw i32 %19, 1
%21 = load i32, i32* %7
%22 = mul nsw i32 20, %21
%23 = sdiv i32 %20, %22
%24 = sub nsw i32 %23, 1
store i32 %24, i32* %8
%25 = load i32, i32* %8
%26 = load i32, i32* %4
%27 = add nsw i32 %26, 12
%28 = sext i32 %27 to i64
%29 = inttoptr i64 %28 to i32*
store volatile i32 %25, i32* %29
%30 = load i32, i32* %4
%31 = add nsw i32 %30, 4032
%32 = sext i32 %31 to i64
%33 = inttoptr i64 %32 to i32*
%34 = load volatile i32, i32* %33
%35 = and i32 %34, 1
%36 = icmp ne i32 %35, 0
br i1 %36, label %37, label %49
37: ; preds = %15
%38 = load i32, i32* %5
%39 = add nsw i32 %38, 20400000
%40 = sub nsw i32 %39, 1
%41 = sdiv i32 %40, 20400000
%42 = sub nsw i32 %41, 1
store i32 %42, i32* %8
%43 = load i32, i32* %8
%44 = or i32 128, %43
%45 = load i32, i32* %4
%46 = add nsw i32 %45, 12
%47 = sext i32 %46 to i64
%48 = inttoptr i64 %47 to i32*
store volatile i32 %44, i32* %48
br label %49
49: ; preds = %37, %15
ret void
}

LLVM IR (-O2):
define void @I2CMasterInitExpClk(i32 %0, i32 %1, i32 %2) {
%4 = tail call i32 @I2CMasterEnable(i32 %0)
%5 = icmp eq i32 %2, 1
%6 = select i1 %5, i32 8000000, i32 2000000
%7 = add i32 %1, -1
%8 = add i32 %7, %6
%9 = sdiv i32 %8, %6
%10 = add nsw i32 %9, -1
%11 = add nsw i32 %0, 12
%12 = sext i32 %11 to i64
%13 = inttoptr i64 %12 to i32*
store volatile i32 %10, i32* %13
%14 = add nsw i32 %0, 4032
%15 = sext i32 %14 to i64
%16 = inttoptr i64 %15 to i32*
%17 = load volatile i32, i32* %16
%18 = and i32 %17, 1
%19 = icmp eq i32 %18, 0
br i1 %19, label %25, label %20
20: ; preds = %3
%21 = add nsw i32 %1, 20399999
%22 = sdiv i32 %21, 20400000
%23 = add nsw i32 %22, -1
%24 = or i32 %23, 128
store volatile i32 %24, i32* %13
br label %25
25: ; preds = %20, %3
ret void
}