user: Converte this assembly snippet into its equivalent C code:

```asm
<fc8300b_tuner_set_pll>:
  endbr64
  push   %rbp
  mov    %rsp,%rbp
  sub    $0x60,%rsp
  mov    %rdi,-0x48(%rbp)
  mov    %esi,%eax
  mov    %edx,-0x50(%rbp)
  mov    %ecx,-0x54(%rbp)
  mov    %ax,-0x4c(%rbp)
  mov    %fs:0x28,%rax
  mov    %rax,-0x8(%rbp)
  xor    %eax,%eax
  movl   $0x5b8d80,-0x28(%rbp)
  movabs $0x6040302018100c08,%rax
  mov    %rax,-0x10(%rbp)
  movb   $0x4,-0x2c(%rbp)
  movb   $0x0,-0x31(%rbp)
  movb   $0x0,-0x30(%rbp)
  movb   $0x11,-0x2b(%rbp)
  movb   $0x0,-0x2f(%rbp)
  jmp    L117
L172:
  movzbl -0x2f(%rbp),%eax
  add    $0x1,%eax
  cltq
  movzbl -0x10(%rbp,%rax,1),%eax
  movzbl %al,%eax
  imul   -0x50(%rbp),%eax
  cmp    %eax,-0x28(%rbp)
  jb     L78
  movzbl -0x2f(%rbp),%eax
  add    $0x1,%eax
  mov    %al,-0x2f(%rbp)
L117:
  cmpb   $0x6,-0x2f(%rbp)
  jbe    L172
  jmp    L71
L78:
  nop
L71:
  movzbl -0x2f(%rbp),%eax
  cltq
  movzbl -0x10(%rbp,%rax,1),%eax
  movzbl %al,%eax
  mov    -0x50(%rbp),%edx
  imul   %edx,%eax
  mov    %eax,-0x24(%rbp)
  mov    -0x24(%rbp),%eax
  mov    %eax,%eax
  imul   $0x1b4e81b5,%rax,%rax
  shr    $0x20,%rax
  shr    $0xb,%eax
  mov    %eax,-0x20(%rbp)
  mov    -0x20(%rbp),%eax
  imul   $0x4b00,%eax,%edx
  mov    -0x24(%rbp),%eax
  sub    %edx,%eax
  mov    %eax,-0x1c(%rbp)
  movzbl -0x2c(%rbp),%edx
  mov    $0x14,%eax
  sub    %edx,%eax
  mov    -0x1c(%rbp),%edx
  mov    %eax,%ecx
  shl    %cl,%edx
  mov    %edx,%eax
  mov    %eax,-0x18(%rbp)
  movzbl -0x2c(%rbp),%eax
  mov    $0x4b00,%edx
  mov    %eax,%ecx
  sar    %cl,%edx
  mov    %edx,%eax
  mov    %eax,%edi
  mov    -0x18(%rbp),%eax
  mov    $0x0,%edx
  div    %edi
  mov    %eax,-0x14(%rbp)
  orl    $0x1,-0x14(%rbp)
  mov    -0x20(%rbp),%eax
  shr    $0x3,%eax
  and    $0x20,%eax
  mov    %al,-0x2a(%rbp)
  mov    -0x14(%rbp),%eax
  shr    $0x10,%eax
  add    %al,-0x2a(%rbp)
  movb   $0x0,-0x29(%rbp)
  movzbl -0x2f(%rbp),%eax
  lea    (%rax,%rax,1),%edx
  movzbl -0x29(%rbp),%eax
  add    %edx,%eax
  add    $0x1,%eax
  mov    %al,-0x29(%rbp)
  movb   $0x0,-0x2d(%rbp)
  jmp    L113
L178:
  movzwl -0x4c(%rbp),%esi
  mov    -0x48(%rbp),%rax
  mov    $0x31,%ecx
  mov    $0x75,%edx
  mov    %rax,%rdi
  call   <fc8300b_write@plt>
  movzwl -0x4c(%rbp),%esi
  mov    -0x48(%rbp),%rax
  mov    $0x0,%ecx
  mov    $0x77,%edx
  mov    %rax,%rdi
  call   <fc8300b_write@plt>
  movzbl -0x29(%rbp),%edx
  movzwl -0x4c(%rbp),%esi
  mov    -0x48(%rbp),%rax
  mov    %edx,%ecx
  mov    $0x51,%edx
  mov    %rax,%rdi
  call   <fc8300b_write@plt>
  movzbl -0x2a(%rbp),%edx
  movzwl -0x4c(%rbp),%esi
  mov    -0x48(%rbp),%rax
  mov    %edx,%ecx
  mov    $0x57,%edx
  mov    %rax,%rdi
  call   <fc8300b_write@plt>
  mov    -0x20(%rbp),%eax
  movzbl %al,%edx
  movzwl -0x4c(%rbp),%esi
  mov    -0x48(%rbp),%rax
  mov    %edx,%ecx
  mov    $0x5a,%edx
  mov    %rax,%rdi
  call   <fc8300b_write@plt>
  movzwl -0x4c(%rbp),%esi
  mov    -0x48(%rbp),%rax
  mov    $0xe3,%ecx
  mov    $0x50,%edx
  mov    %rax,%rdi
  call   <fc8300b_write@plt>
  movzwl -0x4c(%rbp),%esi
  mov    -0x48(%rbp),%rax
  mov    $0xff,%ecx
  mov    $0x50,%edx
  mov    %rax,%rdi
  call   <fc8300b_write@plt>
  mov    -0x14(%rbp),%eax
  shr    $0x8,%eax
  movzbl %al,%edx
  movzwl -0x4c(%rbp),%esi
  mov    -0x48(%rbp),%rax
  mov    %edx,%ecx
  mov    $0x58,%edx
  mov    %rax,%rdi
  call   <fc8300b_write@plt>
  mov    -0x14(%rbp),%eax
  movzbl %al,%edx
  movzwl -0x4c(%rbp),%esi
  mov    -0x48(%rbp),%rax
  mov    %edx,%ecx
  mov    $0x59,%edx
  mov    %rax,%rdi
  call   <fc8300b_write@plt>
  mov    $0x2,%edi
  call   <msWait@plt>
  movb   $0x1,-0x2e(%rbp)
  jmp    L94
L57:
  movzwl -0x4c(%rbp),%esi
  lea    -0x31(%rbp),%rdx
  mov    -0x48(%rbp),%rax
  mov    %rdx,%rcx
  mov    $0x64,%edx
  mov    %rax,%rdi
  call   <fc8300b_read@plt>
  movzwl -0x4c(%rbp),%esi
  lea    -0x30(%rbp),%rdx
  mov    -0x48(%rbp),%rax
  mov    %rdx,%rcx
  mov    $0x65,%edx
  mov    %rax,%rdi
  call   <fc8300b_read@plt>
  movzbl -0x31(%rbp),%eax
  and    -0x2b(%rbp),%al
  cmp    %al,-0x2b(%rbp)
  jne    L153
  movzbl -0x30(%rbp),%eax
  cmp    $0x1,%al
  jbe    L153
  movzwl -0x4c(%rbp),%esi
  lea    -0x30(%rbp),%rdx
  mov    -0x48(%rbp),%rax
  mov    %rdx,%rcx
  mov    $0x76,%edx
  mov    %rax,%rdi
  call   <fc8300b_read@plt>
  movzbl -0x30(%rbp),%eax
  cmp    $0x3d,%al
  ja     L75
  movzbl -0x2f(%rbp),%eax
  and    $0x1,%eax
  test   %al,%al
  jne    L146
  cmpl   $0x5e9ac0,-0x24(%rbp)
  jbe    L75
L146:
  movzwl -0x4c(%rbp),%esi
  mov    -0x48(%rbp),%rax
  mov    $0x2,%ecx
  mov    $0x77,%edx
  mov    %rax,%rdi
  call   <fc8300b_write@plt>
  movzwl -0x4c(%rbp),%esi
  mov    -0x48(%rbp),%rax
  mov    $0xe3,%ecx
  mov    $0x50,%edx
  mov    %rax,%rdi
  call   <fc8300b_write@plt>
  movzwl -0x4c(%rbp),%esi
  mov    -0x48(%rbp),%rax
  mov    $0xff,%ecx
  mov    $0x50,%edx
  mov    %rax,%rdi
  call   <fc8300b_write@plt>
  jmp    L75
L153:
  movzbl -0x2e(%rbp),%eax
  add    $0x1,%eax
  mov    %al,-0x2e(%rbp)
L94:
  cmpb   $0x4,-0x2e(%rbp)
  jbe    L57
  jmp    L34
L75:
  nop
L34:
  movzbl -0x31(%rbp),%eax
  and    -0x2b(%rbp),%al
  cmp    %al,-0x2b(%rbp)
  je     L79
  movzwl -0x4c(%rbp),%esi
  lea    -0x31(%rbp),%rdx
  mov    -0x48(%rbp),%rax
  mov    %rdx,%rcx
  mov    $0x74,%edx
  mov    %rax,%rdi
  call   <fc8300b_read@plt>
  movzbl -0x31(%rbp),%eax
  movzbl %al,%edx
  movzwl -0x4c(%rbp),%ecx
  mov    -0x48(%rbp),%rax
  mov    %ecx,%esi
  mov    %rax,%rdi
  call   <vco_cal@plt>
  movzbl -0x2d(%rbp),%eax
  add    $0x1,%eax
  mov    %al,-0x2d(%rbp)
L113:
  cmpb   $0x3,-0x2d(%rbp)
  jbe    L178
  jmp    L48
L79:
  nop
L48:
  mov    $0x0,%eax
  mov    -0x8(%rbp),%rdx
  sub    %fs:0x28,%rdx
  je     L140
  call   <__stack_chk_fail@plt>
L140:
  leave
  ret
```

