#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*/ st(unsigned char *, unsigned char, int);
void setplayerbright(unsigned char player, char bright) {
  unsigned char xofs, v;
  switch (player) {
  default:
  case 0:
    xofs = 5;
    v = (((0) << 7) | ((0) << 6) | ((0) << 3) | (2));
    break;
  case 1:
    xofs = 11;
    v = (((0) << 7) | ((0) << 6) | ((0) << 3) | (4));
    break;
  case 2:
    xofs = 17;
    v = (((0) << 7) | ((0) << 6) | ((0) << 3) | (5));
    break;
  case 3:
    xofs = 23;
    v = (((0) << 7) | ((0) << 6) | ((0) << 3) | (6));
    break;
  }
  if (bright) {
    v |= (((0) << 7) | ((1) << 6) | ((0) << 3) | (0));
  }
  if (bright < 0)
    v = 0;
  st((unsigned char *)0x5800 + 11 * 32 + xofs, v, 3);
  st((unsigned char *)0x5800 + 12 * 32 + xofs, v, 5);
  *((unsigned char *)0x5800 + 13 * 32 + xofs) = v;
  *((unsigned char *)0x5804 + 13 * 32 + xofs) = v;
  st((unsigned char *)0x5800 + 14 * 32 + xofs, v, 5);
}


