#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 inportb(int);
int /*<<< orphan*/ outportb(int, unsigned char);
void remapPIC(int pic1, int pic2) {
  unsigned char md, sd;
  md = inportb(0x21);
  sd = inportb(0xA1);
  outportb(0x20, 0x20);
  outportb(0x20, 0x10 + 0x01);
  outportb(0xA0, 0x10 + 0x01);
  outportb(0x21, pic1);
  outportb(0xA1, pic2);
  outportb(0x21, 0x04);
  outportb(0xA1, 0x02);
  outportb(0x21, 0x01);
  outportb(0xA1, 0x01);
  outportb(0x21, md);
  outportb(0xA1, sd);
}


x86 assembly (clang, -O0):
<remapPIC>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    $0x21,%edi
call   1030 <inportb@plt>
mov    %al,-0x9(%rbp)
mov    $0xa1,%edi
call   1030 <inportb@plt>
mov    %al,-0xa(%rbp)
mov    $0x20,%esi
mov    %esi,%edi
call   1040 <outportb@plt>
mov    $0x20,%edi
mov    $0x11,%esi
call   1040 <outportb@plt>
mov    $0xa0,%edi
mov    $0x11,%esi
call   1040 <outportb@plt>
mov    -0x4(%rbp),%eax
mov    $0x21,%edi
movzbl %al,%esi
call   1040 <outportb@plt>
mov    -0x8(%rbp),%eax
mov    $0xa1,%edi
movzbl %al,%esi
call   1040 <outportb@plt>
mov    $0x21,%edi
mov    $0x4,%esi
call   1040 <outportb@plt>
mov    $0xa1,%edi
mov    $0x2,%esi
call   1040 <outportb@plt>
mov    $0x21,%edi
mov    $0x1,%esi
call   1040 <outportb@plt>
mov    $0xa1,%edi
mov    $0x1,%esi
call   1040 <outportb@plt>
mov    $0x21,%edi
movzbl -0x9(%rbp),%esi
call   1040 <outportb@plt>
mov    $0xa1,%edi
movzbl -0xa(%rbp),%esi
call   1040 <outportb@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<remapPIC>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %esi,%ebp
mov    %edi,%ebx
mov    $0x21,%edi
call   1030 <inportb@plt>
mov    %eax,%r14d
mov    $0xa1,%edi
call   1030 <inportb@plt>
mov    %eax,%r15d
mov    $0x20,%edi
mov    $0x20,%esi
call   1040 <outportb@plt>
mov    $0x20,%edi
mov    $0x11,%esi
call   1040 <outportb@plt>
mov    $0xa0,%edi
mov    $0x11,%esi
call   1040 <outportb@plt>
movzbl %bl,%esi
mov    $0x21,%edi
call   1040 <outportb@plt>
movzbl %bpl,%esi
mov    $0xa1,%edi
call   1040 <outportb@plt>
mov    $0x21,%edi
mov    $0x4,%esi
call   1040 <outportb@plt>
mov    $0xa1,%edi
mov    $0x2,%esi
call   1040 <outportb@plt>
mov    $0x21,%edi
mov    $0x1,%esi
call   1040 <outportb@plt>
mov    $0xa1,%edi
mov    $0x1,%esi
call   1040 <outportb@plt>
movzbl %r14b,%esi
mov    $0x21,%edi
call   1040 <outportb@plt>
movzbl %r15b,%esi
mov    $0xa1,%edi
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <outportb@plt>

LLVM IR (-O0):
define void @remapPIC(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8
%6 = alloca i8
store i32 %0, i32* %3
store i32 %1, i32* %4
%7 = call zeroext i8 @inportb(i32 33)
store i8 %7, i8* %5
%8 = call zeroext i8 @inportb(i32 161)
store i8 %8, i8* %6
%9 = call i32 @outportb(i32 32, i8 zeroext 32)
%10 = call i32 @outportb(i32 32, i8 zeroext 17)
%11 = call i32 @outportb(i32 160, i8 zeroext 17)
%12 = load i32, i32* %3
%13 = trunc i32 %12 to i8
%14 = call i32 @outportb(i32 33, i8 zeroext %13)
%15 = load i32, i32* %4
%16 = trunc i32 %15 to i8
%17 = call i32 @outportb(i32 161, i8 zeroext %16)
%18 = call i32 @outportb(i32 33, i8 zeroext 4)
%19 = call i32 @outportb(i32 161, i8 zeroext 2)
%20 = call i32 @outportb(i32 33, i8 zeroext 1)
%21 = call i32 @outportb(i32 161, i8 zeroext 1)
%22 = load i8, i8* %5
%23 = call i32 @outportb(i32 33, i8 zeroext %22)
%24 = load i8, i8* %6
%25 = call i32 @outportb(i32 161, i8 zeroext %24)
ret void
}

LLVM IR (-O2):
define void @remapPIC(i32 %0, i32 %1) {
%3 = tail call zeroext i8 @inportb(i32 33)
%4 = tail call zeroext i8 @inportb(i32 161)
%5 = tail call i32 @outportb(i32 32, i8 zeroext 32)
%6 = tail call i32 @outportb(i32 32, i8 zeroext 17)
%7 = tail call i32 @outportb(i32 160, i8 zeroext 17)
%8 = trunc i32 %0 to i8
%9 = tail call i32 @outportb(i32 33, i8 zeroext %8)
%10 = trunc i32 %1 to i8
%11 = tail call i32 @outportb(i32 161, i8 zeroext %10)
%12 = tail call i32 @outportb(i32 33, i8 zeroext 4)
%13 = tail call i32 @outportb(i32 161, i8 zeroext 2)
%14 = tail call i32 @outportb(i32 33, i8 zeroext 1)
%15 = tail call i32 @outportb(i32 161, i8 zeroext 1)
%16 = tail call i32 @outportb(i32 33, i8 zeroext %3)
%17 = tail call i32 @outportb(i32 161, i8 zeroext %4)
ret void
}