#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 */
scalar_t__ fabs(double);
double minmaxs(double, double, scalar_t__, double);
double sin(int /*<<< orphan*/);
double sinth1in(double *, double *, void (*)(double *, double *));
int /*<<< orphan*/ th2in(double *, double *, void (*)(double *, double *));
double func2(double *X0, double *X, void (*vofx)(double *, double *)) {
  double V[(4)];
  double Xca[(4)];
  double func2;
  int j;
  double sth1in, sth2in, sth1inaxis, sth2inaxis;
  for (j = 0; j < (4); j++)
    Xca[j] = X[j];
  Xca[2] = -1;
  vofx(X, V);
  sth1in = sinth1in(X0, X, vofx);
  sth2in = sin(th2in(X0, X, vofx));
  sth1inaxis = sinth1in(X0, Xca, vofx);
  sth2inaxis = sin(th2in(X0, Xca, vofx));
  func2 = minmaxs(sth1in, sth2in, fabs(sth2inaxis - sth1inaxis) + (1.e-20),
                  X[1] - X0[1]);
  return (func2);
}


x86 assembly (clang, -O0):
<func2>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movl   $0x0,-0x6c(%rbp)
cmpl   $0x4,-0x6c(%rbp)
jge    119d <func2+0x4d>
mov    -0x10(%rbp),%rax
movslq -0x6c(%rbp),%rcx
movsd  (%rax,%rcx,8),%xmm0
movslq -0x6c(%rbp),%rax
movsd  %xmm0,-0x60(%rbp,%rax,8)
mov    -0x6c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x6c(%rbp)
jmp    116e <func2+0x1e>
movsd  0xe63(%rip),%xmm0
movsd  %xmm0,-0x50(%rbp)
mov    -0x18(%rbp),%rax
mov    -0x10(%rbp),%rdi
lea    -0x40(%rbp),%rsi
call   *%rax
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
call   1030 <sinth1in@plt>
movsd  %xmm0,-0x78(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
call   1070 <th2in@plt>
mov    %eax,%edi
call   1060 <sin@plt>
movsd  %xmm0,-0x80(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0x60(%rbp),%rsi
mov    -0x18(%rbp),%rdx
call   1030 <sinth1in@plt>
movsd  %xmm0,-0x88(%rbp)
ff
mov    -0x8(%rbp),%rdi
lea    -0x60(%rbp),%rsi
mov    -0x18(%rbp),%rdx
call   1070 <th2in@plt>
mov    %eax,%edi
call   1060 <sin@plt>
movsd  %xmm0,-0x90(%rbp)
ff
movsd  -0x78(%rbp),%xmm0
movsd  %xmm0,-0xa0(%rbp)
ff
movsd  -0x80(%rbp),%xmm0
movsd  %xmm0,-0x98(%rbp)
ff
movsd  -0x90(%rbp),%xmm0
ff
subsd  -0x88(%rbp),%xmm0
ff
call   1050 <fabs@plt>
movsd  -0xa0(%rbp),%xmm0
ff
movsd  -0x98(%rbp),%xmm1
ff
cvtsi2sd %rax,%xmm2
movsd  0xd90(%rip),%xmm3
addsd  %xmm3,%xmm2
cvttsd2si %xmm2,%rdi
mov    -0x10(%rbp),%rax
movsd  0x8(%rax),%xmm2
mov    -0x8(%rbp),%rax
subsd  0x8(%rax),%xmm2
call   1040 <minmaxs@plt>
movsd  %xmm0,-0x68(%rbp)
movsd  -0x68(%rbp),%xmm0
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<func2>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x68,%rsp
mov    %rdx,%rbx
mov    %rsi,%r15
mov    %rdi,%r14
movupd (%rsi),%xmm0
movups 0x10(%rsi),%xmm1
movaps %xmm1,0x30(%rsp)
movapd %xmm0,0x20(%rsp)
movabs $0xbff0000000000000,%rax
mov    %rax,0x30(%rsp)
lea    0x40(%rsp),%rsi
mov    %r15,%rdi
call   *%rdx
mov    %r14,%rdi
mov    %r15,%rsi
mov    %rbx,%rdx
call   1030 <sinth1in@plt>
movsd  %xmm0,0x18(%rsp)
mov    %r14,%rdi
mov    %r15,%rsi
mov    %rbx,%rdx
call   1070 <th2in@plt>
mov    %eax,%edi
call   1060 <sin@plt>
movsd  %xmm0,0x10(%rsp)
lea    0x20(%rsp),%r12
mov    %r14,%rdi
mov    %r12,%rsi
mov    %rbx,%rdx
call   1030 <sinth1in@plt>
movsd  %xmm0,0x8(%rsp)
mov    %r14,%rdi
mov    %r12,%rsi
mov    %rbx,%rdx
call   1070 <th2in@plt>
mov    %eax,%edi
call   1060 <sin@plt>
subsd  0x8(%rsp),%xmm0
call   1050 <fabs@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %rax,%xmm0
addsd  0xdf8(%rip),%xmm0
cvttsd2si %xmm0,%rdi
movsd  0x8(%r15),%xmm2
subsd  0x8(%r14),%xmm2
movsd  0x18(%rsp),%xmm0
movsd  0x10(%rsp),%xmm1
call   1040 <minmaxs@plt>
add    $0x68,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define double @func2(double* %0, double* %1, void (double*, double*)* %2) {
%4 = alloca double*
%5 = alloca double*
%6 = alloca void (double*, double*)*
%7 = alloca [4 x double]
%8 = alloca [4 x double]
%9 = alloca double
%10 = alloca i32
%11 = alloca double
%12 = alloca double
%13 = alloca double
%14 = alloca double
store double* %0, double** %4
store double* %1, double** %5
store void (double*, double*)* %2, void (double*, double*)** %6
store i32 0, i32* %10
br label %15
15: ; preds = %27, %3
%16 = load i32, i32* %10
%17 = icmp slt i32 %16, 4
br i1 %17, label %18, label %30
18: ; preds = %15
%19 = load double*, double** %5
%20 = load i32, i32* %10
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds double, double* %19, i64 %21
%23 = load double, double* %22
%24 = load i32, i32* %10
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds [4 x double], [4 x double]* %8, i64 0, i64 %25
store double %23, double* %26
br label %27
27: ; preds = %18
%28 = load i32, i32* %10
%29 = add nsw i32 %28, 1
store i32 %29, i32* %10
br label %15
30: ; preds = %15
%31 = getelementptr inbounds [4 x double], [4 x double]* %8, i64 0, i64 2
store double -1.000000e+00, double* %31
%32 = load void (double*, double*)*, void (double*, double*)** %6
%33 = load double*, double** %5
%34 = getelementptr inbounds [4 x double], [4 x double]* %7, i64 0, i64 0
%35 = load double*, double** %4
%36 = load double*, double** %5
%37 = load void (double*, double*)*, void (double*, double*)** %6
%38 = call double @sinth1in(double* %35, double* %36, void (double*, double*)* %37)
store double %38, double* %11
%39 = load double*, double** %4
%40 = load double*, double** %5
%41 = load void (double*, double*)*, void (double*, double*)** %6
%42 = call i32 @th2in(double* %39, double* %40, void (double*, double*)* %41)
%43 = call double @sin(i32 %42)
store double %43, double* %12
%44 = load double*, double** %4
%45 = getelementptr inbounds [4 x double], [4 x double]* %8, i64 0, i64 0
%46 = load void (double*, double*)*, void (double*, double*)** %6
%47 = call double @sinth1in(double* %44, double* %45, void (double*, double*)* %46)
store double %47, double* %13
%48 = load double*, double** %4
%49 = getelementptr inbounds [4 x double], [4 x double]* %8, i64 0, i64 0
%50 = load void (double*, double*)*, void (double*, double*)** %6
%51 = call i32 @th2in(double* %48, double* %49, void (double*, double*)* %50)
%52 = call double @sin(i32 %51)
store double %52, double* %14
%53 = load double, double* %11
%54 = load double, double* %12
%55 = load double, double* %14
%56 = load double, double* %13
%57 = fsub double %55, %56
%58 = call i64 @fabs(double %57)
%59 = sitofp i64 %58 to double
%60 = fadd double %59, 0x3BC79CA10C924223
%61 = fptosi double %60 to i64
%62 = load double*, double** %5
%63 = getelementptr inbounds double, double* %62, i64 1
%64 = load double, double* %63
%65 = load double*, double** %4
%66 = getelementptr inbounds double, double* %65, i64 1
%67 = load double, double* %66
%68 = fsub double %64, %67
%69 = call double @minmaxs(double %53, double %54, i64 %61, double %68)
store double %69, double* %9
%70 = load double, double* %9
ret double %70
}

LLVM IR (-O2):
define double @func2(double* %0, double* %1, void (double*, double*)* %2) {
%4 = bitcast double* %1 to i8*
%5 = alloca [4 x double]
%6 = alloca [4 x double]
%7 = bitcast [4 x double]* %6 to i8*
%8 = bitcast [4 x double]* %5 to i8*
%9 = getelementptr inbounds [4 x double], [4 x double]* %6, i64 0, i64 2
store double -1.000000e+00, double* %9
%10 = getelementptr inbounds [4 x double], [4 x double]* %5, i64 0, i64 0
%11 = call double @sinth1in(double* %0, double* %1, void (double*, double*)* %2)
%12 = call i32 @th2in(double* %0, double* %1, void (double*, double*)* %2)
%13 = call double @sin(i32 %12)
%14 = getelementptr inbounds [4 x double], [4 x double]* %6, i64 0, i64 0
%15 = call double @sinth1in(double* %0, double* %14, void (double*, double*)* %2)
%16 = call i32 @th2in(double* %0, double* %14, void (double*, double*)* %2)
%17 = call double @sin(i32 %16)
%18 = fsub double %17, %15
%19 = call i64 @fabs(double %18)
%20 = sitofp i64 %19 to double
%21 = fadd double %20, 0x3BC79CA10C924223
%22 = fptosi double %21 to i64
%23 = getelementptr inbounds double, double* %1, i64 1
%24 = load double, double* %23
%25 = getelementptr inbounds double, double* %0, i64 1
%26 = load double, double* %25
%27 = fsub double %24, %26
%28 = call double @minmaxs(double %11, double %13, i64 %22, double %27)
ret double %28
}