#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*/ WSramAddr(int);
int /*<<< orphan*/ Wreg(int);
int /*<<< orphan*/ Ws(char *);
int WinstB(int i, int code) {
  int reg = (code >> 4) & 0x1f;
  int adr = ((code >> 5) & 0x30) | (code & 0xf);
  if (code & 0x800) {
    Ws("out   ");
    WSramAddr(adr);
    Ws(", ");
    Wreg(reg);
  } else {
    Ws("in    ");
    Wreg(reg);
    Ws(", ");
    WSramAddr(adr);
  }
  return 0;
}


x86 assembly (clang, -O0):
<WinstB>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    -0x8(%rbp),%eax
sar    $0x4,%eax
and    $0x1f,%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%eax
sar    $0x5,%eax
and    $0x30,%eax
mov    -0x8(%rbp),%ecx
and    $0xf,%ecx
or     %ecx,%eax
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%eax
and    $0x800,%eax
cmp    $0x0,%eax
je     119c <WinstB+0x6c>
lea    0xe8a(%rip),%rdi
call   1030 <Ws@plt>
mov    -0x10(%rbp),%edi
call   1040 <WSramAddr@plt>
lea    0xe7d(%rip),%rdi
call   1030 <Ws@plt>
mov    -0xc(%rbp),%edi
call   1050 <Wreg@plt>
jmp    11c4 <WinstB+0x94>
lea    0xe67(%rip),%rdi
call   1030 <Ws@plt>
mov    -0xc(%rbp),%edi
call   1050 <Wreg@plt>
lea    0xe50(%rip),%rdi
call   1030 <Ws@plt>
mov    -0x10(%rbp),%edi
call   1040 <WSramAddr@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<WinstB>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebx
shr    $0x4,%ebx
and    $0x1f,%ebx
mov    %esi,%eax
shr    $0x5,%eax
and    $0x30,%eax
mov    %esi,%ebp
and    $0xf,%ebp
or     %eax,%ebp
test   $0x800,%esi
jne    117a <WinstB+0x4a>
lea    0xeb1(%rip),%rdi
call   1030 <Ws@plt>
mov    %ebx,%edi
call   1050 <Wreg@plt>
lea    0xe9b(%rip),%rdi
call   1030 <Ws@plt>
mov    %ebp,%edi
call   1040 <WSramAddr@plt>
jmp    11a0 <WinstB+0x70>
lea    0xe7f(%rip),%rdi
call   1030 <Ws@plt>
mov    %ebp,%edi
call   1040 <WSramAddr@plt>
lea    0xe73(%rip),%rdi
call   1030 <Ws@plt>
mov    %ebx,%edi
call   1050 <Wreg@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [7 x i8] c"out \00"
@.str.1 = [3 x i8] c", \00"
@.str.2 = [7 x i8] c"in \00"
define i32 @WinstB(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 = ashr i32 %7, 4
%9 = and i32 %8, 31
store i32 %9, i32* %5
%10 = load i32, i32* %4
%11 = ashr i32 %10, 5
%12 = and i32 %11, 48
%13 = load i32, i32* %4
%14 = and i32 %13, 15
%15 = or i32 %12, %14
store i32 %15, i32* %6
%16 = load i32, i32* %4
%17 = and i32 %16, 2048
%18 = icmp ne i32 %17, 0
br i1 %18, label %19, label %26
19: ; preds = %2
%20 = call i32 @Ws(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%21 = load i32, i32* %6
%22 = call i32 @WSramAddr(i32 %21)
%23 = call i32 @Ws(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%24 = load i32, i32* %5
%25 = call i32 @Wreg(i32 %24)
br label %33
26: ; preds = %2
%27 = call i32 @Ws(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
%28 = load i32, i32* %5
%29 = call i32 @Wreg(i32 %28)
%30 = call i32 @Ws(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%31 = load i32, i32* %6
%32 = call i32 @WSramAddr(i32 %31)
br label %33
33: ; preds = %26, %19
ret i32 0
}

LLVM IR (-O2):
@.str = [7 x i8] c"out \00"
@.str.1 = [3 x i8] c", \00"
@.str.2 = [7 x i8] c"in \00"
define i32 @WinstB(i32 %0, i32 %1) {
%3 = lshr i32 %1, 4
%4 = and i32 %3, 31
%5 = lshr i32 %1, 5
%6 = and i32 %5, 48
%7 = and i32 %1, 15
%8 = or i32 %6, %7
%9 = and i32 %1, 2048
%10 = icmp eq i32 %9, 0
br i1 %10, label %16, label %11
11: ; preds = %2
%12 = tail call i32 @Ws(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%13 = tail call i32 @WSramAddr(i32 %8)
%14 = tail call i32 @Ws(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%15 = tail call i32 @Wreg(i32 %4)
br label %21
16: ; preds = %2
%17 = tail call i32 @Ws(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0))
%18 = tail call i32 @Wreg(i32 %4)
%19 = tail call i32 @Ws(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%20 = tail call i32 @WSramAddr(i32 %8)
br label %21
21: ; preds = %16, %11
ret i32 0
}