#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 operand_read(int, int);
int __ms(int ea, int designator, int *target) {
  int multiplicand = *target;
  int multiplier;
  if ((multiplier = operand_read(ea, designator)) < 0)
    return -14;
  multiplicand = (multiplicand << 8) >> 8;
  multiplier = (multiplier << 8) >> 8;
  *target = (multiplicand * multiplier) & 0x00FFFFFF;
  return 0;
}


x86 assembly (clang, -O0):
<__ms>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
call   1030 <operand_read@plt>
mov    %eax,-0x20(%rbp)
cmp    $0x0,%eax
jge    114e <__ms+0x3e>
movl   $0xfffffff2,-0x4(%rbp)
jmp    1180 <__ms+0x70>
mov    -0x1c(%rbp),%eax
shl    $0x8,%eax
sar    $0x8,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x20(%rbp),%eax
shl    $0x8,%eax
sar    $0x8,%eax
mov    %eax,-0x20(%rbp)
mov    -0x1c(%rbp),%ecx
imul   -0x20(%rbp),%ecx
and    $0xffffff,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<__ms>:
push   %rbp
push   %rbx
push   %rax
mov    %rdx,%rbx
mov    (%rdx),%ebp
call   1030 <operand_read@plt>
test   %eax,%eax
js     112f <__ms+0x1f>
imul   %ebp,%eax
and    $0xffffff,%eax
mov    %eax,(%rbx)
xor    %eax,%eax
jmp    1134 <__ms+0x24>
mov    $0xfffffff2,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define i32 @__ms(i32 %0, i32 %1, i32* %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32*
%8 = alloca i32
%9 = alloca i32
store i32 %0, i32* %5
store i32 %1, i32* %6
store i32* %2, i32** %7
%10 = load i32*, i32** %7
%11 = load i32, i32* %10
store i32 %11, i32* %8
%12 = load i32, i32* %5
%13 = load i32, i32* %6
%14 = call i32 @operand_read(i32 %12, i32 %13)
store i32 %14, i32* %9
%15 = icmp slt i32 %14, 0
br i1 %15, label %16, label %17
16: ; preds = %3
store i32 -14, i32* %4
br label %29
17: ; preds = %3
%18 = load i32, i32* %8
%19 = shl i32 %18, 8
%20 = ashr i32 %19, 8
store i32 %20, i32* %8
%21 = load i32, i32* %9
%22 = shl i32 %21, 8
%23 = ashr i32 %22, 8
store i32 %23, i32* %9
%24 = load i32, i32* %8
%25 = load i32, i32* %9
%26 = mul nsw i32 %24, %25
%27 = and i32 %26, 16777215
%28 = load i32*, i32** %7
store i32 %27, i32* %28
store i32 0, i32* %4
br label %29
29: ; preds = %17, %16
%30 = load i32, i32* %4
ret i32 %30
}

LLVM IR (-O2):
define i32 @__ms(i32 %0, i32 %1, i32* nocapture %2) {
%4 = load i32, i32* %2
%5 = tail call i32 @operand_read(i32 %0, i32 %1)
%6 = icmp slt i32 %5, 0
br i1 %6, label %14, label %7
7: ; preds = %3
%8 = shl i32 %4, 8
%9 = ashr exact i32 %8, 8
%10 = shl i32 %5, 8
%11 = ashr exact i32 %10, 8
%12 = mul nsw i32 %11, %9
%13 = and i32 %12, 16777215
store i32 %13, i32* %2
br label %14
14: ; preds = %3, %7
%15 = phi i32 [ 0, %7 ], [ -14, %3 ]
ret i32 %15
}