#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 /*<<< orphan*/ FKinSpace(double **, int, double *, double *, double **);
int /*<<< orphan*/ printf(char *, ...);
void test_FKinSpace() {
  int i;
  double M[4][4] = {1.0000, 0, 0,      213.0000, 0, 1.0000, 0, 267.8000,
                    0,      0, 1.0000, 478.9500, 0, 0,      0, 1.0000};
  int JoinNum = 6;
  double Slist[6][6] = {
      0,      0,        0, 0,         0,         0,         0,        1.0000,
      1.0000, 1.0000,   0, 1.0000,    1.0000,    0,         0,        0,
      1.0000, 0,        0, -151.9000, -395.5500, -395.5500, 110.4000, -478.9500,
      0,      0,        0, 0,         -213.0000, 0,         0,        0,
      0,      213.0000, 0, 213.0000};
  double thetalist[6] = {0.1, 0.2, 0.3, 0.4, 0.5, 3.14159265358979323846 / 4};
  printf("thetalist:\n");
  for (i = 0; i < 6; i++) {
    printf("%lf ", thetalist[i]);
  }
  printf("\n");
  double T[4][4];
  FKinSpace(M, JoinNum, (double *)Slist, thetalist, T);
  printf("T:\n");
  for (i = 0; i < 4; i++) {
    printf("%lf %lf %lf %lf\n", T[i][0], T[i][1], T[i][2], T[i][3]);
  }
  return;
}


