#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*/ int96_mulu(unsigned char *, unsigned char *);
int /*<<< orphan*/ int96_negate(unsigned char *);
unsigned char *int96_muls(unsigned char *x, unsigned char *y) {
  int neg = 0;
  if (x[11] >= 0x80) {
    neg = 1;
    int96_negate(x);
  }
  if (y[11] >= 0x80) {
    neg ^= 1;
    int96_negate(y);
  }
  int96_mulu(x, y);
  if (neg)
    int96_negate(x);
  return x;
}


x86 assembly (clang, -O0):
<int96_muls>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x8(%rbp),%rax
movzbl 0xb(%rax),%eax
cmp    $0x80,%eax
jl     115a <int96_muls+0x3a>
movl   $0x1,-0x14(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <int96_negate@plt>
mov    -0x10(%rbp),%rax
movzbl 0xb(%rax),%eax
cmp    $0x80,%eax
jl     117f <int96_muls+0x5f>
mov    -0x14(%rbp),%eax
xor    $0x1,%eax
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <int96_negate@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <int96_mulu@plt>
cmpl   $0x0,-0x14(%rbp)
je     119f <int96_muls+0x7f>
mov    -0x8(%rbp),%rdi
call   1040 <int96_negate@plt>
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<int96_muls>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %rdi,%rbx
xor    %ebp,%ebp
cmpb   $0x0,0xb(%rdi)
js     1158 <int96_muls+0x38>
cmpb   $0x0,0xb(%r14)
js     116c <int96_muls+0x4c>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1030 <int96_mulu@plt>
test   %ebp,%ebp
je     1150 <int96_muls+0x30>
mov    %rbx,%rdi
call   1040 <int96_negate@plt>
mov    %rbx,%rax
pop    %rbx
pop    %r14
pop    %rbp
ret
mov    %rbx,%rdi
call   1040 <int96_negate@plt>
mov    $0x1,%ebp
cmpb   $0x0,0xb(%r14)
jns    1139 <int96_muls+0x19>
xor    $0x1,%ebp
mov    %r14,%rdi
call   1040 <int96_negate@plt>
jmp    1139 <int96_muls+0x19>

LLVM IR (-O0):
define i8* @int96_muls(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32
store i8* %0, i8** %3
store i8* %1, i8** %4
store i32 0, i32* %5
%6 = load i8*, i8** %3
%7 = getelementptr inbounds i8, i8* %6, i64 11
%8 = load i8, i8* %7
%9 = zext i8 %8 to i32
%10 = icmp sge i32 %9, 128
br i1 %10, label %11, label %14
11: ; preds = %2
store i32 1, i32* %5
%12 = load i8*, i8** %3
%13 = call i32 @int96_negate(i8* %12)
br label %14
14: ; preds = %11, %2
%15 = load i8*, i8** %4
%16 = getelementptr inbounds i8, i8* %15, i64 11
%17 = load i8, i8* %16
%18 = zext i8 %17 to i32
%19 = icmp sge i32 %18, 128
br i1 %19, label %20, label %25
20: ; preds = %14
%21 = load i32, i32* %5
%22 = xor i32 %21, 1
store i32 %22, i32* %5
%23 = load i8*, i8** %4
%24 = call i32 @int96_negate(i8* %23)
br label %25
25: ; preds = %20, %14
%26 = load i8*, i8** %3
%27 = load i8*, i8** %4
%28 = call i32 @int96_mulu(i8* %26, i8* %27)
%29 = load i32, i32* %5
%30 = icmp ne i32 %29, 0
br i1 %30, label %31, label %34
31: ; preds = %25
%32 = load i8*, i8** %3
%33 = call i32 @int96_negate(i8* %32)
br label %34
34: ; preds = %31, %25
%35 = load i8*, i8** %3
ret i8* %35
}

LLVM IR (-O2):
define i8* @int96_muls(i8* returned %0, i8* %1) {
%3 = getelementptr inbounds i8, i8* %0, i64 11
%4 = load i8, i8* %3
%5 = icmp slt i8 %4, 0
br i1 %5, label %6, label %8
6: ; preds = %2
%7 = tail call i32 @int96_negate(i8* %0)
br label %8
8: ; preds = %6, %2
%9 = phi i32 [ 1, %6 ], [ 0, %2 ]
%10 = getelementptr inbounds i8, i8* %1, i64 11
%11 = load i8, i8* %10
%12 = icmp slt i8 %11, 0
br i1 %12, label %13, label %16
13: ; preds = %8
%14 = xor i32 %9, 1
%15 = tail call i32 @int96_negate(i8* %1)
br label %16
16: ; preds = %13, %8
%17 = phi i32 [ %14, %13 ], [ %9, %8 ]
%18 = tail call i32 @int96_mulu(i8* %0, i8* %1)
%19 = icmp eq i32 %17, 0
br i1 %19, label %22, label %20
20: ; preds = %16
%21 = tail call i32 @int96_negate(i8* %0)
br label %22
22: ; preds = %20, %16
ret i8* %0
}