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


x86 assembly (clang, -O0):
<i8254_mm_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_mm_write+0x24>
jmp    117f <i8254_mm_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 <writeb@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 <writeb@plt>
add    $0x20,%rsp
pop    %rbp
ret

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

LLVM IR (-O0):
define void @i8254_mm_write(i8* %0, i32 %1, i32 %2, i32 %3) {
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i8* %0, i8** %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 i8*, i8** %5
%18 = load i32, i32* %7
%19 = load i32, i32* %6
%20 = shl i32 %18, %19
%21 = zext i32 %20 to i64
%22 = getelementptr i8, i8* %17, i64 %21
%23 = call i32 @writeb(i32 %16, i8* %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 i8*, i8** %5
%29 = load i32, i32* %7
%30 = load i32, i32* %6
%31 = shl i32 %29, %30
%32 = zext i32 %31 to i64
%33 = getelementptr i8, i8* %28, i64 %32
%34 = call i32 @writeb(i32 %27, i8* %33)
br label %35
35: ; preds = %13, %12
ret void
}

LLVM IR (-O2):
define void @i8254_mm_write(i8* %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 = getelementptr i8, i8* %0, i64 %9
%11 = tail call i32 @writeb(i32 %7, i8* %10)
%12 = lshr i32 %3, 8
%13 = and i32 %12, 255
%14 = tail call i32 @writeb(i32 %13, i8* %10)
br label %15
15: ; preds = %4, %6
ret void
}