#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 */
unsigned long SysCtlClockConfigGet();
int /*<<< orphan*/ SysCtlClockDividersSet(unsigned long, unsigned long);
int /*<<< orphan*/ SysCtlClockPllConfig(unsigned long, unsigned long);
int /*<<< orphan*/ SysCtlXPllClockDividerSet(unsigned long);
void SysCtlClockConfigSet(unsigned long ulConfig) {
  unsigned long ulMWRAllow;
  unsigned long CurPllSrc = 0, CurPllIMult = 0, CurPllFMult = 0;
  unsigned long CurClockConfig = 0;
  unsigned long ClkSrcReq = 0, PllMult = 0;
  ulMWRAllow = (*((volatile unsigned long *)(0x400FB980)));
  (*((volatile unsigned long *)(0x400FB980))) = 0xA5A5A5A5;
  CurClockConfig = SysCtlClockConfigGet();
  CurPllSrc = CurClockConfig & 0x80000000;
  CurPllIMult = CurClockConfig & 0x0000007F;
  CurPllFMult = CurClockConfig & 0x00000300;
  ClkSrcReq = ulConfig & 0x80000000;
  PllMult = ulConfig & (0x0000007F | 0x00000300);
  if ((CurPllSrc != (ClkSrcReq >> 31)) ||
      (CurPllIMult != (PllMult & 0x0000007F)) ||
      (CurPllFMult != (PllMult & 0x00000300))) {
    (*((volatile unsigned long *)(0x400FB800))) &= ~0x00000002;
    SysCtlClockDividersSet(ulConfig & 0x00300000, (ulConfig & 0x000C0000));
    SysCtlClockPllConfig(ClkSrcReq, (PllMult));
  } else {
    SysCtlClockDividersSet(ulConfig & 0x00300000, (ulConfig & 0x000C0000));
  }
  SysCtlXPllClockDividerSet(ulConfig & 0x00030000);
  (*((volatile unsigned long *)(0x400FB980))) = ulMWRAllow;
}


