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

/* Variables and functions */
int /*<<< orphan*/ get_dreg(int);
int get_opa(int);
int /*<<< orphan*/ get_opd(int);
int /*<<< orphan*/ insn_load(int);
int /*<<< orphan*/ io_out(int, int /*<<< orphan*/);
int /*<<< orphan*/ set_reg(int /*<<< orphan*/, int, int);
int /*<<< orphan*/ sim_warning(char *);
int /*<<< orphan*/ sr_write(int /*<<< orphan*/, int);
void insn_moveloadstore(uint32_t insn) {
  switch (insn & 0x07c00000) {
  case 0x00400000:
    sr_write(get_dreg(insn), get_opa(insn));
    break;
  case 0x02000000:
    set_reg(get_dreg(insn), insn & 0xffff, 1);
    break;
  case 0x02400000:
    sr_write(get_dreg(insn), insn & 0xffff);
    break;
  case 0x04c00000:
    io_out(insn & 0xffff, get_opd(insn));
    break;
  case 0x04000000:
    insn_load(insn);
    break;
  default:
    sim_warning("Unimplemented move/load/store");
    break;
  }
}


x86 assembly (clang, -O0):
<insn_moveloadstore>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%eax
and    $0x7c00000,%eax
mov    %eax,-0x8(%rbp)
sub    $0x400000,%eax
je     11f2 <insn_moveloadstore+0x72>
jmp    11a6 <insn_moveloadstore+0x26>
mov    -0x8(%rbp),%eax
sub    $0x2000000,%eax
je     1214 <insn_moveloadstore+0x94>
jmp    11b9 <insn_moveloadstore+0x39>
mov    -0x8(%rbp),%eax
sub    $0x2400000,%eax
je     1236 <insn_moveloadstore+0xb6>
jmp    11cc <insn_moveloadstore+0x4c>
mov    -0x8(%rbp),%eax
sub    $0x4000000,%eax
je     1275 <insn_moveloadstore+0xf5>
jmp    11df <insn_moveloadstore+0x5f>
mov    -0x8(%rbp),%eax
sub    $0x4c00000,%eax
je     1253 <insn_moveloadstore+0xd3>
jmp    1282 <insn_moveloadstore+0x102>
mov    -0x4(%rbp),%edi
call   1090 <get_dreg@plt>
mov    %eax,-0xc(%rbp)
mov    -0x4(%rbp),%edi
call   1060 <get_opa@plt>
mov    -0xc(%rbp),%edi
mov    %eax,%esi
call   1080 <sr_write@plt>
jmp    128e <insn_moveloadstore+0x10e>
mov    -0x4(%rbp),%edi
call   1090 <get_dreg@plt>
mov    %eax,%edi
mov    -0x4(%rbp),%esi
and    $0xffff,%esi
mov    $0x1,%edx
call   10a0 <set_reg@plt>
jmp    128e <insn_moveloadstore+0x10e>
mov    -0x4(%rbp),%edi
call   1090 <get_dreg@plt>
mov    %eax,%edi
mov    -0x4(%rbp),%esi
and    $0xffff,%esi
call   1080 <sr_write@plt>
jmp    128e <insn_moveloadstore+0x10e>
mov    -0x4(%rbp),%eax
and    $0xffff,%eax
mov    %eax,-0x10(%rbp)
mov    -0x4(%rbp),%edi
call   1030 <get_opd@plt>
mov    -0x10(%rbp),%edi
mov    %eax,%esi
call   1040 <io_out@plt>
jmp    128e <insn_moveloadstore+0x10e>
mov    -0x4(%rbp),%edi
call   1050 <insn_load@plt>
jmp    128e <insn_moveloadstore+0x10e>
lea    0xd77(%rip),%rdi
call   1070 <sim_warning@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<insn_moveloadstore>:
push   %rbp
push   %rbx
push   %rax
mov    %edi,%ebx
mov    %edi,%eax
and    $0x7c00000,%eax
cmp    $0x23fffff,%eax
jle    11c1 <insn_moveloadstore+0x41>
cmp    $0x2400000,%eax
je     11eb <insn_moveloadstore+0x6b>
cmp    $0x4000000,%eax
je     11f9 <insn_moveloadstore+0x79>
cmp    $0x4c00000,%eax
jne    1225 <insn_moveloadstore+0xa5>
movzwl %bx,%ebp
mov    %ebx,%edi
call   1030 <get_opd@plt>
mov    %ebp,%edi
mov    %eax,%esi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1040 <io_out@plt>
cmp    $0x400000,%eax
je     1206 <insn_moveloadstore+0x86>
cmp    $0x2000000,%eax
jne    1225 <insn_moveloadstore+0xa5>
mov    %ebx,%edi
call   1090 <get_dreg@plt>
movzwl %bx,%esi
mov    %eax,%edi
mov    $0x1,%edx
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    10a0 <set_reg@plt>
mov    %ebx,%edi
call   1090 <get_dreg@plt>
movzwl %bx,%esi
mov    %eax,%edi
jmp    121a <insn_moveloadstore+0x9a>
mov    %ebx,%edi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1050 <insn_load@plt>
mov    %ebx,%edi
call   1090 <get_dreg@plt>
mov    %eax,%ebp
mov    %ebx,%edi
call   1060 <get_opa@plt>
mov    %ebp,%edi
mov    %eax,%esi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1080 <sr_write@plt>
lea    0xdd4(%rip),%rdi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1070 <sim_warning@plt>

