int t2ev_mul64_div(unsigned opcode, unsigned address,
                   struct arm_instruction *instruction, char *cp) {
  int op = (opcode >> 4) & 0xf;
  char *infix = "MUL";
  op += (opcode >> 16) & 0x70;
  switch (op) {
  case 0x40:
  case 0x60:
    infix = "MLA";
  case 0:
  case 0x20:
    sprintf(cp, "%c%sL\tr%d, r%d, r%d, r%d", (op & 0x20) ? 'U' : 'S', infix,
            (int)(opcode >> 12) & 0xf, (int)(opcode >> 8) & 0xf,
            (int)(opcode >> 16) & 0xf, (int)(opcode >> 0) & 0xf);
    break;
  case 0x1f:
  case 0x3f:
    sprintf(cp, "%cDIV\tr%d, r%d, r%d", (op & 0x20) ? 'U' : 'S',
            (int)(opcode >> 8) & 0xf, (int)(opcode >> 16) & 0xf,
            (int)(opcode >> 0) & 0xf);
    break;
  default:
    return -1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<t2ev_mul64_div>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x8(%rbp),%eax
shr    $0x4,%eax
and    $0xf,%eax
mov    %eax,-0x24(%rbp)
lea    0xec7(%rip),%rax
mov    %rax,-0x30(%rbp)
movzwl -0x6(%rbp),%ecx
and    $0x70,%ecx
mov    -0x24(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%eax
mov    %eax,-0x34(%rbp)
test   %eax,%eax
je     11bf <t2ev_mul64_div+0xaf>
jmp    115f <t2ev_mul64_div+0x4f>
mov    -0x34(%rbp),%eax
sub    $0x1f,%eax
je     1225 <t2ev_mul64_div+0x115>
jmp    1170 <t2ev_mul64_div+0x60>
mov    -0x34(%rbp),%eax
sub    $0x20,%eax
je     11bf <t2ev_mul64_div+0xaf>
jmp    1181 <t2ev_mul64_div+0x71>
mov    -0x34(%rbp),%eax
sub    $0x3f,%eax
je     1225 <t2ev_mul64_div+0x115>
jmp    1192 <t2ev_mul64_div+0x82>
mov    -0x34(%rbp),%eax
sub    $0x40,%eax
je     11b4 <t2ev_mul64_div+0xa4>
jmp    11a3 <t2ev_mul64_div+0x93>
mov    -0x34(%rbp),%eax
sub    $0x60,%eax
jne    1273 <t2ev_mul64_div+0x163>
jmp    11b4 <t2ev_mul64_div+0xa4>
lea    0xe49(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x24(%rbp),%ecx
and    $0x20,%ecx
mov    $0x53,%edx
mov    $0x55,%eax
cmp    $0x0,%ecx
cmovne %eax,%edx
mov    -0x30(%rbp),%rcx
mov    -0x8(%rbp),%r8d
shr    $0xc,%r8d
and    $0xf,%r8d
mov    -0x8(%rbp),%r9d
shr    $0x8,%r9d
and    $0xf,%r9d
mov    -0x8(%rbp),%r10d
shr    $0x10,%r10d
and    $0xf,%r10d
mov    -0x8(%rbp),%eax
shr    $0x0,%eax
and    $0xf,%eax
lea    0xdf7(%rip),%rsi
mov    %r10d,(%rsp)
mov    %eax,0x8(%rsp)
mov    $0x0,%al
call   1030 <sprintf@plt>
jmp    127f <t2ev_mul64_div+0x16f>
mov    -0x20(%rbp),%rdi
mov    -0x24(%rbp),%ecx
and    $0x20,%ecx
mov    $0x53,%edx
mov    $0x55,%eax
cmp    $0x0,%ecx
cmovne %eax,%edx
mov    -0x8(%rbp),%ecx
shr    $0x8,%ecx
and    $0xf,%ecx
mov    -0x8(%rbp),%r8d
shr    $0x10,%r8d
and    $0xf,%r8d
mov    -0x8(%rbp),%r9d
shr    $0x0,%r9d
and    $0xf,%r9d
lea    0xdba(%rip),%rsi
mov    $0x0,%al
call   1030 <sprintf@plt>
jmp    127f <t2ev_mul64_div+0x16f>
movl   $0xffffffff,-0x4(%rbp)
jmp    1286 <t2ev_mul64_div+0x176>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<t2ev_mul64_div>:
push   %rbx
mov    %edi,%r10d
mov    %edi,%edx
shr    $0x4,%edx
and    $0xf,%edx
mov    %edi,%r11d
shr    $0x10,%r11d
mov    %r11d,%esi
and    $0x70,%esi
lea    0xf58(%rip),%rax
mov    $0xffffffff,%ebx
lea    (%rdx,%rsi,1),%edi
add    $0xffffffe1,%edi
cmp    $0x21,%edi
ja     118a <t2ev_mul64_div+0x7a>
lea    0xeb9(%rip),%rdx
movslq (%rdx,%rdi,4),%rsi
add    %rdx,%rsi
jmp    *%rsi
mov    %r10d,%edx
shr    $0x14,%edx
and    $0x2,%edx
add    $0x53,%edx
mov    %r10d,%eax
shr    $0x8,%eax
and    $0xf,%eax
and    $0xf,%r11d
and    $0xf,%r10d
lea    0xf35(%rip),%rsi
xor    %ebx,%ebx
mov    %rcx,%rdi
mov    %eax,%ecx
mov    %r11d,%r8d
mov    %r10d,%r9d
xor    %eax,%eax
call   1030 <sprintf@plt>
jmp    11e4 <t2ev_mul64_div+0xd4>
or     %esi,%edx
test   %edx,%edx
je     119c <t2ev_mul64_div+0x8c>
cmp    $0x60,%edx
jne    11e4 <t2ev_mul64_div+0xd4>
lea    0xef0(%rip),%rax
mov    %r10d,%edx
shr    $0x14,%edx
and    $0x2,%edx
add    $0x53,%edx
mov    %r10d,%r8d
shr    $0xc,%r8d
and    $0xf,%r8d
mov    %r10d,%r9d
shr    $0x8,%r9d
and    $0xf,%r9d
and    $0xf,%r11d
and    $0xf,%r10d
lea    0xec3(%rip),%rsi
xor    %ebx,%ebx
mov    %rcx,%rdi
mov    %rax,%rcx
xor    %eax,%eax
push   %r10
push   %r11
call   1030 <sprintf@plt>
add    $0x10,%rsp
mov    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
%struct.arm_instruction = type opaque
@.str = [4 x i8] c"MUL\00"
@.str.1 = [4 x i8] c"MLA\00"
@.str.2 = [25 x i8] c"%c%sL\09r%d, r%d, r%d, r%d\00"
@.str.3 = [20 x i8] c"%cDIV\09r%d, r%d, r%d\00"
define i32 @t2ev_mul64_div(i32 %0, i32 %1, %struct.arm_instruction* %2, i8* %3) {
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca %struct.arm_instruction*
%9 = alloca i8*
%10 = alloca i32
%11 = alloca i8*
store i32 %0, i32* %6
store i32 %1, i32* %7
store %struct.arm_instruction* %2, %struct.arm_instruction** %8
store i8* %3, i8** %9
%12 = load i32, i32* %6
%13 = lshr i32 %12, 4
%14 = and i32 %13, 15
store i32 %14, i32* %10
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8** %11
%15 = load i32, i32* %6
%16 = lshr i32 %15, 16
%17 = and i32 %16, 112
%18 = load i32, i32* %10
%19 = add i32 %18, %17
store i32 %19, i32* %10
%20 = load i32, i32* %10
switch i32 %20, label %60 [
i32 64, label %21
i32 96, label %21
i32 0, label %22
i32 32, label %22
i32 31, label %43
i32 63, label %43
]
21: ; preds = %4, %4
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8** %11
br label %22
22: ; preds = %4, %4, %21
%23 = load i8*, i8** %9
%24 = load i32, i32* %10
%25 = and i32 %24, 32
%26 = icmp ne i32 %25, 0
%27 = zext i1 %26 to i64
%28 = select i1 %26, i32 85, i32 83
%29 = load i8*, i8** %11
%30 = load i32, i32* %6
%31 = lshr i32 %30, 12
%32 = and i32 %31, 15
%33 = load i32, i32* %6
%34 = lshr i32 %33, 8
%35 = and i32 %34, 15
%36 = load i32, i32* %6
%37 = lshr i32 %36, 16
%38 = and i32 %37, 15
%39 = load i32, i32* %6
%40 = lshr i32 %39, 0
%41 = and i32 %40, 15
%42 = call i32 (i8*, i8*, ...) @sprintf(i8* %23, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), i32 %28, i8* %29, i32 %32, i32 %35, i32 %38, i32 %41)
br label %61
43: ; preds = %4, %4
%44 = load i8*, i8** %9
%45 = load i32, i32* %10
%46 = and i32 %45, 32
%47 = icmp ne i32 %46, 0
%48 = zext i1 %47 to i64
%49 = select i1 %47, i32 85, i32 83
%50 = load i32, i32* %6
%51 = lshr i32 %50, 8
%52 = and i32 %51, 15
%53 = load i32, i32* %6
%54 = lshr i32 %53, 16
%55 = and i32 %54, 15
%56 = load i32, i32* %6
%57 = lshr i32 %56, 0
%58 = and i32 %57, 15
%59 = call i32 (i8*, i8*, ...) @sprintf(i8* %44, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0), i32 %49, i32 %52, i32 %55, i32 %58)
br label %61
60: ; preds = %4
store i32 -1, i32* %5
br label %62
61: ; preds = %43, %22
store i32 0, i32* %5
br label %62
62: ; preds = %61, %60
%63 = load i32, i32* %5
ret i32 %63
}

LLVM IR (-O2):
%struct.arm_instruction = type opaque
@.str = [4 x i8] c"MUL\00"
@.str.1 = [4 x i8] c"MLA\00"
@.str.2 = [25 x i8] c"%c%sL\09r%d, r%d, r%d, r%d\00"
@.str.3 = [20 x i8] c"%cDIV\09r%d, r%d, r%d\00"
define i32 @t2ev_mul64_div(i32 %0, i32 %1, %struct.arm_instruction* nocapture readnone %2, i8* nocapture writeonly %3) {
%5 = lshr i32 %0, 4
%6 = and i32 %5, 15
%7 = lshr i32 %0, 16
%8 = and i32 %7, 112
%9 = or i32 %6, %8
switch i32 %9, label %32 [
i32 64, label %10
i32 96, label %10
i32 0, label %11
i32 32, label %11
i32 31, label %23
i32 63, label %23
]
10: ; preds = %4, %4
br label %11
11: ; preds = %4, %4, %10
%12 = phi i8* [ getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), %4 ], [ getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), %4 ], [ getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), %10 ]
%13 = and i32 %0, 2097152
%14 = icmp eq i32 %13, 0
%15 = select i1 %14, i32 83, i32 85
%16 = lshr i32 %0, 12
%17 = and i32 %16, 15
%18 = lshr i32 %0, 8
%19 = and i32 %18, 15
%20 = and i32 %7, 15
%21 = and i32 %0, 15
%22 = tail call i32 (i8*, i8*, ...) @sprintf(i8* dereferenceable(1) %3, i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0), i32 %15, i8* %12, i32 %17, i32 %19, i32 %20, i32 %21)
br label %32
23: ; preds = %4, %4
%24 = and i32 %0, 2097152
%25 = icmp eq i32 %24, 0
%26 = select i1 %25, i32 83, i32 85
%27 = lshr i32 %0, 8
%28 = and i32 %27, 15
%29 = and i32 %7, 15
%30 = and i32 %0, 15
%31 = tail call i32 (i8*, i8*, ...) @sprintf(i8* dereferenceable(1) %3, i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0), i32 %26, i32 %28, i32 %29, i32 %30)
br label %32
32: ; preds = %11, %23, %4
%33 = phi i32 [ -1, %4 ], [ 0, %23 ], [ 0, %11 ]
ret i32 %33
}