#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*/ bbm_read(void *, int, unsigned char *);
int /*<<< orphan*/ bbm_write(void *, int, int);
int fc8080_channel_select(void *handle, unsigned char subch_id,
                          unsigned char buf_id) {
  unsigned char buf_en = 0;
  bbm_read(handle, 0x0904, &buf_en);
  bbm_write(handle, 0x0904, buf_en | (1 << buf_id));
  bbm_write(handle, 0x0602 + buf_id, 0x40 | subch_id);
  return 0;
}


x86 assembly (clang, -O0):
<fc8080_channel_select>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %dl,%al
mov    %sil,%cl
mov    %rdi,-0x8(%rbp)
mov    %cl,-0x9(%rbp)
mov    %al,-0xa(%rbp)
movb   $0x0,-0xb(%rbp)
mov    -0x8(%rbp),%rdi
mov    $0x904,%esi
lea    -0xb(%rbp),%rdx
call   1040 <bbm_read@plt>
mov    -0x8(%rbp),%rdi
movzbl -0xb(%rbp),%edx
movzbl -0xa(%rbp),%ecx
mov    $0x1,%eax
shl    %cl,%eax
or     %eax,%edx
mov    $0x904,%esi
call   1030 <bbm_write@plt>
mov    -0x8(%rbp),%rdi
movzbl -0xa(%rbp),%esi
add    $0x602,%esi
movzbl -0x9(%rbp),%edx
or     $0x40,%edx
call   1030 <bbm_write@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fc8080_channel_select>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %edx,%ebx
mov    %esi,%ebp
mov    %rdi,%r14
movb   $0x0,0xf(%rsp)
lea    0xf(%rsp),%rdx
mov    $0x904,%esi
call   1040 <bbm_read@plt>
movzbl 0xf(%rsp),%edx
bts    %ebx,%edx
mov    %r14,%rdi
mov    $0x904,%esi
call   1030 <bbm_write@plt>
add    $0x602,%ebx
or     $0x40,%bpl
movzbl %bpl,%edx
mov    %r14,%rdi
mov    %ebx,%esi
call   1030 <bbm_write@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define i32 @fc8080_channel_select(i8* %0, i8 zeroext %1, i8 zeroext %2) {
%4 = alloca i8*
%5 = alloca i8
%6 = alloca i8
%7 = alloca i8
store i8* %0, i8** %4
store i8 %1, i8* %5
store i8 %2, i8* %6
store i8 0, i8* %7
%8 = load i8*, i8** %4
%9 = call i32 @bbm_read(i8* %8, i32 2308, i8* %7)
%10 = load i8*, i8** %4
%11 = load i8, i8* %7
%12 = zext i8 %11 to i32
%13 = load i8, i8* %6
%14 = zext i8 %13 to i32
%15 = shl i32 1, %14
%16 = or i32 %12, %15
%17 = call i32 @bbm_write(i8* %10, i32 2308, i32 %16)
%18 = load i8*, i8** %4
%19 = load i8, i8* %6
%20 = zext i8 %19 to i32
%21 = add nsw i32 1538, %20
%22 = load i8, i8* %5
%23 = zext i8 %22 to i32
%24 = or i32 64, %23
%25 = call i32 @bbm_write(i8* %18, i32 %21, i32 %24)
ret i32 0
}

LLVM IR (-O2):
define i32 @fc8080_channel_select(i8* %0, i8 zeroext %1, i8 zeroext %2) {
%4 = alloca i8
store i8 0, i8* %4
%5 = call i32 @bbm_read(i8* %0, i32 2308, i8* %4)
%6 = load i8, i8* %4
%7 = zext i8 %6 to i32
%8 = zext i8 %2 to i32
%9 = shl nuw i32 1, %8
%10 = or i32 %9, %7
%11 = call i32 @bbm_write(i8* %0, i32 2308, i32 %10)
%12 = add nuw nsw i32 %8, 1538
%13 = or i8 %1, 64
%14 = zext i8 %13 to i32
%15 = call i32 @bbm_write(i8* %0, i32 %12, i32 %14)
ret i32 0
}