#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 */
typedef int uint8_t;
typedef int /*<<< orphan*/ uint16_t;

/* Variables and functions */
int /*<<< orphan*/ chr8setBank0(int);
int /*<<< orphan*/ ppuSetNameTblSingleLower();
int /*<<< orphan*/ ppuSetNameTblSingleUpper();
int /*<<< orphan*/ prg16setBank0(int);
void m89_setParams(uint16_t addr, uint8_t val) {
  (void)addr;
  prg16setBank0(((val >> 4) & 7) << 14);
  chr8setBank0((((val & 0x80) >> 4) | (val & 7)) << 13);
  if ((val & 0x8) == 0)
    ppuSetNameTblSingleLower();
  else
    ppuSetNameTblSingleUpper();
}


x86 assembly (clang, -O0):
<m89_setParams>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    -0x8(%rbp),%edi
sar    $0x4,%edi
and    $0x7,%edi
shl    $0xe,%edi
call   1040 <prg16setBank0@plt>
mov    -0x8(%rbp),%edi
and    $0x80,%edi
sar    $0x4,%edi
mov    -0x8(%rbp),%eax
and    $0x7,%eax
or     %eax,%edi
shl    $0xd,%edi
call   1060 <chr8setBank0@plt>
mov    -0x8(%rbp),%eax
and    $0x8,%eax
cmp    $0x0,%eax
jne    1196 <m89_setParams+0x56>
mov    $0x0,%al
call   1050 <ppuSetNameTblSingleLower@plt>
jmp    119d <m89_setParams+0x5d>
mov    $0x0,%al
call   1030 <ppuSetNameTblSingleUpper@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<m89_setParams>:
push   %rbx
mov    %esi,%ebx
mov    %esi,%edi
and    $0x70,%edi
shl    $0xa,%edi
call   1040 <prg16setBank0@plt>
mov    %ebx,%eax
shr    $0x4,%eax
and    $0x8,%eax
mov    %ebx,%edi
and    $0x7,%edi
or     %eax,%edi
shl    $0xd,%edi
call   1060 <chr8setBank0@plt>
xor    %eax,%eax
test   $0x8,%bl
jne    1174 <m89_setParams+0x34>
pop    %rbx
jmp    1050 <ppuSetNameTblSingleLower@plt>
pop    %rbx
jmp    1030 <ppuSetNameTblSingleUpper@plt>

LLVM IR (-O0):
define void @m89_setParams(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
%5 = load i32, i32* %3
%6 = load i32, i32* %4
%7 = ashr i32 %6, 4
%8 = and i32 %7, 7
%9 = shl i32 %8, 14
%10 = call i32 @prg16setBank0(i32 %9)
%11 = load i32, i32* %4
%12 = and i32 %11, 128
%13 = ashr i32 %12, 4
%14 = load i32, i32* %4
%15 = and i32 %14, 7
%16 = or i32 %13, %15
%17 = shl i32 %16, 13
%18 = call i32 @chr8setBank0(i32 %17)
%19 = load i32, i32* %4
%20 = and i32 %19, 8
%21 = icmp eq i32 %20, 0
br i1 %21, label %22, label %24
22: ; preds = %2
%23 = call i32 (...) @ppuSetNameTblSingleLower()
br label %26
24: ; preds = %2
%25 = call i32 (...) @ppuSetNameTblSingleUpper()
br label %26
26: ; preds = %24, %22
ret void
}

LLVM IR (-O2):
define void @m89_setParams(i32 %0, i32 %1) {
%3 = shl i32 %1, 10
%4 = and i32 %3, 114688
%5 = tail call i32 @prg16setBank0(i32 %4)
%6 = lshr i32 %1, 4
%7 = and i32 %6, 8
%8 = and i32 %1, 7
%9 = or i32 %7, %8
%10 = shl nuw nsw i32 %9, 13
%11 = tail call i32 @chr8setBank0(i32 %10)
%12 = and i32 %1, 8
%13 = icmp eq i32 %12, 0
br i1 %13, label %14, label %16
14: ; preds = %2
%15 = tail call i32 (...) @ppuSetNameTblSingleLower()
br label %18
16: ; preds = %2
%17 = tail call i32 (...) @ppuSetNameTblSingleUpper()
br label %18
18: ; preds = %16, %14
ret void
}