#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, unsigned char);
int fc8080_channel_deselect(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, 0);
  return 0;
}


x86 assembly (clang, -O0):
<fc8080_channel_deselect>:
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),%eax
movzbl -0xa(%rbp),%ecx
mov    $0x1,%edx
shl    %cl,%edx
mov    %edx,%ecx
xor    $0xffffffff,%ecx
and    %ecx,%eax
mov    $0x904,%esi
movzbl %al,%edx
call   1030 <bbm_write@plt>
mov    -0x8(%rbp),%rdi
movzbl -0xa(%rbp),%esi
add    $0x602,%esi
xor    %edx,%edx
call   1030 <bbm_write@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fc8080_channel_deselect>:
push   %r14
push   %rbx
push   %rax
mov    %edx,%ebx
mov    %rdi,%r14
movb   $0x0,0x7(%rsp)
lea    0x7(%rsp),%rdx
mov    $0x904,%esi
call   1040 <bbm_read@plt>
mov    $0x1,%eax
mov    %ebx,%ecx
shl    %cl,%eax
not    %al
and    0x7(%rsp),%al
movzbl %al,%edx
mov    %r14,%rdi
mov    $0x904,%esi
call   1030 <bbm_write@plt>
add    $0x602,%ebx
mov    %r14,%rdi
mov    %ebx,%esi
xor    %edx,%edx
call   1030 <bbm_write@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i32 @fc8080_channel_deselect(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 = xor i32 %15, -1
%17 = and i32 %12, %16
%18 = trunc i32 %17 to i8
%19 = call i32 @bbm_write(i8* %10, i32 2308, i8 zeroext %18)
%20 = load i8*, i8** %4
%21 = load i8, i8* %6
%22 = zext i8 %21 to i32
%23 = add nsw i32 1538, %22
%24 = call i32 @bbm_write(i8* %20, i32 %23, i8 zeroext 0)
ret i32 0
}

LLVM IR (-O2):
define i32 @fc8080_channel_deselect(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 %2 to i32
%8 = shl nuw i32 1, %7
%9 = trunc i32 %8 to i8
%10 = xor i8 %9, -1
%11 = and i8 %6, %10
%12 = call i32 @bbm_write(i8* %0, i32 2308, i8 zeroext %11)
%13 = add nuw nsw i32 %7, 1538
%14 = call i32 @bbm_write(i8* %0, i32 %13, i8 zeroext 0)
ret i32 0
}