#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 *);
int /*<<< orphan*/ compute_all_bingham_F_2d(double, double, double, double,
                                            double, double);
int /*<<< orphan*/ compute_all_bingham_F_3d(double, double, double, double,
                                            double, double, double, double,
                                            double);
int /*<<< orphan*/ compute_all_bingham_dF1_2d(double, double, double, double,
                                              double, double);
int /*<<< orphan*/ compute_all_bingham_dF1_3d(double, double, double, double,
                                              double, double, double, double,
                                              double);
int /*<<< orphan*/ compute_all_bingham_dF2_2d(double, double, double, double,
                                              double, double);
int /*<<< orphan*/ compute_all_bingham_dF2_3d(double, double, double, double,
                                              double, double, double, double,
                                              double);
int /*<<< orphan*/ compute_all_bingham_dF3_3d(double, double, double, double,
                                              double, double, double, double,
                                              double);
int /*<<< orphan*/ printf(char *, ...);
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ usage(char **);
void test_bingham(int argc, char *argv[]) {
  double z_min, z_max, step;
  int dim;
  if (argc < 5)
    usage(argv);
  if (strcmp(argv[1], "2d") == 0)
    dim = 2;
  else if (strcmp(argv[1], "3d") == 0)
    dim = 3;
  else
    usage(argv);
  z_min = atof(argv[2]);
  z_max = atof(argv[3]);
  step = atof(argv[4]);
  printf("\n");
  printf("[X Y] = meshgrid(%f:%f:%f);\n\n", z_min, step, z_max);
  if (dim == 2) {
    compute_all_bingham_F_2d(z_min, z_max, step, z_min, z_max, step);
    compute_all_bingham_dF1_2d(z_min, z_max, step, z_min, z_max, step);
    compute_all_bingham_dF2_2d(z_min, z_max, step, z_min, z_max, step);
  } else if (dim == 3) {
    compute_all_bingham_F_3d(z_min, z_max, step, z_min, z_max, step, z_min,
                             z_max, step);
    compute_all_bingham_dF1_3d(z_min, z_max, step, z_min, z_max, step, z_min,
                               z_max, step);
    compute_all_bingham_dF2_3d(z_min, z_max, step, z_min, z_max, step, z_min,
                               z_max, step);
    compute_all_bingham_dF3_3d(z_min, z_max, step, z_min, z_max, step, z_min,
                               z_max, step);
  }
}


