#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 */
typedef scalar_t__ int32_t;

/* Variables and functions */
scalar_t__ INT32_MAX;
scalar_t__ INT32_MIN;
int32_t safe_mul_func_int32_t_s_s(int32_t _si1, int32_t _si2) {
  return ((((((int32_t)(_si1)) > ((int32_t)0)) &&
            (((int32_t)(_si2)) > ((int32_t)0)) &&
            (((int32_t)(_si1)) > ((INT32_MAX) / ((int32_t)(_si2))))) ||
           ((((int32_t)(_si1)) > ((int32_t)0)) &&
            (((int32_t)(_si2)) <= ((int32_t)0)) &&
            (((int32_t)(_si2)) < ((INT32_MIN) / ((int32_t)(_si1))))) ||
           ((((int32_t)(_si1)) <= ((int32_t)0)) &&
            (((int32_t)(_si2)) > ((int32_t)0)) &&
            (((int32_t)(_si1)) < ((INT32_MIN) / ((int32_t)(_si2))))) ||
           ((((int32_t)(_si1)) <= ((int32_t)0)) &&
            (((int32_t)(_si2)) <= ((int32_t)0)) &&
            (((int32_t)(_si1)) != ((int32_t)0)) &&
            (((int32_t)(_si2)) < ((INT32_MAX) / ((int32_t)(_si1))))))
              ? ((int32_t)(_si1))
              : ((int32_t)(_si1)) * ((int32_t)(_si2)));
}


