#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 in8(int);
int /*<<< orphan*/ out8(int, int);
int /*<<< orphan*/ printf(char *, int);
void pic_unmask(int interrupt_id) {
  if (((interrupt_id) >= 0x20 && (interrupt_id) < 0x20 + 8)) {
    interrupt_id -= 0x20;
    out8(0x21, in8(0x21) & ~(1 << interrupt_id));
  } else if (((interrupt_id) >= 0x28 && (interrupt_id) < 0x28 + 8)) {
    interrupt_id -= 0x28;
    out8(0xA1, in8(0xA1) & ~(1 << interrupt_id));
  } else {
    printf("Invalid call: pic_unmask(%d)", interrupt_id);
  }
}


x86 assembly (clang, -O0):
<pic_unmask>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
cmpl   $0x20,-0x4(%rbp)
jl     1182 <pic_unmask+0x52>
cmpl   $0x28,-0x4(%rbp)
jge    1182 <pic_unmask+0x52>
mov    -0x4(%rbp),%eax
sub    $0x20,%eax
mov    %eax,-0x4(%rbp)
mov    $0x21,%edi
call   1050 <in8@plt>
mov    %eax,%esi
mov    -0x4(%rbp),%ecx
mov    $0x1,%eax
shl    %cl,%eax
xor    $0xffffffff,%eax
and    %eax,%esi
mov    $0x21,%edi
call   1040 <out8@plt>
jmp    11dd <pic_unmask+0xad>
cmpl   $0x28,-0x4(%rbp)
jl     11c9 <pic_unmask+0x99>
cmpl   $0x30,-0x4(%rbp)
jge    11c9 <pic_unmask+0x99>
mov    -0x4(%rbp),%eax
sub    $0x28,%eax
mov    %eax,-0x4(%rbp)
mov    $0xa1,%edi
call   1050 <in8@plt>
mov    %eax,%esi
mov    -0x4(%rbp),%ecx
mov    $0x1,%eax
shl    %cl,%eax
xor    $0xffffffff,%eax
and    %eax,%esi
mov    $0xa1,%edi
call   1040 <out8@plt>
jmp    11d8 <pic_unmask+0xa8>
mov    -0x4(%rbp),%esi
lea    0xe2d(%rip),%rdi
call   1030 <printf@plt>
jmp    11dd <pic_unmask+0xad>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pic_unmask>:
push   %rbx
mov    %edi,%ebx
mov    %edi,%eax
and    $0xfffffff8,%eax
cmp    $0x28,%eax
je     1159 <pic_unmask+0x29>
cmp    $0x20,%eax
jne    1176 <pic_unmask+0x46>
mov    $0x21,%edi
call   1050 <in8@plt>
add    $0xe0,%bl
btr    %ebx,%eax
mov    $0x21,%edi
jmp    116e <pic_unmask+0x3e>
mov    $0xa1,%edi
call   1050 <in8@plt>
add    $0xd8,%bl
btr    %ebx,%eax
mov    $0xa1,%edi
mov    %eax,%esi
pop    %rbx
jmp    1040 <out8@plt>
lea    0xe83(%rip),%rdi
mov    %ebx,%esi
pop    %rbx
jmp    1030 <printf@plt>

LLVM IR (-O0):
@.str = [29 x i8] c"Invalid call: pic_unmask(%d)\00"
define void @pic_unmask(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = load i32, i32* %2
%4 = icmp sge i32 %3, 32
br i1 %4, label %5, label %17
5: ; preds = %1
%6 = load i32, i32* %2
%7 = icmp slt i32 %6, 40
br i1 %7, label %8, label %17
8: ; preds = %5
%9 = load i32, i32* %2
%10 = sub nsw i32 %9, 32
store i32 %10, i32* %2
%11 = call i32 @in8(i32 33)
%12 = load i32, i32* %2
%13 = shl i32 1, %12
%14 = xor i32 %13, -1
%15 = and i32 %11, %14
%16 = call i32 @out8(i32 33, i32 %15)
br label %36
17: ; preds = %5, %1
%18 = load i32, i32* %2
%19 = icmp sge i32 %18, 40
br i1 %19, label %20, label %32
20: ; preds = %17
%21 = load i32, i32* %2
%22 = icmp slt i32 %21, 48
br i1 %22, label %23, label %32
23: ; preds = %20
%24 = load i32, i32* %2
%25 = sub nsw i32 %24, 40
store i32 %25, i32* %2
%26 = call i32 @in8(i32 161)
%27 = load i32, i32* %2
%28 = shl i32 1, %27
%29 = xor i32 %28, -1
%30 = and i32 %26, %29
%31 = call i32 @out8(i32 161, i32 %30)
br label %35
32: ; preds = %20, %17
%33 = load i32, i32* %2
%34 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i32 %33)
br label %35
35: ; preds = %32, %23
br label %36
36: ; preds = %35, %8
ret void
}

LLVM IR (-O2):
@.str = [29 x i8] c"Invalid call: pic_unmask(%d)\00"
define void @pic_unmask(i32 %0) {
%2 = and i32 %0, -8
switch i32 %2, label %17 [
i32 32, label %3
i32 40, label %10
]
3: ; preds = %1
%4 = add nsw i32 %0, -32
%5 = tail call i32 @in8(i32 33)
%6 = shl nuw nsw i32 1, %4
%7 = xor i32 %6, -1
%8 = and i32 %5, %7
%9 = tail call i32 @out8(i32 33, i32 %8)
br label %19
10: ; preds = %1
%11 = add nsw i32 %0, -40
%12 = tail call i32 @in8(i32 161)
%13 = shl nuw nsw i32 1, %11
%14 = xor i32 %13, -1
%15 = and i32 %12, %14
%16 = tail call i32 @out8(i32 161, i32 %15)
br label %19
17: ; preds = %1
%18 = tail call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i32 %0)
br label %19
19: ; preds = %10, %17, %3
ret void
}