#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(unsigned int, unsigned long);
void i8254_write(unsigned long base_address, unsigned int regshift,
                 unsigned int counter_number, unsigned int count) {
  unsigned int byte;
  if (counter_number > 2)
    return;
  byte = count & 0xff;
  outb(byte, base_address + (counter_number << regshift));
  byte = (count >> 8) & 0xff;
  outb(byte, base_address + (counter_number << regshift));
}


x86 assembly (clang, -O0):
<i8254_write>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
cmpl   $0x2,-0x10(%rbp)
jbe    1134 <i8254_write+0x24>
jmp    117f <i8254_write+0x6f>
mov    -0x14(%rbp),%eax
and    $0xff,%eax
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%edi
mov    -0x8(%rbp),%rsi
mov    -0x10(%rbp),%eax
mov    -0xc(%rbp),%ecx
shl    %cl,%eax
mov    %eax,%eax
add    %rax,%rsi
call   1030 <outb@plt>
mov    -0x14(%rbp),%eax
shr    $0x8,%eax
and    $0xff,%eax
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%edi
mov    -0x8(%rbp),%rsi
mov    -0x10(%rbp),%eax
mov    -0xc(%rbp),%ecx
shl    %cl,%eax
mov    %eax,%eax
add    %rax,%rsi
call   1030 <outb@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<i8254_write>:
cmp    $0x2,%edx
jbe    1116 <i8254_write+0x6>
ret
push   %rbp
push   %rbx
push   %rax
mov    %edx,%ebx
movzbl %cl,%eax
mov    %ecx,%ebp
mov    %esi,%ecx
shl    %cl,%ebx
add    %rdi,%rbx
mov    %eax,%edi
mov    %rbx,%rsi
call   1030 <outb@plt>
mov    %ebp,%eax
movzbl %ah,%edi
mov    %rbx,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1030 <outb@plt>

LLVM IR (-O0):
define void @i8254_write(i64 %0, i32 %1, i32 %2, i32 %3) {
%5 = alloca i64
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i64 %0, i64* %5
store i32 %1, i32* %6
store i32 %2, i32* %7
store i32 %3, i32* %8
%10 = load i32, i32* %7
%11 = icmp ugt i32 %10, 2
br i1 %11, label %12, label %13
12: ; preds = %4
br label %35
13: ; preds = %4
%14 = load i32, i32* %8
%15 = and i32 %14, 255
store i32 %15, i32* %9
%16 = load i32, i32* %9
%17 = load i64, i64* %5
%18 = load i32, i32* %7
%19 = load i32, i32* %6
%20 = shl i32 %18, %19
%21 = zext i32 %20 to i64
%22 = add i64 %17, %21
%23 = call i32 @outb(i32 %16, i64 %22)
%24 = load i32, i32* %8
%25 = lshr i32 %24, 8
%26 = and i32 %25, 255
store i32 %26, i32* %9
%27 = load i32, i32* %9
%28 = load i64, i64* %5
%29 = load i32, i32* %7
%30 = load i32, i32* %6
%31 = shl i32 %29, %30
%32 = zext i32 %31 to i64
%33 = add i64 %28, %32
%34 = call i32 @outb(i32 %27, i64 %33)
br label %35
35: ; preds = %13, %12
ret void
}

LLVM IR (-O2):
define void @i8254_write(i64 %0, i32 %1, i32 %2, i32 %3) {
%5 = icmp ugt i32 %2, 2
br i1 %5, label %15, label %6
6: ; preds = %4
%7 = and i32 %3, 255
%8 = shl i32 %2, %1
%9 = zext i32 %8 to i64
%10 = add i64 %9, %0
%11 = tail call i32 @outb(i32 %7, i64 %10)
%12 = lshr i32 %3, 8
%13 = and i32 %12, 255
%14 = tail call i32 @outb(i32 %13, i64 %10)
br label %15
15: ; preds = %4, %6
ret void
}