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

/* Variables and functions */
int /*<<< orphan*/ printf(char *, char const *, int, unsigned long);
int readb_idx_reg(int, int);
void dump_sl(const char *pfx) {
  uint8_t val;
  unsigned int sl_size_mb;
  unsigned long rtsf_in_sl_addr;
  uint64_t sl_in_mem_addr, temp;
  val = readb_idx_reg(0x3c5, 0x68);
  switch (val) {
  case 0:
    sl_size_mb = 512;
    break;
  case 0x80:
    sl_size_mb = 256;
    break;
  case 0xc0:
    sl_size_mb = 128;
    break;
  case 0xe0:
    sl_size_mb = 64;
    break;
  case 0xf0:
    sl_size_mb = 32;
    break;
  case 0xf8:
    sl_size_mb = 16;
    break;
  case 0xfc:
    sl_size_mb = 8;
    break;
  case 0xfe:
    sl_size_mb = 4;
    break;
  case 0xff:
    sl_size_mb = 2;
    break;
  }
  rtsf_in_sl_addr = readb_idx_reg(0x3c5, 0x6a) << 12;
  rtsf_in_sl_addr |= readb_idx_reg(0x3c5, 0x6b) << 20;
  val = readb_idx_reg(0x3c5, 0x6c);
  rtsf_in_sl_addr |= (val & 0x1) << 28;
  sl_in_mem_addr = readb_idx_reg(0x3c5, 0x6d) << 21;
  sl_in_mem_addr |= readb_idx_reg(0x3c5, 0x6d) << 29;
  temp = (readb_idx_reg(0x3c5, 0x6d) & 0x7f);
  sl_in_mem_addr |= (temp << 37);
  printf("%sSL in System memory: 0x%llx, RTSF in SL: 0x%lx\n", pfx,
         sl_in_mem_addr, rtsf_in_sl_addr);
}