x86 assembly (clang, -O0):
<test_FKinSpace>:
push   %rbp
mov    %rsp,%rbp
sub    $0x270,%rsp
lea    -0x90(%rbp),%rdi
lea    0xed7(%rip),%rsi
mov    $0x80,%edx
call   1050 <memcpy@plt>
movl   $0x6,-0x94(%rbp)
lea    -0x1c0(%rbp),%rdi
lea    0xf35(%rip),%rsi
mov    $0x120,%edx
call   1050 <memcpy@plt>
lea    -0x1f0(%rbp),%rdi
xor    %esi,%esi
mov    $0x30,%edx
call   1040 <memset@plt>
movsd  0xe88(%rip),%xmm0
movsd  %xmm0,-0x1f0(%rbp)
ff
movsd  0xe70(%rip),%xmm0
movsd  %xmm0,-0x1e8(%rbp)
ff
movsd  0xe58(%rip),%xmm0
movsd  %xmm0,-0x1e0(%rbp)
ff
movsd  0xe40(%rip),%xmm0
movsd  %xmm0,-0x1d8(%rbp)
ff
movsd  0xe28(%rip),%xmm0
movsd  %xmm0,-0x1d0(%rbp)
ff
movsd  0xe10(%rip),%xmm0
movsd  %xmm0,-0x1c8(%rbp)
ff
lea    0xfd1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
cmpl   $0x6,-0x4(%rbp)
jge    1240 <test_FKinSpace+0x100>
movslq -0x4(%rbp),%rax
movsd  -0x1f0(%rbp,%rax,8),%xmm0
ff ff
lea    0xfb1(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    120d <test_FKinSpace+0xcd>
lea    0xf9c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x90(%rbp),%rdi
mov    -0x94(%rbp),%esi
lea    -0x1c0(%rbp),%rdx
lea    -0x1f0(%rbp),%rcx
lea    -0x270(%rbp),%r8
call   1060 <FKinSpace@plt>
lea    0xf65(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
cmpl   $0x4,-0x4(%rbp)
jge    130b <test_FKinSpace+0x1cb>
movslq -0x4(%rbp),%rcx
lea    -0x270(%rbp),%rax
shl    $0x5,%rcx
add    %rcx,%rax
movsd  (%rax),%xmm0
movslq -0x4(%rbp),%rcx
lea    -0x270(%rbp),%rax
shl    $0x5,%rcx
add    %rcx,%rax
movsd  0x8(%rax),%xmm1
movslq -0x4(%rbp),%rcx
lea    -0x270(%rbp),%rax
shl    $0x5,%rcx
add    %rcx,%rax
movsd  0x10(%rax),%xmm2
movslq -0x4(%rbp),%rcx
lea    -0x270(%rbp),%rax
shl    $0x5,%rcx
add    %rcx,%rax
movsd  0x18(%rax),%xmm3
lea    0xeef(%rip),%rdi
mov    $0x4,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    128a <test_FKinSpace+0x14a>
add    $0x270,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_FKinSpace>:
push   %r14
push   %rbx
sub    $0x258,%rsp
movaps 0xf6f(%rip),%xmm0
movaps %xmm0,0x120(%rsp)
movaps 0xf50(%rip),%xmm0
movaps %xmm0,0x110(%rsp)
movaps 0xf31(%rip),%xmm0
movaps %xmm0,0x100(%rsp)
movaps 0xf12(%rip),%xmm0
movaps %xmm0,0xf0(%rsp)
movaps 0xef3(%rip),%xmm0
movaps %xmm0,0xe0(%rsp)
movaps 0xed4(%rip),%xmm0
movaps %xmm0,0xd0(%rsp)
movaps 0xeb5(%rip),%xmm0
movaps %xmm0,0xc0(%rsp)
movaps 0xe96(%rip),%xmm0
movaps %xmm0,0xb0(%rsp)
lea    0xf07(%rip),%rsi
lea    0x130(%rsp),%r14
mov    $0x120,%edx
mov    %r14,%rdi
call   1060 <memcpy@plt>
movaps 0xe0b(%rip),%xmm0
movaps %xmm0,0x80(%rsp)
movaps 0xe0c(%rip),%xmm0
movaps %xmm0,0x90(%rsp)
movaps 0xe0d(%rip),%xmm0
movaps %xmm0,0xa0(%rsp)
lea    0xff4(%rip),%rdi
call   1040 <puts@plt>
lea    0xfd2(%rip),%rbx
movsd  0xdfa(%rip),%xmm0
mov    %rbx,%rdi
mov    $0x1,%al
call   1050 <printf@plt>
movsd  0xdf0(%rip),%xmm0
mov    %rbx,%rdi
mov    $0x1,%al
call   1050 <printf@plt>
movsd  0xde6(%rip),%xmm0
mov    %rbx,%rdi
mov    $0x1,%al
call   1050 <printf@plt>
movsd  0xddc(%rip),%xmm0
mov    %rbx,%rdi
mov    $0x1,%al
call   1050 <printf@plt>
movsd  0xdd2(%rip),%xmm0
mov    %rbx,%rdi
mov    $0x1,%al
call   1050 <printf@plt>
movsd  0xdc8(%rip),%xmm0
mov    %rbx,%rdi
mov    $0x1,%al
call   1050 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0xb0(%rsp),%rdi
lea    0x80(%rsp),%rcx
mov    %rsp,%r8
mov    $0x6,%esi
mov    %r14,%rdx
call   1070 <FKinSpace@plt>
lea    0xf56(%rip),%rdi
call   1040 <puts@plt>
movsd  (%rsp),%xmm0
movsd  0x8(%rsp),%xmm1
movsd  0x10(%rsp),%xmm2
movsd  0x18(%rsp),%xmm3
lea    0xf17(%rip),%rbx
mov    %rbx,%rdi
mov    $0x4,%al
call   1050 <printf@plt>
movsd  0x20(%rsp),%xmm0
movsd  0x28(%rsp),%xmm1
movsd  0x30(%rsp),%xmm2
movsd  0x38(%rsp),%xmm3
mov    %rbx,%rdi
mov    $0x4,%al
call   1050 <printf@plt>
movsd  0x40(%rsp),%xmm0
movsd  0x48(%rsp),%xmm1
movsd  0x50(%rsp),%xmm2
movsd  0x58(%rsp),%xmm3
mov    %rbx,%rdi
mov    $0x4,%al
call   1050 <printf@plt>
movsd  0x60(%rsp),%xmm0
movsd  0x68(%rsp),%xmm1
movsd  0x70(%rsp),%xmm2
movsd  0x78(%rsp),%xmm3
mov    %rbx,%rdi
mov    $0x4,%al
call   1050 <printf@plt>
add    $0x258,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@__const.test_FKinSpace.M = [4 x [4 x double]] [[4 x double] [double 1.000000e+00, double 0.000000e+00, double 0.000000e+00, double 2.130000e+02], [4 x double] [double 0.000000e+00, double 1.000000e+00, double 0.000000e+00, double 2.678000e+02], [4 x double] [double 0.000000e+00, double 0.000000e+00, double 1.000000e+00, double 4.789500e+02], [4 x double] [double 0.000000e+00, double 0.000000e+00, double 0.000000e+00, double 1.000000e+00]]
@__const.test_FKinSpace.Slist = [6 x [6 x double]] [[6 x double] zeroinitializer, [6 x double] [double 0.000000e+00, double 1.000000e+00, double 1.000000e+00, double 1.000000e+00, double 0.000000e+00, double 1.000000e+00], [6 x double] [double 1.000000e+00, double 0.000000e+00, double 0.000000e+00, double 0.000000e+00, double 1.000000e+00, double 0.000000e+00], [6 x double] [double 0.000000e+00, double -1.519000e+02, double -3.955500e+02, double -3.955500e+02, double 1.104000e+02, double -4.789500e+02], [6 x double] [double 0.000000e+00, double 0.000000e+00, double 0.000000e+00, double 0.000000e+00, double -2.130000e+02, double 0.000000e+00], [6 x double] [double 0.000000e+00, double 0.000000e+00, double 0.000000e+00, double 2.130000e+02, double 0.000000e+00, double 2.130000e+02]]
@.str = [12 x i8] c"thetalist:\0A\00"
@.str.1 = [5 x i8] c"%lf \00"
@.str.2 = [2 x i8] c"\0A\00"
@.str.3 = [4 x i8] c"T:\0A\00"
@.str.4 = [17 x i8] c"%lf %lf %lf %lf\0A\00"
define void @test_FKinSpace() {
%1 = alloca i32
%2 = alloca [4 x [4 x double]]
%3 = alloca i32
%4 = alloca [6 x [6 x double]]
%5 = alloca [6 x double]
%6 = alloca [4 x [4 x double]]
%7 = bitcast [4 x [4 x double]]* %2 to i8*
store i32 6, i32* %3
%8 = bitcast [6 x [6 x double]]* %4 to i8*
%9 = bitcast [6 x double]* %5 to i8*
%10 = bitcast i8* %9 to [6 x double]*
%11 = getelementptr inbounds [6 x double], [6 x double]* %10, i32 0, i32 0
store double 1.000000e-01, double* %11
%12 = getelementptr inbounds [6 x double], [6 x double]* %10, i32 0, i32 1
store double 2.000000e-01, double* %12
%13 = getelementptr inbounds [6 x double], [6 x double]* %10, i32 0, i32 2
store double 3.000000e-01, double* %13
%14 = getelementptr inbounds [6 x double], [6 x double]* %10, i32 0, i32 3
store double 4.000000e-01, double* %14
%15 = getelementptr inbounds [6 x double], [6 x double]* %10, i32 0, i32 4
store double 5.000000e-01, double* %15
%16 = getelementptr inbounds [6 x double], [6 x double]* %10, i32 0, i32 5
store double 0x3FE921FB54442D18, double* %16
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %1
br label %18
18: ; preds = %27, %0
%19 = load i32, i32* %1
%20 = icmp slt i32 %19, 6
br i1 %20, label %21, label %30
21: ; preds = %18
%22 = load i32, i32* %1
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds [6 x double], [6 x double]* %5, i64 0, i64 %23
%25 = load double, double* %24
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), double %25)
br label %27
27: ; preds = %21
%28 = load i32, i32* %1
%29 = add nsw i32 %28, 1
store i32 %29, i32* %1
br label %18
30: ; preds = %18
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%32 = getelementptr inbounds [4 x [4 x double]], [4 x [4 x double]]* %2, i64 0, i64 0
%33 = bitcast [4 x double]* %32 to double**
%34 = load i32, i32* %3
%35 = getelementptr inbounds [6 x [6 x double]], [6 x [6 x double]]* %4, i64 0, i64 0
%36 = bitcast [6 x double]* %35 to double*
%37 = getelementptr inbounds [6 x double], [6 x double]* %5, i64 0, i64 0
%38 = getelementptr inbounds [4 x [4 x double]], [4 x [4 x double]]* %6, i64 0, i64 0
%39 = bitcast [4 x double]* %38 to double**
%40 = call i32 @FKinSpace(double** %33, i32 %34, double* %36, double* %37, double** %39)
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
store i32 0, i32* %1
br label %42
42: ; preds = %67, %30
%43 = load i32, i32* %1
%44 = icmp slt i32 %43, 4
br i1 %44, label %45, label %70
45: ; preds = %42
%46 = load i32, i32* %1
%47 = sext i32 %46 to i64
%48 = getelementptr inbounds [4 x [4 x double]], [4 x [4 x double]]* %6, i64 0, i64 %47
%49 = getelementptr inbounds [4 x double], [4 x double]* %48, i64 0, i64 0
%50 = load double, double* %49
%51 = load i32, i32* %1
%52 = sext i32 %51 to i64
%53 = getelementptr inbounds [4 x [4 x double]], [4 x [4 x double]]* %6, i64 0, i64 %52
%54 = getelementptr inbounds [4 x double], [4 x double]* %53, i64 0, i64 1
%55 = load double, double* %54
%56 = load i32, i32* %1
%57 = sext i32 %56 to i64
%58 = getelementptr inbounds [4 x [4 x double]], [4 x [4 x double]]* %6, i64 0, i64 %57
%59 = getelementptr inbounds [4 x double], [4 x double]* %58, i64 0, i64 2
%60 = load double, double* %59
%61 = load i32, i32* %1
%62 = sext i32 %61 to i64
%63 = getelementptr inbounds [4 x [4 x double]], [4 x [4 x double]]* %6, i64 0, i64 %62
%64 = getelementptr inbounds [4 x double], [4 x double]* %63, i64 0, i64 3
%65 = load double, double* %64
%66 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0), double %50, double %55, double %60, double %65)
br label %67
67: ; preds = %45
%68 = load i32, i32* %1
%69 = add nsw i32 %68, 1
store i32 %69, i32* %1
br label %42
70: ; preds = %42
ret void
}