x86 assembly (clang, -O0):
<safe_mul_func_int32_t_s_s>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpq   $0x0,-0x8(%rbp)
jle    114a <safe_mul_func_int32_t_s_s+0x4a>
cmpq   $0x0,-0x10(%rbp)
jle    114a <safe_mul_func_int32_t_s_s+0x4a>
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    0x2eaf(%rip),%rax
mov    (%rax),%rax
cqto
idivq  -0x10(%rbp)
mov    %rax,%rcx
mov    -0x18(%rbp),%rax
cmp    %rcx,%rax
jg     120f <safe_mul_func_int32_t_s_s+0x10f>
cmpq   $0x0,-0x8(%rbp)
jle    1188 <safe_mul_func_int32_t_s_s+0x88>
cmpq   $0x0,-0x10(%rbp)
jg     1188 <safe_mul_func_int32_t_s_s+0x88>
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    0x2e69(%rip),%rax
mov    (%rax),%rax
cqto
idivq  -0x8(%rbp)
mov    %rax,%rcx
mov    -0x20(%rbp),%rax
cmp    %rcx,%rax
jl     120f <safe_mul_func_int32_t_s_s+0x10f>
cmpq   $0x0,-0x8(%rbp)
jg     11c6 <safe_mul_func_int32_t_s_s+0xc6>
cmpq   $0x0,-0x10(%rbp)
jle    11c6 <safe_mul_func_int32_t_s_s+0xc6>
mov    -0x8(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    0x2e2b(%rip),%rax
mov    (%rax),%rax
cqto
idivq  -0x10(%rbp)
mov    %rax,%rcx
mov    -0x28(%rbp),%rax
cmp    %rcx,%rax
jl     120f <safe_mul_func_int32_t_s_s+0x10f>
cmpq   $0x0,-0x8(%rbp)
jg     121c <safe_mul_func_int32_t_s_s+0x11c>
cmpq   $0x0,-0x10(%rbp)
jg     121c <safe_mul_func_int32_t_s_s+0x11c>
cmpq   $0x0,-0x8(%rbp)
je     121c <safe_mul_func_int32_t_s_s+0x11c>
mov    -0x10(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    0x2dea(%rip),%rax
mov    (%rax),%rax
cqto
idivq  -0x8(%rbp)
mov    %rax,%rcx
mov    -0x30(%rbp),%rax
cmp    %rcx,%rax
jge    121c <safe_mul_func_int32_t_s_s+0x11c>
mov    -0x8(%rbp),%rax
mov    %rax,-0x38(%rbp)
jmp    1229 <safe_mul_func_int32_t_s_s+0x129>
mov    -0x8(%rbp),%rax
imul   -0x10(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<safe_mul_func_int32_t_s_s>:
test   %rdi,%rdi
jle    1127 <safe_mul_func_int32_t_s_s+0x27>
test   %rsi,%rsi
jle    1127 <safe_mul_func_int32_t_s_s+0x27>
mov    0x2ecf(%rip),%rax
mov    (%rax),%rax
mov    %rax,%rcx
or     %rsi,%rcx
shr    $0x20,%rcx
je     1168 <safe_mul_func_int32_t_s_s+0x68>
cqto
idiv   %rsi
jmp    116c <safe_mul_func_int32_t_s_s+0x6c>
test   %rdi,%rdi
jle    113a <safe_mul_func_int32_t_s_s+0x3a>
test   %rsi,%rsi
jg     113a <safe_mul_func_int32_t_s_s+0x3a>
mov    0x2ea0(%rip),%rax
jmp    118d <safe_mul_func_int32_t_s_s+0x8d>
test   %rdi,%rdi
jg     117c <safe_mul_func_int32_t_s_s+0x7c>
test   %rsi,%rsi
jle    117c <safe_mul_func_int32_t_s_s+0x7c>
mov    0x2e8d(%rip),%rax
mov    (%rax),%rax
mov    %rax,%rcx
or     %rsi,%rcx
shr    $0x20,%rcx
je     1173 <safe_mul_func_int32_t_s_s+0x73>
cqto
idiv   %rsi
cmp    %rdi,%rax
jle    117c <safe_mul_func_int32_t_s_s+0x7c>
mov    %rdi,%rax
ret
xor    %edx,%edx
div    %esi
cmp    %rdi,%rax
jl     1164 <safe_mul_func_int32_t_s_s+0x64>
jmp    11b1 <safe_mul_func_int32_t_s_s+0xb1>
xor    %edx,%edx
div    %esi
cmp    %rdi,%rax
jg     1164 <safe_mul_func_int32_t_s_s+0x64>
test   %rdi,%rdi
jns    11b1 <safe_mul_func_int32_t_s_s+0xb1>
test   %rsi,%rsi
jg     11b1 <safe_mul_func_int32_t_s_s+0xb1>
mov    0x2e53(%rip),%rax
mov    (%rax),%rax
mov    %rax,%rcx
or     %rdi,%rcx
shr    $0x20,%rcx
je     11a8 <safe_mul_func_int32_t_s_s+0xa8>
cqto
idiv   %rdi
cmp    %rsi,%rax
jg     1164 <safe_mul_func_int32_t_s_s+0x64>
jmp    11b1 <safe_mul_func_int32_t_s_s+0xb1>
xor    %edx,%edx
div    %edi
cmp    %rsi,%rax
jg     1164 <safe_mul_func_int32_t_s_s+0x64>
imul   %rsi,%rdi
mov    %rdi,%rax
ret

LLVM IR (-O0):
@INT32_MAX = global i64 0
@INT32_MIN = global i64 0
define i64 @safe_mul_func_int32_t_s_s(i64 %0, i64 %1) {
%3 = alloca i64
%4 = alloca i64
store i64 %0, i64* %3
store i64 %1, i64* %4
%5 = load i64, i64* %3
%6 = icmp sgt i64 %5, 0
br i1 %6, label %7, label %16
7: ; preds = %2
%8 = load i64, i64* %4
%9 = icmp sgt i64 %8, 0
br i1 %9, label %10, label %16
10: ; preds = %7
%11 = load i64, i64* %3
%12 = load i64, i64* @INT32_MAX
%13 = load i64, i64* %4
%14 = sdiv i64 %12, %13
%15 = icmp sgt i64 %11, %14
br i1 %15, label %55, label %16
16: ; preds = %10, %7, %2
%17 = load i64, i64* %3
%18 = icmp sgt i64 %17, 0
br i1 %18, label %19, label %28
19: ; preds = %16
%20 = load i64, i64* %4
%21 = icmp sle i64 %20, 0
br i1 %21, label %22, label %28
22: ; preds = %19
%23 = load i64, i64* %4
%24 = load i64, i64* @INT32_MIN
%25 = load i64, i64* %3
%26 = sdiv i64 %24, %25
%27 = icmp slt i64 %23, %26
br i1 %27, label %55, label %28
28: ; preds = %22, %19, %16
%29 = load i64, i64* %3
%30 = icmp sle i64 %29, 0
br i1 %30, label %31, label %40
31: ; preds = %28
%32 = load i64, i64* %4
%33 = icmp sgt i64 %32, 0
br i1 %33, label %34, label %40
34: ; preds = %31
%35 = load i64, i64* %3
%36 = load i64, i64* @INT32_MIN
%37 = load i64, i64* %4
%38 = sdiv i64 %36, %37
%39 = icmp slt i64 %35, %38
br i1 %39, label %55, label %40
40: ; preds = %34, %31, %28
%41 = load i64, i64* %3
%42 = icmp sle i64 %41, 0
br i1 %42, label %43, label %57
43: ; preds = %40
%44 = load i64, i64* %4
%45 = icmp sle i64 %44, 0
br i1 %45, label %46, label %57
46: ; preds = %43
%47 = load i64, i64* %3
%48 = icmp ne i64 %47, 0
br i1 %48, label %49, label %57
49: ; preds = %46
%50 = load i64, i64* %4
%51 = load i64, i64* @INT32_MAX
%52 = load i64, i64* %3
%53 = sdiv i64 %51, %52
%54 = icmp slt i64 %50, %53
br i1 %54, label %55, label %57
55: ; preds = %49, %34, %22, %10
%56 = load i64, i64* %3
br label %61
57: ; preds = %49, %46, %43, %40
%58 = load i64, i64* %3
%59 = load i64, i64* %4
%60 = mul nsw i64 %58, %59
br label %61
61: ; preds = %57, %55
%62 = phi i64 [ %56, %55 ], [ %60, %57 ]
ret i64 %62
}

LLVM IR (-O2):
@INT32_MAX = global i64 0
@INT32_MIN = global i64 0
define i64 @safe_mul_func_int32_t_s_s(i64 %0, i64 %1) {
%3 = icmp sgt i64 %0, 0
%4 = icmp sgt i64 %1, 0
%5 = and i1 %3, %4
br i1 %5, label %6, label %10
6: ; preds = %2
%7 = load i64, i64* @INT32_MAX
%8 = sdiv i64 %7, %1
%9 = icmp slt i64 %8, %0
br i1 %9, label %33, label %31
10: ; preds = %2
%11 = icmp slt i64 %1, 1
%12 = and i1 %3, %11
br i1 %12, label %13, label %17
13: ; preds = %10
%14 = load i64, i64* @INT32_MIN
%15 = sdiv i64 %14, %0
%16 = icmp sgt i64 %15, %1
br i1 %16, label %33, label %31
17: ; preds = %10
%18 = icmp slt i64 %0, 1
%19 = and i1 %18, %4
br i1 %19, label %20, label %24
20: ; preds = %17
%21 = load i64, i64* @INT32_MIN
%22 = sdiv i64 %21, %1
%23 = icmp sgt i64 %22, %0
br i1 %23, label %33, label %24
24: ; preds = %20, %17
%25 = icmp slt i64 %0, 0
%26 = and i1 %25, %11
br i1 %26, label %27, label %31
27: ; preds = %24
%28 = load i64, i64* @INT32_MAX
%29 = sdiv i64 %28, %0
%30 = icmp sgt i64 %29, %1
br i1 %30, label %33, label %31
31: ; preds = %13, %6, %27, %24
%32 = mul nsw i64 %1, %0
br label %33
33: ; preds = %6, %13, %20, %27, %31
%34 = phi i64 [ %32, %31 ], [ %0, %27 ], [ %0, %20 ], [ %0, %13 ], [ %0, %6 ]
ret i64 %34
}