#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 int /*<<< orphan*/ uint32_t;
typedef int int64_t;

/* Variables and functions */
int max_int(int /*<<< orphan*/);
int min_int(int /*<<< orphan*/);
int /*<<< orphan*/ test_mul(int, int, int /*<<< orphan*/);
void sample_mul(int64_t x, uint32_t n) {
  int64_t min, max;
  min = min_int(n);
  max = max_int(n);
  test_mul(x, min, n);
  test_mul(x, min + 1, n);
  test_mul(x, min + 2, n);
  test_mul(x, min / 2, n);
  test_mul(x, min / 3, n);
  test_mul(x, min / 4, n);
  test_mul(x, -2, n);
  test_mul(x, -1, n);
  test_mul(x, 0, n);
  test_mul(x, 1, n);
  test_mul(x, 2, n);
  test_mul(x, max / 4, n);
  test_mul(x, max / 3, n);
  test_mul(x, max / 2, n);
  test_mul(x, max - 2, n);
  test_mul(x, max - 1, n);
  test_mul(x, max, n);
}


x86 assembly (clang, -O0):
<sample_mul>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    -0x8(%rbp),%edi
call   1050 <min_int@plt>
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%edi
call   1030 <max_int@plt>
mov    %eax,-0x10(%rbp)
mov    -0x4(%rbp),%edi
mov    -0xc(%rbp),%esi
mov    -0x8(%rbp),%edx
call   1040 <test_mul@plt>
mov    -0x4(%rbp),%edi
mov    -0xc(%rbp),%esi
add    $0x1,%esi
mov    -0x8(%rbp),%edx
call   1040 <test_mul@plt>
mov    -0x4(%rbp),%edi
mov    -0xc(%rbp),%esi
add    $0x2,%esi
mov    -0x8(%rbp),%edx
call   1040 <test_mul@plt>
mov    -0x4(%rbp),%edi
mov    -0xc(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%esi
mov    -0x8(%rbp),%edx
call   1040 <test_mul@plt>
mov    -0x4(%rbp),%edi
mov    -0xc(%rbp),%eax
mov    $0x3,%ecx
cltd
idiv   %ecx
mov    %eax,%esi
mov    -0x8(%rbp),%edx
call   1040 <test_mul@plt>
mov    -0x4(%rbp),%edi
mov    -0xc(%rbp),%eax
mov    $0x4,%ecx
cltd
idiv   %ecx
mov    %eax,%esi
mov    -0x8(%rbp),%edx
call   1040 <test_mul@plt>
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%edx
mov    $0xfffffffe,%esi
call   1040 <test_mul@plt>
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%edx
mov    $0xffffffff,%esi
call   1040 <test_mul@plt>
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%edx
xor    %esi,%esi
call   1040 <test_mul@plt>
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%edx
mov    $0x1,%esi
call   1040 <test_mul@plt>
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%edx
mov    $0x2,%esi
call   1040 <test_mul@plt>
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%eax
mov    $0x4,%ecx
cltd
idiv   %ecx
mov    %eax,%esi
mov    -0x8(%rbp),%edx
call   1040 <test_mul@plt>
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%eax
mov    $0x3,%ecx
cltd
idiv   %ecx
mov    %eax,%esi
mov    -0x8(%rbp),%edx
call   1040 <test_mul@plt>
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%esi
mov    -0x8(%rbp),%edx
call   1040 <test_mul@plt>
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%esi
sub    $0x2,%esi
mov    -0x8(%rbp),%edx
call   1040 <test_mul@plt>
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%esi
sub    $0x1,%esi
mov    -0x8(%rbp),%edx
call   1040 <test_mul@plt>
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%esi
mov    -0x8(%rbp),%edx
call   1040 <test_mul@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sample_mul>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %esi,%ebx
mov    %edi,%r15d
mov    %esi,%edi
call   1050 <min_int@plt>
mov    %eax,%ebp
mov    %ebx,%edi
call   1030 <max_int@plt>
mov    %eax,%r14d
mov    %r15d,%edi
mov    %ebp,%esi
mov    %ebx,%edx
call   1040 <test_mul@plt>
lea    0x1(%rbp),%esi
mov    %r15d,%edi
mov    %ebx,%edx
call   1040 <test_mul@plt>
lea    0x2(%rbp),%esi
mov    %r15d,%edi
mov    %ebx,%edx
call   1040 <test_mul@plt>
mov    %ebp,%esi
shr    $0x1f,%esi
add    %ebp,%esi
sar    %esi
mov    %r15d,%edi
mov    %ebx,%edx
call   1040 <test_mul@plt>
movslq %ebp,%rbp
imul   $0x55555556,%rbp,%rsi
mov    %rsi,%rax
shr    $0x3f,%rax
shr    $0x20,%rsi
add    %eax,%esi
mov    %r15d,%edi
mov    %ebx,%edx
call   1040 <test_mul@plt>
lea    0x3(%rbp),%esi
test   %ebp,%ebp
cmovns %ebp,%esi
sar    $0x2,%esi
mov    %r15d,%edi
mov    %ebx,%edx
call   1040 <test_mul@plt>
mov    %r15d,%edi
mov    $0xfffffffe,%esi
mov    %ebx,%edx
call   1040 <test_mul@plt>
mov    %r15d,%edi
mov    $0xffffffff,%esi
mov    %ebx,%edx
call   1040 <test_mul@plt>
mov    %r15d,%edi
xor    %esi,%esi
mov    %ebx,%edx
call   1040 <test_mul@plt>
mov    %r15d,%edi
mov    $0x1,%esi
mov    %ebx,%edx
call   1040 <test_mul@plt>
mov    %r15d,%edi
mov    $0x2,%esi
mov    %ebx,%edx
call   1040 <test_mul@plt>
lea    0x3(%r14),%esi
test   %r14d,%r14d
cmovns %r14d,%esi
sar    $0x2,%esi
mov    %r15d,%edi
mov    %ebx,%edx
call   1040 <test_mul@plt>
movslq %r14d,%rbp
imul   $0x55555556,%rbp,%rsi
mov    %rsi,%rax
shr    $0x3f,%rax
shr    $0x20,%rsi
add    %eax,%esi
mov    %r15d,%edi
mov    %ebx,%edx
call   1040 <test_mul@plt>
mov    %ebp,%esi
shr    $0x1f,%esi
add    %ebp,%esi
sar    %esi
mov    %r15d,%edi
mov    %ebx,%edx
call   1040 <test_mul@plt>
lea    -0x2(%rbp),%esi
mov    %r15d,%edi
mov    %ebx,%edx
call   1040 <test_mul@plt>
lea    -0x1(%rbp),%esi
mov    %r15d,%edi
mov    %ebx,%edx
call   1040 <test_mul@plt>
mov    %r15d,%edi
mov    %ebp,%esi
mov    %ebx,%edx
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <test_mul@plt>

LLVM IR (-O0):
define void @sample_mul(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
%7 = load i32, i32* %4
%8 = call i32 @min_int(i32 %7)
store i32 %8, i32* %5
%9 = load i32, i32* %4
%10 = call i32 @max_int(i32 %9)
store i32 %10, i32* %6
%11 = load i32, i32* %3
%12 = load i32, i32* %5
%13 = load i32, i32* %4
%14 = call i32 @test_mul(i32 %11, i32 %12, i32 %13)
%15 = load i32, i32* %3
%16 = load i32, i32* %5
%17 = add nsw i32 %16, 1
%18 = load i32, i32* %4
%19 = call i32 @test_mul(i32 %15, i32 %17, i32 %18)
%20 = load i32, i32* %3
%21 = load i32, i32* %5
%22 = add nsw i32 %21, 2
%23 = load i32, i32* %4
%24 = call i32 @test_mul(i32 %20, i32 %22, i32 %23)
%25 = load i32, i32* %3
%26 = load i32, i32* %5
%27 = sdiv i32 %26, 2
%28 = load i32, i32* %4
%29 = call i32 @test_mul(i32 %25, i32 %27, i32 %28)
%30 = load i32, i32* %3
%31 = load i32, i32* %5
%32 = sdiv i32 %31, 3
%33 = load i32, i32* %4
%34 = call i32 @test_mul(i32 %30, i32 %32, i32 %33)
%35 = load i32, i32* %3
%36 = load i32, i32* %5
%37 = sdiv i32 %36, 4
%38 = load i32, i32* %4
%39 = call i32 @test_mul(i32 %35, i32 %37, i32 %38)
%40 = load i32, i32* %3
%41 = load i32, i32* %4
%42 = call i32 @test_mul(i32 %40, i32 -2, i32 %41)
%43 = load i32, i32* %3
%44 = load i32, i32* %4
%45 = call i32 @test_mul(i32 %43, i32 -1, i32 %44)
%46 = load i32, i32* %3
%47 = load i32, i32* %4
%48 = call i32 @test_mul(i32 %46, i32 0, i32 %47)
%49 = load i32, i32* %3
%50 = load i32, i32* %4
%51 = call i32 @test_mul(i32 %49, i32 1, i32 %50)
%52 = load i32, i32* %3
%53 = load i32, i32* %4
%54 = call i32 @test_mul(i32 %52, i32 2, i32 %53)
%55 = load i32, i32* %3
%56 = load i32, i32* %6
%57 = sdiv i32 %56, 4
%58 = load i32, i32* %4
%59 = call i32 @test_mul(i32 %55, i32 %57, i32 %58)
%60 = load i32, i32* %3
%61 = load i32, i32* %6
%62 = sdiv i32 %61, 3
%63 = load i32, i32* %4
%64 = call i32 @test_mul(i32 %60, i32 %62, i32 %63)
%65 = load i32, i32* %3
%66 = load i32, i32* %6
%67 = sdiv i32 %66, 2
%68 = load i32, i32* %4
%69 = call i32 @test_mul(i32 %65, i32 %67, i32 %68)
%70 = load i32, i32* %3
%71 = load i32, i32* %6
%72 = sub nsw i32 %71, 2
%73 = load i32, i32* %4
%74 = call i32 @test_mul(i32 %70, i32 %72, i32 %73)
%75 = load i32, i32* %3
%76 = load i32, i32* %6
%77 = sub nsw i32 %76, 1
%78 = load i32, i32* %4
%79 = call i32 @test_mul(i32 %75, i32 %77, i32 %78)
%80 = load i32, i32* %3
%81 = load i32, i32* %6
%82 = load i32, i32* %4
%83 = call i32 @test_mul(i32 %80, i32 %81, i32 %82)
ret void
}

LLVM IR (-O2):
define void @sample_mul(i32 %0, i32 %1) {
%3 = tail call i32 @min_int(i32 %1)
%4 = tail call i32 @max_int(i32 %1)
%5 = tail call i32 @test_mul(i32 %0, i32 %3, i32 %1)
%6 = add nsw i32 %3, 1
%7 = tail call i32 @test_mul(i32 %0, i32 %6, i32 %1)
%8 = add nsw i32 %3, 2
%9 = tail call i32 @test_mul(i32 %0, i32 %8, i32 %1)
%10 = sdiv i32 %3, 2
%11 = tail call i32 @test_mul(i32 %0, i32 %10, i32 %1)
%12 = sdiv i32 %3, 3
%13 = tail call i32 @test_mul(i32 %0, i32 %12, i32 %1)
%14 = sdiv i32 %3, 4
%15 = tail call i32 @test_mul(i32 %0, i32 %14, i32 %1)
%16 = tail call i32 @test_mul(i32 %0, i32 -2, i32 %1)
%17 = tail call i32 @test_mul(i32 %0, i32 -1, i32 %1)
%18 = tail call i32 @test_mul(i32 %0, i32 0, i32 %1)
%19 = tail call i32 @test_mul(i32 %0, i32 1, i32 %1)
%20 = tail call i32 @test_mul(i32 %0, i32 2, i32 %1)
%21 = sdiv i32 %4, 4
%22 = tail call i32 @test_mul(i32 %0, i32 %21, i32 %1)
%23 = sdiv i32 %4, 3
%24 = tail call i32 @test_mul(i32 %0, i32 %23, i32 %1)
%25 = sdiv i32 %4, 2
%26 = tail call i32 @test_mul(i32 %0, i32 %25, i32 %1)
%27 = add nsw i32 %4, -2
%28 = tail call i32 @test_mul(i32 %0, i32 %27, i32 %1)
%29 = add nsw i32 %4, -1
%30 = tail call i32 @test_mul(i32 %0, i32 %29, i32 %1)
%31 = tail call i32 @test_mul(i32 %0, i32 %4, i32 %1)
ret void
}