#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*/ FKinBody(double **, int, double *, double *, double **);
int /*<<< orphan*/ printf(char *, ...);
void test_FKinBody() {
  double M[4][4] = {-1, 0, 0, 0, 0, 1, 0, 6, 0, 0, -1, 2, 0, 0, 0, 1};
  int JoinNum = 3;
  double Blist[6][3] = {0, 0, 0, 0, 0, 0, -1, 0, 1,
                        2, 0, 0, 0, 1, 0, 0,  0, 0.1};
  double thetalist[3] = {3.14159265358979323846 / 2, 3, 3.14159265358979323846};
  double T[4][4];
  FKinBody(M, JoinNum, (double *)Blist, thetalist, T);
  int i;
  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_FKinBody>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1d0,%rsp
lea    -0x80(%rbp),%rdi
xor    %esi,%esi
mov    $0x80,%edx
call   1040 <memset@plt>
movsd  0xec5(%rip),%xmm0
movsd  %xmm0,-0x80(%rbp)
movsd  0xea8(%rip),%xmm0
movsd  %xmm0,-0x58(%rbp)
movsd  0xeb3(%rip),%xmm0
movsd  %xmm0,-0x48(%rbp)
movsd  0xe9e(%rip),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  0xe89(%rip),%xmm0
movsd  %xmm0,-0x28(%rbp)
movsd  0xe74(%rip),%xmm0
movsd  %xmm0,-0x8(%rbp)
movl   $0x3,-0x84(%rbp)
lea    -0x120(%rbp),%rdi
xor    %esi,%esi
mov    $0x90,%edx
call   1040 <memset@plt>
movsd  0xe5a(%rip),%xmm0
movsd  %xmm0,-0xf0(%rbp)
ff
movsd  0xe3a(%rip),%xmm0
movsd  %xmm0,-0xe0(%rbp)
ff
movsd  0xe32(%rip),%xmm0
movsd  %xmm0,-0xd8(%rbp)
ff
movsd  0xe1a(%rip),%xmm0
movsd  %xmm0,-0xb8(%rbp)
ff
movsd  0xe02(%rip),%xmm0
movsd  %xmm0,-0x98(%rbp)
ff
mov    0xe23(%rip),%rax
mov    %rax,-0x140(%rbp)
mov    0xe1d(%rip),%rax
mov    %rax,-0x138(%rbp)
mov    0xe17(%rip),%rax
mov    %rax,-0x130(%rbp)
lea    -0x80(%rbp),%rdi
mov    -0x84(%rbp),%esi
lea    -0x120(%rbp),%rdx
lea    -0x140(%rbp),%rcx
lea    -0x1c0(%rbp),%r8
call   1050 <FKinBody@plt>
lea    0xded(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x1c4(%rbp)
cmpl   $0x4,-0x1c4(%rbp)
jge    1302 <test_FKinBody+0x1d2>
movslq -0x1c4(%rbp),%rcx
lea    -0x1c0(%rbp),%rax
shl    $0x5,%rcx
add    %rcx,%rax
movsd  (%rax),%xmm0
movslq -0x1c4(%rbp),%rcx
lea    -0x1c0(%rbp),%rax
shl    $0x5,%rcx
add    %rcx,%rax
movsd  0x8(%rax),%xmm1
movslq -0x1c4(%rbp),%rcx
lea    -0x1c0(%rbp),%rax
shl    $0x5,%rcx
add    %rcx,%rax
movsd  0x10(%rax),%xmm2
movslq -0x1c4(%rbp),%rcx
lea    -0x1c0(%rbp),%rax
shl    $0x5,%rcx
add    %rcx,%rax
movsd  0x18(%rax),%xmm3
lea    0xd65(%rip),%rdi
mov    $0x4,%al
call   1030 <printf@plt>
mov    -0x1c4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c4(%rbp)
jmp    126c <test_FKinBody+0x13c>
add    $0x1d0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_FKinBody>:
push   %rbx
sub    $0x1b0,%rsp
xorps  %xmm0,%xmm0
movaps %xmm0,0xa0(%rsp)
movaps %xmm0,0xc0(%rsp)
movaps %xmm0,0xd0(%rsp)
movaps %xmm0,0x110(%rsp)
movaps %xmm0,0x100(%rsp)
movaps %xmm0,0xe0(%rsp)
movaps %xmm0,0xb0(%rsp)
movabs $0xbff0000000000000,%rax
mov    %rax,0xa0(%rsp)
movabs $0x3ff0000000000000,%rcx
mov    %rcx,0xc8(%rsp)
movabs $0x4018000000000000,%rdx
mov    %rdx,0xd8(%rsp)
movaps 0xe50(%rip),%xmm1
movaps %xmm1,0xf0(%rsp)
mov    %rcx,0x118(%rsp)
movaps %xmm0,0x150(%rsp)
movaps %xmm0,0x180(%rsp)
movaps %xmm0,0x1a0(%rsp)
movaps %xmm0,0x190(%rsp)
movaps %xmm0,0x170(%rsp)
movaps %xmm0,0x140(%rsp)
movaps %xmm0,0x130(%rsp)
movaps %xmm0,0x120(%rsp)
mov    %rax,0x150(%rsp)
movaps 0xe01(%rip),%xmm0
movaps %xmm0,0x160(%rsp)
mov    %rcx,0x188(%rsp)
movabs $0x3fb999999999999a,%rax
99 b9 3f
mov    %rax,0x1a8(%rsp)
mov    0xdf8(%rip),%rax
mov    %rax,0x90(%rsp)
movaps 0xdd9(%rip),%xmm0
movaps %xmm0,0x80(%rsp)
lea    0xa0(%rsp),%rdi
lea    0x120(%rsp),%rdx
lea    0x80(%rsp),%rcx
mov    %rsp,%r8
mov    $0x3,%esi
call   1050 <FKinBody@plt>
lea    0xdce(%rip),%rdi
call   1030 <puts@plt>
movsd  (%rsp),%xmm0
movsd  0x8(%rsp),%xmm1
movsd  0x10(%rsp),%xmm2
movsd  0x18(%rsp),%xmm3
lea    0xd9a(%rip),%rbx
mov    %rbx,%rdi
mov    $0x4,%al
call   1040 <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   1040 <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   1040 <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   1040 <printf@plt>
add    $0x1b0,%rsp
pop    %rbx
ret

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

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