#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 */
scalar_t__ inb(int);
int /*<<< orphan*/ outb(int, int);
void uart_init_line(int offset, int baud) {
  int i;
  int baudconst;
  switch (baud) {
  case 56000:
    baudconst = 2;
    break;
  case 38400:
    baudconst = 3;
    break;
  case 19200:
    baudconst = 6;
    break;
  case 9600:
    baudconst = 12;
    break;
  case 4800:
    baudconst = 24;
    break;
  case 2400:
    baudconst = 48;
    break;
  case 1200:
    baudconst = 96;
    break;
  case 300:
    baudconst = 384;
    break;
  case 150:
    baudconst = 768;
    break;
  default:
    baudconst = 12;
    break;
  }
  outb(0x87, 0x2fb + offset);
  outb(0, 0x2f9 + offset);
  outb(baudconst, 0x2f8 + offset);
  outb(0x07, 0x2fb + offset);
  outb(0x0F, 0x2fc + offset);
  for (i = 10; i > 0; i--) {
    if (inb(0x2fd + offset) == 0)
      break;
    inb(0x2f8 + offset);
  }
}


x86 assembly (clang, -O0):
<uart_init_line>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x14(%rbp)
sub    $0x96,%eax
je     123c <uart_init_line+0x11c>
jmp    1144 <uart_init_line+0x24>
mov    -0x14(%rbp),%eax
sub    $0x12c,%eax
je     1230 <uart_init_line+0x110>
jmp    1157 <uart_init_line+0x37>
mov    -0x14(%rbp),%eax
sub    $0x4b0,%eax
je     1224 <uart_init_line+0x104>
jmp    116a <uart_init_line+0x4a>
mov    -0x14(%rbp),%eax
sub    $0x960,%eax
je     1218 <uart_init_line+0xf8>
jmp    117d <uart_init_line+0x5d>
mov    -0x14(%rbp),%eax
sub    $0x12c0,%eax
je     120c <uart_init_line+0xec>
jmp    1190 <uart_init_line+0x70>
mov    -0x14(%rbp),%eax
sub    $0x2580,%eax
je     1200 <uart_init_line+0xe0>
jmp    11a3 <uart_init_line+0x83>
mov    -0x14(%rbp),%eax
sub    $0x4b00,%eax
je     11f4 <uart_init_line+0xd4>
jmp    11b6 <uart_init_line+0x96>
mov    -0x14(%rbp),%eax
sub    $0x9600,%eax
je     11e8 <uart_init_line+0xc8>
jmp    11c9 <uart_init_line+0xa9>
mov    -0x14(%rbp),%eax
sub    $0xdac0,%eax
jne    1248 <uart_init_line+0x128>
jmp    11dc <uart_init_line+0xbc>
movl   $0x2,-0x10(%rbp)
jmp    124f <uart_init_line+0x12f>
movl   $0x3,-0x10(%rbp)
jmp    124f <uart_init_line+0x12f>
movl   $0x6,-0x10(%rbp)
jmp    124f <uart_init_line+0x12f>
movl   $0xc,-0x10(%rbp)
jmp    124f <uart_init_line+0x12f>
movl   $0x18,-0x10(%rbp)
jmp    124f <uart_init_line+0x12f>
movl   $0x30,-0x10(%rbp)
jmp    124f <uart_init_line+0x12f>
movl   $0x60,-0x10(%rbp)
jmp    124f <uart_init_line+0x12f>
movl   $0x180,-0x10(%rbp)
jmp    124f <uart_init_line+0x12f>
movl   $0x300,-0x10(%rbp)
jmp    124f <uart_init_line+0x12f>
movl   $0xc,-0x10(%rbp)
mov    -0x4(%rbp),%esi
add    $0x2fb,%esi
mov    $0x87,%edi
call   1030 <outb@plt>
mov    -0x4(%rbp),%esi
add    $0x2f9,%esi
xor    %edi,%edi
call   1030 <outb@plt>
mov    -0x10(%rbp),%edi
mov    -0x4(%rbp),%esi
add    $0x2f8,%esi
call   1030 <outb@plt>
mov    -0x4(%rbp),%esi
add    $0x2fb,%esi
mov    $0x7,%edi
call   1030 <outb@plt>
mov    -0x4(%rbp),%esi
add    $0x2fc,%esi
mov    $0xf,%edi
call   1030 <outb@plt>
movl   $0xa,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jle    12f3 <uart_init_line+0x1d3>
mov    -0x4(%rbp),%edi
add    $0x2fd,%edi
call   1040 <inb@plt>
cmp    $0x0,%rax
jne    12d7 <uart_init_line+0x1b7>
jmp    12f3 <uart_init_line+0x1d3>
mov    -0x4(%rbp),%edi
add    $0x2f8,%edi
call   1040 <inb@plt>
mov    -0xc(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0xc(%rbp)
jmp    12b0 <uart_init_line+0x190>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<uart_init_line>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %edi,%ebx
cmp    $0x12bf,%esi
jle    115f <uart_init_line+0x3f>
cmp    $0x4aff,%esi
jle    117f <uart_init_line+0x5f>
cmp    $0x4b00,%esi
je     11ad <uart_init_line+0x8d>
mov    $0x2,%r15d
cmp    $0xdac0,%esi
je     11cb <uart_init_line+0xab>
cmp    $0x9600,%esi
jne    118d <uart_init_line+0x6d>
mov    $0x3,%r15d
jmp    11cb <uart_init_line+0xab>
cmp    $0x4af,%esi
jg     1195 <uart_init_line+0x75>
cmp    $0x96,%esi
je     11b5 <uart_init_line+0x95>
cmp    $0x12c,%esi
jne    118d <uart_init_line+0x6d>
mov    $0x180,%r15d
jmp    11cb <uart_init_line+0xab>
cmp    $0x12c0,%esi
je     11bd <uart_init_line+0x9d>
cmp    $0x2580,%esi
mov    $0xc,%r15d
jmp    11cb <uart_init_line+0xab>
cmp    $0x4b0,%esi
je     11c5 <uart_init_line+0xa5>
cmp    $0x960,%esi
jne    118d <uart_init_line+0x6d>
mov    $0x30,%r15d
jmp    11cb <uart_init_line+0xab>
mov    $0x6,%r15d
jmp    11cb <uart_init_line+0xab>
mov    $0x300,%r15d
jmp    11cb <uart_init_line+0xab>
mov    $0x18,%r15d
jmp    11cb <uart_init_line+0xab>
mov    $0x60,%r15d
lea    0x2fb(%rbx),%ebp
mov    $0x87,%edi
mov    %ebp,%esi
call   1030 <outb@plt>
lea    0x2f9(%rbx),%esi
xor    %edi,%edi
call   1030 <outb@plt>
lea    0x2f8(%rbx),%r14d
mov    %r15d,%edi
mov    %r14d,%esi
call   1030 <outb@plt>
mov    $0x7,%edi
mov    %ebp,%esi
call   1030 <outb@plt>
lea    0x2fc(%rbx),%esi
mov    $0xf,%edi
call   1030 <outb@plt>
add    $0x2fd,%ebx
mov    %ebx,%edi
call   1040 <inb@plt>
test   %rax,%rax
je     1300 <uart_init_line+0x1e0>
mov    %r14d,%edi
call   1040 <inb@plt>
mov    %ebx,%edi
call   1040 <inb@plt>
test   %rax,%rax
je     1300 <uart_init_line+0x1e0>
mov    %r14d,%edi
call   1040 <inb@plt>
mov    %ebx,%edi
call   1040 <inb@plt>
test   %rax,%rax
je     1300 <uart_init_line+0x1e0>
mov    %r14d,%edi
call   1040 <inb@plt>
mov    %ebx,%edi
call   1040 <inb@plt>
test   %rax,%rax
je     1300 <uart_init_line+0x1e0>
mov    %r14d,%edi
call   1040 <inb@plt>
mov    %ebx,%edi
call   1040 <inb@plt>
test   %rax,%rax
je     1300 <uart_init_line+0x1e0>
mov    %r14d,%edi
call   1040 <inb@plt>
mov    %ebx,%edi
call   1040 <inb@plt>
test   %rax,%rax
je     1300 <uart_init_line+0x1e0>
mov    %r14d,%edi
call   1040 <inb@plt>
mov    %ebx,%edi
call   1040 <inb@plt>
test   %rax,%rax
je     1300 <uart_init_line+0x1e0>
mov    %r14d,%edi
call   1040 <inb@plt>
mov    %ebx,%edi
call   1040 <inb@plt>
test   %rax,%rax
je     1300 <uart_init_line+0x1e0>
mov    %r14d,%edi
call   1040 <inb@plt>
mov    %ebx,%edi
call   1040 <inb@plt>
test   %rax,%rax
je     1300 <uart_init_line+0x1e0>
mov    %r14d,%edi
call   1040 <inb@plt>
mov    %ebx,%edi
call   1040 <inb@plt>
test   %rax,%rax
je     1300 <uart_init_line+0x1e0>
mov    %r14d,%edi
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <inb@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @uart_init_line(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
%7 = load i32, i32* %4
switch i32 %7, label %17 [
i32 56000, label %8
i32 38400, label %9
i32 19200, label %10
i32 9600, label %11
i32 4800, label %12
i32 2400, label %13
i32 1200, label %14
i32 300, label %15
i32 150, label %16
]
8: ; preds = %2
store i32 2, i32* %6
br label %18
9: ; preds = %2
store i32 3, i32* %6
br label %18
10: ; preds = %2
store i32 6, i32* %6
br label %18
11: ; preds = %2
store i32 12, i32* %6
br label %18
12: ; preds = %2
store i32 24, i32* %6
br label %18
13: ; preds = %2
store i32 48, i32* %6
br label %18
14: ; preds = %2
store i32 96, i32* %6
br label %18
15: ; preds = %2
store i32 384, i32* %6
br label %18
16: ; preds = %2
store i32 768, i32* %6
br label %18
17: ; preds = %2
store i32 12, i32* %6
br label %18
18: ; preds = %17, %16, %15, %14, %13, %12, %11, %10, %9, %8
%19 = load i32, i32* %3
%20 = add nsw i32 763, %19
%21 = call i32 @outb(i32 135, i32 %20)
%22 = load i32, i32* %3
%23 = add nsw i32 761, %22
%24 = call i32 @outb(i32 0, i32 %23)
%25 = load i32, i32* %6
%26 = load i32, i32* %3
%27 = add nsw i32 760, %26
%28 = call i32 @outb(i32 %25, i32 %27)
%29 = load i32, i32* %3
%30 = add nsw i32 763, %29
%31 = call i32 @outb(i32 7, i32 %30)
%32 = load i32, i32* %3
%33 = add nsw i32 764, %32
%34 = call i32 @outb(i32 15, i32 %33)
store i32 10, i32* %5
br label %35
35: ; preds = %48, %18
%36 = load i32, i32* %5
%37 = icmp sgt i32 %36, 0
br i1 %37, label %38, label %51
38: ; preds = %35
%39 = load i32, i32* %3
%40 = add nsw i32 765, %39
%41 = call i64 @inb(i32 %40)
%42 = icmp eq i64 %41, 0
br i1 %42, label %43, label %44
43: ; preds = %38
br label %51
44: ; preds = %38
%45 = load i32, i32* %3
%46 = add nsw i32 760, %45
%47 = call i64 @inb(i32 %46)
br label %48
48: ; preds = %44
%49 = load i32, i32* %5
%50 = add nsw i32 %49, -1
store i32 %50, i32* %5
br label %35
51: ; preds = %43, %35
ret void
}

LLVM IR (-O2):
define void @uart_init_line(i32 %0, i32 %1) {
switch i32 %1, label %11 [
i32 56000, label %12
i32 38400, label %3
i32 19200, label %4
i32 9600, label %5
i32 4800, label %6
i32 2400, label %7
i32 1200, label %8
i32 300, label %9
i32 150, label %10
]
3: ; preds = %2
br label %12
4: ; preds = %2
br label %12
5: ; preds = %2
br label %12
6: ; preds = %2
br label %12
7: ; preds = %2
br label %12
8: ; preds = %2
br label %12
9: ; preds = %2
br label %12
10: ; preds = %2
br label %12
11: ; preds = %2
br label %12
12: ; preds = %2, %11, %10, %9, %8, %7, %6, %5, %4, %3
%13 = phi i32 [ 12, %11 ], [ 768, %10 ], [ 384, %9 ], [ 96, %8 ], [ 48, %7 ], [ 24, %6 ], [ 12, %5 ], [ 6, %4 ], [ 3, %3 ], [ 2, %2 ]
%14 = add nsw i32 %0, 763
%15 = tail call i32 @outb(i32 135, i32 %14)
%16 = add nsw i32 %0, 761
%17 = tail call i32 @outb(i32 0, i32 %16)
%18 = add nsw i32 %0, 760
%19 = tail call i32 @outb(i32 %13, i32 %18)
%20 = tail call i32 @outb(i32 7, i32 %14)
%21 = add nsw i32 %0, 764
%22 = tail call i32 @outb(i32 15, i32 %21)
%23 = add nsw i32 %0, 765
%24 = tail call i64 @inb(i32 %23)
%25 = icmp eq i64 %24, 0
br i1 %25, label %64, label %26
26: ; preds = %12
%27 = tail call i64 @inb(i32 %18)
%28 = tail call i64 @inb(i32 %23)
%29 = icmp eq i64 %28, 0
br i1 %29, label %64, label %30
30: ; preds = %26
%31 = tail call i64 @inb(i32 %18)
%32 = tail call i64 @inb(i32 %23)
%33 = icmp eq i64 %32, 0
br i1 %33, label %64, label %34
34: ; preds = %30
%35 = tail call i64 @inb(i32 %18)
%36 = tail call i64 @inb(i32 %23)
%37 = icmp eq i64 %36, 0
br i1 %37, label %64, label %38
38: ; preds = %34
%39 = tail call i64 @inb(i32 %18)
%40 = tail call i64 @inb(i32 %23)
%41 = icmp eq i64 %40, 0
br i1 %41, label %64, label %42
42: ; preds = %38
%43 = tail call i64 @inb(i32 %18)
%44 = tail call i64 @inb(i32 %23)
%45 = icmp eq i64 %44, 0
br i1 %45, label %64, label %46
46: ; preds = %42
%47 = tail call i64 @inb(i32 %18)
%48 = tail call i64 @inb(i32 %23)
%49 = icmp eq i64 %48, 0
br i1 %49, label %64, label %50
50: ; preds = %46
%51 = tail call i64 @inb(i32 %18)
%52 = tail call i64 @inb(i32 %23)
%53 = icmp eq i64 %52, 0
br i1 %53, label %64, label %54
54: ; preds = %50
%55 = tail call i64 @inb(i32 %18)
%56 = tail call i64 @inb(i32 %23)
%57 = icmp eq i64 %56, 0
br i1 %57, label %64, label %58
58: ; preds = %54
%59 = tail call i64 @inb(i32 %18)
%60 = tail call i64 @inb(i32 %23)
%61 = icmp eq i64 %60, 0
br i1 %61, label %64, label %62
62: ; preds = %58
%63 = tail call i64 @inb(i32 %18)
br label %64
64: ; preds = %62, %58, %54, %50, %46, %42, %38, %34, %30, %26, %12
ret void
}