#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 scalar_t__ k_val;

/* Variables and functions */
int /*<<< orphan*/ fc8300_read(void *, unsigned short, int, unsigned char *);
int /*<<< orphan*/ fc8300_write(void *, unsigned short, int, int);
int /*<<< orphan*/ msWait(int);
int /*<<< orphan*/ vco_cal(void *, unsigned short, unsigned char);
int fc8300_tuner_set_pll(void *handle, unsigned short devid, unsigned int freq,
                         unsigned int offset) {
  unsigned char data_0x51, data_0x57, lo_select;
  unsigned int f_diff, f_diff_shifted, n_val, k_val, f_vco;
  unsigned int f_vco_max = 6000000;
  unsigned char lo_divide_ratio[8] = {8, 12, 16, 24, 32, 48, 64, 96};
  unsigned char pre_shift_bits = 4;
  unsigned char lock_detect = 0;
  unsigned char lock_bank = 0;
  unsigned char lock_condition = 0x11;
  unsigned char i, j;
  for (lo_select = 0; lo_select < 7; lo_select++)
    if (f_vco_max < freq * lo_divide_ratio[lo_select + 1])
      break;
  f_vco = freq * lo_divide_ratio[lo_select];
  n_val = f_vco / 26000;
  f_diff = f_vco - 26000 * n_val;
  f_diff_shifted = f_diff << (20 - pre_shift_bits);
  k_val = f_diff_shifted / (26000 >> pre_shift_bits);
  k_val = k_val | 1;
  data_0x57 = ((n_val >> 3) & 0x20);
  data_0x57 += (k_val >> 16);
  data_0x51 = 0x00;
  data_0x51 += (lo_select * 2) + 1;
  for (j = 0; j < 4; j++) {
    fc8300_write(handle, devid, 0x75, 0x31);
    fc8300_write(handle, devid, 0x77, 0x00);
    fc8300_write(handle, devid, 0x51, data_0x51);
    fc8300_write(handle, devid, 0x57, data_0x57);
    fc8300_write(handle, devid, 0x5a, (unsigned char)n_val);
    fc8300_write(handle, devid, 0x50, 0xe3);
    fc8300_write(handle, devid, 0x50, 0xff);
    fc8300_write(handle, devid, 0x58, (unsigned char)((k_val >> 8) & 0xff));
    fc8300_write(handle, devid, 0x59, (unsigned char)((k_val)&0xff));
    msWait(2);
    for (i = 1; i < 5; i++) {
      fc8300_read(handle, devid, 0x64, &lock_detect);
      fc8300_read(handle, devid, 0x65, &lock_bank);
      if (((lock_detect & lock_condition) == lock_condition) &&
          (lock_bank > 1)) {
        fc8300_read(handle, devid, 0x76, &lock_bank);
        if (lock_bank < 62) {
          if (((lo_select % 2) != 0) || (f_vco > 6200000)) {
            fc8300_write(handle, devid, 0x77, 0x02);
            fc8300_write(handle, devid, 0x50, 0xe3);
            fc8300_write(handle, devid, 0x50, 0xff);
          }
        }
        break;
      }
    }
    if ((lock_detect & lock_condition) != lock_condition) {
      fc8300_read(handle, devid, 0x74, &lock_detect);
      vco_cal(handle, devid, lock_detect);
    } else {
      break;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %si,%ax
mov    %rdi,-0x8(%rbp)
mov    %ax,-0xa(%rbp)
mov    %edx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
movl   $0x5b8d80,-0x30(%rbp)
mov    0xe99(%rip),%rax
mov    %rax,-0x38(%rbp)
movb   $0x4,-0x39(%rbp)
movb   $0x0,-0x3a(%rbp)
movb   $0x0,-0x3b(%rbp)
movb   $0x11,-0x3c(%rbp)
movb   $0x0,-0x17(%rbp)
movzbl -0x17(%rbp),%eax
cmp    $0x7,%eax
jge    11c3 <fc8300_tuner_set_pll+0x83>
mov    -0x30(%rbp),%eax
mov    -0x10(%rbp),%ecx
movzbl -0x17(%rbp),%edx
add    $0x1,%edx
movslq %edx,%rdx
movzbl -0x38(%rbp,%rdx,1),%edx
imul   %edx,%ecx
cmp    %ecx,%eax
jae    11b1 <fc8300_tuner_set_pll+0x71>
jmp    11c3 <fc8300_tuner_set_pll+0x83>
jmp    11b6 <fc8300_tuner_set_pll+0x76>
mov    -0x17(%rbp),%al
add    $0x1,%al
mov    %al,-0x17(%rbp)
jmp    117f <fc8300_tuner_set_pll+0x3f>
mov    -0x10(%rbp),%eax
movzbl -0x17(%rbp),%ecx
movzbl -0x38(%rbp,%rcx,1),%ecx
imul   %ecx,%eax
mov    %eax,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
mov    $0x6590,%ecx
xor    %edx,%edx
div    %ecx
mov    %eax,-0x24(%rbp)
mov    -0x2c(%rbp),%eax
imul   $0x6590,-0x24(%rbp),%ecx
sub    %ecx,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
movzbl -0x39(%rbp),%edx
mov    $0x14,%ecx
sub    %edx,%ecx
shl    %cl,%eax
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%eax
movzbl -0x39(%rbp),%ecx
mov    $0x6590,%edx
sar    %cl,%edx
mov    %edx,%ecx
xor    %edx,%edx
div    %ecx
mov    %eax,-0x28(%rbp)
mov    -0x28(%rbp),%eax
or     $0x1,%eax
mov    %eax,-0x28(%rbp)
mov    -0x24(%rbp),%eax
shr    $0x3,%eax
and    $0x20,%eax
mov    %al,-0x16(%rbp)
mov    -0x28(%rbp),%ecx
shr    $0x10,%ecx
movzbl -0x16(%rbp),%eax
add    %ecx,%eax
mov    %al,-0x16(%rbp)
movb   $0x0,-0x15(%rbp)
movzbl -0x17(%rbp),%ecx
shl    $0x1,%ecx
add    $0x1,%ecx
movzbl -0x15(%rbp),%eax
add    %ecx,%eax
mov    %al,-0x15(%rbp)
movb   $0x0,-0x3e(%rbp)
movzbl -0x3e(%rbp),%eax
cmp    $0x4,%eax
jge    14c0 <fc8300_tuner_set_pll+0x380>
mov    -0x8(%rbp),%rdi
mov    $0x75,%edx
mov    $0x31,%ecx
movzwl -0xa(%rbp),%esi
call   1060 <fc8300_write@plt>
mov    -0x8(%rbp),%rdi
mov    $0x77,%edx
xor    %ecx,%ecx
movzwl -0xa(%rbp),%esi
call   1060 <fc8300_write@plt>
mov    -0x8(%rbp),%rdi
mov    -0xa(%rbp),%ax
movzbl -0x15(%rbp),%ecx
mov    $0x51,%edx
movzwl %ax,%esi
call   1060 <fc8300_write@plt>
mov    -0x8(%rbp),%rdi
mov    -0xa(%rbp),%ax
movzbl -0x16(%rbp),%ecx
mov    $0x57,%edx
movzwl %ax,%esi
call   1060 <fc8300_write@plt>
mov    -0x8(%rbp),%rdi
mov    -0xa(%rbp),%ax
mov    -0x24(%rbp),%ecx
movzbl %cl,%ecx
mov    $0x5a,%edx
movzwl %ax,%esi
call   1060 <fc8300_write@plt>
mov    -0x8(%rbp),%rdi
mov    $0x50,%edx
mov    $0xe3,%ecx
movzwl -0xa(%rbp),%esi
call   1060 <fc8300_write@plt>
mov    -0x8(%rbp),%rdi
mov    $0x50,%edx
mov    $0xff,%ecx
movzwl -0xa(%rbp),%esi
call   1060 <fc8300_write@plt>
mov    -0x8(%rbp),%rdi
mov    -0xa(%rbp),%ax
mov    -0x28(%rbp),%ecx
shr    $0x8,%ecx
and    $0xff,%ecx
movzbl %cl,%ecx
mov    $0x58,%edx
movzwl %ax,%esi
call   1060 <fc8300_write@plt>
mov    -0x8(%rbp),%rdi
mov    -0xa(%rbp),%ax
mov    -0x28(%rbp),%ecx
and    $0xff,%ecx
movzbl %cl,%ecx
mov    $0x59,%edx
movzwl %ax,%esi
call   1060 <fc8300_write@plt>
mov    $0x2,%edi
call   1050 <msWait@plt>
movb   $0x1,-0x3d(%rbp)
movzbl -0x3d(%rbp),%eax
cmp    $0x5,%eax
jge    1464 <fc8300_tuner_set_pll+0x324>
mov    -0x8(%rbp),%rdi
mov    $0x64,%edx
lea    -0x3a(%rbp),%rcx
movzwl -0xa(%rbp),%esi
call   1040 <fc8300_read@plt>
mov    -0x8(%rbp),%rdi
mov    $0x65,%edx
lea    -0x3b(%rbp),%rcx
movzwl -0xa(%rbp),%esi
call   1040 <fc8300_read@plt>
movzbl -0x3a(%rbp),%eax
movzbl -0x3c(%rbp),%ecx
and    %ecx,%eax
movzbl -0x3c(%rbp),%ecx
cmp    %ecx,%eax
jne    1452 <fc8300_tuner_set_pll+0x312>
movzbl -0x3b(%rbp),%eax
cmp    $0x1,%eax
jle    1452 <fc8300_tuner_set_pll+0x312>
mov    -0x8(%rbp),%rdi
mov    $0x76,%edx
lea    -0x3b(%rbp),%rcx
movzwl -0xa(%rbp),%esi
call   1040 <fc8300_read@plt>
movzbl -0x3b(%rbp),%eax
cmp    $0x3e,%eax
jge    144d <fc8300_tuner_set_pll+0x30d>
movzbl -0x17(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    1403 <fc8300_tuner_set_pll+0x2c3>
cmpl   $0x5e9ac0,-0x2c(%rbp)
jbe    1448 <fc8300_tuner_set_pll+0x308>
mov    -0x8(%rbp),%rdi
mov    $0x77,%edx
mov    $0x2,%ecx
movzwl -0xa(%rbp),%esi
call   1060 <fc8300_write@plt>
mov    -0x8(%rbp),%rdi
mov    $0x50,%edx
mov    $0xe3,%ecx
movzwl -0xa(%rbp),%esi
call   1060 <fc8300_write@plt>
mov    -0x8(%rbp),%rdi
mov    $0x50,%edx
mov    $0xff,%ecx
movzwl -0xa(%rbp),%esi
call   1060 <fc8300_write@plt>
jmp    144d <fc8300_tuner_set_pll+0x30d>
jmp    1464 <fc8300_tuner_set_pll+0x324>
jmp    1457 <fc8300_tuner_set_pll+0x317>
mov    -0x3d(%rbp),%al
add    $0x1,%al
mov    %al,-0x3d(%rbp)
jmp    1362 <fc8300_tuner_set_pll+0x222>
movzbl -0x3a(%rbp),%eax
movzbl -0x3c(%rbp),%ecx
and    %ecx,%eax
movzbl -0x3c(%rbp),%ecx
cmp    %ecx,%eax
je     14a9 <fc8300_tuner_set_pll+0x369>
mov    -0x8(%rbp),%rdi
mov    $0x74,%edx
lea    -0x3a(%rbp),%rcx
movzwl -0xa(%rbp),%esi
call   1040 <fc8300_read@plt>
mov    -0x8(%rbp),%rdi
mov    -0xa(%rbp),%ax
movzwl %ax,%esi
movzbl -0x3a(%rbp),%edx
call   1030 <vco_cal@plt>
jmp    14ae <fc8300_tuner_set_pll+0x36e>
jmp    14c0 <fc8300_tuner_set_pll+0x380>
jmp    14b3 <fc8300_tuner_set_pll+0x373>
mov    -0x3e(%rbp),%al
add    $0x1,%al
mov    %al,-0x3e(%rbp)
jmp    125c <fc8300_tuner_set_pll+0x11c>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rdi,%rbx
movb   $0x0,0x5(%rsp)
movb   $0x0,0x6(%rsp)
lea    0x0(,%rdx,4),%eax
lea    (%rax,%rax,2),%eax
cmp    $0x5b8d80,%eax
jbe    1173 <fc8300_tuner_set_pll+0x33>
mov    $0x1,%r8b
xor    %ecx,%ecx
jmp    11e5 <fc8300_tuner_set_pll+0xa5>
mov    %edx,%edi
shl    $0x4,%edi
cmp    $0x5b8d80,%edi
jbe    1187 <fc8300_tuner_set_pll+0x47>
mov    $0x1,%cl
xor    %r8d,%r8d
jmp    11e5 <fc8300_tuner_set_pll+0xa5>
lea    0x0(,%rdx,8),%eax
lea    (%rax,%rax,2),%ebp
mov    $0x1,%r8b
mov    $0x2,%cl
cmp    $0x5b8d80,%ebp
ja     11e5 <fc8300_tuner_set_pll+0xa5>
mov    %edx,%ebp
shl    $0x5,%ebp
cmp    $0x5b8d80,%ebp
jbe    11b2 <fc8300_tuner_set_pll+0x72>
mov    $0x3,%cl
xor    %r8d,%r8d
jmp    11e5 <fc8300_tuner_set_pll+0xa5>
lea    (%rdi,%rdi,2),%edi
mov    $0x4,%cl
cmp    $0x5b8d80,%edi
ja     11e5 <fc8300_tuner_set_pll+0xa5>
mov    %edx,%eax
shl    $0x6,%eax
cmp    $0x5b8d80,%eax
jbe    11d2 <fc8300_tuner_set_pll+0x92>
mov    $0x5,%cl
xor    %r8d,%r8d
jmp    11e5 <fc8300_tuner_set_pll+0xa5>
lea    0x0(%rbp,%rbp,2),%eax
cmp    $0x5b8d81,%eax
setae  %r8b
mov    %r8d,%ecx
xor    $0x7,%cl
movzbl %cl,%edi
lea    0xe11(%rip),%rcx
movzbl (%rdi,%rcx,1),%r10d
imul   %edx,%r10d
mov    $0xa151c331,%r9d
mov    %r10,%rcx
imul   %r9,%rcx
mov    %rcx,%rbp
shr    $0x2e,%rbp
imul   $0xffff9a70,%ebp,%edx
add    %r10d,%edx
shl    $0x10,%edx
imul   %r9,%rdx
mov    %rdx,%rax
shr    $0x2a,%rax
shr    $0x31,%rcx
and    $0x20,%ecx
mov    %rdx,%r14
shr    $0x3a,%r14
add    %ecx,%r14d
add    %dil,%dil
or     $0x1,%dil
movzbl %dil,%ecx
mov    %ecx,0x14(%rsp)
movzbl %bpl,%ecx
mov    %ecx,0x10(%rsp)
shr    $0x32,%rdx
movzbl %dl,%ecx
mov    %ecx,0xc(%rsp)
or     $0x1,%eax
movzbl %al,%eax
mov    %eax,0x8(%rsp)
cmp    $0x5e9ac1,%r10d
setb   %al
and    %r8b,%al
mov    %al,0x7(%rsp)
mov    $0x4,%bpl
movzwl %si,%r15d
lea    0x5(%rsp),%r12
lea    0x6(%rsp),%r13
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %rbx,%rdi
mov    %r15d,%esi
mov    $0x75,%edx
mov    $0x31,%ecx
call   1060 <fc8300_write@plt>
mov    %rbx,%rdi
mov    %r15d,%esi
mov    $0x77,%edx
xor    %ecx,%ecx
call   1060 <fc8300_write@plt>
mov    %rbx,%rdi
mov    %r15d,%esi
mov    $0x51,%edx
mov    0x14(%rsp),%ecx
call   1060 <fc8300_write@plt>
mov    %rbx,%rdi
mov    %r15d,%esi
mov    $0x57,%edx
mov    %r14d,%ecx
call   1060 <fc8300_write@plt>
mov    %rbx,%rdi
mov    %r15d,%esi
mov    $0x5a,%edx
mov    0x10(%rsp),%ecx
call   1060 <fc8300_write@plt>
mov    %rbx,%rdi
mov    %r15d,%esi
mov    $0x50,%edx
mov    $0xe3,%ecx
call   1060 <fc8300_write@plt>
mov    %rbx,%rdi
mov    %r15d,%esi
mov    $0x50,%edx
mov    $0xff,%ecx
call   1060 <fc8300_write@plt>
mov    %rbx,%rdi
mov    %r15d,%esi
mov    $0x58,%edx
mov    0xc(%rsp),%ecx
call   1060 <fc8300_write@plt>
mov    %rbx,%rdi
mov    %r15d,%esi
mov    $0x59,%edx
mov    0x8(%rsp),%ecx
call   1060 <fc8300_write@plt>
mov    $0x2,%edi
call   1050 <msWait@plt>
mov    %rbx,%rdi
mov    %r15d,%esi
mov    $0x64,%edx
mov    %r12,%rcx
call   1040 <fc8300_read@plt>
mov    %rbx,%rdi
mov    %r15d,%esi
mov    $0x65,%edx
mov    %r13,%rcx
call   1040 <fc8300_read@plt>
movzbl 0x5(%rsp),%eax
not    %al
test   $0x11,%al
jne    138a <fc8300_tuner_set_pll+0x24a>
cmpb   $0x1,0x6(%rsp)
ja     1440 <fc8300_tuner_set_pll+0x300>
mov    %rbx,%rdi
mov    %r15d,%esi
mov    $0x64,%edx
mov    %r12,%rcx
call   1040 <fc8300_read@plt>
mov    %rbx,%rdi
mov    %r15d,%esi
mov    $0x65,%edx
mov    %r13,%rcx
call   1040 <fc8300_read@plt>
movzbl 0x5(%rsp),%eax
not    %al
test   $0x11,%al
jne    13c2 <fc8300_tuner_set_pll+0x282>
cmpb   $0x1,0x6(%rsp)
ja     1440 <fc8300_tuner_set_pll+0x300>
mov    %rbx,%rdi
mov    %r15d,%esi
mov    $0x64,%edx
mov    %r12,%rcx
call   1040 <fc8300_read@plt>
mov    %rbx,%rdi
mov    %r15d,%esi
mov    $0x65,%edx
mov    %r13,%rcx
call   1040 <fc8300_read@plt>
movzbl 0x5(%rsp),%eax
not    %al
test   $0x11,%al
jne    13fa <fc8300_tuner_set_pll+0x2ba>
cmpb   $0x1,0x6(%rsp)
ja     1440 <fc8300_tuner_set_pll+0x300>
mov    %rbx,%rdi
mov    %r15d,%esi
mov    $0x64,%edx
mov    %r12,%rcx
call   1040 <fc8300_read@plt>
mov    %rbx,%rdi
mov    %r15d,%esi
mov    $0x65,%edx
mov    %r13,%rcx
call   1040 <fc8300_read@plt>
movzbl 0x5(%rsp),%eax
not    %al
test   $0x11,%al
jne    14a0 <fc8300_tuner_set_pll+0x360>
cmpb   $0x2,0x6(%rsp)
jb     14a0 <fc8300_tuner_set_pll+0x360>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %rbx,%rdi
mov    %r15d,%esi
mov    $0x76,%edx
mov    %r13,%rcx
call   1040 <fc8300_read@plt>
cmpb   $0x3e,0x6(%rsp)
setae  %al
or     0x7(%rsp),%al
jne    14a0 <fc8300_tuner_set_pll+0x360>
mov    %rbx,%rdi
mov    %r15d,%esi
mov    $0x77,%edx
mov    $0x2,%ecx
call   1060 <fc8300_write@plt>
mov    %rbx,%rdi
mov    %r15d,%esi
mov    $0x50,%edx
mov    $0xe3,%ecx
call   1060 <fc8300_write@plt>
mov    %rbx,%rdi
mov    %r15d,%esi
mov    $0x50,%edx
mov    $0xff,%ecx
call   1060 <fc8300_write@plt>
movzbl 0x5(%rsp),%eax
not    %al
test   $0x11,%al
je     14d8 <fc8300_tuner_set_pll+0x398>
mov    %rbx,%rdi
mov    %r15d,%esi
mov    $0x74,%edx
mov    %r12,%rcx
call   1040 <fc8300_read@plt>
movzbl 0x5(%rsp),%edx
mov    %rbx,%rdi
mov    %r15d,%esi
call   1030 <vco_cal@plt>
add    $0xff,%bpl
jne    1290 <fc8300_tuner_set_pll+0x150>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@__const.fc8300_tuner_set_pll.lo_divide_ratio = [8 x i8] c"\08\0C\10\18 0@`"
define i32 @fc8300_tuner_set_pll(i8* %0, i16 zeroext %1, i32 %2, i32 %3) {
%5 = alloca i8*
%6 = alloca i16
%7 = alloca i32
%8 = alloca i32
%9 = alloca i8
%10 = alloca i8
%11 = alloca i8
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32
%18 = alloca [8 x i8]
%19 = alloca i8
%20 = alloca i8
%21 = alloca i8
%22 = alloca i8
%23 = alloca i8
%24 = alloca i8
store i8* %0, i8** %5
store i16 %1, i16* %6
store i32 %2, i32* %7
store i32 %3, i32* %8
store i32 6000000, i32* %17
%25 = bitcast [8 x i8]* %18 to i8*
store i8 4, i8* %19
store i8 0, i8* %20
store i8 0, i8* %21
store i8 17, i8* %22
store i8 0, i8* %11
br label %26
26: ; preds = %44, %4
%27 = load i8, i8* %11
%28 = zext i8 %27 to i32
%29 = icmp slt i32 %28, 7
br i1 %29, label %30, label %47
30: ; preds = %26
%31 = load i32, i32* %17
%32 = load i32, i32* %7
%33 = load i8, i8* %11
%34 = zext i8 %33 to i32
%35 = add nsw i32 %34, 1
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds [8 x i8], [8 x i8]* %18, i64 0, i64 %36
%38 = load i8, i8* %37
%39 = zext i8 %38 to i32
%40 = mul i32 %32, %39
%41 = icmp ult i32 %31, %40
br i1 %41, label %42, label %43
42: ; preds = %30
br label %47
43: ; preds = %30
br label %44
44: ; preds = %43
%45 = load i8, i8* %11
%46 = add i8 %45, 1
store i8 %46, i8* %11
br label %26
47: ; preds = %42, %26
%48 = load i32, i32* %7
%49 = load i8, i8* %11
%50 = zext i8 %49 to i64
%51 = getelementptr inbounds [8 x i8], [8 x i8]* %18, i64 0, i64 %50
%52 = load i8, i8* %51
%53 = zext i8 %52 to i32
%54 = mul i32 %48, %53
store i32 %54, i32* %16
%55 = load i32, i32* %16
%56 = udiv i32 %55, 26000
store i32 %56, i32* %14
%57 = load i32, i32* %16
%58 = load i32, i32* %14
%59 = mul i32 26000, %58
%60 = sub i32 %57, %59
store i32 %60, i32* %12
%61 = load i32, i32* %12
%62 = load i8, i8* %19
%63 = zext i8 %62 to i32
%64 = sub nsw i32 20, %63
%65 = shl i32 %61, %64
store i32 %65, i32* %13
%66 = load i32, i32* %13
%67 = load i8, i8* %19
%68 = zext i8 %67 to i32
%69 = ashr i32 26000, %68
%70 = udiv i32 %66, %69
store i32 %70, i32* %15
%71 = load i32, i32* %15
%72 = or i32 %71, 1
store i32 %72, i32* %15
%73 = load i32, i32* %14
%74 = lshr i32 %73, 3
%75 = and i32 %74, 32
%76 = trunc i32 %75 to i8
store i8 %76, i8* %10
%77 = load i32, i32* %15
%78 = lshr i32 %77, 16
%79 = load i8, i8* %10
%80 = zext i8 %79 to i32
%81 = add i32 %80, %78
%82 = trunc i32 %81 to i8
store i8 %82, i8* %10
store i8 0, i8* %9
%83 = load i8, i8* %11
%84 = zext i8 %83 to i32
%85 = mul nsw i32 %84, 2
%86 = add nsw i32 %85, 1
%87 = load i8, i8* %9
%88 = zext i8 %87 to i32
%89 = add nsw i32 %88, %86
%90 = trunc i32 %89 to i8
store i8 %90, i8* %9
store i8 0, i8* %24
br label %91
91: ; preds = %213, %47
%92 = load i8, i8* %24
%93 = zext i8 %92 to i32
%94 = icmp slt i32 %93, 4
br i1 %94, label %95, label %216
95: ; preds = %91
%96 = load i8*, i8** %5
%97 = load i16, i16* %6
%98 = call i32 @fc8300_write(i8* %96, i16 zeroext %97, i32 117, i32 49)
%99 = load i8*, i8** %5
%100 = load i16, i16* %6
%101 = call i32 @fc8300_write(i8* %99, i16 zeroext %100, i32 119, i32 0)
%102 = load i8*, i8** %5
%103 = load i16, i16* %6
%104 = load i8, i8* %9
%105 = zext i8 %104 to i32
%106 = call i32 @fc8300_write(i8* %102, i16 zeroext %103, i32 81, i32 %105)
%107 = load i8*, i8** %5
%108 = load i16, i16* %6
%109 = load i8, i8* %10
%110 = zext i8 %109 to i32
%111 = call i32 @fc8300_write(i8* %107, i16 zeroext %108, i32 87, i32 %110)
%112 = load i8*, i8** %5
%113 = load i16, i16* %6
%114 = load i32, i32* %14
%115 = trunc i32 %114 to i8
%116 = zext i8 %115 to i32
%117 = call i32 @fc8300_write(i8* %112, i16 zeroext %113, i32 90, i32 %116)
%118 = load i8*, i8** %5
%119 = load i16, i16* %6
%120 = call i32 @fc8300_write(i8* %118, i16 zeroext %119, i32 80, i32 227)
%121 = load i8*, i8** %5
%122 = load i16, i16* %6
%123 = call i32 @fc8300_write(i8* %121, i16 zeroext %122, i32 80, i32 255)
%124 = load i8*, i8** %5
%125 = load i16, i16* %6
%126 = load i32, i32* %15
%127 = lshr i32 %126, 8
%128 = and i32 %127, 255
%129 = trunc i32 %128 to i8
%130 = zext i8 %129 to i32
%131 = call i32 @fc8300_write(i8* %124, i16 zeroext %125, i32 88, i32 %130)
%132 = load i8*, i8** %5
%133 = load i16, i16* %6
%134 = load i32, i32* %15
%135 = and i32 %134, 255
%136 = trunc i32 %135 to i8
%137 = zext i8 %136 to i32
%138 = call i32 @fc8300_write(i8* %132, i16 zeroext %133, i32 89, i32 %137)
%139 = call i32 @msWait(i32 2)
store i8 1, i8* %23
br label %140
140: ; preds = %191, %95
%141 = load i8, i8* %23
%142 = zext i8 %141 to i32
%143 = icmp slt i32 %142, 5
br i1 %143, label %144, label %194
144: ; preds = %140
%145 = load i8*, i8** %5
%146 = load i16, i16* %6
%147 = call i32 @fc8300_read(i8* %145, i16 zeroext %146, i32 100, i8* %20)
%148 = load i8*, i8** %5
%149 = load i16, i16* %6
%150 = call i32 @fc8300_read(i8* %148, i16 zeroext %149, i32 101, i8* %21)
%151 = load i8, i8* %20
%152 = zext i8 %151 to i32
%153 = load i8, i8* %22
%154 = zext i8 %153 to i32
%155 = and i32 %152, %154
%156 = load i8, i8* %22
%157 = zext i8 %156 to i32
%158 = icmp eq i32 %155, %157
br i1 %158, label %159, label %190
159: ; preds = %144
%160 = load i8, i8* %21
%161 = zext i8 %160 to i32
%162 = icmp sgt i32 %161, 1
br i1 %162, label %163, label %190
163: ; preds = %159
%164 = load i8*, i8** %5
%165 = load i16, i16* %6
%166 = call i32 @fc8300_read(i8* %164, i16 zeroext %165, i32 118, i8* %21)
%167 = load i8, i8* %21
%168 = zext i8 %167 to i32
%169 = icmp slt i32 %168, 62
br i1 %169, label %170, label %189
170: ; preds = %163
%171 = load i8, i8* %11
%172 = zext i8 %171 to i32
%173 = srem i32 %172, 2
%174 = icmp ne i32 %173, 0
br i1 %174, label %178, label %175
175: ; preds = %170
%176 = load i32, i32* %16
%177 = icmp ugt i32 %176, 6200000
br i1 %177, label %178, label %188
178: ; preds = %175, %170
%179 = load i8*, i8** %5
%180 = load i16, i16* %6
%181 = call i32 @fc8300_write(i8* %179, i16 zeroext %180, i32 119, i32 2)
%182 = load i8*, i8** %5
%183 = load i16, i16* %6
%184 = call i32 @fc8300_write(i8* %182, i16 zeroext %183, i32 80, i32 227)
%185 = load i8*, i8** %5
%186 = load i16, i16* %6
%187 = call i32 @fc8300_write(i8* %185, i16 zeroext %186, i32 80, i32 255)
br label %188
188: ; preds = %178, %175
br label %189
189: ; preds = %188, %163
br label %194
190: ; preds = %159, %144
br label %191
191: ; preds = %190
%192 = load i8, i8* %23
%193 = add i8 %192, 1
store i8 %193, i8* %23
br label %140
194: ; preds = %189, %140
%195 = load i8, i8* %20
%196 = zext i8 %195 to i32
%197 = load i8, i8* %22
%198 = zext i8 %197 to i32
%199 = and i32 %196, %198
%200 = load i8, i8* %22
%201 = zext i8 %200 to i32
%202 = icmp ne i32 %199, %201
br i1 %202, label %203, label %211
203: ; preds = %194
%204 = load i8*, i8** %5
%205 = load i16, i16* %6
%206 = call i32 @fc8300_read(i8* %204, i16 zeroext %205, i32 116, i8* %20)
%207 = load i8*, i8** %5
%208 = load i16, i16* %6
%209 = load i8, i8* %20
%210 = call i32 @vco_cal(i8* %207, i16 zeroext %208, i8 zeroext %209)
br label %212
211: ; preds = %194
br label %216
212: ; preds = %203
br label %213
213: ; preds = %212
%214 = load i8, i8* %24
%215 = add i8 %214, 1
store i8 %215, i8* %24
br label %91
216: ; preds = %211, %91
ret i32 0
}

LLVM IR (-O2):
@__const.fc8300_tuner_set_pll.lo_divide_ratio = [8 x i8] c"\08\0C\10\18 0@`"
define i32 @fc8300_tuner_set_pll(i8* %0, i16 zeroext %1, i32 %2, i32 %3) {
%5 = alloca i8
%6 = alloca i8
store i8 0, i8* %5
store i8 0, i8* %6
%7 = mul i32 %2, 12
%8 = icmp ugt i32 %7, 6000000
br i1 %8, label %28, label %9
9: ; preds = %4
%10 = shl i32 %2, 4
%11 = icmp ugt i32 %10, 6000000
br i1 %11, label %28, label %12
12: ; preds = %9
%13 = mul i32 %2, 24
%14 = icmp ugt i32 %13, 6000000
br i1 %14, label %28, label %15
15: ; preds = %12
%16 = shl i32 %2, 5
%17 = icmp ugt i32 %16, 6000000
br i1 %17, label %28, label %18
18: ; preds = %15
%19 = mul i32 %2, 48
%20 = icmp ugt i32 %19, 6000000
br i1 %20, label %28, label %21
21: ; preds = %18
%22 = shl i32 %2, 6
%23 = icmp ugt i32 %22, 6000000
br i1 %23, label %28, label %24
24: ; preds = %21
%25 = mul i32 %2, 96
%26 = icmp ugt i32 %25, 6000000
%27 = select i1 %26, i8 6, i8 7
br label %28
28: ; preds = %24, %21, %18, %15, %12, %9, %4
%29 = phi i8 [ 0, %4 ], [ 1, %9 ], [ 2, %12 ], [ 3, %15 ], [ 4, %18 ], [ 5, %21 ], [ %27, %24 ]
%30 = phi i1 [ true, %4 ], [ false, %9 ], [ true, %12 ], [ false, %15 ], [ true, %18 ], [ false, %21 ], [ %26, %24 ]
%31 = zext i8 %29 to i64
%32 = getelementptr inbounds [8 x i8], [8 x i8]* @__const.fc8300_tuner_set_pll.lo_divide_ratio, i64 0, i64 %31
%33 = load i8, i8* %32
%34 = zext i8 %33 to i32
%35 = mul i32 %34, %2
%36 = udiv i32 %35, 26000
%37 = mul i32 %36, -26000
%38 = add i32 %37, %35
%39 = shl i32 %38, 16
%40 = udiv i32 %39, 1625
%41 = lshr i32 %36, 3
%42 = and i32 %41, 32
%43 = lshr i32 %40, 16
%44 = add nuw nsw i32 %43, %42
%45 = shl nuw nsw i8 %29, 1
%46 = or i8 %45, 1
%47 = zext i8 %46 to i32
%48 = and i32 %36, 255
%49 = lshr i32 %40, 8
%50 = and i32 %49, 255
%51 = and i32 %40, 254
%52 = or i32 %51, 1
%53 = icmp ult i32 %35, 6200001
%54 = select i1 %30, i1 %53, i1 false
br label %55
55: ; preds = %28, %115
%56 = phi i8 [ 0, %28 ], [ %119, %115 ]
%57 = call i32 @fc8300_write(i8* %0, i16 zeroext %1, i32 117, i32 49)
%58 = call i32 @fc8300_write(i8* %0, i16 zeroext %1, i32 119, i32 0)
%59 = call i32 @fc8300_write(i8* %0, i16 zeroext %1, i32 81, i32 %47)
%60 = call i32 @fc8300_write(i8* %0, i16 zeroext %1, i32 87, i32 %44)
%61 = call i32 @fc8300_write(i8* %0, i16 zeroext %1, i32 90, i32 %48)
%62 = call i32 @fc8300_write(i8* %0, i16 zeroext %1, i32 80, i32 227)
%63 = call i32 @fc8300_write(i8* %0, i16 zeroext %1, i32 80, i32 255)
%64 = call i32 @fc8300_write(i8* %0, i16 zeroext %1, i32 88, i32 %50)
%65 = call i32 @fc8300_write(i8* %0, i16 zeroext %1, i32 89, i32 %52)
%66 = call i32 @msWait(i32 2)
%67 = call i32 @fc8300_read(i8* %0, i16 zeroext %1, i32 100, i8* %5)
%68 = call i32 @fc8300_read(i8* %0, i16 zeroext %1, i32 101, i8* %6)
%69 = load i8, i8* %5
%70 = and i8 %69, 17
%71 = icmp eq i8 %70, 17
%72 = load i8, i8* %6
%73 = icmp ugt i8 %72, 1
%74 = select i1 %71, i1 %73, i1 false
br i1 %74, label %102, label %75
75: ; preds = %55
%76 = call i32 @fc8300_read(i8* %0, i16 zeroext %1, i32 100, i8* %5)
%77 = call i32 @fc8300_read(i8* %0, i16 zeroext %1, i32 101, i8* %6)
%78 = load i8, i8* %5
%79 = and i8 %78, 17
%80 = icmp eq i8 %79, 17
%81 = load i8, i8* %6
%82 = icmp ugt i8 %81, 1
%83 = select i1 %80, i1 %82, i1 false
br i1 %83, label %102, label %84
84: ; preds = %75
%85 = call i32 @fc8300_read(i8* %0, i16 zeroext %1, i32 100, i8* %5)
%86 = call i32 @fc8300_read(i8* %0, i16 zeroext %1, i32 101, i8* %6)
%87 = load i8, i8* %5
%88 = and i8 %87, 17
%89 = icmp eq i8 %88, 17
%90 = load i8, i8* %6
%91 = icmp ugt i8 %90, 1
%92 = select i1 %89, i1 %91, i1 false
br i1 %92, label %102, label %93
93: ; preds = %84
%94 = call i32 @fc8300_read(i8* %0, i16 zeroext %1, i32 100, i8* %5)
%95 = call i32 @fc8300_read(i8* %0, i16 zeroext %1, i32 101, i8* %6)
%96 = load i8, i8* %5
%97 = and i8 %96, 17
%98 = icmp eq i8 %97, 17
%99 = load i8, i8* %6
%100 = icmp ugt i8 %99, 1
%101 = select i1 %98, i1 %100, i1 false
br i1 %101, label %102, label %111
102: ; preds = %93, %84, %75, %55
%103 = call i32 @fc8300_read(i8* %0, i16 zeroext %1, i32 118, i8* %6)
%104 = load i8, i8* %6
%105 = icmp ugt i8 %104, 61
%106 = select i1 %105, i1 true, i1 %54
br i1 %106, label %111, label %107
107: ; preds = %102
%108 = call i32 @fc8300_write(i8* %0, i16 zeroext %1, i32 119, i32 2)
%109 = call i32 @fc8300_write(i8* %0, i16 zeroext %1, i32 80, i32 227)
%110 = call i32 @fc8300_write(i8* %0, i16 zeroext %1, i32 80, i32 255)
br label %111
111: ; preds = %93, %102, %107
%112 = load i8, i8* %5
%113 = and i8 %112, 17
%114 = icmp eq i8 %113, 17
br i1 %114, label %121, label %115
115: ; preds = %111
%116 = call i32 @fc8300_read(i8* %0, i16 zeroext %1, i32 116, i8* %5)
%117 = load i8, i8* %5
%118 = call i32 @vco_cal(i8* %0, i16 zeroext %1, i8 zeroext %117)
%119 = add nuw nsw i8 %56, 1
%120 = icmp eq i8 %119, 4
br i1 %120, label %121, label %55
121: ; preds = %111, %115
ret i32 0
}