x86 assembly (clang, -O0):
<test_bingham>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x5,-0x4(%rbp)
jge    11d2 <test_bingham+0x22>
mov    -0x10(%rbp),%rdi
call   10b0 <usage@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe1f(%rip),%rsi
call   10a0 <strcmp@plt>
cmp    $0x0,%rax
jne    11fc <test_bingham+0x4c>
movl   $0x2,-0x2c(%rbp)
jmp    1234 <test_bingham+0x84>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xdf8(%rip),%rsi
call   10a0 <strcmp@plt>
cmp    $0x0,%rax
jne    1226 <test_bingham+0x76>
movl   $0x3,-0x2c(%rbp)
jmp    122f <test_bingham+0x7f>
mov    -0x10(%rbp),%rdi
call   10b0 <usage@plt>
jmp    1234 <test_bingham+0x84>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1060 <atof@plt>
movsd  %xmm0,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
call   1060 <atof@plt>
movsd  %xmm0,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rdi
call   1060 <atof@plt>
movsd  %xmm0,-0x28(%rbp)
lea    0xdb1(%rip),%rdi
mov    $0x0,%al
call   1070 <printf@plt>
movsd  -0x18(%rbp),%xmm0
movsd  -0x28(%rbp),%xmm1
movsd  -0x20(%rbp),%xmm2
lea    0xd78(%rip),%rdi
mov    $0x3,%al
call   1070 <printf@plt>
cmpl   $0x2,-0x2c(%rbp)
jne    130d <test_bingham+0x15d>
movsd  -0x18(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
movsd  -0x28(%rbp),%xmm2
movsd  -0x18(%rbp),%xmm3
movsd  -0x20(%rbp),%xmm4
movsd  -0x28(%rbp),%xmm5
call   1030 <compute_all_bingham_F_2d@plt>
movsd  -0x18(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
movsd  -0x28(%rbp),%xmm2
movsd  -0x18(%rbp),%xmm3
movsd  -0x20(%rbp),%xmm4
movsd  -0x28(%rbp),%xmm5
call   10c0 <compute_all_bingham_dF1_2d@plt>
movsd  -0x18(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
movsd  -0x28(%rbp),%xmm2
movsd  -0x18(%rbp),%xmm3
movsd  -0x20(%rbp),%xmm4
movsd  -0x28(%rbp),%xmm5
call   10d0 <compute_all_bingham_dF2_2d@plt>
jmp    1400 <test_bingham+0x250>
cmpl   $0x3,-0x2c(%rbp)
jne    13fb <test_bingham+0x24b>
movsd  -0x18(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
movsd  -0x28(%rbp),%xmm2
movsd  -0x18(%rbp),%xmm3
movsd  -0x20(%rbp),%xmm4
movsd  -0x28(%rbp),%xmm5
movsd  -0x18(%rbp),%xmm6
movsd  -0x20(%rbp),%xmm7
movsd  -0x28(%rbp),%xmm8
movsd  %xmm8,(%rsp)
call   1090 <compute_all_bingham_F_3d@plt>
movsd  -0x18(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
movsd  -0x28(%rbp),%xmm2
movsd  -0x18(%rbp),%xmm3
movsd  -0x20(%rbp),%xmm4
movsd  -0x28(%rbp),%xmm5
movsd  -0x18(%rbp),%xmm6
movsd  -0x20(%rbp),%xmm7
movsd  -0x28(%rbp),%xmm8
movsd  %xmm8,(%rsp)
call   1050 <compute_all_bingham_dF1_3d@plt>
movsd  -0x18(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
movsd  -0x28(%rbp),%xmm2
movsd  -0x18(%rbp),%xmm3
movsd  -0x20(%rbp),%xmm4
movsd  -0x28(%rbp),%xmm5
movsd  -0x18(%rbp),%xmm6
movsd  -0x20(%rbp),%xmm7
movsd  -0x28(%rbp),%xmm8
movsd  %xmm8,(%rsp)
call   1080 <compute_all_bingham_dF2_3d@plt>
movsd  -0x18(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
movsd  -0x28(%rbp),%xmm2
movsd  -0x18(%rbp),%xmm3
movsd  -0x20(%rbp),%xmm4
movsd  -0x28(%rbp),%xmm5
movsd  -0x18(%rbp),%xmm6
movsd  -0x20(%rbp),%xmm7
movsd  -0x28(%rbp),%xmm8
movsd  %xmm8,(%rsp)
call   1040 <compute_all_bingham_dF3_3d@plt>
jmp    1400 <test_bingham+0x250>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_bingham>:
push   %rbp
push   %r14
push   %rbx
sub    $0x20,%rsp
mov    %rsi,%rbx
cmp    $0x4,%edi
jg     11d8 <test_bingham+0x18>
mov    %rbx,%rdi
call   10c0 <usage@plt>
mov    0x8(%rbx),%rdi
lea    0xe1d(%rip),%rsi
call   10b0 <strcmp@plt>
test   %rax,%rax
je     120c <test_bingham+0x4c>
mov    0x8(%rbx),%rdi
lea    0xe0b(%rip),%rsi
call   10b0 <strcmp@plt>
test   %rax,%rax
je     1214 <test_bingham+0x54>
mov    %rbx,%rdi
call   10c0 <usage@plt>
jmp    1219 <test_bingham+0x59>
mov    $0x1,%bpl
xor    %r14d,%r14d
jmp    1219 <test_bingham+0x59>
mov    $0x1,%r14b
xor    %ebp,%ebp
mov    0x10(%rbx),%rdi
call   1070 <atof@plt>
movsd  %xmm0,0x18(%rsp)
mov    0x18(%rbx),%rdi
call   1070 <atof@plt>
movsd  %xmm0,0x10(%rsp)
mov    0x20(%rbx),%rdi
call   1070 <atof@plt>
movsd  %xmm0,0x8(%rsp)
mov    $0xa,%edi
call   1050 <putchar@plt>
lea    0xdaf(%rip),%rdi
movsd  0x18(%rsp),%xmm0
movsd  0x8(%rsp),%xmm1
movsd  0x10(%rsp),%xmm2
mov    $0x3,%al
call   1080 <printf@plt>
test   $0x1,%bpl
je     12de <test_bingham+0x11e>
movsd  0x18(%rsp),%xmm0
movsd  0x10(%rsp),%xmm1
movsd  0x8(%rsp),%xmm2
movaps %xmm0,%xmm3
movaps %xmm1,%xmm4
movaps %xmm2,%xmm5
call   1030 <compute_all_bingham_F_2d@plt>
movsd  0x18(%rsp),%xmm0
movsd  0x10(%rsp),%xmm1
movsd  0x8(%rsp),%xmm2
movaps %xmm0,%xmm3
movaps %xmm1,%xmm4
movaps %xmm2,%xmm5
call   10d0 <compute_all_bingham_dF1_2d@plt>
movsd  0x18(%rsp),%xmm0
movsd  0x10(%rsp),%xmm1
movsd  0x8(%rsp),%xmm2
movaps %xmm0,%xmm3
movaps %xmm1,%xmm4
movaps %xmm2,%xmm5
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %rbp
jmp    10e0 <compute_all_bingham_dF2_2d@plt>
movsd  0x8(%rsp),%xmm2
movsd  0x10(%rsp),%xmm1
movsd  0x18(%rsp),%xmm0
test   $0x1,%r14b
je     1394 <test_bingham+0x1d4>
movsd  %xmm2,(%rsp)
movaps %xmm0,%xmm3
movaps %xmm1,%xmm4
movaps %xmm2,%xmm5
movaps %xmm0,%xmm6
movaps %xmm1,%xmm7
call   10a0 <compute_all_bingham_F_3d@plt>
movsd  0x8(%rsp),%xmm2
movsd  %xmm2,(%rsp)
movsd  0x18(%rsp),%xmm0
movsd  0x10(%rsp),%xmm1
movaps %xmm0,%xmm3
movaps %xmm1,%xmm4
movaps %xmm2,%xmm5
movaps %xmm0,%xmm6
movaps %xmm1,%xmm7
call   1060 <compute_all_bingham_dF1_3d@plt>
movsd  0x8(%rsp),%xmm2
movsd  %xmm2,(%rsp)
movsd  0x18(%rsp),%xmm0
movsd  0x10(%rsp),%xmm1
movaps %xmm0,%xmm3
movaps %xmm1,%xmm4
movaps %xmm2,%xmm5
movaps %xmm0,%xmm6
movaps %xmm1,%xmm7
call   1090 <compute_all_bingham_dF2_3d@plt>
movsd  0x8(%rsp),%xmm2
movsd  %xmm2,(%rsp)
movsd  0x18(%rsp),%xmm0
movsd  0x10(%rsp),%xmm1
movaps %xmm2,%xmm5
movaps %xmm0,%xmm3
movaps %xmm0,%xmm6
movaps %xmm1,%xmm4
movaps %xmm1,%xmm7
call   1040 <compute_all_bingham_dF3_3d@plt>
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"2d\00"
@.str.1 = [3 x i8] c"3d\00"
@.str.2 = [2 x i8] c"\0A\00"
@.str.3 = [30 x i8] c"[X Y] = meshgrid(%f:%f:%f);\0A\0A\00"
define void @test_bingham(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8**
%5 = alloca double
%6 = alloca double
%7 = alloca double
%8 = alloca i32
store i32 %0, i32* %3
store i8** %1, i8*** %4
%9 = load i32, i32* %3
%10 = icmp slt i32 %9, 5
br i1 %10, label %11, label %14
11: ; preds = %2
%12 = load i8**, i8*** %4
%13 = call i32 @usage(i8** %12)
br label %14
14: ; preds = %11, %2
%15 = load i8**, i8*** %4
%16 = getelementptr inbounds i8*, i8** %15, i64 1
%17 = load i8*, i8** %16
%18 = call i64 @strcmp(i8* %17, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%19 = icmp eq i64 %18, 0
br i1 %19, label %20, label %21
20: ; preds = %14
store i32 2, i32* %8
br label %32
21: ; preds = %14
%22 = load i8**, i8*** %4
%23 = getelementptr inbounds i8*, i8** %22, i64 1
%24 = load i8*, i8** %23
%25 = call i64 @strcmp(i8* %24, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%26 = icmp eq i64 %25, 0
br i1 %26, label %27, label %28
27: ; preds = %21
store i32 3, i32* %8
br label %31
28: ; preds = %21
%29 = load i8**, i8*** %4
%30 = call i32 @usage(i8** %29)
br label %31
31: ; preds = %28, %27
br label %32
32: ; preds = %31, %20
%33 = load i8**, i8*** %4
%34 = getelementptr inbounds i8*, i8** %33, i64 2
%35 = load i8*, i8** %34
%36 = call double @atof(i8* %35)
store double %36, double* %5
%37 = load i8**, i8*** %4
%38 = getelementptr inbounds i8*, i8** %37, i64 3
%39 = load i8*, i8** %38
%40 = call double @atof(i8* %39)
store double %40, double* %6
%41 = load i8**, i8*** %4
%42 = getelementptr inbounds i8*, i8** %41, i64 4
%43 = load i8*, i8** %42
%44 = call double @atof(i8* %43)
store double %44, double* %7
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%46 = load double, double* %5
%47 = load double, double* %7
%48 = load double, double* %6
%49 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.3, i64 0, i64 0), double %46, double %47, double %48)
%50 = load i32, i32* %8
%51 = icmp eq i32 %50, 2
br i1 %51, label %52, label %74
52: ; preds = %32
%53 = load double, double* %5
%54 = load double, double* %6
%55 = load double, double* %7
%56 = load double, double* %5
%57 = load double, double* %6
%58 = load double, double* %7
%59 = call i32 @compute_all_bingham_F_2d(double %53, double %54, double %55, double %56, double %57, double %58)
%60 = load double, double* %5
%61 = load double, double* %6
%62 = load double, double* %7
%63 = load double, double* %5
%64 = load double, double* %6
%65 = load double, double* %7
%66 = call i32 @compute_all_bingham_dF1_2d(double %60, double %61, double %62, double %63, double %64, double %65)
%67 = load double, double* %5
%68 = load double, double* %6
%69 = load double, double* %7
%70 = load double, double* %5
%71 = load double, double* %6
%72 = load double, double* %7
%73 = call i32 @compute_all_bingham_dF2_2d(double %67, double %68, double %69, double %70, double %71, double %72)
br label %119
74: ; preds = %32
%75 = load i32, i32* %8
%76 = icmp eq i32 %75, 3
br i1 %76, label %77, label %118
77: ; preds = %74
%78 = load double, double* %5
%79 = load double, double* %6
%80 = load double, double* %7
%81 = load double, double* %5
%82 = load double, double* %6
%83 = load double, double* %7
%84 = load double, double* %5
%85 = load double, double* %6
%86 = load double, double* %7
%87 = call i32 @compute_all_bingham_F_3d(double %78, double %79, double %80, double %81, double %82, double %83, double %84, double %85, double %86)
%88 = load double, double* %5
%89 = load double, double* %6
%90 = load double, double* %7
%91 = load double, double* %5
%92 = load double, double* %6
%93 = load double, double* %7
%94 = load double, double* %5
%95 = load double, double* %6
%96 = load double, double* %7
%97 = call i32 @compute_all_bingham_dF1_3d(double %88, double %89, double %90, double %91, double %92, double %93, double %94, double %95, double %96)
%98 = load double, double* %5
%99 = load double, double* %6
%100 = load double, double* %7
%101 = load double, double* %5
%102 = load double, double* %6
%103 = load double, double* %7
%104 = load double, double* %5
%105 = load double, double* %6
%106 = load double, double* %7
%107 = call i32 @compute_all_bingham_dF2_3d(double %98, double %99, double %100, double %101, double %102, double %103, double %104, double %105, double %106)
%108 = load double, double* %5
%109 = load double, double* %6
%110 = load double, double* %7
%111 = load double, double* %5
%112 = load double, double* %6
%113 = load double, double* %7
%114 = load double, double* %5
%115 = load double, double* %6
%116 = load double, double* %7
%117 = call i32 @compute_all_bingham_dF3_3d(double %108, double %109, double %110, double %111, double %112, double %113, double %114, double %115, double %116)
br label %118
118: ; preds = %77, %74
br label %119
119: ; preds = %118, %52
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"2d\00"
@.str.1 = [3 x i8] c"3d\00"
@.str.3 = [30 x i8] c"[X Y] = meshgrid(%f:%f:%f);\0A\0A\00"
define void @test_bingham(i32 %0, i8** %1) {
%3 = icmp slt i32 %0, 5
br i1 %3, label %4, label %6
4: ; preds = %2
%5 = tail call i32 @usage(i8** %1)
br label %6
6: ; preds = %4, %2
%7 = getelementptr inbounds i8*, i8** %1, i64 1
%8 = load i8*, i8** %7
%9 = tail call i64 @strcmp(i8* %8, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%10 = icmp eq i64 %9, 0
br i1 %10, label %17, label %11
11: ; preds = %6
%12 = load i8*, i8** %7
%13 = tail call i64 @strcmp(i8* %12, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%14 = icmp eq i64 %13, 0
br i1 %14, label %17, label %15
15: ; preds = %11
%16 = tail call i32 @usage(i8** %1)
br label %17
17: ; preds = %11, %6, %15
%18 = phi i1 [ undef, %15 ], [ true, %6 ], [ false, %11 ]
%19 = phi i1 [ undef, %15 ], [ false, %6 ], [ true, %11 ]
%20 = getelementptr inbounds i8*, i8** %1, i64 2
%21 = load i8*, i8** %20
%22 = tail call double @atof(i8* %21)
%23 = getelementptr inbounds i8*, i8** %1, i64 3
%24 = load i8*, i8** %23
%25 = tail call double @atof(i8* %24)
%26 = getelementptr inbounds i8*, i8** %1, i64 4
%27 = load i8*, i8** %26
%28 = tail call double @atof(i8* %27)
%29 = tail call i32 @putchar(i32 10)
%30 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.3, i64 0, i64 0), double %22, double %28, double %25)
br i1 %18, label %31, label %35
31: ; preds = %17
%32 = tail call i32 @compute_all_bingham_F_2d(double %22, double %25, double %28, double %22, double %25, double %28)
%33 = tail call i32 @compute_all_bingham_dF1_2d(double %22, double %25, double %28, double %22, double %25, double %28)
%34 = tail call i32 @compute_all_bingham_dF2_2d(double %22, double %25, double %28, double %22, double %25, double %28)
br label %41
35: ; preds = %17
br i1 %19, label %36, label %41
36: ; preds = %35
%37 = tail call i32 @compute_all_bingham_F_3d(double %22, double %25, double %28, double %22, double %25, double %28, double %22, double %25, double %28)
%38 = tail call i32 @compute_all_bingham_dF1_3d(double %22, double %25, double %28, double %22, double %25, double %28, double %22, double %25, double %28)
%39 = tail call i32 @compute_all_bingham_dF2_3d(double %22, double %25, double %28, double %22, double %25, double %28, double %22, double %25, double %28)
%40 = tail call i32 @compute_all_bingham_dF3_3d(double %22, double %25, double %28, double %22, double %25, double %28, double %22, double %25, double %28)
br label %41
41: ; preds = %35, %36, %31
ret void
}