#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 == 1) {
    ui32SCLFreq = 400000;
  } else {
    ui32SCLFreq = 100000;
  }
  ui32TPR =
      ((ui32I2CClk + (2 * 10 * ui32SCLFreq) - 1) / (2 * 10 * ui32SCLFreq)) - 1;
  (*((volatile unsigned long *)(ui32Base + 0x0000000C))) = ui32TPR;
  if ((*((volatile unsigned long *)(ui32Base + 0x00000FC0))) & 0x00000001) {
    ui32TPR = ((ui32I2CClk + (2 * 3 * 3400000) - 1) / (2 * 3 * 3400000)) - 1;
    (*((volatile unsigned long *)(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)
movslq -0x14(%rbp),%rcx
mov    -0x4(%rbp),%eax
add    $0xc,%eax
cltq
mov    %rcx,(%rax)
mov    -0x4(%rbp),%eax
add    $0xfc0,%eax
cltq
mov    (%rax),%rax
and    $0x1,%rax
cmp    $0x0,%rax
je     11b8 <I2CMasterInitExpClk+0xa8>
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),%eax
or     $0x80,%eax
movslq %eax,%rcx
mov    -0x4(%rbp),%eax
add    $0xc,%eax
cltq
mov    %rcx,(%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 %eax,%rcx
movslq %ebp,%rax
mov    %rcx,0xc(%rax)
testq  $0x1,0xfc0(%rax)
je     1181 <I2CMasterInitExpClk+0x71>
add    $0x137477f,%ebx
movslq %ebx,%rcx
imul   $0x6944d07d,%rcx,%rcx
mov    %rcx,%rdx
sar    $0x37,%rdx
shr    $0x3f,%rcx
add    %edx,%ecx
add    $0xffffffff,%ecx
or     $0x80,%ecx
movslq %ecx,%rcx
mov    %rcx,0xc(%rax)
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 = sext i32 %25 to i64
%27 = load i32, i32* %4
%28 = add nsw i32 %27, 12
%29 = sext i32 %28 to i64
%30 = inttoptr i64 %29 to i64*
store volatile i64 %26, i64* %30
%31 = load i32, i32* %4
%32 = add nsw i32 %31, 4032
%33 = sext i32 %32 to i64
%34 = inttoptr i64 %33 to i64*
%35 = load volatile i64, i64* %34
%36 = and i64 %35, 1
%37 = icmp ne i64 %36, 0
br i1 %37, label %38, label %51
38: ; preds = %15
%39 = load i32, i32* %5
%40 = add nsw i32 %39, 20400000
%41 = sub nsw i32 %40, 1
%42 = sdiv i32 %41, 20400000
%43 = sub nsw i32 %42, 1
store i32 %43, i32* %8
%44 = load i32, i32* %8
%45 = or i32 128, %44
%46 = sext i32 %45 to i64
%47 = load i32, i32* %4
%48 = add nsw i32 %47, 12
%49 = sext i32 %48 to i64
%50 = inttoptr i64 %49 to i64*
store volatile i64 %46, i64* %50
br label %51
51: ; preds = %38, %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 = sext i32 %10 to i64
%12 = add nsw i32 %0, 12
%13 = sext i32 %12 to i64
%14 = inttoptr i64 %13 to i64*
store volatile i64 %11, i64* %14
%15 = add nsw i32 %0, 4032
%16 = sext i32 %15 to i64
%17 = inttoptr i64 %16 to i64*
%18 = load volatile i64, i64* %17
%19 = and i64 %18, 1
%20 = icmp eq i64 %19, 0
br i1 %20, label %27, label %21
21: ; preds = %3
%22 = add nsw i32 %1, 20399999
%23 = sdiv i32 %22, 20400000
%24 = add nsw i32 %23, -1
%25 = or i32 %24, 128
%26 = sext i32 %25 to i64
store volatile i64 %26, i64* %14
br label %27
27: ; preds = %21, %3
ret void
}