#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 */
unsigned char inb(int);
int /*<<< orphan*/ outb(int, unsigned char);
void disable_irq(unsigned char irq) {
  unsigned char mask_master, mask_slave;
  mask_master = inb(0x21);
  mask_slave = inb(0xa1);
  if (irq > 7) {
    outb(0xa1, mask_slave | (1 << (irq - 8)));
  } else {
    outb(0x21, mask_master | (1 << irq));
  }
}


x86 assembly (clang, -O0):
<disable_irq>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %dil,%al
mov    %al,-0x1(%rbp)
mov    $0x21,%edi
call   1040 <inb@plt>
mov    %al,-0x2(%rbp)
mov    $0xa1,%edi
call   1040 <inb@plt>
mov    %al,-0x3(%rbp)
movzbl -0x1(%rbp),%eax
cmp    $0x7,%eax
jle    117d <disable_irq+0x5d>
movzbl -0x3(%rbp),%eax
movzbl -0x1(%rbp),%ecx
sub    $0x8,%ecx
mov    $0x1,%edx
shl    %cl,%edx
mov    %edx,%ecx
or     %ecx,%eax
mov    $0xa1,%edi
movzbl %al,%esi
call   1030 <outb@plt>
jmp    119d <disable_irq+0x7d>
movzbl -0x2(%rbp),%eax
movzbl -0x1(%rbp),%ecx
mov    $0x1,%edx
shl    %cl,%edx
mov    %edx,%ecx
or     %ecx,%eax
mov    $0x21,%edi
movzbl %al,%esi
call   1030 <outb@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<disable_irq>:
push   %rbp
push   %rbx
push   %rax
mov    %edi,%ebx
mov    $0x21,%edi
call   1040 <inb@plt>
mov    %eax,%ebp
mov    $0xa1,%edi
call   1040 <inb@plt>
lea    -0x8(%rbx),%ecx
xor    %edi,%edi
cmp    $0x8,%bl
movzbl %bpl,%edx
movzbl %al,%eax
cmovb  %edx,%eax
setae  %dil
movzbl %cl,%ecx
cmovb  %ebx,%ecx
shl    $0x7,%edi
or     $0x21,%edi
bts    %ecx,%eax
movzbl %al,%esi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1030 <outb@plt>

LLVM IR (-O0):
define void @disable_irq(i8 zeroext %0) {
%2 = alloca i8
%3 = alloca i8
%4 = alloca i8
store i8 %0, i8* %2
%5 = call zeroext i8 @inb(i32 33)
store i8 %5, i8* %3
%6 = call zeroext i8 @inb(i32 161)
store i8 %6, i8* %4
%7 = load i8, i8* %2
%8 = zext i8 %7 to i32
%9 = icmp sgt i32 %8, 7
br i1 %9, label %10, label %20
10: ; preds = %1
%11 = load i8, i8* %4
%12 = zext i8 %11 to i32
%13 = load i8, i8* %2
%14 = zext i8 %13 to i32
%15 = sub nsw i32 %14, 8
%16 = shl i32 1, %15
%17 = or i32 %12, %16
%18 = trunc i32 %17 to i8
%19 = call i32 @outb(i32 161, i8 zeroext %18)
br label %29
20: ; preds = %1
%21 = load i8, i8* %3
%22 = zext i8 %21 to i32
%23 = load i8, i8* %2
%24 = zext i8 %23 to i32
%25 = shl i32 1, %24
%26 = or i32 %22, %25
%27 = trunc i32 %26 to i8
%28 = call i32 @outb(i32 33, i8 zeroext %27)
br label %29
29: ; preds = %20, %10
ret void
}

LLVM IR (-O2):
define void @disable_irq(i8 zeroext %0) {
%2 = tail call zeroext i8 @inb(i32 33)
%3 = tail call zeroext i8 @inb(i32 161)
%4 = zext i8 %0 to i32
%5 = icmp ugt i8 %0, 7
%6 = add nsw i32 %4, -8
%7 = select i1 %5, i32 %6, i32 %4
%8 = select i1 %5, i8 %3, i8 %2
%9 = select i1 %5, i32 161, i32 33
%10 = shl nuw i32 1, %7
%11 = trunc i32 %10 to i8
%12 = or i8 %8, %11
%13 = tail call i32 @outb(i32 %9, i8 zeroext %12)
ret void
}