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


x86 assembly (clang, -O0):
<random_input_planes>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    -0x4(%rbp),%edx
mov    -0x8(%rbp),%esi
mov    %edx,%eax
imul   %esi,%eax
mov    -0xc(%rbp),%ecx
add    %esi,%edx
imul   %edx,%ecx
add    %ecx,%eax
mov    %eax,-0x10(%rbp)
mov    -0x4(%rbp),%ecx
mov    -0x8(%rbp),%edx
mov    %ecx,%eax
add    %edx,%eax
imul   %ecx,%eax
mov    -0x10(%rbp),%ecx
imul   %ecx,%eax
add    %eax,%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x30(%rbp)
lea    0xf(,%rax,8),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x40(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x38(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x20(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    11e2 <random_input_planes+0xc2>
mov    $0x0,%al
call   1040 <rand@plt>
mov    %rax,%rcx
mov    -0x40(%rbp),%rax
cvtsi2sd %rcx,%xmm0
mov    0x2e21(%rip),%rcx
divsd  (%rcx),%xmm0
movslq -0x18(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    11a1 <random_input_planes+0x81>
mov    -0x40(%rbp),%rcx
lea    -0x28(%rbp),%rsi
mov    $0x2,%edi
lea    -0x10(%rbp),%rdx
call   1030 <_ada_use_c2pieri@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    -0x30(%rbp),%rcx
mov    %rcx,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<random_input_planes>:
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),%r13d
mov    %edi,%ecx
imul   %r13d,%ecx
imul   %edx,%r13d
add    %eax,%r13d
mov    %r13d,-0x2c(%rbp)
imul   %ecx,%r13d
add    %r13d,%r13d
lea    0x0(,%r13,8),%rax
mov    %rsp,%r15
sub    %rax,%r15
mov    %r15,%rsp
mov    %edi,-0x38(%rbp)
mov    %esi,-0x34(%rbp)
mov    %edx,-0x30(%rbp)
test   %r13d,%r13d
jle    11a4 <random_input_planes+0x84>
mov    0x2e6d(%rip),%r12
xor    %ebx,%ebx
nopl   (%rax)
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_input_planes+0x60>
lea    -0x38(%rbp),%rsi
lea    -0x2c(%rbp),%rdx
mov    $0x2,%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_input_planes(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 [3 x i32]
%12 = alloca i8*
%13 = alloca i64
store i32 %0, i32* %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%14 = load i32, i32* %4
%15 = load i32, i32* %5
%16 = mul nsw i32 %14, %15
%17 = load i32, i32* %6
%18 = load i32, i32* %4
%19 = load i32, i32* %5
%20 = add nsw i32 %18, %19
%21 = mul nsw i32 %17, %20
%22 = add nsw i32 %16, %21
store i32 %22, i32* %7
%23 = load i32, i32* %4
%24 = load i32, i32* %5
%25 = add nsw i32 %23, %24
%26 = mul nsw i32 2, %25
%27 = load i32, i32* %4
%28 = mul nsw i32 %26, %27
%29 = load i32, i32* %7
%30 = mul nsw i32 %28, %29
store i32 %30, i32* %8
%31 = load i32, i32* %8
%32 = zext i32 %31 to i64
%33 = call i8* @llvm.stacksave()
store i8* %33, i8** %12
%34 = alloca double, i64 %32
store i64 %32, i64* %13
%35 = load i32, i32* %4
%36 = getelementptr inbounds [3 x i32], [3 x i32]* %11, i64 0, i64 0
store i32 %35, i32* %36
%37 = load i32, i32* %5
%38 = getelementptr inbounds [3 x i32], [3 x i32]* %11, i64 0, i64 1
store i32 %37, i32* %38
%39 = load i32, i32* %6
%40 = getelementptr inbounds [3 x i32], [3 x i32]* %11, i64 0, i64 2
store i32 %39, i32* %40
store i32 0, i32* %9
br label %41
41: ; preds = %53, %3
%42 = load i32, i32* %9
%43 = load i32, i32* %8
%44 = icmp slt i32 %42, %43
br i1 %44, label %45, label %56
45: ; preds = %41
%46 = call i64 (...) @rand()
%47 = sitofp i64 %46 to double
%48 = load double, double* @RAND_MAX
%49 = fdiv double %47, %48
%50 = load i32, i32* %9
%51 = sext i32 %50 to i64
%52 = getelementptr inbounds double, double* %34, i64 %51
store double %49, double* %52
br label %53
53: ; preds = %45
%54 = load i32, i32* %9
%55 = add nsw i32 %54, 1
store i32 %55, i32* %9
br label %41
56: ; preds = %41
%57 = getelementptr inbounds [3 x i32], [3 x i32]* %11, i64 0, i64 0
%58 = call i32 @_ada_use_c2pieri(i32 2, i32* %57, i32* %7, double* %34)
store i32 %58, i32* %10
%59 = load i32, i32* %10
%60 = load i8*, i8** %12
ret i32 %59
}

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