#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 */
typedef int uint16_t;

/* Variables and functions */
int /*<<< orphan*/ outb(int, unsigned char);
int /*<<< orphan*/ pause();
scalar_t__ serial_transmit_empty(int);
void serial_write_com(int com, unsigned char data) {
  uint16_t port;
  switch (com) {
  case 1:
    port = 0x3F8;
    break;
  case 2:
    port = 0x2F8;
    break;
  default:
    return;
  }
  while (serial_transmit_empty(port) == 0)
    pause();
  outb(port, data);
}


x86 assembly (clang, -O0):
<serial_write_com>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %sil,%al
mov    %edi,-0x4(%rbp)
mov    %al,-0x5(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0x10(%rbp)
sub    $0x1,%eax
je     1166 <serial_write_com+0x36>
jmp    1155 <serial_write_com+0x25>
mov    -0x10(%rbp),%eax
sub    $0x2,%eax
je     1172 <serial_write_com+0x42>
jmp    117e <serial_write_com+0x4e>
movl   $0x3f8,-0xc(%rbp)
jmp    1183 <serial_write_com+0x53>
movl   $0x2f8,-0xc(%rbp)
jmp    1183 <serial_write_com+0x53>
jmp    11b2 <serial_write_com+0x82>
jmp    1188 <serial_write_com+0x58>
mov    -0xc(%rbp),%edi
call   1040 <serial_transmit_empty@plt>
cmp    $0x0,%rax
jne    11a6 <serial_write_com+0x76>
mov    $0x0,%al
call   1050 <pause@plt>
jmp    1188 <serial_write_com+0x58>
mov    -0xc(%rbp),%edi
movzbl -0x5(%rbp),%esi
call   1030 <outb@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<serial_write_com>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebx
cmp    $0x1,%edi
je     1146 <serial_write_com+0x16>
cmp    $0x2,%edi
jne    1173 <serial_write_com+0x43>
mov    $0x2f8,%ebp
jmp    1157 <serial_write_com+0x27>
mov    $0x3f8,%ebp
jmp    1157 <serial_write_com+0x27>
nopl   (%rax)
xor    %eax,%eax
call   1050 <pause@plt>
mov    %ebp,%edi
call   1040 <serial_transmit_empty@plt>
test   %rax,%rax
je     1150 <serial_write_com+0x20>
movzbl %bl,%esi
mov    %ebp,%edi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1030 <outb@plt>
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define void @serial_write_com(i32 %0, i8 zeroext %1) {
%3 = alloca i32
%4 = alloca i8
%5 = alloca i32
store i32 %0, i32* %3
store i8 %1, i8* %4
%6 = load i32, i32* %3
switch i32 %6, label %9 [
i32 1, label %7
i32 2, label %8
]
7: ; preds = %2
store i32 1016, i32* %5
br label %10
8: ; preds = %2
store i32 760, i32* %5
br label %10
9: ; preds = %2
br label %21
10: ; preds = %8, %7
br label %11
11: ; preds = %15, %10
%12 = load i32, i32* %5
%13 = call i64 @serial_transmit_empty(i32 %12)
%14 = icmp eq i64 %13, 0
br i1 %14, label %15, label %17
15: ; preds = %11
%16 = call i32 (...) @pause()
br label %11
17: ; preds = %11
%18 = load i32, i32* %5
%19 = load i8, i8* %4
%20 = call i32 @outb(i32 %18, i8 zeroext %19)
br label %21
21: ; preds = %17, %9
ret void
}

LLVM IR (-O2):
define void @serial_write_com(i32 %0, i8 zeroext %1) {
switch i32 %0, label %14 [
i32 1, label %4
i32 2, label %3
]
3: ; preds = %2
br label %4
4: ; preds = %2, %3
%5 = phi i32 [ 760, %3 ], [ 1016, %2 ]
%6 = tail call i64 @serial_transmit_empty(i32 %5)
%7 = icmp eq i64 %6, 0
br i1 %7, label %8, label %12
8: ; preds = %4, %8
%9 = tail call i32 (...) @pause()
%10 = tail call i64 @serial_transmit_empty(i32 %5)
%11 = icmp eq i64 %10, 0
br i1 %11, label %8, label %12
12: ; preds = %8, %4
%13 = tail call i32 @outb(i32 %5, i8 zeroext %1)
br label %14
14: ; preds = %2, %12
ret void
}