x86 assembly (clang, -O0):
<dump_sl>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    $0x3c5,%edi
mov    $0x68,%esi
call   1040 <readb_idx_reg@plt>
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x24(%rbp)
test   %eax,%eax
je     11e9 <dump_sl+0xc9>
jmp    1151 <dump_sl+0x31>
mov    -0x24(%rbp),%eax
sub    $0x80,%eax
je     11f5 <dump_sl+0xd5>
jmp    1164 <dump_sl+0x44>
mov    -0x24(%rbp),%eax
sub    $0xc0,%eax
je     1201 <dump_sl+0xe1>
jmp    1177 <dump_sl+0x57>
mov    -0x24(%rbp),%eax
sub    $0xe0,%eax
je     120d <dump_sl+0xed>
jmp    118a <dump_sl+0x6a>
mov    -0x24(%rbp),%eax
sub    $0xf0,%eax
je     1219 <dump_sl+0xf9>
jmp    119d <dump_sl+0x7d>
mov    -0x24(%rbp),%eax
sub    $0xf8,%eax
je     1225 <dump_sl+0x105>
jmp    11b0 <dump_sl+0x90>
mov    -0x24(%rbp),%eax
sub    $0xfc,%eax
je     1231 <dump_sl+0x111>
jmp    11c3 <dump_sl+0xa3>
mov    -0x24(%rbp),%eax
sub    $0xfe,%eax
je     123d <dump_sl+0x11d>
jmp    11d6 <dump_sl+0xb6>
mov    -0x24(%rbp),%eax
sub    $0xff,%eax
je     1249 <dump_sl+0x129>
jmp    1250 <dump_sl+0x130>
movl   $0x200,-0x10(%rbp)
jmp    1250 <dump_sl+0x130>
movl   $0x100,-0x10(%rbp)
jmp    1250 <dump_sl+0x130>
movl   $0x80,-0x10(%rbp)
jmp    1250 <dump_sl+0x130>
movl   $0x40,-0x10(%rbp)
jmp    1250 <dump_sl+0x130>
movl   $0x20,-0x10(%rbp)
jmp    1250 <dump_sl+0x130>
movl   $0x10,-0x10(%rbp)
jmp    1250 <dump_sl+0x130>
movl   $0x8,-0x10(%rbp)
jmp    1250 <dump_sl+0x130>
movl   $0x4,-0x10(%rbp)
jmp    1250 <dump_sl+0x130>
movl   $0x2,-0x10(%rbp)
mov    $0x3c5,%edi
mov    $0x6a,%esi
call   1040 <readb_idx_reg@plt>
shl    $0xc,%eax
cltq
mov    %rax,-0x18(%rbp)
mov    $0x3c5,%edi
mov    $0x6b,%esi
call   1040 <readb_idx_reg@plt>
shl    $0x14,%eax
cltq
or     -0x18(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    $0x3c5,%edi
mov    $0x6c,%esi
call   1040 <readb_idx_reg@plt>
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
and    $0x1,%eax
shl    $0x1c,%eax
cltq
or     -0x18(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    $0x3c5,%edi
mov    $0x6d,%esi
call   1040 <readb_idx_reg@plt>
shl    $0x15,%eax
mov    %eax,-0x1c(%rbp)
mov    $0x3c5,%edi
mov    $0x6d,%esi
call   1040 <readb_idx_reg@plt>
shl    $0x1d,%eax
or     -0x1c(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    $0x3c5,%edi
mov    $0x6d,%esi
call   1040 <readb_idx_reg@plt>
and    $0x7f,%eax
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%eax
mov    $0x25,%ecx
shl    %cl,%eax
or     -0x1c(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x8(%rbp),%rsi
mov    -0x1c(%rbp),%edx
mov    -0x18(%rbp),%rcx
lea    0xcf3(%rip),%rdi
call   1030 <printf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dump_sl>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
mov    $0x3c5,%edi
mov    $0x68,%esi
call   1040 <readb_idx_reg@plt>
mov    $0x3c5,%edi
mov    $0x6a,%esi
call   1040 <readb_idx_reg@plt>
mov    %eax,%ebx
shl    $0xc,%ebx
mov    $0x3c5,%edi
mov    $0x6b,%esi
call   1040 <readb_idx_reg@plt>
shl    $0x14,%eax
or     %ebx,%eax
movslq %eax,%rbx
mov    $0x3c5,%edi
mov    $0x6c,%esi
call   1040 <readb_idx_reg@plt>
and    $0x1,%eax
shl    $0x1c,%eax
or     %rax,%rbx
mov    $0x3c5,%edi
mov    $0x6d,%esi
call   1040 <readb_idx_reg@plt>
mov    $0x3c5,%edi
mov    $0x6d,%esi
call   1040 <readb_idx_reg@plt>
mov    $0x3c5,%edi
mov    $0x6d,%esi
call   1040 <readb_idx_reg@plt>
lea    0xe53(%rip),%rdi
mov    %r14,%rsi
mov    %rbx,%rcx
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <printf@plt>

LLVM IR (-O0):
@.str = [50 x i8] c"%sSL in System memory: 0x%llx, RTSF in SL: 0x%lx\0A\00"
define void @dump_sl(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i32
%5 = alloca i64
%6 = alloca i32
%7 = alloca i32
store i8* %0, i8** %2
%8 = call i32 @readb_idx_reg(i32 965, i32 104)
store i32 %8, i32* %3
%9 = load i32, i32* %3
switch i32 %9, label %19 [
i32 0, label %10
i32 128, label %11
i32 192, label %12
i32 224, label %13
i32 240, label %14
i32 248, label %15
i32 252, label %16
i32 254, label %17
i32 255, label %18
]
10: ; preds = %1
store i32 512, i32* %4
br label %19
11: ; preds = %1
store i32 256, i32* %4
br label %19
12: ; preds = %1
store i32 128, i32* %4
br label %19
13: ; preds = %1
store i32 64, i32* %4
br label %19
14: ; preds = %1
store i32 32, i32* %4
br label %19
15: ; preds = %1
store i32 16, i32* %4
br label %19
16: ; preds = %1
store i32 8, i32* %4
br label %19
17: ; preds = %1
store i32 4, i32* %4
br label %19
18: ; preds = %1
store i32 2, i32* %4
br label %19
19: ; preds = %1, %18, %17, %16, %15, %14, %13, %12, %11, %10
%20 = call i32 @readb_idx_reg(i32 965, i32 106)
%21 = shl i32 %20, 12
%22 = sext i32 %21 to i64
store i64 %22, i64* %5
%23 = call i32 @readb_idx_reg(i32 965, i32 107)
%24 = shl i32 %23, 20
%25 = sext i32 %24 to i64
%26 = load i64, i64* %5
%27 = or i64 %26, %25
store i64 %27, i64* %5
%28 = call i32 @readb_idx_reg(i32 965, i32 108)
store i32 %28, i32* %3
%29 = load i32, i32* %3
%30 = and i32 %29, 1
%31 = shl i32 %30, 28
%32 = sext i32 %31 to i64
%33 = load i64, i64* %5
%34 = or i64 %33, %32
store i64 %34, i64* %5
%35 = call i32 @readb_idx_reg(i32 965, i32 109)
%36 = shl i32 %35, 21
store i32 %36, i32* %6
%37 = call i32 @readb_idx_reg(i32 965, i32 109)
%38 = shl i32 %37, 29
%39 = load i32, i32* %6
%40 = or i32 %39, %38
store i32 %40, i32* %6
%41 = call i32 @readb_idx_reg(i32 965, i32 109)
%42 = and i32 %41, 127
store i32 %42, i32* %7
%43 = load i32, i32* %7
%44 = shl i32 %43, 37
%45 = load i32, i32* %6
%46 = or i32 %45, %44
store i32 %46, i32* %6
%47 = load i8*, i8** %2
%48 = load i32, i32* %6
%49 = load i64, i64* %5
%50 = call i32 @printf(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str, i64 0, i64 0), i8* %47, i32 %48, i64 %49)
ret void
}

LLVM IR (-O2):
@.str = [50 x i8] c"%sSL in System memory: 0x%llx, RTSF in SL: 0x%lx\0A\00"
define void @dump_sl(i8* %0) {
%2 = tail call i32 @readb_idx_reg(i32 965, i32 104)
%3 = tail call i32 @readb_idx_reg(i32 965, i32 106)
%4 = shl i32 %3, 12
%5 = tail call i32 @readb_idx_reg(i32 965, i32 107)
%6 = shl i32 %5, 20
%7 = or i32 %6, %4
%8 = sext i32 %7 to i64
%9 = tail call i32 @readb_idx_reg(i32 965, i32 108)
%10 = shl i32 %9, 28
%11 = and i32 %10, 268435456
%12 = zext i32 %11 to i64
%13 = or i64 %12, %8
%14 = tail call i32 @readb_idx_reg(i32 965, i32 109)
%15 = tail call i32 @readb_idx_reg(i32 965, i32 109)
%16 = tail call i32 @readb_idx_reg(i32 965, i32 109)
%17 = tail call i32 @printf(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str, i64 0, i64 0), i8* %0, i32 poison, i64 %13)
ret void
}