#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 uint32_t *)(ui32Base + 0x00000004)));
  } else {
    while ((*((volatile uint32_t *)(ui32Base + 0x00000020))) & 0x00008000) {
    }
    (*((volatile uint32_t *)(ui32Base + 0x00000024))) = 0x00000008;
    (*((volatile uint32_t *)(ui32Base + 0x00000020))) = ui32IntClr & 0x0000003F;
    while ((*((volatile uint32_t *)(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    1126 <CANIntClear+0x26>
mov    -0x4(%rbp),%eax
add    $0x4,%eax
cltq
mov    (%rax),%eax
jmp    1188 <CANIntClear+0x88>
jmp    112b <CANIntClear+0x2b>
mov    -0x4(%rbp),%eax
add    $0x20,%eax
cltq
mov    (%rax),%eax
and    $0x8000,%eax
cmp    $0x0,%eax
je     1148 <CANIntClear+0x48>
jmp    112b <CANIntClear+0x2b>
mov    -0x4(%rbp),%eax
add    $0x24,%eax
cltq
movl   $0x8,(%rax)
mov    -0x8(%rbp),%ecx
and    $0x3f,%ecx
mov    -0x4(%rbp),%eax
add    $0x20,%eax
cltq
mov    %ecx,(%rax)
mov    -0x4(%rbp),%eax
add    $0x20,%eax
cltq
mov    (%rax),%eax
and    $0x8000,%eax
cmp    $0x0,%eax
je     1183 <CANIntClear+0x83>
jmp    1166 <CANIntClear+0x66>
jmp    1188 <CANIntClear+0x88>
pop    %rbp
ret

x86 assembly (clang, -O2):
<CANIntClear>:
movslq %edi,%rax
cmp    $0x8000,%esi
jne    1110 <CANIntClear+0x10>
mov    0x4(%rax),%eax
ret
nop
testl  $0x8000,0x20(%rax)
jne    1110 <CANIntClear+0x10>
movl   $0x8,0x24(%rax)
and    $0x3f,%esi
mov    %esi,0x20(%rax)
cs nopw 0x0(%rax,%rax,1)
testl  $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 i32*
%12 = load volatile i32, i32* %11
br label %44
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 i32*
%19 = load volatile i32, i32* %18
%20 = and i32 %19, 32768
%21 = icmp ne i32 %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 i32*
store volatile i32 8, i32* %27
%28 = load i32, i32* %4
%29 = and i32 %28, 63
%30 = load i32, i32* %3
%31 = add nsw i32 %30, 32
%32 = sext i32 %31 to i64
%33 = inttoptr i64 %32 to i32*
store volatile i32 %29, i32* %33
br label %34
34: ; preds = %42, %23
%35 = load i32, i32* %3
%36 = add nsw i32 %35, 32
%37 = sext i32 %36 to i64
%38 = inttoptr i64 %37 to i32*
%39 = load volatile i32, i32* %38
%40 = and i32 %39, 32768
%41 = icmp ne i32 %40, 0
br i1 %41, label %42, label %43
42: ; preds = %34
br label %34
43: ; preds = %34
br label %44
44: ; preds = %43, %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 i32*
br label %13
8: ; preds = %2
%9 = add nsw i32 %0, 4
%10 = sext i32 %9 to i64
%11 = inttoptr i64 %10 to i32*
%12 = load volatile i32, i32* %11
br label %26
13: ; preds = %4, %13
%14 = load volatile i32, i32* %7
%15 = and i32 %14, 32768
%16 = icmp eq i32 %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 i32*
store volatile i32 8, i32* %20
%21 = and i32 %1, 63
store volatile i32 %21, i32* %7
br label %22
22: ; preds = %22, %17
%23 = load volatile i32, i32* %7
%24 = and i32 %23, 32768
%25 = icmp eq i32 %24, 0
br i1 %25, label %26, label %22
26: ; preds = %22, %8
ret void
}