#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 unsigned long volatile uint8_t;
typedef int uint32_t;

/* Variables and functions */
int /*<<< orphan*/ _pll_feed();
void pll_init(uint8_t cfg, uint8_t apb_divider) {
  uint32_t loop_counter = 0;
  (*(volatile unsigned long *)(0xE01FC000 + 0x084)) = cfg;
  (*(volatile unsigned long *)(0xE01FC000 + 0x080)) = 0x01;
  (*(volatile unsigned long *)(0xE01FC000 + 0x100)) |= apb_divider;
  _pll_feed();
  while (((*(volatile unsigned long *)(0xE01FC000 + 0x088)) & (1 << 10)) == 0 &&
         loop_counter <= 1000)
    loop_counter++;
  (*(volatile unsigned long *)(0xE01FC000 + 0x080)) |= 0x04;
  _pll_feed();
}


x86 assembly (clang, -O0):
<pll_init>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x8(%rbp),%rcx
mov    $0xe01fc084,%eax
mov    %rcx,(%rax)
mov    $0xe01fc080,%eax
movq   $0x1,(%rax)
mov    -0x10(%rbp),%rax
mov    $0xe01fc100,%ecx
mov    (%rcx),%rcx
or     %rax,%rcx
mov    $0xe01fc100,%eax
mov    %rcx,(%rax)
mov    $0x0,%al
call   1030 <_pll_feed@plt>
mov    $0xe01fc088,%eax
mov    (%rax),%rcx
and    $0x400,%rcx
xor    %eax,%eax
cmp    $0x0,%rcx
mov    %al,-0x15(%rbp)
jne    1188 <pll_init+0x78>
cmpl   $0x3e8,-0x14(%rbp)
setle  %al
mov    %al,-0x15(%rbp)
mov    -0x15(%rbp),%al
test   $0x1,%al
jne    1198 <pll_init+0x88>
jmp    11a6 <pll_init+0x96>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    115d <pll_init+0x4d>
mov    $0xe01fc080,%eax
mov    (%rax),%rcx
or     $0x4,%rcx
mov    $0xe01fc080,%eax
mov    %rcx,(%rax)
mov    $0x0,%al
call   1030 <_pll_feed@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pll_init>:
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    $0xe01fc080,%r14d
mov    %rdi,0x10(%rsp)
mov    %rsi,0x8(%rsp)
mov    0x10(%rsp),%rax
mov    %rax,0x4(%r14)
movq   $0x1,(%r14)
mov    0x8(%rsp),%rax
or     %rax,0x80(%r14)
xor    %ebx,%ebx
xor    %eax,%eax
call   1030 <_pll_feed@plt>
nopl   0x0(%rax)
testq  $0x400,0x8(%r14)
jne    1167 <pll_init+0x57>
lea    0x1(%rbx),%eax
cmp    $0x3e9,%ebx
mov    %eax,%ebx
jb     1150 <pll_init+0x40>
orq    $0x4,(%r14)
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
jmp    1030 <_pll_feed@plt>

LLVM IR (-O0):
define void @pll_init(i64 %0, i64 %1) {
%3 = alloca i64
%4 = alloca i64
%5 = alloca i32
store volatile i64 %0, i64* %3
store volatile i64 %1, i64* %4
store i32 0, i32* %5
%6 = load volatile i64, i64* %3
store volatile i64 %6, i64* inttoptr (i64 3760177284 to i64*)
store volatile i64 1, i64* inttoptr (i64 3760177280 to i64*)
%7 = load volatile i64, i64* %4
%8 = load volatile i64, i64* inttoptr (i64 3760177408 to i64*)
%9 = or i64 %8, %7
store volatile i64 %9, i64* inttoptr (i64 3760177408 to i64*)
%10 = call i32 (...) @_pll_feed()
br label %11
11: ; preds = %20, %2
%12 = load volatile i64, i64* inttoptr (i64 3760177288 to i64*)
%13 = and i64 %12, 1024
%14 = icmp eq i64 %13, 0
br i1 %14, label %15, label %18
15: ; preds = %11
%16 = load i32, i32* %5
%17 = icmp sle i32 %16, 1000
br label %18
18: ; preds = %15, %11
%19 = phi i1 [ false, %11 ], [ %17, %15 ]
br i1 %19, label %20, label %23
20: ; preds = %18
%21 = load i32, i32* %5
%22 = add nsw i32 %21, 1
store i32 %22, i32* %5
br label %11
23: ; preds = %18
%24 = load volatile i64, i64* inttoptr (i64 3760177280 to i64*)
%25 = or i64 %24, 4
store volatile i64 %25, i64* inttoptr (i64 3760177280 to i64*)
%26 = call i32 (...) @_pll_feed()
ret void
}

LLVM IR (-O2):
define void @pll_init(i64 %0, i64 %1) {
%3 = alloca i64
%4 = alloca i64
store volatile i64 %0, i64* %3
store volatile i64 %1, i64* %4
%5 = load volatile i64, i64* %3
store volatile i64 %5, i64* inttoptr (i64 3760177284 to i64*)
store volatile i64 1, i64* inttoptr (i64 3760177280 to i64*)
%6 = load volatile i64, i64* %4
%7 = load volatile i64, i64* inttoptr (i64 3760177408 to i64*)
%8 = or i64 %7, %6
store volatile i64 %8, i64* inttoptr (i64 3760177408 to i64*)
%9 = tail call i32 (...) @_pll_feed()
br label %10
10: ; preds = %10, %2
%11 = phi i32 [ 0, %2 ], [ %17, %10 ]
%12 = load volatile i64, i64* inttoptr (i64 3760177288 to i64*)
%13 = and i64 %12, 1024
%14 = icmp eq i64 %13, 0
%15 = icmp ult i32 %11, 1001
%16 = select i1 %14, i1 %15, i1 false
%17 = add nuw nsw i32 %11, 1
br i1 %16, label %10, label %18
18: ; preds = %10
%19 = load volatile i64, i64* inttoptr (i64 3760177280 to i64*)
%20 = or i64 %19, 4
store volatile i64 %20, i64* inttoptr (i64 3760177280 to i64*)
%21 = tail call i32 (...) @_pll_feed()
ret void
}