#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 int uint32_t;

/* Variables and functions */
int _SysCtlMemTimingGet(int);
void SysCtlDeepSleepClockConfigSet(uint32_t ui32Div, uint32_t ui32Config) {
  uint32_t ui32Value, ui32Clock;
  ;
  if ((((*((volatile uint32_t *)(0x400FE000))) & (0x70000000 | 0x00FF0000)) ==
       (0x10000000 | 0x00050000))) {
    (*((volatile uint32_t *)(0x400FE144))) =
        (ui32Config & ~0x1F800000) | ((ui32Div - 1) << 23);
  } else {
    ui32Value = ui32Div - 1;
    switch (ui32Config & 0x00000070) {
    case 0x00000000: {
      ui32Value |= 0x00300000;
      ui32Clock = 25000000;
      break;
    }
    case 0x00000030: {
      ui32Value |= 0x00200000;
      ui32Clock = 30000;
      break;
    }
    case 0x00000070: {
      ui32Value |= 0x00400000;
      ui32Clock = 32768;
      break;
    }
    case 0x00000010:
    default: {
      ui32Clock = 16000000;
      break;
    }
    }
    if (ui32Config & 0x00000002) {
      ui32Value |= 0x80000000;
    }
    if (ui32Config & 0x40000000) {
      ui32Value |= 0x40000000;
    }
    (*((volatile uint32_t *)(0x400FE144))) = ui32Value;
    (*((volatile uint32_t *)(0x400FE0C8))) = _SysCtlMemTimingGet(ui32Clock);
  }
}


