#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 */
unsigned int INT_MIN;
unsigned int signed_high_prod(unsigned int, unsigned int);
unsigned unsigned_high_prod(unsigned x, unsigned y) {
  int x_highest_bit = (x & INT_MIN) == INT_MIN;
  int y_highest_bit = (y & INT_MIN) == INT_MIN;
  int result = signed_high_prod(x, y) + x * y_highest_bit + y * x_highest_bit;
  return result;
}


x86 assembly (clang, -O0):
<unsigned_high_prod>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    -0x4(%rbp),%eax
mov    0x2ec0(%rip),%rcx
and    (%rcx),%eax
mov    0x2eb7(%rip),%rcx
cmp    (%rcx),%eax
sete   %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%eax
mov    0x2ea0(%rip),%rcx
and    (%rcx),%eax
mov    0x2e97(%rip),%rcx
cmp    (%rcx),%eax
sete   %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x10(%rbp)
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
call   1030 <signed_high_prod@plt>
mov    -0x4(%rbp),%ecx
imul   -0x10(%rbp),%ecx
add    %ecx,%eax
mov    -0x8(%rbp),%ecx
imul   -0xc(%rbp),%ecx
add    %ecx,%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<unsigned_high_prod>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %esi,%r15d
mov    %edi,%ebp
mov    0x2ec4(%rip),%rax
mov    (%rax),%r14d
mov    %edi,%r12d
not    %r12d
mov    %esi,%ebx
not    %ebx
call   1030 <signed_high_prod@plt>
xor    %ecx,%ecx
test   %ebx,%r14d
cmovne %ecx,%ebp
add    %ebp,%eax
test   %r12d,%r14d
cmove  %r15d,%ecx
add    %ecx,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@INT_MIN = global i32 0
define i32 @unsigned_high_prod(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
%8 = load i32, i32* %3
%9 = load i32, i32* @INT_MIN
%10 = and i32 %8, %9
%11 = load i32, i32* @INT_MIN
%12 = icmp eq i32 %10, %11
%13 = zext i1 %12 to i32
store i32 %13, i32* %5
%14 = load i32, i32* %4
%15 = load i32, i32* @INT_MIN
%16 = and i32 %14, %15
%17 = load i32, i32* @INT_MIN
%18 = icmp eq i32 %16, %17
%19 = zext i1 %18 to i32
store i32 %19, i32* %6
%20 = load i32, i32* %3
%21 = load i32, i32* %4
%22 = call i32 @signed_high_prod(i32 %20, i32 %21)
%23 = load i32, i32* %3
%24 = load i32, i32* %6
%25 = mul i32 %23, %24
%26 = add i32 %22, %25
%27 = load i32, i32* %4
%28 = load i32, i32* %5
%29 = mul i32 %27, %28
%30 = add i32 %26, %29
store i32 %30, i32* %7
%31 = load i32, i32* %7
ret i32 %31
}

LLVM IR (-O2):
@INT_MIN = global i32 0
define i32 @unsigned_high_prod(i32 %0, i32 %1) {
%3 = load i32, i32* @INT_MIN
%4 = and i32 %3, %0
%5 = icmp eq i32 %4, %3
%6 = and i32 %3, %1
%7 = icmp eq i32 %6, %3
%8 = tail call i32 @signed_high_prod(i32 %0, i32 %1)
%9 = select i1 %7, i32 %0, i32 0
%10 = add i32 %9, %8
%11 = select i1 %5, i32 %1, i32 0
%12 = add i32 %10, %11
ret i32 %12
}