x86 assembly (clang, -O0):
<setplayerbright>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %sil,%al
mov    %dil,%cl
mov    %cl,-0x1(%rbp)
mov    %al,-0x2(%rbp)
movzbl -0x1(%rbp),%eax
mov    %rax,-0x10(%rbp)
sub    $0x3,%rax
ja     114a <setplayerbright+0x3a>
mov    -0x10(%rbp),%rax
lea    0xebf(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
jmp    114f <setplayerbright+0x3f>
movb   $0x5,-0x3(%rbp)
movb   $0x2,-0x4(%rbp)
jmp    117e <setplayerbright+0x6e>
movb   $0xb,-0x3(%rbp)
movb   $0x4,-0x4(%rbp)
jmp    117e <setplayerbright+0x6e>
movb   $0x11,-0x3(%rbp)
movb   $0x5,-0x4(%rbp)
jmp    117e <setplayerbright+0x6e>
movb   $0x17,-0x3(%rbp)
movb   $0x6,-0x4(%rbp)
cmpb   $0x0,-0x2(%rbp)
je     1192 <setplayerbright+0x82>
movzbl -0x4(%rbp),%eax
or     $0x40,%eax
mov    %al,-0x4(%rbp)
movsbl -0x2(%rbp),%eax
cmp    $0x0,%eax
jge    11a3 <setplayerbright+0x93>
movb   $0x0,-0x4(%rbp)
movzbl -0x3(%rbp),%eax
cltq
mov    $0x5800,%edi
add    $0x160,%rdi
add    %rax,%rdi
mov    $0x3,%edx
movzbl -0x4(%rbp),%esi
call   1030 <st@plt>
movzbl -0x3(%rbp),%eax
cltq
mov    $0x5800,%edi
add    $0x180,%rdi
add    %rax,%rdi
mov    $0x5,%edx
movzbl -0x4(%rbp),%esi
call   1030 <st@plt>
mov    -0x4(%rbp),%dl
movzbl -0x3(%rbp),%eax
movslq %eax,%rcx
mov    $0x5800,%eax
mov    %dl,0x1a0(%rax,%rcx,1)
mov    -0x4(%rbp),%dl
movzbl -0x3(%rbp),%eax
movslq %eax,%rcx
mov    $0x5804,%eax
mov    %dl,0x1a0(%rax,%rcx,1)
movzbl -0x3(%rbp),%eax
cltq
mov    $0x5800,%edi
add    $0x1c0,%rdi
add    %rax,%rdi
mov    $0x5,%edx
movzbl -0x4(%rbp),%esi
call   1030 <st@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<setplayerbright>:
push   %rbp
push   %r14
push   %rbx
lea    -0x1(%rdi),%eax
add    $0x3,%dil
cmp    $0x3,%al
movzbl %al,%eax
lea    (%rax,%rax,2),%rax
lea    0xb(%rax,%rax,1),%rax
mov    $0x5,%r14d
cmovb  %rax,%r14
movzbl %dil,%eax
mov    $0x2,%ecx
cmovb  %eax,%ecx
mov    %ecx,%eax
or     $0x40,%al
movzbl %al,%eax
xor    %edx,%edx
test   %sil,%sil
cmove  %ecx,%eax
cmovs  %edx,%eax
lea    0x5960(%r14),%rbx
movzbl %al,%ebp
mov    %rbx,%rdi
mov    %ebp,%esi
mov    $0x3,%edx
call   1030 <st@plt>
lea    0x20(%rbx),%rdi
mov    %ebp,%esi
mov    $0x5,%edx
call   1030 <st@plt>
mov    %bpl,0x59a0(%r14)
mov    %bpl,0x59a4(%r14)
add    $0x60,%rbx
mov    %rbx,%rdi
mov    %ebp,%esi
mov    $0x5,%edx
pop    %rbx
pop    %r14
pop    %rbp
jmp    1030 <st@plt>

LLVM IR (-O0):
define void @setplayerbright(i8 zeroext %0, i8 signext %1) {
%3 = alloca i8
%4 = alloca i8
%5 = alloca i8
%6 = alloca i8
store i8 %0, i8* %3
store i8 %1, i8* %4
%7 = load i8, i8* %3
%8 = zext i8 %7 to i32
switch i32 %8, label %9 [
i32 0, label %10
i32 1, label %11
i32 2, label %12
i32 3, label %13
]
9: ; preds = %2
br label %10
10: ; preds = %2, %9
store i8 5, i8* %5
store i8 2, i8* %6
br label %14
11: ; preds = %2
store i8 11, i8* %5
store i8 4, i8* %6
br label %14
12: ; preds = %2
store i8 17, i8* %5
store i8 5, i8* %6
br label %14
13: ; preds = %2
store i8 23, i8* %5
store i8 6, i8* %6
br label %14
14: ; preds = %13, %12, %11, %10
%15 = load i8, i8* %4
%16 = icmp ne i8 %15, 0
br i1 %16, label %17, label %22
17: ; preds = %14
%18 = load i8, i8* %6
%19 = zext i8 %18 to i32
%20 = or i32 %19, 64
%21 = trunc i32 %20 to i8
store i8 %21, i8* %6
br label %22
22: ; preds = %17, %14
%23 = load i8, i8* %4
%24 = sext i8 %23 to i32
%25 = icmp slt i32 %24, 0
br i1 %25, label %26, label %27
26: ; preds = %22
store i8 0, i8* %6
br label %27
27: ; preds = %26, %22
%28 = load i8, i8* %5
%29 = zext i8 %28 to i32
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds i8, i8* getelementptr inbounds (i8, i8* inttoptr (i64 22528 to i8*), i64 352), i64 %30
%32 = load i8, i8* %6
%33 = call i32 @st(i8* %31, i8 zeroext %32, i32 3)
%34 = load i8, i8* %5
%35 = zext i8 %34 to i32
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds i8, i8* getelementptr inbounds (i8, i8* inttoptr (i64 22528 to i8*), i64 384), i64 %36
%38 = load i8, i8* %6
%39 = call i32 @st(i8* %37, i8 zeroext %38, i32 5)
%40 = load i8, i8* %6
%41 = load i8, i8* %5
%42 = zext i8 %41 to i32
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds i8, i8* getelementptr inbounds (i8, i8* inttoptr (i64 22528 to i8*), i64 416), i64 %43
store i8 %40, i8* %44
%45 = load i8, i8* %6
%46 = load i8, i8* %5
%47 = zext i8 %46 to i32
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds i8, i8* getelementptr inbounds (i8, i8* inttoptr (i64 22532 to i8*), i64 416), i64 %48
store i8 %45, i8* %49
%50 = load i8, i8* %5
%51 = zext i8 %50 to i32
%52 = sext i32 %51 to i64
%53 = getelementptr inbounds i8, i8* getelementptr inbounds (i8, i8* inttoptr (i64 22528 to i8*), i64 448), i64 %52
%54 = load i8, i8* %6
%55 = call i32 @st(i8* %53, i8 zeroext %54, i32 5)
ret void
}

LLVM IR (-O2):
define void @setplayerbright(i8 zeroext %0, i8 signext %1) {
%3 = add i8 %0, -1
%4 = icmp ult i8 %3, 3
%5 = zext i8 %3 to i64
%6 = mul nuw nsw i64 %5, 6
%7 = add nuw nsw i64 %6, 11
%8 = add i8 %0, 3
%9 = select i1 %4, i64 %7, i64 5
%10 = select i1 %4, i8 %8, i8 2
%11 = icmp eq i8 %1, 0
%12 = or i8 %10, 64
%13 = select i1 %11, i8 %10, i8 %12
%14 = icmp slt i8 %1, 0
%15 = select i1 %14, i8 0, i8 %13
%16 = getelementptr inbounds i8, i8* inttoptr (i64 22880 to i8*), i64 %9
%17 = tail call i32 @st(i8* %16, i8 zeroext %15, i32 3)
%18 = getelementptr inbounds i8, i8* inttoptr (i64 22912 to i8*), i64 %9
%19 = tail call i32 @st(i8* %18, i8 zeroext %15, i32 5)
%20 = getelementptr inbounds i8, i8* inttoptr (i64 22944 to i8*), i64 %9
store i8 %15, i8* %20
%21 = getelementptr inbounds i8, i8* inttoptr (i64 22948 to i8*), i64 %9
store i8 %15, i8* %21
%22 = getelementptr inbounds i8, i8* inttoptr (i64 22976 to i8*), i64 %9
%23 = tail call i32 @st(i8* %22, i8 zeroext %15, i32 5)
ret void
}