x86 assembly (clang, -O0):
<SysCtlDeepSleepClockConfigSet>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    $0x400fe000,%eax
mov    (%rax),%eax
and    $0x70ff0000,%eax
cmp    $0x10050000,%eax
jne    1155 <SysCtlDeepSleepClockConfigSet+0x45>
mov    -0x8(%rbp),%ecx
and    $0xe07fffff,%ecx
mov    -0x4(%rbp),%eax
sub    $0x1,%eax
shl    $0x17,%eax
or     %eax,%ecx
mov    $0x400fe144,%eax
mov    %ecx,(%rax)
jmp    1247 <SysCtlDeepSleepClockConfigSet+0x137>
mov    -0x4(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%eax
and    $0x70,%eax
mov    %eax,-0x14(%rbp)
je     11a5 <SysCtlDeepSleepClockConfigSet+0x95>
jmp    1172 <SysCtlDeepSleepClockConfigSet+0x62>
mov    -0x14(%rbp),%eax
sub    $0x10,%eax
je     11ea <SysCtlDeepSleepClockConfigSet+0xda>
jmp    1183 <SysCtlDeepSleepClockConfigSet+0x73>
mov    -0x14(%rbp),%eax
sub    $0x30,%eax
je     11bc <SysCtlDeepSleepClockConfigSet+0xac>
jmp    1194 <SysCtlDeepSleepClockConfigSet+0x84>
mov    -0x14(%rbp),%eax
sub    $0x70,%eax
je     11d3 <SysCtlDeepSleepClockConfigSet+0xc3>
jmp    11ef <SysCtlDeepSleepClockConfigSet+0xdf>
mov    -0xc(%rbp),%eax
or     $0x300000,%eax
mov    %eax,-0xc(%rbp)
movl   $0x17d7840,-0x10(%rbp)
jmp    11f6 <SysCtlDeepSleepClockConfigSet+0xe6>
mov    -0xc(%rbp),%eax
or     $0x200000,%eax
mov    %eax,-0xc(%rbp)
movl   $0x7530,-0x10(%rbp)
jmp    11f6 <SysCtlDeepSleepClockConfigSet+0xe6>
mov    -0xc(%rbp),%eax
or     $0x400000,%eax
mov    %eax,-0xc(%rbp)
movl   $0x8000,-0x10(%rbp)
jmp    11f6 <SysCtlDeepSleepClockConfigSet+0xe6>
jmp    11ef <SysCtlDeepSleepClockConfigSet+0xdf>
movl   $0xf42400,-0x10(%rbp)
mov    -0x8(%rbp),%eax
and    $0x2,%eax
cmp    $0x0,%eax
je     1210 <SysCtlDeepSleepClockConfigSet+0x100>
mov    -0xc(%rbp),%eax
or     $0x80000000,%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%eax
and    $0x40000000,%eax
cmp    $0x0,%eax
je     122c <SysCtlDeepSleepClockConfigSet+0x11c>
mov    -0xc(%rbp),%eax
or     $0x40000000,%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%ecx
mov    $0x400fe144,%eax
mov    %ecx,(%rax)
mov    -0x10(%rbp),%edi
call   1030 <_SysCtlMemTimingGet@plt>
mov    %eax,%ecx
mov    $0x400fe0c8,%eax
mov    %ecx,(%rax)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<SysCtlDeepSleepClockConfigSet>:
push   %rax
mov    $0x70ff0000,%eax
and    0x400fe000,%eax
cmp    $0x10050000,%eax
jne    113e <SysCtlDeepSleepClockConfigSet+0x2e>
and    $0xe07fffff,%esi
shl    $0x17,%edi
add    $0xff800000,%edi
or     %esi,%edi
mov    %edi,0x400fe144
pop    %rax
ret
add    $0xffffffff,%edi
mov    %esi,%ecx
shr    $0x4,%ecx
and    $0x7,%ecx
cmp    $0x7,%ecx
je     1169 <SysCtlDeepSleepClockConfigSet+0x59>
cmp    $0x3,%ecx
je     1176 <SysCtlDeepSleepClockConfigSet+0x66>
mov    $0xf42400,%eax
test   %ecx,%ecx
jne    1181 <SysCtlDeepSleepClockConfigSet+0x71>
or     $0x300000,%edi
mov    $0x17d7840,%eax
jmp    1181 <SysCtlDeepSleepClockConfigSet+0x71>
or     $0x400000,%edi
mov    $0x8000,%eax
jmp    1181 <SysCtlDeepSleepClockConfigSet+0x71>
or     $0x200000,%edi
mov    $0x7530,%eax
mov    %esi,%ecx
and    $0xfffffffe,%ecx
shl    $0x1e,%ecx
and    $0x40000000,%esi
or     %ecx,%esi
or     %edi,%esi
mov    %esi,0x400fe144
mov    %eax,%edi
call   1030 <_SysCtlMemTimingGet@plt>
mov    %eax,0x400fe0c8
pop    %rax
ret

LLVM IR (-O0):
define void @SysCtlDeepSleepClockConfigSet(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
%7 = load volatile i32, i32* inttoptr (i64 1074782208 to i32*)
%8 = and i32 %7, 1895759872
%9 = icmp eq i32 %8, 268763136
br i1 %9, label %10, label %17
10: ; preds = %2
%11 = load i32, i32* %4
%12 = and i32 %11, -528482305
%13 = load i32, i32* %3
%14 = sub nsw i32 %13, 1
%15 = shl i32 %14, 23
%16 = or i32 %12, %15
store volatile i32 %16, i32* inttoptr (i64 1074782532 to i32*)
br label %51
17: ; preds = %2
%18 = load i32, i32* %3
%19 = sub nsw i32 %18, 1
store i32 %19, i32* %5
%20 = load i32, i32* %4
%21 = and i32 %20, 112
switch i32 %21, label %32 [
i32 0, label %22
i32 48, label %25
i32 112, label %28
i32 16, label %31
]
22: ; preds = %17
%23 = load i32, i32* %5
%24 = or i32 %23, 3145728
store i32 %24, i32* %5
store i32 25000000, i32* %6
br label %33
25: ; preds = %17
%26 = load i32, i32* %5
%27 = or i32 %26, 2097152
store i32 %27, i32* %5
store i32 30000, i32* %6
br label %33
28: ; preds = %17
%29 = load i32, i32* %5
%30 = or i32 %29, 4194304
store i32 %30, i32* %5
store i32 32768, i32* %6
br label %33
31: ; preds = %17
br label %32
32: ; preds = %17, %31
store i32 16000000, i32* %6
br label %33
33: ; preds = %32, %28, %25, %22
%34 = load i32, i32* %4
%35 = and i32 %34, 2
%36 = icmp ne i32 %35, 0
br i1 %36, label %37, label %40
37: ; preds = %33
%38 = load i32, i32* %5
%39 = or i32 %38, -2147483648
store i32 %39, i32* %5
br label %40
40: ; preds = %37, %33
%41 = load i32, i32* %4
%42 = and i32 %41, 1073741824
%43 = icmp ne i32 %42, 0
br i1 %43, label %44, label %47
44: ; preds = %40
%45 = load i32, i32* %5
%46 = or i32 %45, 1073741824
store i32 %46, i32* %5
br label %47
47: ; preds = %44, %40
%48 = load i32, i32* %5
store volatile i32 %48, i32* inttoptr (i64 1074782532 to i32*)
%49 = load i32, i32* %6
%50 = call i32 @_SysCtlMemTimingGet(i32 %49)
store volatile i32 %50, i32* inttoptr (i64 1074782408 to i32*)
br label %51
51: ; preds = %47, %10
ret void
}

LLVM IR (-O2):
define void @SysCtlDeepSleepClockConfigSet(i32 %0, i32 %1) {
%3 = load volatile i32, i32* inttoptr (i64 1074782208 to i32*)
%4 = and i32 %3, 1895759872
%5 = icmp eq i32 %4, 268763136
br i1 %5, label %6, label %11
6: ; preds = %2
%7 = and i32 %1, -528482305
%8 = shl i32 %0, 23
%9 = add i32 %8, -8388608
%10 = or i32 %7, %9
store volatile i32 %10, i32* inttoptr (i64 1074782532 to i32*)
br label %30
11: ; preds = %2
%12 = add nsw i32 %0, -1
%13 = lshr i32 %1, 4
%14 = and i32 %13, 7
switch i32 %14, label %21 [
i32 0, label %15
i32 3, label %17
i32 7, label %19
]
15: ; preds = %11
%16 = or i32 %12, 3145728
br label %21
17: ; preds = %11
%18 = or i32 %12, 2097152
br label %21
19: ; preds = %11
%20 = or i32 %12, 4194304
br label %21
21: ; preds = %11, %19, %17, %15
%22 = phi i32 [ %20, %19 ], [ %18, %17 ], [ %16, %15 ], [ %12, %11 ]
%23 = phi i32 [ 32768, %19 ], [ 30000, %17 ], [ 25000000, %15 ], [ 16000000, %11 ]
%24 = shl i32 %1, 30
%25 = and i32 %24, -2147483648
%26 = and i32 %1, 1073741824
%27 = or i32 %25, %26
%28 = or i32 %27, %22
store volatile i32 %28, i32* inttoptr (i64 1074782532 to i32*)
%29 = tail call i32 @_SysCtlMemTimingGet(i32 %23)
store volatile i32 %29, i32* inttoptr (i64 1074782408 to i32*)
br label %30
30: ; preds = %21, %6
ret void
}