#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 uint16_t;

/* Variables and functions */
int /*<<< orphan*/ chr8setBank0(int);
int /*<<< orphan*/ ppuSetNameTblHorizontal();
int /*<<< orphan*/ ppuSetNameTblVertical();
int /*<<< orphan*/ prg16setBank0(int);
int /*<<< orphan*/ prg16setBank1(int);
void m225setParams(uint16_t addr, uint8_t val) {
  (void)val;
  uint8_t chrBank = addr & 0x3F;
  uint8_t prgBank = (addr >> 6) & 0x3F;
  if (addr & 0x4000) {
    chrBank |= 0x40;
    prgBank |= 0x40;
  }
  if ((addr & 0x1000) == 0) {
    prg16setBank0((prgBank & 0xFE) << 14);
    prg16setBank1((prgBank | 0x01) << 14);
  } else {
    prg16setBank0(prgBank << 14);
    prg16setBank1(prgBank << 14);
  }
  chr8setBank0(chrBank << 13);
  if ((addr & 0x2000) == 0)
    ppuSetNameTblVertical();
  else
    ppuSetNameTblHorizontal();
}


x86 assembly (clang, -O0):
<m225setParams>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    -0x4(%rbp),%eax
and    $0x3f,%eax
mov    %eax,-0xc(%rbp)
mov    -0x4(%rbp),%eax
sar    $0x6,%eax
and    $0x3f,%eax
mov    %eax,-0x10(%rbp)
mov    -0x4(%rbp),%eax
and    $0x4000,%eax
cmp    $0x0,%eax
je     1196 <m225setParams+0x46>
mov    -0xc(%rbp),%eax
or     $0x40,%eax
mov    %eax,-0xc(%rbp)
mov    -0x10(%rbp),%eax
or     $0x40,%eax
mov    %eax,-0x10(%rbp)
mov    -0x4(%rbp),%eax
and    $0x1000,%eax
cmp    $0x0,%eax
jne    11cb <m225setParams+0x7b>
mov    -0x10(%rbp),%edi
and    $0xfe,%edi
shl    $0xe,%edi
call   1030 <prg16setBank0@plt>
mov    -0x10(%rbp),%edi
or     $0x1,%edi
shl    $0xe,%edi
call   1070 <prg16setBank1@plt>
jmp    11e1 <m225setParams+0x91>
mov    -0x10(%rbp),%edi
shl    $0xe,%edi
call   1030 <prg16setBank0@plt>
mov    -0x10(%rbp),%edi
shl    $0xe,%edi
call   1070 <prg16setBank1@plt>
mov    -0xc(%rbp),%edi
shl    $0xd,%edi
call   1040 <chr8setBank0@plt>
mov    -0x4(%rbp),%eax
and    $0x2000,%eax
cmp    $0x0,%eax
jne    1209 <m225setParams+0xb9>
mov    $0x0,%al
call   1060 <ppuSetNameTblVertical@plt>
jmp    1210 <m225setParams+0xc0>
mov    $0x0,%al
call   1050 <ppuSetNameTblHorizontal@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<m225setParams>:
push   %rbp
push   %r14
push   %rbx
mov    %edi,%r14d
mov    %edi,%ebp
and    $0x3f,%ebp
mov    %edi,%eax
shr    $0x6,%eax
and    $0x3f,%eax
mov    %edi,%ebx
shr    $0x8,%ebx
and    $0x40,%ebx
or     %ebx,%ebp
or     %eax,%ebx
shl    $0xe,%ebx
test   $0x1000,%edi
jne    1190 <m225setParams+0x40>
mov    %ebx,%edi
and    $0x1f8000,%edi
call   1030 <prg16setBank0@plt>
or     $0x4000,%ebx
jmp    1197 <m225setParams+0x47>
mov    %ebx,%edi
call   1030 <prg16setBank0@plt>
mov    %ebx,%edi
call   1070 <prg16setBank1@plt>
shl    $0xd,%ebp
mov    %ebp,%edi
call   1040 <chr8setBank0@plt>
xor    %eax,%eax
test   $0x2000,%r14d
jne    11bc <m225setParams+0x6c>
pop    %rbx
pop    %r14
pop    %rbp
jmp    1060 <ppuSetNameTblVertical@plt>
pop    %rbx
pop    %r14
pop    %rbp
jmp    1050 <ppuSetNameTblHorizontal@plt>