LLVM IR (-O2):
@__const.test_FKinSpace.M = [4 x [4 x double]] [[4 x double] [double 1.000000e+00, double 0.000000e+00, double 0.000000e+00, double 2.130000e+02], [4 x double] [double 0.000000e+00, double 1.000000e+00, double 0.000000e+00, double 2.678000e+02], [4 x double] [double 0.000000e+00, double 0.000000e+00, double 1.000000e+00, double 4.789500e+02], [4 x double] [double 0.000000e+00, double 0.000000e+00, double 0.000000e+00, double 1.000000e+00]]
@__const.test_FKinSpace.Slist = [6 x [6 x double]] [[6 x double] zeroinitializer, [6 x double] [double 0.000000e+00, double 1.000000e+00, double 1.000000e+00, double 1.000000e+00, double 0.000000e+00, double 1.000000e+00], [6 x double] [double 1.000000e+00, double 0.000000e+00, double 0.000000e+00, double 0.000000e+00, double 1.000000e+00, double 0.000000e+00], [6 x double] [double 0.000000e+00, double -1.519000e+02, double -3.955500e+02, double -3.955500e+02, double 1.104000e+02, double -4.789500e+02], [6 x double] [double 0.000000e+00, double 0.000000e+00, double 0.000000e+00, double 0.000000e+00, double -2.130000e+02, double 0.000000e+00], [6 x double] [double 0.000000e+00, double 0.000000e+00, double 0.000000e+00, double 2.130000e+02, double 0.000000e+00, double 2.130000e+02]]
@.str.1 = [5 x i8] c"%lf \00"
@.str.4 = [17 x i8] c"%lf %lf %lf %lf\0A\00"
@str = [11 x i8] c"thetalist:\00"
@str.5 = [3 x i8] c"T:\00"
define void @test_FKinSpace() {
%1 = alloca [4 x [4 x double]]
%2 = alloca [6 x [6 x double]]
%3 = alloca [6 x double]
%4 = alloca [4 x [4 x double]]
%5 = bitcast [4 x [4 x double]]* %1 to i8*
%6 = bitcast [6 x [6 x double]]* %2 to i8*
%7 = bitcast [6 x double]* %3 to i8*
%8 = getelementptr inbounds [6 x double], [6 x double]* %3, i64 0, i64 0
%9 = bitcast [6 x double]* %3 to <2 x double>*
store <2 x double> <double 1.000000e-01, double 2.000000e-01>, <2 x double>* %9
%10 = getelementptr inbounds [6 x double], [6 x double]* %3, i64 0, i64 2
%11 = bitcast double* %10 to <2 x double>*
store <2 x double> <double 3.000000e-01, double 4.000000e-01>, <2 x double>* %11
%12 = getelementptr inbounds [6 x double], [6 x double]* %3, i64 0, i64 4
%13 = bitcast double* %12 to <2 x double>*
store <2 x double> <double 5.000000e-01, double 0x3FE921FB54442D18>, <2 x double>* %13
%14 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @str, i64 0, i64 0))
%15 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), double 1.000000e-01)
%16 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), double 2.000000e-01)
%17 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), double 3.000000e-01)
%18 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), double 4.000000e-01)
%19 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), double 5.000000e-01)
%20 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), double 0x3FE921FB54442D18)
%21 = tail call i32 @putchar(i32 10)
%22 = bitcast [4 x [4 x double]]* %4 to i8*
%23 = bitcast [4 x [4 x double]]* %1 to double**
%24 = getelementptr inbounds [6 x [6 x double]], [6 x [6 x double]]* %2, i64 0, i64 0, i64 0
%25 = bitcast [4 x [4 x double]]* %4 to double**
%26 = call i32 @FKinSpace(double** %23, i32 6, double* %24, double* %8, double** %25)
%27 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @str.5, i64 0, i64 0))
%28 = getelementptr inbounds [4 x [4 x double]], [4 x [4 x double]]* %4, i64 0, i64 0, i64 0
%29 = load double, double* %28
%30 = getelementptr inbounds [4 x [4 x double]], [4 x [4 x double]]* %4, i64 0, i64 0, i64 1
%31 = load double, double* %30
%32 = getelementptr inbounds [4 x [4 x double]], [4 x [4 x double]]* %4, i64 0, i64 0, i64 2
%33 = load double, double* %32
%34 = getelementptr inbounds [4 x [4 x double]], [4 x [4 x double]]* %4, i64 0, i64 0, i64 3
%35 = load double, double* %34
%36 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0), double %29, double %31, double %33, double %35)
%37 = getelementptr inbounds [4 x [4 x double]], [4 x [4 x double]]* %4, i64 0, i64 1, i64 0
%38 = load double, double* %37
%39 = getelementptr inbounds [4 x [4 x double]], [4 x [4 x double]]* %4, i64 0, i64 1, i64 1
%40 = load double, double* %39
%41 = getelementptr inbounds [4 x [4 x double]], [4 x [4 x double]]* %4, i64 0, i64 1, i64 2
%42 = load double, double* %41
%43 = getelementptr inbounds [4 x [4 x double]], [4 x [4 x double]]* %4, i64 0, i64 1, i64 3
%44 = load double, double* %43
%45 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0), double %38, double %40, double %42, double %44)
%46 = getelementptr inbounds [4 x [4 x double]], [4 x [4 x double]]* %4, i64 0, i64 2, i64 0
%47 = load double, double* %46
%48 = getelementptr inbounds [4 x [4 x double]], [4 x [4 x double]]* %4, i64 0, i64 2, i64 1
%49 = load double, double* %48
%50 = getelementptr inbounds [4 x [4 x double]], [4 x [4 x double]]* %4, i64 0, i64 2, i64 2
%51 = load double, double* %50
%52 = getelementptr inbounds [4 x [4 x double]], [4 x [4 x double]]* %4, i64 0, i64 2, i64 3
%53 = load double, double* %52
%54 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0), double %47, double %49, double %51, double %53)
%55 = getelementptr inbounds [4 x [4 x double]], [4 x [4 x double]]* %4, i64 0, i64 3, i64 0
%56 = load double, double* %55
%57 = getelementptr inbounds [4 x [4 x double]], [4 x [4 x double]]* %4, i64 0, i64 3, i64 1
%58 = load double, double* %57
%59 = getelementptr inbounds [4 x [4 x double]], [4 x [4 x double]]* %4, i64 0, i64 3, i64 2
%60 = load double, double* %59
%61 = getelementptr inbounds [4 x [4 x double]], [4 x [4 x double]]* %4, i64 0, i64 3, i64 3
%62 = load double, double* %61
%63 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0), double %56, double %58, double %60, double %62)
ret void
}