#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 atof(char *);
double bingham_F_lookup_3d(double *);
int /*<<< orphan*/ bingham_dF_lookup_3d(double *, double *);
int /*<<< orphan*/ printf(char *, double, double, double, double);
int /*<<< orphan*/ usage(int, char **);
int main(int argc, char *argv[]) {
  if (argc < 4)
    usage(argc, argv);
  double z1 = atof(argv[1]);
  double z2 = atof(argv[2]);
  double z3 = atof(argv[3]);
  double Z[3] = {z1, z2, z3};
  double F = bingham_F_lookup_3d(Z);
  double dF[3];
  bingham_dF_lookup_3d(dF, Z);
  printf("F = %e, dF = [%e, %e, %e]\n", F, dF[0], dF[1], dF[2]);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x4,-0x8(%rbp)
jge    117c <main+0x2c>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1060 <usage@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1030 <atof@plt>
movsd  %xmm0,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1030 <atof@plt>
movsd  %xmm0,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
call   1030 <atof@plt>
movsd  %xmm0,-0x28(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
lea    -0x40(%rbp),%rdi
call   1050 <bingham_F_lookup_3d@plt>
movsd  %xmm0,-0x48(%rbp)
lea    -0x60(%rbp),%rdi
lea    -0x40(%rbp),%rsi
call   1070 <bingham_dF_lookup_3d@plt>
movsd  -0x48(%rbp),%xmm0
movsd  -0x60(%rbp),%xmm1
movsd  -0x58(%rbp),%xmm2
movsd  -0x50(%rbp),%xmm3
lea    0xdfa(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x50,%rsp
mov    %rsi,%rbx
cmp    $0x3,%edi
jg     1165 <main+0x15>
mov    %rbx,%rsi
call   1060 <usage@plt>
mov    0x8(%rbx),%rdi
call   1030 <atof@plt>
movsd  %xmm0,(%rsp)
mov    0x10(%rbx),%rdi
call   1030 <atof@plt>
movsd  %xmm0,0x8(%rsp)
mov    0x18(%rbx),%rdi
call   1030 <atof@plt>
movsd  (%rsp),%xmm1
movsd  %xmm1,0x30(%rsp)
movsd  0x8(%rsp),%xmm1
movsd  %xmm1,0x38(%rsp)
movsd  %xmm0,0x40(%rsp)
lea    0x30(%rsp),%rbx
mov    %rbx,%rdi
call   1050 <bingham_F_lookup_3d@plt>
movsd  %xmm0,(%rsp)
lea    0x10(%rsp),%rdi
mov    %rbx,%rsi
call   1070 <bingham_dF_lookup_3d@plt>
movsd  0x10(%rsp),%xmm1
movsd  0x18(%rsp),%xmm2
movsd  0x20(%rsp),%xmm3
lea    0xe20(%rip),%rdi
movsd  (%rsp),%xmm0
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [27 x i8] c"F = %e, dF = [%e, %e, %e]\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca double
%7 = alloca double
%8 = alloca double
%9 = alloca [3 x double]
%10 = alloca double
%11 = alloca [3 x double]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%12 = load i32, i32* %4
%13 = icmp slt i32 %12, 4
br i1 %13, label %14, label %18
14: ; preds = %2
%15 = load i32, i32* %4
%16 = load i8**, i8*** %5
%17 = call i32 @usage(i32 %15, i8** %16)
br label %18
18: ; preds = %14, %2
%19 = load i8**, i8*** %5
%20 = getelementptr inbounds i8*, i8** %19, i64 1
%21 = load i8*, i8** %20
%22 = call double @atof(i8* %21)
store double %22, double* %6
%23 = load i8**, i8*** %5
%24 = getelementptr inbounds i8*, i8** %23, i64 2
%25 = load i8*, i8** %24
%26 = call double @atof(i8* %25)
store double %26, double* %7
%27 = load i8**, i8*** %5
%28 = getelementptr inbounds i8*, i8** %27, i64 3
%29 = load i8*, i8** %28
%30 = call double @atof(i8* %29)
store double %30, double* %8
%31 = getelementptr inbounds [3 x double], [3 x double]* %9, i64 0, i64 0
%32 = load double, double* %6
store double %32, double* %31
%33 = getelementptr inbounds double, double* %31, i64 1
%34 = load double, double* %7
store double %34, double* %33
%35 = getelementptr inbounds double, double* %33, i64 1
%36 = load double, double* %8
store double %36, double* %35
%37 = getelementptr inbounds [3 x double], [3 x double]* %9, i64 0, i64 0
%38 = call double @bingham_F_lookup_3d(double* %37)
store double %38, double* %10
%39 = getelementptr inbounds [3 x double], [3 x double]* %11, i64 0, i64 0
%40 = getelementptr inbounds [3 x double], [3 x double]* %9, i64 0, i64 0
%41 = call i32 @bingham_dF_lookup_3d(double* %39, double* %40)
%42 = load double, double* %10
%43 = getelementptr inbounds [3 x double], [3 x double]* %11, i64 0, i64 0
%44 = load double, double* %43
%45 = getelementptr inbounds [3 x double], [3 x double]* %11, i64 0, i64 1
%46 = load double, double* %45
%47 = getelementptr inbounds [3 x double], [3 x double]* %11, i64 0, i64 2
%48 = load double, double* %47
%49 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), double %42, double %44, double %46, double %48)
ret i32 0
}

LLVM IR (-O2):
@.str = [27 x i8] c"F = %e, dF = [%e, %e, %e]\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca [3 x double]
%4 = alloca [3 x double]
%5 = icmp slt i32 %0, 4
br i1 %5, label %6, label %8
6: ; preds = %2
%7 = tail call i32 @usage(i32 %0, i8** %1)
br label %8
8: ; preds = %6, %2
%9 = getelementptr inbounds i8*, i8** %1, i64 1
%10 = load i8*, i8** %9
%11 = tail call double @atof(i8* %10)
%12 = getelementptr inbounds i8*, i8** %1, i64 2
%13 = load i8*, i8** %12
%14 = tail call double @atof(i8* %13)
%15 = getelementptr inbounds i8*, i8** %1, i64 3
%16 = load i8*, i8** %15
%17 = tail call double @atof(i8* %16)
%18 = bitcast [3 x double]* %3 to i8*
%19 = getelementptr inbounds [3 x double], [3 x double]* %3, i64 0, i64 0
store double %11, double* %19
%20 = getelementptr inbounds [3 x double], [3 x double]* %3, i64 0, i64 1
store double %14, double* %20
%21 = getelementptr inbounds [3 x double], [3 x double]* %3, i64 0, i64 2
store double %17, double* %21
%22 = call double @bingham_F_lookup_3d(double* %19)
%23 = bitcast [3 x double]* %4 to i8*
%24 = getelementptr inbounds [3 x double], [3 x double]* %4, i64 0, i64 0
%25 = call i32 @bingham_dF_lookup_3d(double* %24, double* %19)
%26 = load double, double* %24
%27 = getelementptr inbounds [3 x double], [3 x double]* %4, i64 0, i64 1
%28 = load double, double* %27
%29 = getelementptr inbounds [3 x double], [3 x double]* %4, i64 0, i64 2
%30 = load double, double* %29
%31 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), double %22, double %26, double %28, double %30)
ret i32 0
}