#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 CANIntClear(uint32_t ui32Base, uint32_t ui32IntClr) {
  ;

  ;
  if (ui32IntClr == 0x00008000) {
    (*((volatile unsigned long *)(ui32Base + 0x00000004)));
  } else {
    while ((*((volatile unsigned long *)(ui32Base + 0x00000020))) &
           0x00008000) {
    }
    (*((volatile unsigned long *)(ui32Base + 0x00000024))) = 0x00000008;
    (*((volatile unsigned long *)(ui32Base + 0x00000020))) =
        ui32IntClr & 0x0000003F;
    while ((*((volatile unsigned long *)(ui32Base + 0x00000020))) &
           0x00008000) {
    }
  }
}


x86 assembly (clang, -O0):
<CANIntClear>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
cmpl   $0x8000,-0x8(%rbp)
jne    1127 <CANIntClear+0x27>
mov    -0x4(%rbp),%eax
add    $0x4,%eax
cltq
mov    (%rax),%rax
jmp    1194 <CANIntClear+0x94>
jmp    112c <CANIntClear+0x2c>
mov    -0x4(%rbp),%eax
add    $0x20,%eax
cltq
mov    (%rax),%rax
and    $0x8000,%rax
cmp    $0x0,%rax
je     114c <CANIntClear+0x4c>
jmp    112c <CANIntClear+0x2c>
mov    -0x4(%rbp),%eax
add    $0x24,%eax
cltq
movq   $0x8,(%rax)
mov    -0x8(%rbp),%eax
and    $0x3f,%eax
movslq %eax,%rcx
mov    -0x4(%rbp),%eax
add    $0x20,%eax
cltq
mov    %rcx,(%rax)
mov    -0x4(%rbp),%eax
add    $0x20,%eax
cltq
mov    (%rax),%rax
and    $0x8000,%rax
cmp    $0x0,%rax
je     118f <CANIntClear+0x8f>
jmp    116f <CANIntClear+0x6f>
jmp    1194 <CANIntClear+0x94>
pop    %rbp
ret

x86 assembly (clang, -O2):
<CANIntClear>:
movslq %edi,%rax
cmp    $0x8000,%esi
jne    1110 <CANIntClear+0x10>
mov    0x4(%rax),%rax
ret
testq  $0x8000,0x20(%rax)
jne    1110 <CANIntClear+0x10>
movq   $0x8,0x24(%rax)
and    $0x3f,%esi
mov    %rsi,0x20(%rax)
nopl   0x0(%rax)
testq  $0x8000,0x20(%rax)
jne    1130 <CANIntClear+0x30>
ret

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

LLVM IR (-O2):
define void @CANIntClear(i32 %0, i32 %1) {
%3 = icmp eq i32 %1, 32768
br i1 %3, label %8, label %4
4: ; preds = %2
%5 = add nsw i32 %0, 32
%6 = sext i32 %5 to i64
%7 = inttoptr i64 %6 to i64*
br label %13
8: ; preds = %2
%9 = add nsw i32 %0, 4
%10 = sext i32 %9 to i64
%11 = inttoptr i64 %10 to i64*
%12 = load volatile i64, i64* %11
br label %27
13: ; preds = %4, %13
%14 = load volatile i64, i64* %7
%15 = and i64 %14, 32768
%16 = icmp eq i64 %15, 0
br i1 %16, label %17, label %13
17: ; preds = %13
%18 = add nsw i32 %0, 36
%19 = sext i32 %18 to i64
%20 = inttoptr i64 %19 to i64*
store volatile i64 8, i64* %20
%21 = and i32 %1, 63
%22 = zext i32 %21 to i64
store volatile i64 %22, i64* %7
br label %23
23: ; preds = %23, %17
%24 = load volatile i64, i64* %7
%25 = and i64 %24, 32768
%26 = icmp eq i64 %25, 0
br i1 %26, label %27, label %23
27: ; preds = %23, %8
ret void
}