#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*/ __set_irq(int, void (*)());
int /*<<< orphan*/ unmask_pic1(int);
int /*<<< orphan*/ unmask_pic2(int);
void __enable_hwirq(int hwirq, void (*func)(void)) {
  int vector;
  if (hwirq < 8) {
    unmask_pic1(1 << hwirq);
    vector = 0x08 + hwirq;
  } else {
    unmask_pic2(1 << (hwirq - 8));
    vector = 0x70 + hwirq - 8;
  }
  __set_irq(vector, func);
}


x86 assembly (clang, -O0):
<__enable_hwirq>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x8,-0x4(%rbp)
jge    1166 <__enable_hwirq+0x36>
mov    -0x4(%rbp),%ecx
mov    $0x1,%edi
shl    %cl,%edi
call   1030 <unmask_pic1@plt>
mov    -0x4(%rbp),%eax
add    $0x8,%eax
mov    %eax,-0x14(%rbp)
jmp    1184 <__enable_hwirq+0x54>
mov    -0x4(%rbp),%ecx
sub    $0x8,%ecx
mov    $0x1,%edi
shl    %cl,%edi
call   1050 <unmask_pic2@plt>
mov    -0x4(%rbp),%eax
add    $0x70,%eax
sub    $0x8,%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1040 <__set_irq@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<__enable_hwirq>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %edi,%ebx
cmp    $0x7,%edi
jg     1153 <__enable_hwirq+0x23>
mov    $0x1,%edi
mov    %ebx,%ecx
shl    %cl,%edi
call   1030 <unmask_pic1@plt>
mov    $0x8,%edi
jmp    1167 <__enable_hwirq+0x37>
lea    -0x8(%rbx),%ecx
mov    $0x1,%edi
shl    %cl,%edi
call   1050 <unmask_pic2@plt>
mov    $0x68,%edi
add    %ebx,%edi
mov    %r14,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1040 <__set_irq@plt>

LLVM IR (-O0):
define void @__enable_hwirq(i32 %0, void ()* %1) {
%3 = alloca i32
%4 = alloca void ()*
%5 = alloca i32
store i32 %0, i32* %3
store void ()* %1, void ()** %4
%6 = load i32, i32* %3
%7 = icmp slt i32 %6, 8
br i1 %7, label %8, label %14
8: ; preds = %2
%9 = load i32, i32* %3
%10 = shl i32 1, %9
%11 = call i32 @unmask_pic1(i32 %10)
%12 = load i32, i32* %3
%13 = add nsw i32 8, %12
store i32 %13, i32* %5
br label %22
14: ; preds = %2
%15 = load i32, i32* %3
%16 = sub nsw i32 %15, 8
%17 = shl i32 1, %16
%18 = call i32 @unmask_pic2(i32 %17)
%19 = load i32, i32* %3
%20 = add nsw i32 112, %19
%21 = sub nsw i32 %20, 8
store i32 %21, i32* %5
br label %22
22: ; preds = %14, %8
%23 = load i32, i32* %5
%24 = load void ()*, void ()** %4
%25 = bitcast void ()* %24 to void (...)*
%26 = call i32 @__set_irq(i32 %23, void (...)* %25)
ret void
}

LLVM IR (-O2):
define void @__enable_hwirq(i32 %0, void ()* %1) {
%3 = icmp slt i32 %0, 8
br i1 %3, label %4, label %7
4: ; preds = %2
%5 = shl nuw nsw i32 1, %0
%6 = tail call i32 @unmask_pic1(i32 %5)
br label %11
7: ; preds = %2
%8 = add nsw i32 %0, -8
%9 = shl nuw i32 1, %8
%10 = tail call i32 @unmask_pic2(i32 %9)
br label %11
11: ; preds = %7, %4
%12 = phi i32 [ 104, %7 ], [ 8, %4 ]
%13 = add nsw i32 %12, %0
%14 = bitcast void ()* %1 to void (...)*
%15 = tail call i32 @__set_irq(i32 %13, void (...)* %14)
ret void
}