#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(short, int);
void serial_set_baud(short combase, short rate) {
  short divisor;
  divisor = 115200 / rate;
  outb(combase + 1, 0x00);
  outb(combase + 3, 0x80);
  outb(combase + 0, divisor & 0x00FF);
  outb(combase + 1, (divisor & 0xFF00) >> 8);
  outb(combase + 3, 0x03);
  return;
}


x86 assembly (clang, -O0):
<serial_set_baud>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %si,%ax
mov    %di,%cx
mov    %cx,-0x2(%rbp)
mov    %ax,-0x4(%rbp)
movswl -0x4(%rbp),%ecx
mov    $0x1c200,%eax
cltd
idiv   %ecx
mov    %ax,-0x6(%rbp)
movswl -0x2(%rbp),%eax
add    $0x1,%eax
xor    %esi,%esi
movswl %ax,%edi
call   1030 <outb@plt>
movswl -0x2(%rbp),%eax
add    $0x3,%eax
mov    $0x80,%esi
movswl %ax,%edi
call   1030 <outb@plt>
movswl -0x2(%rbp),%eax
add    $0x0,%eax
movswl -0x6(%rbp),%esi
and    $0xff,%esi
movswl %ax,%edi
call   1030 <outb@plt>
movswl -0x2(%rbp),%eax
add    $0x1,%eax
movswl -0x6(%rbp),%esi
and    $0xff00,%esi
sar    $0x8,%esi
movswl %ax,%edi
call   1030 <outb@plt>
movswl -0x2(%rbp),%eax
add    $0x3,%eax
mov    $0x3,%esi
movswl %ax,%edi
call   1030 <outb@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<serial_set_baud>:
push   %rbp
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %edi,%ebp
mov    $0x1c200,%eax
xor    %edx,%edx
idiv   %esi
mov    %eax,%ebx
lea    0x1(%rbp),%eax
movswl %ax,%r14d
mov    %r14d,%edi
xor    %esi,%esi
call   1030 <outb@plt>
lea    0x3(%rbp),%eax
movswl %ax,%r12d
mov    %r12d,%edi
mov    $0x80,%esi
call   1030 <outb@plt>
movzbl %bl,%esi
mov    %ebp,%edi
call   1030 <outb@plt>
movzbl %bh,%esi
mov    %r14d,%edi
call   1030 <outb@plt>
mov    %r12d,%edi
mov    $0x3,%esi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %rbp
jmp    1030 <outb@plt>

LLVM IR (-O0):
define void @serial_set_baud(i16 signext %0, i16 signext %1) {
%3 = alloca i16
%4 = alloca i16
%5 = alloca i16
store i16 %0, i16* %3
store i16 %1, i16* %4
%6 = load i16, i16* %4
%7 = sext i16 %6 to i32
%8 = sdiv i32 115200, %7
%9 = trunc i32 %8 to i16
store i16 %9, i16* %5
%10 = load i16, i16* %3
%11 = sext i16 %10 to i32
%12 = add nsw i32 %11, 1
%13 = trunc i32 %12 to i16
%14 = call i32 @outb(i16 signext %13, i32 0)
%15 = load i16, i16* %3
%16 = sext i16 %15 to i32
%17 = add nsw i32 %16, 3
%18 = trunc i32 %17 to i16
%19 = call i32 @outb(i16 signext %18, i32 128)
%20 = load i16, i16* %3
%21 = sext i16 %20 to i32
%22 = add nsw i32 %21, 0
%23 = trunc i32 %22 to i16
%24 = load i16, i16* %5
%25 = sext i16 %24 to i32
%26 = and i32 %25, 255
%27 = call i32 @outb(i16 signext %23, i32 %26)
%28 = load i16, i16* %3
%29 = sext i16 %28 to i32
%30 = add nsw i32 %29, 1
%31 = trunc i32 %30 to i16
%32 = load i16, i16* %5
%33 = sext i16 %32 to i32
%34 = and i32 %33, 65280
%35 = ashr i32 %34, 8
%36 = call i32 @outb(i16 signext %31, i32 %35)
%37 = load i16, i16* %3
%38 = sext i16 %37 to i32
%39 = add nsw i32 %38, 3
%40 = trunc i32 %39 to i16
%41 = call i32 @outb(i16 signext %40, i32 3)
ret void
}

LLVM IR (-O2):
define void @serial_set_baud(i16 signext %0, i16 signext %1) {
%3 = sext i16 %1 to i32
%4 = sdiv i32 115200, %3
%5 = add i16 %0, 1
%6 = tail call i32 @outb(i16 signext %5, i32 0)
%7 = add i16 %0, 3
%8 = tail call i32 @outb(i16 signext %7, i32 128)
%9 = and i32 %4, 255
%10 = tail call i32 @outb(i16 signext %0, i32 %9)
%11 = lshr i32 %4, 8
%12 = and i32 %11, 255
%13 = tail call i32 @outb(i16 signext %5, i32 %12)
%14 = tail call i32 @outb(i16 signext %7, i32 3)
ret void
}