#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*/ ppuSetNameTblHorizontal();
int /*<<< orphan*/ ppuSetNameTblSingleLower();
int /*<<< orphan*/ ppuSetNameTblSingleUpper();
int /*<<< orphan*/ ppuSetNameTblVertical();
int /*<<< orphan*/ prg16setBank1(int);
void m97_setParams(uint16_t addr, uint8_t val) {
  (void)addr;
  prg16setBank1((val & 0xF) << 14);
  switch (val >> 6) {
  case 0:
    ppuSetNameTblSingleLower();
    break;
  case 1:
    ppuSetNameTblHorizontal();
    break;
  case 2:
    ppuSetNameTblVertical();
    break;
  default:
    ppuSetNameTblSingleUpper();
    break;
  }
}


x86 assembly (clang, -O0):
<m97_setParams>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    -0x8(%rbp),%edi
and    $0xf,%edi
shl    $0xe,%edi
call   1070 <prg16setBank1@plt>
mov    -0x8(%rbp),%eax
sar    $0x6,%eax
mov    %eax,-0xc(%rbp)
test   %eax,%eax
je     11a4 <m97_setParams+0x54>
jmp    1182 <m97_setParams+0x32>
mov    -0xc(%rbp),%eax
sub    $0x1,%eax
je     11b0 <m97_setParams+0x60>
jmp    1193 <m97_setParams+0x43>
mov    -0xc(%rbp),%eax
sub    $0x2,%eax
je     11bc <m97_setParams+0x6c>
jmp    11c8 <m97_setParams+0x78>
mov    $0x0,%al
call   1040 <ppuSetNameTblSingleLower@plt>
jmp    11cf <m97_setParams+0x7f>
mov    $0x0,%al
call   1050 <ppuSetNameTblHorizontal@plt>
jmp    11cf <m97_setParams+0x7f>
mov    $0x0,%al
call   1060 <ppuSetNameTblVertical@plt>
jmp    11cf <m97_setParams+0x7f>
mov    $0x0,%al
call   1030 <ppuSetNameTblSingleUpper@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<m97_setParams>:
push   %rbx
mov    %esi,%ebx
mov    %esi,%edi
and    $0xf,%edi
shl    $0xe,%edi
call   1070 <prg16setBank1@plt>
sar    $0x6,%ebx
xor    %eax,%eax
cmp    $0x2,%ebx
je     1179 <m97_setParams+0x29>
cmp    $0x1,%ebx
je     117f <m97_setParams+0x2f>
test   %ebx,%ebx
jne    1185 <m97_setParams+0x35>
pop    %rbx
jmp    1040 <ppuSetNameTblSingleLower@plt>
pop    %rbx
jmp    1060 <ppuSetNameTblVertical@plt>
pop    %rbx
jmp    1050 <ppuSetNameTblHorizontal@plt>
pop    %rbx
jmp    1030 <ppuSetNameTblSingleUpper@plt>

LLVM IR (-O0):
define void @m97_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 = and i32 %6, 15
%8 = shl i32 %7, 14
%9 = call i32 @prg16setBank1(i32 %8)
%10 = load i32, i32* %4
%11 = ashr i32 %10, 6
switch i32 %11, label %18 [
i32 0, label %12
i32 1, label %14
i32 2, label %16
]
12: ; preds = %2
%13 = call i32 (...) @ppuSetNameTblSingleLower()
br label %20
14: ; preds = %2
%15 = call i32 (...) @ppuSetNameTblHorizontal()
br label %20
16: ; preds = %2
%17 = call i32 (...) @ppuSetNameTblVertical()
br label %20
18: ; preds = %2
%19 = call i32 (...) @ppuSetNameTblSingleUpper()
br label %20
20: ; preds = %18, %16, %14, %12
ret void
}

LLVM IR (-O2):
define void @m97_setParams(i32 %0, i32 %1) {
%3 = shl i32 %1, 14
%4 = and i32 %3, 245760
%5 = tail call i32 @prg16setBank1(i32 %4)
%6 = ashr i32 %1, 6
switch i32 %6, label %13 [
i32 0, label %7
i32 1, label %9
i32 2, label %11
]
7: ; preds = %2
%8 = tail call i32 (...) @ppuSetNameTblSingleLower()
br label %15
9: ; preds = %2
%10 = tail call i32 (...) @ppuSetNameTblHorizontal()
br label %15
11: ; preds = %2
%12 = tail call i32 (...) @ppuSetNameTblVertical()
br label %15
13: ; preds = %2
%14 = tail call i32 (...) @ppuSetNameTblSingleUpper()
br label %15
15: ; preds = %13, %11, %9, %7
ret void
}