#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 *double_alloc(int);
int /*<<< orphan*/ free(void *);
int /*<<< orphan*/ mt2sm(double *, double *);
void residual_moment(double **vm, double *ma, double *mb, double *mc) {
  int i;
  double *vmc;
  vmc = double_alloc(6);
  mt2sm(vm[0], ma);
  mt2sm(vm[1], mb);
  for (i = 0; i < 6; i++) {
    vmc[i] = vm[1][i] / (*mb) - vm[0][i] / (*ma);
  }
  mt2sm(vmc, mc);
  free((void *)vmc);
}


x86 assembly (clang, -O0):
<residual_moment>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    $0x6,%edi
call   1050 <double_alloc@plt>
mov    %rax,-0x30(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%rdi
mov    -0x10(%rbp),%rsi
call   1040 <mt2sm@plt>
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%rdi
mov    -0x18(%rbp),%rsi
call   1040 <mt2sm@plt>
movl   $0x0,-0x24(%rbp)
cmpl   $0x6,-0x24(%rbp)
jge    11d8 <residual_moment+0xa8>
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%rax
movslq -0x24(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
mov    -0x18(%rbp),%rax
divsd  (%rax),%xmm0
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
movslq -0x24(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm1
mov    -0x10(%rbp),%rax
divsd  (%rax),%xmm1
subsd  %xmm1,%xmm0
mov    -0x30(%rbp),%rax
movslq -0x24(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    117e <residual_moment+0x4e>
mov    -0x30(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1040 <mt2sm@plt>
mov    -0x30(%rbp),%rdi
call   1030 <free@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<residual_moment>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %rcx,%r14
mov    %rdx,%r12
mov    %rsi,%r15
mov    %rdi,%rbx
mov    $0x6,%edi
call   1050 <double_alloc@plt>
mov    %rax,%r13
mov    (%rbx),%rdi
mov    %r15,%rsi
call   1040 <mt2sm@plt>
mov    0x8(%rbx),%rdi
mov    %r12,%rsi
call   1040 <mt2sm@plt>
mov    (%rbx),%rax
mov    0x8(%rbx),%rcx
movsd  (%rcx),%xmm0
divsd  (%r12),%xmm0
movsd  (%rax),%xmm1
divsd  (%r15),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,0x0(%r13)
movsd  0x8(%rcx),%xmm0
divsd  (%r12),%xmm0
movsd  0x8(%rax),%xmm1
divsd  (%r15),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,0x8(%r13)
movsd  0x10(%rcx),%xmm0
divsd  (%r12),%xmm0
movsd  0x10(%rax),%xmm1
divsd  (%r15),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,0x10(%r13)
movsd  0x18(%rcx),%xmm0
divsd  (%r12),%xmm0
movsd  0x18(%rax),%xmm1
divsd  (%r15),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,0x18(%r13)
movsd  0x20(%rcx),%xmm0
divsd  (%r12),%xmm0
movsd  0x20(%rax),%xmm1
divsd  (%r15),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,0x20(%r13)
movsd  0x28(%rcx),%xmm0
divsd  (%r12),%xmm0
movsd  0x28(%rax),%xmm1
divsd  (%r15),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,0x28(%r13)
mov    %r13,%rdi
mov    %r14,%rsi
call   1040 <mt2sm@plt>
mov    %r13,%rdi
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
jmp    1030 <free@plt>

LLVM IR (-O0):
define void @residual_moment(double** %0, double* %1, double* %2, double* %3) {
%5 = alloca double**
%6 = alloca double*
%7 = alloca double*
%8 = alloca double*
%9 = alloca i32
%10 = alloca double*
store double** %0, double*** %5
store double* %1, double** %6
store double* %2, double** %7
store double* %3, double** %8
%11 = call double* @double_alloc(i32 6)
store double* %11, double** %10
%12 = load double**, double*** %5
%13 = getelementptr inbounds double*, double** %12, i64 0
%14 = load double*, double** %13
%15 = load double*, double** %6
%16 = call i32 @mt2sm(double* %14, double* %15)
%17 = load double**, double*** %5
%18 = getelementptr inbounds double*, double** %17, i64 1
%19 = load double*, double** %18
%20 = load double*, double** %7
%21 = call i32 @mt2sm(double* %19, double* %20)
store i32 0, i32* %9
br label %22
22: ; preds = %51, %4
%23 = load i32, i32* %9
%24 = icmp slt i32 %23, 6
br i1 %24, label %25, label %54
25: ; preds = %22
%26 = load double**, double*** %5
%27 = getelementptr inbounds double*, double** %26, i64 1
%28 = load double*, double** %27
%29 = load i32, i32* %9
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds double, double* %28, i64 %30
%32 = load double, double* %31
%33 = load double*, double** %7
%34 = load double, double* %33
%35 = fdiv double %32, %34
%36 = load double**, double*** %5
%37 = getelementptr inbounds double*, double** %36, i64 0
%38 = load double*, double** %37
%39 = load i32, i32* %9
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds double, double* %38, i64 %40
%42 = load double, double* %41
%43 = load double*, double** %6
%44 = load double, double* %43
%45 = fdiv double %42, %44
%46 = fsub double %35, %45
%47 = load double*, double** %10
%48 = load i32, i32* %9
%49 = sext i32 %48 to i64
%50 = getelementptr inbounds double, double* %47, i64 %49
store double %46, double* %50
br label %51
51: ; preds = %25
%52 = load i32, i32* %9
%53 = add nsw i32 %52, 1
store i32 %53, i32* %9
br label %22
54: ; preds = %22
%55 = load double*, double** %10
%56 = load double*, double** %8
%57 = call i32 @mt2sm(double* %55, double* %56)
%58 = load double*, double** %10
%59 = bitcast double* %58 to i8*
%60 = call i32 @free(i8* %59)
ret void
}

LLVM IR (-O2):
define void @residual_moment(double** nocapture %0, double* %1, double* %2, double* %3) {
%5 = tail call double* @double_alloc(i32 6)
%6 = load double*, double** %0
%7 = tail call i32 @mt2sm(double* %6, double* %1)
%8 = getelementptr inbounds double*, double** %0, i64 1
%9 = load double*, double** %8
%10 = tail call i32 @mt2sm(double* %9, double* %2)
%11 = load double*, double** %8
%12 = load double*, double** %0
%13 = load double, double* %11
%14 = load double, double* %2
%15 = fdiv double %13, %14
%16 = load double, double* %12
%17 = load double, double* %1
%18 = fdiv double %16, %17
%19 = fsub double %15, %18
store double %19, double* %5
%20 = getelementptr inbounds double, double* %11, i64 1
%21 = load double, double* %20
%22 = load double, double* %2
%23 = fdiv double %21, %22
%24 = getelementptr inbounds double, double* %12, i64 1
%25 = load double, double* %24
%26 = load double, double* %1
%27 = fdiv double %25, %26
%28 = fsub double %23, %27
%29 = getelementptr inbounds double, double* %5, i64 1
store double %28, double* %29
%30 = getelementptr inbounds double, double* %11, i64 2
%31 = load double, double* %30
%32 = load double, double* %2
%33 = fdiv double %31, %32
%34 = getelementptr inbounds double, double* %12, i64 2
%35 = load double, double* %34
%36 = load double, double* %1
%37 = fdiv double %35, %36
%38 = fsub double %33, %37
%39 = getelementptr inbounds double, double* %5, i64 2
store double %38, double* %39
%40 = getelementptr inbounds double, double* %11, i64 3
%41 = load double, double* %40
%42 = load double, double* %2
%43 = fdiv double %41, %42
%44 = getelementptr inbounds double, double* %12, i64 3
%45 = load double, double* %44
%46 = load double, double* %1
%47 = fdiv double %45, %46
%48 = fsub double %43, %47
%49 = getelementptr inbounds double, double* %5, i64 3
store double %48, double* %49
%50 = getelementptr inbounds double, double* %11, i64 4
%51 = load double, double* %50
%52 = load double, double* %2
%53 = fdiv double %51, %52
%54 = getelementptr inbounds double, double* %12, i64 4
%55 = load double, double* %54
%56 = load double, double* %1
%57 = fdiv double %55, %56
%58 = fsub double %53, %57
%59 = getelementptr inbounds double, double* %5, i64 4
store double %58, double* %59
%60 = getelementptr inbounds double, double* %11, i64 5
%61 = load double, double* %60
%62 = load double, double* %2
%63 = fdiv double %61, %62
%64 = getelementptr inbounds double, double* %12, i64 5
%65 = load double, double* %64
%66 = load double, double* %1
%67 = fdiv double %65, %66
%68 = fsub double %63, %67
%69 = getelementptr inbounds double, double* %5, i64 5
store double %68, double* %69
%70 = tail call i32 @mt2sm(double* %5, double* %3)
%71 = bitcast double* %5 to i8*
%72 = tail call i32 @free(i8* %71)
ret void
}