assistant: ```c
int fc8300b_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 / 19200;
  f_diff = f_vco - 19200 * n_val;
  f_diff_shifted = f_diff << (20 - pre_shift_bits);
  k_val = f_diff_shifted / (19200 >> 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++) {
    fc8300b_write(handle, devid, 0x75, 0x31);
    fc8300b_write(handle, devid, 0x77, 0x00);
    fc8300b_write(handle, devid, 0x51, data_0x51);
    fc8300b_write(handle, devid, 0x57, data_0x57);
    fc8300b_write(handle, devid, 0x5a, (unsigned char)n_val);
    fc8300b_write(handle, devid, 0x50, 0xe3);
    fc8300b_write(handle, devid, 0x50, 0xff);
    fc8300b_write(handle, devid, 0x58, (unsigned char)((k_val >> 8) & 0xff));
    fc8300b_write(handle, devid, 0x59, (unsigned char)((k_val)&0xff));
    msWait(2);
    for (i = 1; i < 5; i++) {
      fc8300b_read(handle, devid, 0x64, &lock_detect);
      fc8300b_read(handle, devid, 0x65, &lock_bank);
      if (((lock_detect & lock_condition) == lock_condition) && (lock_bank > 1)) {
        fc8300b_read(handle, devid, 0x76, &lock_bank);
        if (lock_bank < 62) {
          if (((lo_select % 2) != 0) || (f_vco > 6200000)) {
            fc8300b_write(handle, devid, 0x77, 0x02);
            fc8300b_write(handle, devid, 0x50, 0xe3);
            fc8300b_write(handle, devid, 0x50, 0xff);
          }
        }
        break;
      }
    }
    if ((lock_detect & lock_condition) != lock_condition) {
      fc8300b_read(handle, devid, 0x74, &lock_detect);
      vco_cal(handle, devid, lock_detect);
    } else {
      break;
    }
  }
  return 0;
}
```