#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 int GET32(int);
int /*<<< orphan*/ PUT32(int, int);
void set_tick_and_enable_timer_TS(int priority) {
  unsigned int rx = GET32(0x20003004);
  switch (priority) {
  case 0:
    rx += 0x00200000;
    break;
  case 1:
    rx += 0x00100000;
    break;
  case 2:
    rx += 0x00080000;
    break;
  case 3:
    rx += 0x00040000;
    break;
  }
  PUT32(0x20003010, rx);
  PUT32(0x20003000, 2);
}


x86 assembly (clang, -O0):
<set_tick_and_enable_timer_TS>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    $0x20003004,%edi
call   1040 <GET32@plt>
mov    %eax,-0x8(%rbp)
mov    -0x4(%rbp),%eax
mov    %rax,-0x10(%rbp)
sub    $0x3,%rax
ja     1198 <set_tick_and_enable_timer_TS+0x78>
mov    -0x10(%rbp),%rax
lea    0xeac(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x8(%rbp),%eax
add    $0x200000,%eax
mov    %eax,-0x8(%rbp)
jmp    1198 <set_tick_and_enable_timer_TS+0x78>
mov    -0x8(%rbp),%eax
add    $0x100000,%eax
mov    %eax,-0x8(%rbp)
jmp    1198 <set_tick_and_enable_timer_TS+0x78>
mov    -0x8(%rbp),%eax
add    $0x80000,%eax
mov    %eax,-0x8(%rbp)
jmp    1198 <set_tick_and_enable_timer_TS+0x78>
mov    -0x8(%rbp),%eax
add    $0x40000,%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%esi
mov    $0x20003010,%edi
call   1030 <PUT32@plt>
mov    $0x20003000,%edi
mov    $0x2,%esi
call   1030 <PUT32@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<set_tick_and_enable_timer_TS>:
push   %rbx
mov    %edi,%ebx
mov    $0x20003004,%edi
call   1040 <GET32@plt>
cmp    $0x3,%ebx
ja     115e <set_tick_and_enable_timer_TS+0x3e>
mov    %ebx,%ecx
lea    0xec5(%rip),%rdx
movslq (%rdx,%rcx,4),%rcx
add    %rdx,%rcx
jmp    *%rcx
add    $0x200000,%eax
jmp    115e <set_tick_and_enable_timer_TS+0x3e>
add    $0x100000,%eax
jmp    115e <set_tick_and_enable_timer_TS+0x3e>
add    $0x80000,%eax
jmp    115e <set_tick_and_enable_timer_TS+0x3e>
add    $0x40000,%eax
mov    $0x20003010,%edi
mov    %eax,%esi
call   1030 <PUT32@plt>
mov    $0x20003000,%edi
mov    $0x2,%esi
pop    %rbx
jmp    1030 <PUT32@plt>

LLVM IR (-O0):
define void @set_tick_and_enable_timer_TS(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %2
%4 = call i32 @GET32(i32 536883204)
store i32 %4, i32* %3
%5 = load i32, i32* %2
switch i32 %5, label %18 [
i32 0, label %6
i32 1, label %9
i32 2, label %12
i32 3, label %15
]
6: ; preds = %1
%7 = load i32, i32* %3
%8 = add i32 %7, 2097152
store i32 %8, i32* %3
br label %18
9: ; preds = %1
%10 = load i32, i32* %3
%11 = add i32 %10, 1048576
store i32 %11, i32* %3
br label %18
12: ; preds = %1
%13 = load i32, i32* %3
%14 = add i32 %13, 524288
store i32 %14, i32* %3
br label %18
15: ; preds = %1
%16 = load i32, i32* %3
%17 = add i32 %16, 262144
store i32 %17, i32* %3
br label %18
18: ; preds = %1, %15, %12, %9, %6
%19 = load i32, i32* %3
%20 = call i32 @PUT32(i32 536883216, i32 %19)
%21 = call i32 @PUT32(i32 536883200, i32 2)
ret void
}

LLVM IR (-O2):
define void @set_tick_and_enable_timer_TS(i32 %0) {
%2 = tail call i32 @GET32(i32 536883204)
switch i32 %0, label %11 [
i32 0, label %3
i32 1, label %5
i32 2, label %7
i32 3, label %9
]
3: ; preds = %1
%4 = add i32 %2, 2097152
br label %11
5: ; preds = %1
%6 = add i32 %2, 1048576
br label %11
7: ; preds = %1
%8 = add i32 %2, 524288
br label %11
9: ; preds = %1
%10 = add i32 %2, 262144
br label %11
11: ; preds = %1, %9, %7, %5, %3
%12 = phi i32 [ %2, %1 ], [ %10, %9 ], [ %8, %7 ], [ %6, %5 ], [ %4, %3 ]
%13 = tail call i32 @PUT32(i32 536883216, i32 %12)
%14 = tail call i32 @PUT32(i32 536883200, i32 2)
ret void
}