#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 */
void TimerUpdateMode(uint32_t ui32Base, uint32_t ui32Timer,
                     uint32_t ui32Config) {
  uint32_t ui32Value;
  if ((ui32Timer & 0x000000ff) == 0x000000ff) {
    ui32Value =
        (*((volatile uint32_t *)(ui32Base + 0x00000004))) & ~(0x00000500);
    ui32Value |= ui32Config;
    (*((volatile uint32_t *)(ui32Base + 0x00000004))) = ui32Value;
  }
  if ((ui32Timer & 0x0000ff00) == 0x0000ff00) {
    ui32Value =
        (*((volatile uint32_t *)(ui32Base + 0x00000008))) & ~(0x00000500);
    ui32Value |= ui32Config;
    (*((volatile uint32_t *)(ui32Base + 0x00000008))) = ui32Value;
  }
}


x86 assembly (clang, -O0):
<TimerUpdateMode>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    -0x8(%rbp),%eax
and    $0xff,%eax
cmp    $0xff,%eax
jne    1148 <TimerUpdateMode+0x48>
mov    -0x4(%rbp),%eax
add    $0x4,%eax
cltq
mov    (%rax),%eax
and    $0xfffffaff,%eax
mov    %eax,-0x10(%rbp)
mov    -0xc(%rbp),%eax
or     -0x10(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%ecx
mov    -0x4(%rbp),%eax
add    $0x4,%eax
cltq
mov    %ecx,(%rax)
mov    -0x8(%rbp),%eax
and    $0xff00,%eax
cmp    $0xff00,%eax
jne    1183 <TimerUpdateMode+0x83>
mov    -0x4(%rbp),%eax
add    $0x8,%eax
cltq
mov    (%rax),%eax
and    $0xfffffaff,%eax
mov    %eax,-0x10(%rbp)
mov    -0xc(%rbp),%eax
or     -0x10(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%ecx
mov    -0x4(%rbp),%eax
add    $0x8,%eax
cltq
mov    %ecx,(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<TimerUpdateMode>:
movslq %edi,%rax
cmp    $0xff,%sil
jne    1116 <TimerUpdateMode+0x16>
mov    $0xfffffaff,%ecx
and    0x4(%rax),%ecx
or     %edx,%ecx
mov    %ecx,0x4(%rax)
not    %esi
test   $0xff00,%esi
jne    112d <TimerUpdateMode+0x2d>
mov    $0xfffffaff,%ecx
and    0x8(%rax),%ecx
or     %edx,%ecx
mov    %ecx,0x8(%rax)
ret

LLVM IR (-O0):
define void @TimerUpdateMode(i32 %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%8 = load i32, i32* %5
%9 = and i32 %8, 255
%10 = icmp eq i32 %9, 255
br i1 %10, label %11, label %26
11: ; preds = %3
%12 = load i32, i32* %4
%13 = add nsw i32 %12, 4
%14 = sext i32 %13 to i64
%15 = inttoptr i64 %14 to i32*
%16 = load volatile i32, i32* %15
%17 = and i32 %16, -1281
store i32 %17, i32* %7
%18 = load i32, i32* %6
%19 = load i32, i32* %7
%20 = or i32 %19, %18
store i32 %20, i32* %7
%21 = load i32, i32* %7
%22 = load i32, i32* %4
%23 = add nsw i32 %22, 4
%24 = sext i32 %23 to i64
%25 = inttoptr i64 %24 to i32*
store volatile i32 %21, i32* %25
br label %26
26: ; preds = %11, %3
%27 = load i32, i32* %5
%28 = and i32 %27, 65280
%29 = icmp eq i32 %28, 65280
br i1 %29, label %30, label %45
30: ; preds = %26
%31 = load i32, i32* %4
%32 = add nsw i32 %31, 8
%33 = sext i32 %32 to i64
%34 = inttoptr i64 %33 to i32*
%35 = load volatile i32, i32* %34
%36 = and i32 %35, -1281
store i32 %36, i32* %7
%37 = load i32, i32* %6
%38 = load i32, i32* %7
%39 = or i32 %38, %37
store i32 %39, i32* %7
%40 = load i32, i32* %7
%41 = load i32, i32* %4
%42 = add nsw i32 %41, 8
%43 = sext i32 %42 to i64
%44 = inttoptr i64 %43 to i32*
store volatile i32 %40, i32* %44
br label %45
45: ; preds = %30, %26
ret void
}

LLVM IR (-O2):
define void @TimerUpdateMode(i32 %0, i32 %1, i32 %2) {
%4 = and i32 %1, 255
%5 = icmp eq i32 %4, 255
br i1 %5, label %6, label %13
6: ; preds = %3
%7 = add nsw i32 %0, 4
%8 = sext i32 %7 to i64
%9 = inttoptr i64 %8 to i32*
%10 = load volatile i32, i32* %9
%11 = and i32 %10, -1281
%12 = or i32 %11, %2
store volatile i32 %12, i32* %9
br label %13
13: ; preds = %6, %3
%14 = and i32 %1, 65280
%15 = icmp eq i32 %14, 65280
br i1 %15, label %16, label %23
16: ; preds = %13
%17 = add nsw i32 %0, 8
%18 = sext i32 %17 to i64
%19 = inttoptr i64 %18 to i32*
%20 = load volatile i32, i32* %19
%21 = and i32 %20, -1281
%22 = or i32 %21, %2
store volatile i32 %22, i32* %19
br label %23
23: ; preds = %16, %13
ret void
}