LLVM IR (-O0):
define void @m225setParams(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
%7 = load i32, i32* %4
%8 = load i32, i32* %3
%9 = and i32 %8, 63
store i32 %9, i32* %5
%10 = load i32, i32* %3
%11 = ashr i32 %10, 6
%12 = and i32 %11, 63
store i32 %12, i32* %6
%13 = load i32, i32* %3
%14 = and i32 %13, 16384
%15 = icmp ne i32 %14, 0
br i1 %15, label %16, label %21
16: ; preds = %2
%17 = load i32, i32* %5
%18 = or i32 %17, 64
store i32 %18, i32* %5
%19 = load i32, i32* %6
%20 = or i32 %19, 64
store i32 %20, i32* %6
br label %21
21: ; preds = %16, %2
%22 = load i32, i32* %3
%23 = and i32 %22, 4096
%24 = icmp eq i32 %23, 0
br i1 %24, label %25, label %34
25: ; preds = %21
%26 = load i32, i32* %6
%27 = and i32 %26, 254
%28 = shl i32 %27, 14
%29 = call i32 @prg16setBank0(i32 %28)
%30 = load i32, i32* %6
%31 = or i32 %30, 1
%32 = shl i32 %31, 14
%33 = call i32 @prg16setBank1(i32 %32)
br label %41
34: ; preds = %21
%35 = load i32, i32* %6
%36 = shl i32 %35, 14
%37 = call i32 @prg16setBank0(i32 %36)
%38 = load i32, i32* %6
%39 = shl i32 %38, 14
%40 = call i32 @prg16setBank1(i32 %39)
br label %41
41: ; preds = %34, %25
%42 = load i32, i32* %5
%43 = shl i32 %42, 13
%44 = call i32 @chr8setBank0(i32 %43)
%45 = load i32, i32* %3
%46 = and i32 %45, 8192
%47 = icmp eq i32 %46, 0
br i1 %47, label %48, label %50
48: ; preds = %41
%49 = call i32 (...) @ppuSetNameTblVertical()
br label %52
50: ; preds = %41
%51 = call i32 (...) @ppuSetNameTblHorizontal()
br label %52
52: ; preds = %50, %48
ret void
}

LLVM IR (-O2):
define void @m225setParams(i32 %0, i32 %1) {
%3 = and i32 %0, 63
%4 = lshr i32 %0, 6
%5 = and i32 %4, 63
%6 = lshr i32 %0, 8
%7 = and i32 %6, 64
%8 = or i32 %7, %3
%9 = or i32 %7, %5
%10 = and i32 %0, 4096
%11 = icmp eq i32 %10, 0
%12 = shl nuw nsw i32 %9, 14
br i1 %11, label %13, label %17
13: ; preds = %2
%14 = and i32 %12, 2064384
%15 = tail call i32 @prg16setBank0(i32 %14)
%16 = or i32 %12, 16384
br label %19
17: ; preds = %2
%18 = tail call i32 @prg16setBank0(i32 %12)
br label %19
19: ; preds = %17, %13
%20 = phi i32 [ %12, %17 ], [ %16, %13 ]
%21 = tail call i32 @prg16setBank1(i32 %20)
%22 = shl nuw nsw i32 %8, 13
%23 = tail call i32 @chr8setBank0(i32 %22)
%24 = and i32 %0, 8192
%25 = icmp eq i32 %24, 0
br i1 %25, label %26, label %28
26: ; preds = %19
%27 = tail call i32 (...) @ppuSetNameTblVertical()
br label %30
28: ; preds = %19
%29 = tail call i32 (...) @ppuSetNameTblHorizontal()
br label %30
30: ; preds = %28, %26
ret void
}