#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 READ_TX0_18BIT(unsigned int);
int /*<<< orphan*/ sprintf(char *, char *, int);
unsigned dasmtx0_64kw(char *buffer, unsigned _pc) {
  int md;
  int x;
  md = READ_TX0_18BIT(_pc);
  x = md & 0177777;
  switch (md >> 16) {
  case 0:
    sprintf(buffer, "sto 0%06o", x);
    break;
  case 1:
    sprintf(buffer, "add 0%06o", x);
    break;
  case 2:
    sprintf(buffer, "trn 0%06o", x);
    break;
  case 3:
    sprintf(buffer, "opr 0%06o", x);
    break;
  }
  return 1;
}


x86 assembly (clang, -O0):
<dasmtx0_64kw>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0xc(%rbp),%edi
call   1040 <READ_TX0_18BIT@plt>
mov    %eax,-0x10(%rbp)
movzwl -0x10(%rbp),%eax
mov    %eax,-0x14(%rbp)
movswl -0xe(%rbp),%eax
mov    %eax,%ecx
mov    %rcx,-0x20(%rbp)
sub    $0x3,%eax
ja     11c3 <dasmtx0_64kw+0xa3>
mov    -0x20(%rbp),%rax
lea    0xea1(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x8(%rbp),%rdi
mov    -0x14(%rbp),%edx
lea    0xe9a(%rip),%rsi
call   1030 <sprintf@plt>
jmp    11c3 <dasmtx0_64kw+0xa3>
mov    -0x8(%rbp),%rdi
mov    -0x14(%rbp),%edx
lea    0xe8c(%rip),%rsi
call   1030 <sprintf@plt>
jmp    11c3 <dasmtx0_64kw+0xa3>
mov    -0x8(%rbp),%rdi
mov    -0x14(%rbp),%edx
lea    0xe7e(%rip),%rsi
call   1030 <sprintf@plt>
jmp    11c3 <dasmtx0_64kw+0xa3>
mov    -0x8(%rbp),%rdi
mov    -0x14(%rbp),%edx
lea    0xe70(%rip),%rsi
call   1030 <sprintf@plt>
mov    $0x1,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dasmtx0_64kw>:
push   %rbx
mov    %rdi,%rbx
mov    %esi,%edi
call   1040 <READ_TX0_18BIT@plt>
cmp    $0x3ffff,%eax
ja     1153 <dasmtx0_64kw+0x33>
mov    %eax,%ecx
sar    $0x10,%ecx
movzwl %ax,%edx
movslq %ecx,%rax
lea    0xee4(%rip),%rcx
movslq (%rcx,%rax,4),%rsi
add    %rcx,%rsi
mov    %rbx,%rdi
call   1030 <sprintf@plt>
mov    $0x1,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [10 x i8] c"sto 0%06o\00"
@.str.1 = [10 x i8] c"add 0%06o\00"
@.str.2 = [10 x i8] c"trn 0%06o\00"
@.str.3 = [10 x i8] c"opr 0%06o\00"
define i32 @dasmtx0_64kw(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i8* %0, i8** %3
store i32 %1, i32* %4
%7 = load i32, i32* %4
%8 = call i32 @READ_TX0_18BIT(i32 %7)
store i32 %8, i32* %5
%9 = load i32, i32* %5
%10 = and i32 %9, 65535
store i32 %10, i32* %6
%11 = load i32, i32* %5
%12 = ashr i32 %11, 16
switch i32 %12, label %29 [
i32 0, label %13
i32 1, label %17
i32 2, label %21
i32 3, label %25
]
13: ; preds = %2
%14 = load i8*, i8** %3
%15 = load i32, i32* %6
%16 = call i32 @sprintf(i8* %14, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 %15)
br label %29
17: ; preds = %2
%18 = load i8*, i8** %3
%19 = load i32, i32* %6
%20 = call i32 @sprintf(i8* %18, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i32 %19)
br label %29
21: ; preds = %2
%22 = load i8*, i8** %3
%23 = load i32, i32* %6
%24 = call i32 @sprintf(i8* %22, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i32 %23)
br label %29
25: ; preds = %2
%26 = load i8*, i8** %3
%27 = load i32, i32* %6
%28 = call i32 @sprintf(i8* %26, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i32 %27)
br label %29
29: ; preds = %2, %25, %21, %17, %13
ret i32 1
}

LLVM IR (-O2):
@.str = [10 x i8] c"sto 0%06o\00"
@.str.1 = [10 x i8] c"add 0%06o\00"
@.str.2 = [10 x i8] c"trn 0%06o\00"
@.str.3 = [10 x i8] c"opr 0%06o\00"
@reltable.dasmtx0_64kw = [4 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([10 x i8]* @.str to i64), i64 ptrtoint ([4 x i32]* @reltable.dasmtx0_64kw to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([10 x i8]* @.str.1 to i64), i64 ptrtoint ([4 x i32]* @reltable.dasmtx0_64kw to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([10 x i8]* @.str.2 to i64), i64 ptrtoint ([4 x i32]* @reltable.dasmtx0_64kw to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([10 x i8]* @.str.3 to i64), i64 ptrtoint ([4 x i32]* @reltable.dasmtx0_64kw to i64)) to i32)]
define i32 @dasmtx0_64kw(i8* nocapture writeonly %0, i32 %1) {
%3 = tail call i32 @READ_TX0_18BIT(i32 %1)
%4 = icmp ult i32 %3, 262144
br i1 %4, label %5, label %12
5: ; preds = %2
%6 = ashr i32 %3, 16
%7 = and i32 %3, 65535
%8 = sext i32 %6 to i64
%9 = shl i64 %8, 2
%10 = call i8* @llvm.load.relative.i64(i8* bitcast ([4 x i32]* @reltable.dasmtx0_64kw to i8*), i64 %9)
%11 = tail call i32 @sprintf(i8* dereferenceable(1) %0, i8* dereferenceable(1) %10, i32 %7)
br label %12
12: ; preds = %2, %5
ret i32 1
}