#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 */
double RAND_MAX;
int _ada_use_c2pieri(int, int *, int *, double *);
scalar_t__ rand();
int random_interpolation_points(int m, int p, int q) {
  int n = m * p + q * (m + p);
  int nbcff = 2 * n;
  int i, fail, mpq[3];
  double c[nbcff];
  mpq[0] = m;
  mpq[1] = p;
  mpq[2] = q;
  nbcff = 2 * n;
  for (i = 0; i < nbcff; i++)
    c[i] = ((double)rand()) / RAND_MAX;
  fail = _ada_use_c2pieri(3, mpq, &n, c);
}


x86 assembly (clang, -O0):
<random_interpolation_points>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    -0x8(%rbp),%edx
mov    -0xc(%rbp),%esi
mov    %edx,%eax
imul   %esi,%eax
mov    -0x10(%rbp),%ecx
add    %esi,%edx
imul   %edx,%ecx
add    %ecx,%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
add    %eax,%eax
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x38(%rbp)
lea    0xf(,%rax,8),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x48(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x40(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x2c(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    -0x10(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x14(%rbp),%eax
shl    $0x1,%eax
mov    %eax,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    11db <random_interpolation_points+0xbb>
mov    $0x0,%al
call   1040 <rand@plt>
mov    %rax,%rcx
mov    -0x48(%rbp),%rax
cvtsi2sd %rcx,%xmm0
mov    0x2e28(%rip),%rcx
divsd  (%rcx),%xmm0
movslq -0x1c(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    119a <random_interpolation_points+0x7a>
mov    -0x48(%rbp),%rcx
lea    -0x2c(%rbp),%rsi
mov    $0x3,%edi
lea    -0x14(%rbp),%rdx
call   1030 <_ada_use_c2pieri@plt>
mov    %eax,-0x20(%rbp)
mov    -0x38(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<random_interpolation_points>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rsp,%r14
mov    %esi,%eax
imul   %edi,%eax
lea    (%rsi,%rdi,1),%ecx
imul   %edx,%ecx
add    %eax,%ecx
mov    %ecx,-0x2c(%rbp)
lea    (%rcx,%rcx,1),%eax
lea    0x0(,%rax,8),%rbx
mov    %rsp,%r15
sub    %rbx,%r15
mov    %r15,%rsp
mov    %edi,-0x38(%rbp)
mov    %esi,-0x34(%rbp)
mov    %edx,-0x30(%rbp)
test   %ecx,%ecx
jle    11a4 <random_interpolation_points+0x84>
cmp    $0x2,%eax
mov    $0x1,%r13d
cmovge %eax,%r13d
mov    0x2e6f(%rip),%r12
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1040 <rand@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
divsd  (%r12),%xmm0
movsd  %xmm0,(%r15,%rbx,8)
add    $0x1,%rbx
cmp    %rbx,%r13
jne    1180 <random_interpolation_points+0x60>
lea    -0x38(%rbp),%rsi
lea    -0x2c(%rbp),%rdx
mov    $0x3,%edi
mov    %r15,%rcx
call   1030 <_ada_use_c2pieri@plt>
mov    %r14,%rsp
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@RAND_MAX = global double 0.000000e+00
define i32 @random_interpolation_points(i32 %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca [3 x i32]
%13 = alloca i8*
%14 = alloca i64
store i32 %0, i32* %5
store i32 %1, i32* %6
store i32 %2, i32* %7
%15 = load i32, i32* %5
%16 = load i32, i32* %6
%17 = mul nsw i32 %15, %16
%18 = load i32, i32* %7
%19 = load i32, i32* %5
%20 = load i32, i32* %6
%21 = add nsw i32 %19, %20
%22 = mul nsw i32 %18, %21
%23 = add nsw i32 %17, %22
store i32 %23, i32* %8
%24 = load i32, i32* %8
%25 = mul nsw i32 2, %24
store i32 %25, i32* %9
%26 = load i32, i32* %9
%27 = zext i32 %26 to i64
%28 = call i8* @llvm.stacksave()
store i8* %28, i8** %13
%29 = alloca double, i64 %27
store i64 %27, i64* %14
%30 = load i32, i32* %5
%31 = getelementptr inbounds [3 x i32], [3 x i32]* %12, i64 0, i64 0
store i32 %30, i32* %31
%32 = load i32, i32* %6
%33 = getelementptr inbounds [3 x i32], [3 x i32]* %12, i64 0, i64 1
store i32 %32, i32* %33
%34 = load i32, i32* %7
%35 = getelementptr inbounds [3 x i32], [3 x i32]* %12, i64 0, i64 2
store i32 %34, i32* %35
%36 = load i32, i32* %8
%37 = mul nsw i32 2, %36
store i32 %37, i32* %9
store i32 0, i32* %10
br label %38
38: ; preds = %50, %3
%39 = load i32, i32* %10
%40 = load i32, i32* %9
%41 = icmp slt i32 %39, %40
br i1 %41, label %42, label %53
42: ; preds = %38
%43 = call i64 (...) @rand()
%44 = sitofp i64 %43 to double
%45 = load double, double* @RAND_MAX
%46 = fdiv double %44, %45
%47 = load i32, i32* %10
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds double, double* %29, i64 %48
store double %46, double* %49
br label %50
50: ; preds = %42
%51 = load i32, i32* %10
%52 = add nsw i32 %51, 1
store i32 %52, i32* %10
br label %38
53: ; preds = %38
%54 = getelementptr inbounds [3 x i32], [3 x i32]* %12, i64 0, i64 0
%55 = call i32 @_ada_use_c2pieri(i32 3, i32* %54, i32* %8, double* %29)
store i32 %55, i32* %11
%56 = load i8*, i8** %13
%57 = load i32, i32* %4
ret i32 %57
}

LLVM IR (-O2):
@RAND_MAX = global double 0.000000e+00
define i32 @random_interpolation_points(i32 %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca [3 x i32]
%6 = bitcast i32* %4 to i8*
%7 = mul nsw i32 %1, %0
%8 = add nsw i32 %1, %0
%9 = mul nsw i32 %8, %2
%10 = add nsw i32 %9, %7
store i32 %10, i32* %4
%11 = shl i32 %10, 1
%12 = bitcast [3 x i32]* %5 to i8*
%13 = zext i32 %11 to i64
%14 = tail call i8* @llvm.stacksave()
%15 = alloca double, i64 %13
%16 = getelementptr inbounds [3 x i32], [3 x i32]* %5, i64 0, i64 0
store i32 %0, i32* %16
%17 = getelementptr inbounds [3 x i32], [3 x i32]* %5, i64 0, i64 1
store i32 %1, i32* %17
%18 = getelementptr inbounds [3 x i32], [3 x i32]* %5, i64 0, i64 2
store i32 %2, i32* %18
%19 = icmp sgt i32 %10, 0
br i1 %19, label %20, label %32
20: ; preds = %3
%21 = call i32 @llvm.smax.i32(i32 %11, i32 1)
%22 = zext i32 %21 to i64
br label %23
23: ; preds = %20, %23
%24 = phi i64 [ 0, %20 ], [ %30, %23 ]
%25 = tail call i64 (...) @rand()
%26 = sitofp i64 %25 to double
%27 = load double, double* @RAND_MAX
%28 = fdiv double %26, %27
%29 = getelementptr inbounds double, double* %15, i64 %24
store double %28, double* %29
%30 = add nuw nsw i64 %24, 1
%31 = icmp eq i64 %30, %22
br i1 %31, label %32, label %23
32: ; preds = %23, %3
%33 = call i32 @_ada_use_c2pieri(i32 3, i32* %16, i32* %4, double* %15)
ret i32 undef
}