#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 drand48();
int /*<<< orphan*/ free(double *);
int /*<<< orphan*/ matmul(int const, int const, int const, double *, double *,
                          double *const);
scalar_t__ memalign(int, int);
void gen_data(double *const data, const int ambient_dim,
              const int intrinsic_dim, const int num_points) {
  int i;
  double *latent_data =
      (double *)memalign(64, sizeof(double) * intrinsic_dim * num_points);
  double *transformation =
      (double *)memalign(64, sizeof(double) * intrinsic_dim * ambient_dim);
  for (i = 0; i < intrinsic_dim * num_points; i++) {
    latent_data[i] = 2 * drand48() - 1;
  }
  for (i = 0; i < intrinsic_dim * ambient_dim; i++) {
    transformation[i] = 2 * drand48() - 1;
  }
  matmul(ambient_dim, num_points, intrinsic_dim, transformation, latent_data,
         data);
  free(latent_data);
  free(transformation);
}


x86 assembly (clang, -O0):
<gen_data>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
movslq -0x10(%rbp),%rax
shl    $0x3,%rax
movslq -0x14(%rbp),%rcx
imul   %rcx,%rax
mov    %eax,%esi
mov    $0x40,%edi
call   1040 <memalign@plt>
mov    %rax,-0x20(%rbp)
movslq -0x10(%rbp),%rax
shl    $0x3,%rax
movslq -0xc(%rbp),%rcx
imul   %rcx,%rax
mov    %eax,%esi
mov    $0x40,%edi
call   1040 <memalign@plt>
mov    %rax,-0x28(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    -0x10(%rbp),%ecx
imul   -0x14(%rbp),%ecx
cmp    %ecx,%eax
jge    11da <gen_data+0x9a>
mov    $0x0,%al
call   1060 <drand48@plt>
shl    $0x1,%eax
sub    $0x1,%eax
cvtsi2sd %eax,%xmm0
mov    -0x20(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    119c <gen_data+0x5c>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    -0x10(%rbp),%ecx
imul   -0xc(%rbp),%ecx
cmp    %ecx,%eax
jge    121f <gen_data+0xdf>
mov    $0x0,%al
call   1060 <drand48@plt>
shl    $0x1,%eax
sub    $0x1,%eax
cvtsi2sd %eax,%xmm0
mov    -0x28(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    11e1 <gen_data+0xa1>
mov    -0xc(%rbp),%edi
mov    -0x14(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    -0x28(%rbp),%rcx
mov    -0x20(%rbp),%r8
mov    -0x8(%rbp),%r9
call   1050 <matmul@plt>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gen_data>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %ecx,%ebp
mov    %edx,%r13d
mov    %esi,%r14d
mov    %rdi,0x10(%rsp)
lea    0x0(,%r13,8),%ebx
mov    %ebx,%esi
imul   %ecx,%esi
mov    $0x40,%edi
call   1040 <memalign@plt>
mov    %rax,%r15
mov    %r14d,0x8(%rsp)
imul   %r14d,%ebx
mov    $0x40,%edi
mov    %ebx,%esi
call   1040 <memalign@plt>
mov    %rax,%r12
mov    %ebp,0xc(%rsp)
imul   %r13d,%ebp
test   %ebp,%ebp
jle    11c2 <gen_data+0x82>
mov    %ebp,%r14d
xor    %ebp,%ebp
xchg   %ax,%ax
xor    %eax,%eax
call   1060 <drand48@plt>
add    %eax,%eax
add    $0xffffffff,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
movsd  %xmm0,(%r15,%rbp,8)
add    $0x1,%rbp
cmp    %rbp,%r14
jne    11a0 <gen_data+0x60>
mov    %r13d,%eax
mov    0x8(%rsp),%r14d
imul   %r14d,%eax
test   %eax,%eax
jle    1202 <gen_data+0xc2>
mov    %eax,%ebp
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
xor    %eax,%eax
call   1060 <drand48@plt>
add    %eax,%eax
add    $0xffffffff,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
movsd  %xmm0,(%r12,%rbx,8)
add    $0x1,%rbx
cmp    %rbx,%rbp
jne    11e0 <gen_data+0xa0>
mov    %r14d,%edi
mov    0xc(%rsp),%esi
mov    %r13d,%edx
mov    %r12,%rcx
mov    %r15,%r8
mov    0x10(%rsp),%r9
call   1050 <matmul@plt>
mov    %r15,%rdi
call   1030 <free@plt>
mov    %r12,%rdi
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <free@plt>

LLVM IR (-O0):
define void @gen_data(double* %0, i32 %1, i32 %2, i32 %3) {
%5 = alloca double*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca double*
%11 = alloca double*
store double* %0, double** %5
store i32 %1, i32* %6
store i32 %2, i32* %7
store i32 %3, i32* %8
%12 = load i32, i32* %7
%13 = sext i32 %12 to i64
%14 = mul i64 8, %13
%15 = load i32, i32* %8
%16 = sext i32 %15 to i64
%17 = mul i64 %14, %16
%18 = trunc i64 %17 to i32
%19 = call i64 @memalign(i32 64, i32 %18)
%20 = inttoptr i64 %19 to double*
store double* %20, double** %10
%21 = load i32, i32* %7
%22 = sext i32 %21 to i64
%23 = mul i64 8, %22
%24 = load i32, i32* %6
%25 = sext i32 %24 to i64
%26 = mul i64 %23, %25
%27 = trunc i64 %26 to i32
%28 = call i64 @memalign(i32 64, i32 %27)
%29 = inttoptr i64 %28 to double*
store double* %29, double** %11
store i32 0, i32* %9
br label %30
30: ; preds = %45, %4
%31 = load i32, i32* %9
%32 = load i32, i32* %7
%33 = load i32, i32* %8
%34 = mul nsw i32 %32, %33
%35 = icmp slt i32 %31, %34
br i1 %35, label %36, label %48
36: ; preds = %30
%37 = call i32 (...) @drand48()
%38 = mul nsw i32 2, %37
%39 = sub nsw i32 %38, 1
%40 = sitofp i32 %39 to double
%41 = load double*, double** %10
%42 = load i32, i32* %9
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds double, double* %41, i64 %43
store double %40, double* %44
br label %45
45: ; preds = %36
%46 = load i32, i32* %9
%47 = add nsw i32 %46, 1
store i32 %47, i32* %9
br label %30
48: ; preds = %30
store i32 0, i32* %9
br label %49
49: ; preds = %64, %48
%50 = load i32, i32* %9
%51 = load i32, i32* %7
%52 = load i32, i32* %6
%53 = mul nsw i32 %51, %52
%54 = icmp slt i32 %50, %53
br i1 %54, label %55, label %67
55: ; preds = %49
%56 = call i32 (...) @drand48()
%57 = mul nsw i32 2, %56
%58 = sub nsw i32 %57, 1
%59 = sitofp i32 %58 to double
%60 = load double*, double** %11
%61 = load i32, i32* %9
%62 = sext i32 %61 to i64
%63 = getelementptr inbounds double, double* %60, i64 %62
store double %59, double* %63
br label %64
64: ; preds = %55
%65 = load i32, i32* %9
%66 = add nsw i32 %65, 1
store i32 %66, i32* %9
br label %49
67: ; preds = %49
%68 = load i32, i32* %6
%69 = load i32, i32* %8
%70 = load i32, i32* %7
%71 = load double*, double** %11
%72 = load double*, double** %10
%73 = load double*, double** %5
%74 = call i32 @matmul(i32 %68, i32 %69, i32 %70, double* %71, double* %72, double* %73)
%75 = load double*, double** %10
%76 = call i32 @free(double* %75)
%77 = load double*, double** %11
%78 = call i32 @free(double* %77)
ret void
}

LLVM IR (-O2):
define void @gen_data(double* %0, i32 %1, i32 %2, i32 %3) {
%5 = shl i32 %2, 3
%6 = mul i32 %5, %3
%7 = tail call i64 @memalign(i32 64, i32 %6)
%8 = inttoptr i64 %7 to double*
%9 = mul i32 %5, %1
%10 = tail call i64 @memalign(i32 64, i32 %9)
%11 = inttoptr i64 %10 to double*
%12 = mul i32 %3, %2
%13 = icmp sgt i32 %12, 0
br i1 %13, label %14, label %16
14: ; preds = %4
%15 = zext i32 %12 to i64
br label %21
16: ; preds = %21, %4
%17 = mul i32 %2, %1
%18 = icmp sgt i32 %17, 0
br i1 %18, label %19, label %39
19: ; preds = %16
%20 = zext i32 %17 to i64
br label %30
21: ; preds = %14, %21
%22 = phi i64 [ 0, %14 ], [ %28, %21 ]
%23 = tail call i32 (...) @drand48()
%24 = shl nsw i32 %23, 1
%25 = add nsw i32 %24, -1
%26 = sitofp i32 %25 to double
%27 = getelementptr inbounds double, double* %8, i64 %22
store double %26, double* %27
%28 = add nuw nsw i64 %22, 1
%29 = icmp eq i64 %28, %15
br i1 %29, label %16, label %21
30: ; preds = %19, %30
%31 = phi i64 [ 0, %19 ], [ %37, %30 ]
%32 = tail call i32 (...) @drand48()
%33 = shl nsw i32 %32, 1
%34 = add nsw i32 %33, -1
%35 = sitofp i32 %34 to double
%36 = getelementptr inbounds double, double* %11, i64 %31
store double %35, double* %36
%37 = add nuw nsw i64 %31, 1
%38 = icmp eq i64 %37, %20
br i1 %38, label %39, label %30
39: ; preds = %30, %16
%40 = tail call i32 @matmul(i32 %1, i32 %3, i32 %2, double* %11, double* %8, double* %0)
%41 = tail call i32 @free(double* %8)
%42 = tail call i32 @free(double* %11)
ret void
}