LLVM IR (-O0):
@.str = [30 x i8] c"Unimplemented move/load/store\00"
define void @insn_moveloadstore(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = load i32, i32* %2
%4 = and i32 %3, 130023424
switch i32 %4, label %32 [
i32 4194304, label %5
i32 33554432, label %11
i32 37748736, label %17
i32 79691776, label %23
i32 67108864, label %29
]
5: ; preds = %1
%6 = load i32, i32* %2
%7 = call i32 @get_dreg(i32 %6)
%8 = load i32, i32* %2
%9 = call i32 @get_opa(i32 %8)
%10 = call i32 @sr_write(i32 %7, i32 %9)
br label %34
11: ; preds = %1
%12 = load i32, i32* %2
%13 = call i32 @get_dreg(i32 %12)
%14 = load i32, i32* %2
%15 = and i32 %14, 65535
%16 = call i32 @set_reg(i32 %13, i32 %15, i32 1)
br label %34
17: ; preds = %1
%18 = load i32, i32* %2
%19 = call i32 @get_dreg(i32 %18)
%20 = load i32, i32* %2
%21 = and i32 %20, 65535
%22 = call i32 @sr_write(i32 %19, i32 %21)
br label %34
23: ; preds = %1
%24 = load i32, i32* %2
%25 = and i32 %24, 65535
%26 = load i32, i32* %2
%27 = call i32 @get_opd(i32 %26)
%28 = call i32 @io_out(i32 %25, i32 %27)
br label %34
29: ; preds = %1
%30 = load i32, i32* %2
%31 = call i32 @insn_load(i32 %30)
br label %34
32: ; preds = %1
%33 = call i32 @sim_warning(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0))
br label %34
34: ; preds = %32, %29, %23, %17, %11, %5
ret void
}

LLVM IR (-O2):
@.str = [30 x i8] c"Unimplemented move/load/store\00"
define void @insn_moveloadstore(i32 %0) {
%2 = and i32 %0, 130023424
switch i32 %2, label %21 [
i32 4194304, label %3
i32 33554432, label %7
i32 37748736, label %11
i32 79691776, label %15
i32 67108864, label %19
]
3: ; preds = %1
%4 = tail call i32 @get_dreg(i32 %0)
%5 = tail call i32 @get_opa(i32 %0)
%6 = tail call i32 @sr_write(i32 %4, i32 %5)
br label %23
7: ; preds = %1
%8 = tail call i32 @get_dreg(i32 %0)
%9 = and i32 %0, 65535
%10 = tail call i32 @set_reg(i32 %8, i32 %9, i32 1)
br label %23
11: ; preds = %1
%12 = tail call i32 @get_dreg(i32 %0)
%13 = and i32 %0, 65535
%14 = tail call i32 @sr_write(i32 %12, i32 %13)
br label %23
15: ; preds = %1
%16 = and i32 %0, 65535
%17 = tail call i32 @get_opd(i32 %0)
%18 = tail call i32 @io_out(i32 %16, i32 %17)
br label %23
19: ; preds = %1
%20 = tail call i32 @insn_load(i32 %0)
br label %23
21: ; preds = %1
%22 = tail call i32 @sim_warning(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0))
br label %23
23: ; preds = %21, %19, %15, %11, %7, %3
ret void
}