#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 */
int /*<<< orphan*/ bbm_byte_write(void *, unsigned short, int, int);
int /*<<< orphan*/ bbm_word_write(void *, unsigned short, int, unsigned short);
int fc8300_get_current_clk(void *, unsigned short);
int /*<<< orphan*/ msWait(int);
int fc8300_set_default_core_clk(void *handle, unsigned short devid) {
  unsigned short pll_set;
  pll_set = 0x1d12;
  bbm_byte_write(handle, devid, 0x0085, 0x00);
  bbm_byte_write(handle, devid, 0x0052, 0x01);
  bbm_word_write(handle, devid, 0x0055, pll_set);
  bbm_byte_write(handle, devid, 0x0052, 0x00);
  msWait(1);
  bbm_byte_write(handle, devid, 0x0085, 0x01);
  return fc8300_get_current_clk(handle, devid);
}


x86 assembly (clang, -O0):
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %si,%ax
mov    %rdi,-0x8(%rbp)
mov    %ax,-0xa(%rbp)
movw   $0x1d12,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
mov    $0x85,%edx
xor    %ecx,%ecx
movzwl -0xa(%rbp),%esi
call   1040 <bbm_byte_write@plt>
mov    -0x8(%rbp),%rdi
mov    $0x52,%edx
mov    $0x1,%ecx
movzwl -0xa(%rbp),%esi
call   1040 <bbm_byte_write@plt>
mov    -0x8(%rbp),%rdi
mov    -0xa(%rbp),%ax
mov    $0x55,%edx
movzwl %ax,%esi
movzwl -0xc(%rbp),%ecx
call   1060 <bbm_word_write@plt>
mov    -0x8(%rbp),%rdi
mov    $0x52,%edx
xor    %ecx,%ecx
movzwl -0xa(%rbp),%esi
call   1040 <bbm_byte_write@plt>
mov    $0x1,%edi
call   1050 <msWait@plt>
mov    -0x8(%rbp),%rdi
mov    $0x85,%edx
mov    $0x1,%ecx
movzwl -0xa(%rbp),%esi
call   1040 <bbm_byte_write@plt>
mov    -0x8(%rbp),%rdi
movzwl -0xa(%rbp),%esi
call   1030 <fc8300_get_current_clk@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebp
mov    %rdi,%rbx
mov    $0x85,%edx
xor    %ecx,%ecx
call   1040 <bbm_byte_write@plt>
mov    %rbx,%rdi
mov    %ebp,%esi
mov    $0x52,%edx
mov    $0x1,%ecx
call   1040 <bbm_byte_write@plt>
mov    %rbx,%rdi
mov    %ebp,%esi
mov    $0x55,%edx
mov    $0x1d12,%ecx
call   1060 <bbm_word_write@plt>
mov    %rbx,%rdi
mov    %ebp,%esi
mov    $0x52,%edx
xor    %ecx,%ecx
call   1040 <bbm_byte_write@plt>
mov    $0x1,%edi
call   1050 <msWait@plt>
mov    %rbx,%rdi
mov    %ebp,%esi
mov    $0x85,%edx
mov    $0x1,%ecx
call   1040 <bbm_byte_write@plt>
mov    %rbx,%rdi
mov    %ebp,%esi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1030 <fc8300_get_current_clk@plt>

LLVM IR (-O0):
define i32 @fc8300_set_default_core_clk(i8* %0, i16 zeroext %1) {
%3 = alloca i8*
%4 = alloca i16
%5 = alloca i16
store i8* %0, i8** %3
store i16 %1, i16* %4
store i16 7442, i16* %5
%6 = load i8*, i8** %3
%7 = load i16, i16* %4
%8 = call i32 @bbm_byte_write(i8* %6, i16 zeroext %7, i32 133, i32 0)
%9 = load i8*, i8** %3
%10 = load i16, i16* %4
%11 = call i32 @bbm_byte_write(i8* %9, i16 zeroext %10, i32 82, i32 1)
%12 = load i8*, i8** %3
%13 = load i16, i16* %4
%14 = load i16, i16* %5
%15 = call i32 @bbm_word_write(i8* %12, i16 zeroext %13, i32 85, i16 zeroext %14)
%16 = load i8*, i8** %3
%17 = load i16, i16* %4
%18 = call i32 @bbm_byte_write(i8* %16, i16 zeroext %17, i32 82, i32 0)
%19 = call i32 @msWait(i32 1)
%20 = load i8*, i8** %3
%21 = load i16, i16* %4
%22 = call i32 @bbm_byte_write(i8* %20, i16 zeroext %21, i32 133, i32 1)
%23 = load i8*, i8** %3
%24 = load i16, i16* %4
%25 = call i32 @fc8300_get_current_clk(i8* %23, i16 zeroext %24)
ret i32 %25
}

LLVM IR (-O2):
define i32 @fc8300_set_default_core_clk(i8* %0, i16 zeroext %1) {
%3 = tail call i32 @bbm_byte_write(i8* %0, i16 zeroext %1, i32 133, i32 0)
%4 = tail call i32 @bbm_byte_write(i8* %0, i16 zeroext %1, i32 82, i32 1)
%5 = tail call i32 @bbm_word_write(i8* %0, i16 zeroext %1, i32 85, i16 zeroext 7442)
%6 = tail call i32 @bbm_byte_write(i8* %0, i16 zeroext %1, i32 82, i32 0)
%7 = tail call i32 @msWait(i32 1)
%8 = tail call i32 @bbm_byte_write(i8* %0, i16 zeroext %1, i32 133, i32 1)
%9 = tail call i32 @fc8300_get_current_clk(i8* %0, i16 zeroext %1)
ret i32 %9
}