#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*/ printf(char *, long, long);
int product(long, long, long *);
void run_test(long multiplier, long multiplicand, long expected_product,
              int expected_result) {
  long test_product;
  int test_result;
  test_result = product(multiplier, multiplicand, &test_product);
  if (test_result != expected_result) {
    printf("FAILURE on %ld * %ld\n", multiplier, multiplicand);
    return;
  }
  if (test_result == -1 || test_product == expected_product) {
    printf("Success on %ld * %ld\n", multiplier, multiplicand);
  } else {
    printf("FAILURE on %ld * %ld\n", multiplier, multiplicand);
  }
}


x86 assembly (clang, -O0):
<run_test>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
lea    -0x28(%rbp),%rdx
call   1040 <product@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0x1c(%rbp),%eax
je     1170 <run_test+0x50>
mov    -0x8(%rbp),%rsi
mov    -0x10(%rbp),%rdx
lea    0xe9a(%rip),%rdi
call   1030 <printf@plt>
jmp    11b5 <run_test+0x95>
cmpl   $0xffffffff,-0x2c(%rbp)
je     1188 <run_test+0x68>
mov    -0x28(%rbp),%rax
cmp    -0x18(%rbp),%rax
jne    11a1 <run_test+0x81>
mov    -0x8(%rbp),%rsi
mov    -0x10(%rbp),%rdx
lea    0xe7f(%rip),%rdi
call   1030 <printf@plt>
jmp    11b5 <run_test+0x95>
mov    -0x8(%rbp),%rsi
mov    -0x10(%rbp),%rdx
lea    0xe50(%rip),%rdi
call   1030 <printf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<run_test>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %ecx,%ebp
mov    %rdx,%r15
mov    %rsi,%r14
mov    %rdi,%rbx
mov    %rsp,%rdx
call   1040 <product@plt>
cmp    %ebp,%eax
jne    115d <run_test+0x3d>
cmp    %r15,(%rsp)
lea    0xecd(%rip),%rax
lea    0xeb0(%rip),%rdi
cmove  %rax,%rdi
cmp    $0xffffffff,%ebp
cmove  %rax,%rdi
jmp    1164 <run_test+0x44>
lea    0xe9c(%rip),%rdi
mov    %rbx,%rsi
mov    %r14,%rdx
call   1030 <printf@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [22 x i8] c"FAILURE on %ld * %ld\0A\00"
@.str.1 = [22 x i8] c"Success on %ld * %ld\0A\00"
define void @run_test(i64 %0, i64 %1, i64 %2, i32 %3) {
%5 = alloca i64
%6 = alloca i64
%7 = alloca i64
%8 = alloca i32
%9 = alloca i64
%10 = alloca i32
store i64 %0, i64* %5
store i64 %1, i64* %6
store i64 %2, i64* %7
store i32 %3, i32* %8
%11 = load i64, i64* %5
%12 = load i64, i64* %6
%13 = call i32 @product(i64 %11, i64 %12, i64* %9)
store i32 %13, i32* %10
%14 = load i32, i32* %10
%15 = load i32, i32* %8
%16 = icmp ne i32 %14, %15
br i1 %16, label %17, label %21
17: ; preds = %4
%18 = load i64, i64* %5
%19 = load i64, i64* %6
%20 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i64 %18, i64 %19)
br label %36
21: ; preds = %4
%22 = load i32, i32* %10
%23 = icmp eq i32 %22, -1
br i1 %23, label %28, label %24
24: ; preds = %21
%25 = load i64, i64* %9
%26 = load i64, i64* %7
%27 = icmp eq i64 %25, %26
br i1 %27, label %28, label %32
28: ; preds = %24, %21
%29 = load i64, i64* %5
%30 = load i64, i64* %6
%31 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i64 %29, i64 %30)
br label %36
32: ; preds = %24
%33 = load i64, i64* %5
%34 = load i64, i64* %6
%35 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i64 %33, i64 %34)
br label %36
36: ; preds = %17, %32, %28
ret void
}

LLVM IR (-O2):
@.str = [22 x i8] c"FAILURE on %ld * %ld\0A\00"
@.str.1 = [22 x i8] c"Success on %ld * %ld\0A\00"
define void @run_test(i64 %0, i64 %1, i64 %2, i32 %3) {
%5 = alloca i64
%6 = bitcast i64* %5 to i8*
%7 = call i32 @product(i64 %0, i64 %1, i64* %5)
%8 = icmp eq i32 %7, %3
br i1 %8, label %9, label %15
9: ; preds = %4
%10 = icmp eq i32 %3, -1
%11 = load i64, i64* %5
%12 = icmp eq i64 %11, %2
%13 = select i1 %10, i1 true, i1 %12
%14 = select i1 %13, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0)
br label %15
15: ; preds = %9, %4
%16 = phi i8* [ getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), %4 ], [ %14, %9 ]
%17 = call i32 @printf(i8* %16, i64 %0, i64 %1)
ret void
}