#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 */
int /*<<< orphan*/ usb_handle_int(int);
void usb_handle_interrupts(void) {
  while (1) {
    unsigned long ints;
    int i;
    ints = (*(volatile unsigned long *)((0x24100000) + 0x18)) &
           (*(volatile unsigned long *)((0x24100000) + 0x14));
    if (!ints)
      break;
    i = 0;
    while (!(ints & (1 << i)))
      i++;
    (*(volatile unsigned long *)((0x24100000) + 0x18)) = 1 << i;
    usb_handle_int(i);
  }
}


x86 assembly (clang, -O0):
<usb_handle_interrupts>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x24100018,%eax
mov    (%rax),%rax
mov    $0x24100014,%ecx
mov    (%rcx),%rcx
and    %rcx,%rax
mov    %rax,-0x8(%rbp)
cmpq   $0x0,-0x8(%rbp)
jne    113f <usb_handle_interrupts+0x2f>
jmp    11a2 <usb_handle_interrupts+0x92>
movl   $0x0,-0xc(%rbp)
mov    -0x8(%rbp),%rax
mov    -0xc(%rbp),%ecx
mov    $0x1,%edx
shl    %cl,%edx
mov    %edx,%ecx
movslq %ecx,%rcx
and    %rcx,%rax
cmp    $0x0,%rax
setne  %al
xor    $0xff,%al
test   $0x1,%al
jne    1172 <usb_handle_interrupts+0x62>
jmp    1180 <usb_handle_interrupts+0x70>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1146 <usb_handle_interrupts+0x36>
mov    -0xc(%rbp),%ecx
mov    $0x1,%eax
shl    %cl,%eax
movslq %eax,%rcx
mov    $0x24100018,%eax
mov    %rcx,(%rax)
mov    -0xc(%rbp),%edi
call   1030 <usb_handle_int@plt>
jmp    1118 <usb_handle_interrupts+0x8>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<usb_handle_interrupts>:
push   %rax
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    0x24100018,%rax
24
and    0x24100014,%rax
24
je     1163 <usb_handle_interrupts+0x53>
mov    $0xffffffff,%ecx
nopw   0x0(%rax,%rax,1)
add    $0x1,%ecx
mov    $0x1,%edx
shl    %cl,%edx
movslq %edx,%rdx
test   %rdx,%rax
je     1140 <usb_handle_interrupts+0x30>
mov    %rdx,0x24100018
24
mov    %ecx,%edi
call   1030 <usb_handle_int@plt>
jmp    1120 <usb_handle_interrupts+0x10>
pop    %rax
ret

LLVM IR (-O0):
define void @usb_handle_interrupts() {
%1 = alloca i64
%2 = alloca i32
br label %3
3: ; preds = %0, %22
%4 = load volatile i64, i64* inttoptr (i64 605028376 to i64*)
%5 = load volatile i64, i64* inttoptr (i64 605028372 to i64*)
%6 = and i64 %4, %5
store i64 %6, i64* %1
%7 = load i64, i64* %1
%8 = icmp ne i64 %7, 0
br i1 %8, label %10, label %9
9: ; preds = %3
br label %28
10: ; preds = %3
store i32 0, i32* %2
br label %11
11: ; preds = %19, %10
%12 = load i64, i64* %1
%13 = load i32, i32* %2
%14 = shl i32 1, %13
%15 = sext i32 %14 to i64
%16 = and i64 %12, %15
%17 = icmp ne i64 %16, 0
%18 = xor i1 %17, true
br i1 %18, label %19, label %22
19: ; preds = %11
%20 = load i32, i32* %2
%21 = add nsw i32 %20, 1
store i32 %21, i32* %2
br label %11
22: ; preds = %11
%23 = load i32, i32* %2
%24 = shl i32 1, %23
%25 = sext i32 %24 to i64
store volatile i64 %25, i64* inttoptr (i64 605028376 to i64*)
%26 = load i32, i32* %2
%27 = call i32 @usb_handle_int(i32 %26)
br label %3
28: ; preds = %9
ret void
}

LLVM IR (-O2):
define void @usb_handle_interrupts() {
%1 = load volatile i64, i64* inttoptr (i64 605028376 to i64*)
%2 = load volatile i64, i64* inttoptr (i64 605028372 to i64*)
%3 = and i64 %2, %1
%4 = icmp eq i64 %3, 0
br i1 %4, label %20, label %5
5: ; preds = %0, %14
%6 = phi i64 [ %18, %14 ], [ %3, %0 ]
br label %7
7: ; preds = %7, %5
%8 = phi i32 [ %13, %7 ], [ 0, %5 ]
%9 = shl nuw i32 1, %8
%10 = sext i32 %9 to i64
%11 = and i64 %6, %10
%12 = icmp eq i64 %11, 0
%13 = add nuw nsw i32 %8, 1
br i1 %12, label %7, label %14
14: ; preds = %7
store volatile i64 %10, i64* inttoptr (i64 605028376 to i64*)
%15 = tail call i32 @usb_handle_int(i32 %8)
%16 = load volatile i64, i64* inttoptr (i64 605028376 to i64*)
%17 = load volatile i64, i64* inttoptr (i64 605028372 to i64*)
%18 = and i64 %17, %16
%19 = icmp eq i64 %18, 0
br i1 %19, label %20, label %5
20: ; preds = %14, %0
ret void
}