x86 assembly (clang, -O0):
<SysCtlClockConfigSet>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
movq   $0x0,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
movq   $0x0,-0x30(%rbp)
movq   $0x0,-0x38(%rbp)
movq   $0x0,-0x40(%rbp)
mov    $0x400fb980,%eax
mov    (%rax),%rax
mov    %rax,-0x10(%rbp)
mov    $0x400fb980,%eax
mov    $0xa5a5a5a5,%ecx
mov    %rcx,(%rax)
mov    $0x0,%al
call   1050 <SysCtlClockConfigGet@plt>
mov    %rax,-0x30(%rbp)
movabs $0x80000000,%rax
and    -0x30(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x30(%rbp),%rax
and    $0x7f,%rax
mov    %rax,-0x20(%rbp)
mov    -0x30(%rbp),%rax
and    $0x300,%rax
mov    %rax,-0x28(%rbp)
movabs $0x80000000,%rax
and    -0x8(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x8(%rbp),%rax
and    $0x37f,%rax
mov    %rax,-0x40(%rbp)
mov    -0x18(%rbp),%rax
mov    -0x38(%rbp),%rcx
shr    $0x1f,%rcx
cmp    %rcx,%rax
jne    122e <SysCtlClockConfigSet+0xee>
mov    -0x20(%rbp),%rax
mov    -0x40(%rbp),%rcx
and    $0x7f,%rcx
cmp    %rcx,%rax
jne    122e <SysCtlClockConfigSet+0xee>
mov    -0x28(%rbp),%rax
mov    -0x40(%rbp),%rcx
and    $0x300,%rcx
cmp    %rcx,%rax
je     126f <SysCtlClockConfigSet+0x12f>
mov    $0x400fb800,%eax
mov    (%rax),%rcx
and    $0xfffffffffffffffd,%rcx
mov    $0x400fb800,%eax
mov    %rcx,(%rax)
mov    -0x8(%rbp),%rdi
and    $0x300000,%rdi
mov    -0x8(%rbp),%rsi
and    $0xc0000,%rsi
call   1030 <SysCtlClockDividersSet@plt>
mov    -0x38(%rbp),%rdi
mov    -0x40(%rbp),%rsi
call   1060 <SysCtlClockPllConfig@plt>
jmp    128a <SysCtlClockConfigSet+0x14a>
mov    -0x8(%rbp),%rdi
and    $0x300000,%rdi
mov    -0x8(%rbp),%rsi
and    $0xc0000,%rsi
call   1030 <SysCtlClockDividersSet@plt>
mov    -0x8(%rbp),%rdi
and    $0x30000,%rdi
call   1040 <SysCtlXPllClockDividerSet@plt>
mov    -0x10(%rbp),%rcx
mov    $0x400fb980,%eax
mov    %rcx,(%rax)
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<SysCtlClockConfigSet>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdi,%rbx
mov    0x400fb980,%r12
40
mov    $0xa5a5a5a5,%eax
mov    %rax,0x400fb980
40
xor    %eax,%eax
call   1050 <SysCtlClockConfigGet@plt>
mov    %eax,%ecx
and    $0x80000000,%ecx
mov    %ebx,%r14d
and    $0x80000000,%r14d
mov    %r14,%rdx
shr    $0x1f,%rdx
cmp    %rdx,%rcx
jne    118e <SysCtlClockConfigSet+0x4e>
xor    %ebx,%eax
test   $0x37f,%eax
je     11c3 <SysCtlClockConfigSet+0x83>
andq   $0xfffffffffffffffd,0x400fb800
40 fd
mov    %ebx,%r15d
and    $0x37f,%r15d
mov    %ebx,%edi
and    $0x300000,%edi
mov    %ebx,%esi
and    $0xc0000,%esi
call   1030 <SysCtlClockDividersSet@plt>
mov    %r14,%rdi
mov    %r15,%rsi
call   1060 <SysCtlClockPllConfig@plt>
jmp    11d8 <SysCtlClockConfigSet+0x98>
mov    %ebx,%edi
and    $0x300000,%edi
mov    %ebx,%esi
and    $0xc0000,%esi
call   1030 <SysCtlClockDividersSet@plt>
and    $0x30000,%ebx
mov    %rbx,%rdi
call   1040 <SysCtlXPllClockDividerSet@plt>
mov    %r12,0x400fb980
40
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @SysCtlClockConfigSet(i64 %0) {
%2 = alloca i64
%3 = alloca i64
%4 = alloca i64
%5 = alloca i64
%6 = alloca i64
%7 = alloca i64
%8 = alloca i64
%9 = alloca i64
store i64 %0, i64* %2
store i64 0, i64* %4
store i64 0, i64* %5
store i64 0, i64* %6
store i64 0, i64* %7
store i64 0, i64* %8
store i64 0, i64* %9
%10 = load volatile i64, i64* inttoptr (i64 1074772352 to i64*)
store i64 %10, i64* %3
store volatile i64 2779096485, i64* inttoptr (i64 1074772352 to i64*)
%11 = call i64 (...) @SysCtlClockConfigGet()
store i64 %11, i64* %7
%12 = load i64, i64* %7
%13 = and i64 %12, 2147483648
store i64 %13, i64* %4
%14 = load i64, i64* %7
%15 = and i64 %14, 127
store i64 %15, i64* %5
%16 = load i64, i64* %7
%17 = and i64 %16, 768
store i64 %17, i64* %6
%18 = load i64, i64* %2
%19 = and i64 %18, 2147483648
store i64 %19, i64* %8
%20 = load i64, i64* %2
%21 = and i64 %20, 895
store i64 %21, i64* %9
%22 = load i64, i64* %4
%23 = load i64, i64* %8
%24 = lshr i64 %23, 31
%25 = icmp ne i64 %22, %24
br i1 %25, label %36, label %26
26: ; preds = %1
%27 = load i64, i64* %5
%28 = load i64, i64* %9
%29 = and i64 %28, 127
%30 = icmp ne i64 %27, %29
br i1 %30, label %36, label %31
31: ; preds = %26
%32 = load i64, i64* %6
%33 = load i64, i64* %9
%34 = and i64 %33, 768
%35 = icmp ne i64 %32, %34
br i1 %35, label %36, label %47
36: ; preds = %31, %26, %1
%37 = load volatile i64, i64* inttoptr (i64 1074771968 to i64*)
%38 = and i64 %37, -3
store volatile i64 %38, i64* inttoptr (i64 1074771968 to i64*)
%39 = load i64, i64* %2
%40 = and i64 %39, 3145728
%41 = load i64, i64* %2
%42 = and i64 %41, 786432
%43 = call i32 @SysCtlClockDividersSet(i64 %40, i64 %42)
%44 = load i64, i64* %8
%45 = load i64, i64* %9
%46 = call i32 @SysCtlClockPllConfig(i64 %44, i64 %45)
br label %53
47: ; preds = %31
%48 = load i64, i64* %2
%49 = and i64 %48, 3145728
%50 = load i64, i64* %2
%51 = and i64 %50, 786432
%52 = call i32 @SysCtlClockDividersSet(i64 %49, i64 %51)
br label %53
53: ; preds = %47, %36
%54 = load i64, i64* %2
%55 = and i64 %54, 196608
%56 = call i32 @SysCtlXPllClockDividerSet(i64 %55)
%57 = load i64, i64* %3
store volatile i64 %57, i64* inttoptr (i64 1074772352 to i64*)
ret void
}

LLVM IR (-O2):
define void @SysCtlClockConfigSet(i64 %0) {
%2 = load volatile i64, i64* inttoptr (i64 1074772352 to i64*)
store volatile i64 2779096485, i64* inttoptr (i64 1074772352 to i64*)
%3 = tail call i64 (...) @SysCtlClockConfigGet()
%4 = and i64 %3, 2147483648
%5 = and i64 %0, 2147483648
%6 = and i64 %0, 895
%7 = lshr exact i64 %5, 31
%8 = icmp eq i64 %4, %7
br i1 %8, label %9, label %13
9: ; preds = %1
%10 = xor i64 %3, %0
%11 = and i64 %10, 895
%12 = icmp eq i64 %11, 0
br i1 %12, label %20, label %13
13: ; preds = %9, %1
%14 = load volatile i64, i64* inttoptr (i64 1074771968 to i64*)
%15 = and i64 %14, -3
store volatile i64 %15, i64* inttoptr (i64 1074771968 to i64*)
%16 = and i64 %0, 3145728
%17 = and i64 %0, 786432
%18 = tail call i32 @SysCtlClockDividersSet(i64 %16, i64 %17)
%19 = tail call i32 @SysCtlClockPllConfig(i64 %5, i64 %6)
br label %24
20: ; preds = %9
%21 = and i64 %0, 3145728
%22 = and i64 %0, 786432
%23 = tail call i32 @SysCtlClockDividersSet(i64 %21, i64 %22)
br label %24
24: ; preds = %20, %13
%25 = and i64 %0, 196608
%26 = tail call i32 @SysCtlXPllClockDividerSet(i64 %25)
store volatile i64 %2, i64* inttoptr (i64 1074772352 to i64*)
ret void
}