#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*/ outb(int, int);
void serial_init_port(int port) {
  outb(0x00, port + 1);
  outb((0x01 << 3), port + 3);
  outb(0x03, port + 0);
  outb(0x00, port + 1);
  outb((0x01 << 0) * 3, port + 3);
  outb((0x01 << 0) | (0x01 << 1) | (0x01 << 2) | (0x01 << 6) | (0x01 << 7),
       port + 2);
  outb((0x01 << 0) | (0x01 << 1) | (0x01 << 3), port + 4);
}


x86 assembly (clang, -O0):
<serial_init_port>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%esi
add    $0x1,%esi
xor    %edi,%edi
call   1030 <outb@plt>
mov    -0x4(%rbp),%esi
add    $0x3,%esi
mov    $0x8,%edi
call   1030 <outb@plt>
mov    -0x4(%rbp),%esi
add    $0x0,%esi
mov    $0x3,%edi
call   1030 <outb@plt>
mov    -0x4(%rbp),%esi
add    $0x1,%esi
xor    %edi,%edi
call   1030 <outb@plt>
mov    -0x4(%rbp),%esi
add    $0x3,%esi
mov    $0x3,%edi
call   1030 <outb@plt>
mov    -0x4(%rbp),%esi
add    $0x2,%esi
mov    $0xc7,%edi
call   1030 <outb@plt>
mov    -0x4(%rbp),%esi
add    $0x4,%esi
mov    $0xb,%edi
call   1030 <outb@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<serial_init_port>:
push   %rbp
push   %r14
push   %rbx
mov    %edi,%ebx
lea    0x1(%rbx),%r14d
xor    %edi,%edi
mov    %r14d,%esi
call   1030 <outb@plt>
lea    0x3(%rbx),%ebp
mov    $0x8,%edi
mov    %ebp,%esi
call   1030 <outb@plt>
mov    $0x3,%edi
mov    %ebx,%esi
call   1030 <outb@plt>
xor    %edi,%edi
mov    %r14d,%esi
call   1030 <outb@plt>
mov    $0x3,%edi
mov    %ebp,%esi
call   1030 <outb@plt>
lea    0x2(%rbx),%esi
mov    $0xc7,%edi
call   1030 <outb@plt>
add    $0x4,%ebx
mov    $0xb,%edi
mov    %ebx,%esi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1030 <outb@plt>

LLVM IR (-O0):
define void @serial_init_port(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = load i32, i32* %2
%4 = add nsw i32 %3, 1
%5 = call i32 @outb(i32 0, i32 %4)
%6 = load i32, i32* %2
%7 = add nsw i32 %6, 3
%8 = call i32 @outb(i32 8, i32 %7)
%9 = load i32, i32* %2
%10 = add nsw i32 %9, 0
%11 = call i32 @outb(i32 3, i32 %10)
%12 = load i32, i32* %2
%13 = add nsw i32 %12, 1
%14 = call i32 @outb(i32 0, i32 %13)
%15 = load i32, i32* %2
%16 = add nsw i32 %15, 3
%17 = call i32 @outb(i32 3, i32 %16)
%18 = load i32, i32* %2
%19 = add nsw i32 %18, 2
%20 = call i32 @outb(i32 199, i32 %19)
%21 = load i32, i32* %2
%22 = add nsw i32 %21, 4
%23 = call i32 @outb(i32 11, i32 %22)
ret void
}

LLVM IR (-O2):
define void @serial_init_port(i32 %0) {
%2 = add nsw i32 %0, 1
%3 = tail call i32 @outb(i32 0, i32 %2)
%4 = add nsw i32 %0, 3
%5 = tail call i32 @outb(i32 8, i32 %4)
%6 = tail call i32 @outb(i32 3, i32 %0)
%7 = tail call i32 @outb(i32 0, i32 %2)
%8 = tail call i32 @outb(i32 3, i32 %4)
%9 = add nsw i32 %0, 2
%10 = tail call i32 @outb(i32 199, i32 %9)
%11 = add nsw i32 %0, 4
%12 = tail call i32 @outb(i32 11, i32 %11)
ret void
}