#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*/ ppuSetNameTblHorizontal();
int /*<<< orphan*/ ppuSetNameTblVertical();
int /*<<< orphan*/ prg32setBank0(int);
void m113_setParams(uint16_t addr, uint8_t val) {
  (void)addr;
  chr8setBank0((((val >> 3) & 8) | (val & 7)) << 13);
  prg32setBank0(((val >> 3) & 7) << 15);
  if ((val & (1 << 7)) == 0)
    ppuSetNameTblHorizontal();
  else
    ppuSetNameTblVertical();
}


x86 assembly (clang, -O0):
<m113_setParams>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    -0x8(%rbp),%edi
sar    $0x3,%edi
and    $0x8,%edi
mov    -0x8(%rbp),%eax
and    $0x7,%eax
or     %eax,%edi
shl    $0xd,%edi
call   1040 <chr8setBank0@plt>
mov    -0x8(%rbp),%edi
sar    $0x3,%edi
and    $0x7,%edi
shl    $0xf,%edi
call   1030 <prg32setBank0@plt>
mov    -0x8(%rbp),%eax
and    $0x80,%eax
cmp    $0x0,%eax
jne    1195 <m113_setParams+0x55>
mov    $0x0,%al
call   1050 <ppuSetNameTblHorizontal@plt>
jmp    119c <m113_setParams+0x5c>
mov    $0x0,%al
call   1060 <ppuSetNameTblVertical@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<m113_setParams>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebx
mov    %esi,%ebp
sar    $0x3,%ebp
mov    %ebp,%eax
and    $0x8,%eax
mov    %esi,%edi
and    $0x7,%edi
or     %eax,%edi
shl    $0xd,%edi
call   1040 <chr8setBank0@plt>
and    $0x7,%ebp
shl    $0xf,%ebp
mov    %ebp,%edi
call   1030 <prg32setBank0@plt>
xor    %eax,%eax
add    $0x8,%rsp
test   $0x80,%bl
jne    117d <m113_setParams+0x3d>
pop    %rbx
pop    %rbp
jmp    1050 <ppuSetNameTblHorizontal@plt>
pop    %rbx
pop    %rbp
jmp    1060 <ppuSetNameTblVertical@plt>

LLVM IR (-O0):
define void @m113_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, 3
%8 = and i32 %7, 8
%9 = load i32, i32* %4
%10 = and i32 %9, 7
%11 = or i32 %8, %10
%12 = shl i32 %11, 13
%13 = call i32 @chr8setBank0(i32 %12)
%14 = load i32, i32* %4
%15 = ashr i32 %14, 3
%16 = and i32 %15, 7
%17 = shl i32 %16, 15
%18 = call i32 @prg32setBank0(i32 %17)
%19 = load i32, i32* %4
%20 = and i32 %19, 128
%21 = icmp eq i32 %20, 0
br i1 %21, label %22, label %24
22: ; preds = %2
%23 = call i32 (...) @ppuSetNameTblHorizontal()
br label %26
24: ; preds = %2
%25 = call i32 (...) @ppuSetNameTblVertical()
br label %26
26: ; preds = %24, %22
ret void
}

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