#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 atan(double);
double sqrt(double);
void helval(double *p, double *x, int m, int n, void *data) {
  double theta;
  if (p[0] < 0.0)
    theta = atan(p[1] / p[0]) / (2.0 * 3.14159265358979323846) + 0.5;
  else if (0.0 < p[0])
    theta = atan(p[1] / p[0]) / (2.0 * 3.14159265358979323846);
  else
    theta = (p[1] >= 0) ? 0.25 : -0.25;
  x[0] = 10.0 * (p[2] - 10.0 * theta);
  x[1] = 10.0 * (sqrt(p[0] * p[0] + p[1] * p[1]) - 1.0);
  x[2] = p[2];
}


x86 assembly (clang, -O0):
<helval>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
mov    %r8,-0x20(%rbp)
mov    -0x8(%rbp),%rax
xorps  %xmm0,%xmm0
ucomisd (%rax),%xmm0
jbe    1183 <helval+0x63>
mov    -0x8(%rbp),%rax
movsd  0x8(%rax),%xmm0
mov    -0x8(%rbp),%rax
divsd  (%rax),%xmm0
call   1030 <atan@plt>
movsd  0xea7(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  0xea3(%rip),%xmm1
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
jmp    11fe <helval+0xde>
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jbe    11c4 <helval+0xa4>
mov    -0x8(%rbp),%rax
movsd  0x8(%rax),%xmm0
mov    -0x8(%rbp),%rax
divsd  (%rax),%xmm0
call   1030 <atan@plt>
movsd  0xe5a(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
jmp    11f9 <helval+0xd9>
mov    -0x8(%rbp),%rax
movsd  0x8(%rax),%xmm1
movsd  0xe2b(%rip),%xmm3
movsd  0xe2b(%rip),%xmm2
xorps  %xmm0,%xmm0
cmplesd %xmm1,%xmm0
movaps %xmm0,%xmm1
andpd  %xmm3,%xmm1
andnpd %xmm2,%xmm0
orpd   %xmm1,%xmm0
movsd  %xmm0,-0x28(%rbp)
jmp    11fe <helval+0xde>
mov    -0x8(%rbp),%rax
movsd  0x10(%rax),%xmm0
movsd  -0x28(%rbp),%xmm1
movsd  0xe1c(%rip),%xmm2
mulsd  %xmm2,%xmm1
addsd  %xmm0,%xmm1
movsd  0xdfc(%rip),%xmm0
mulsd  %xmm1,%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x8(%rbp),%rax
movsd  (%rax),%xmm2
mov    -0x8(%rbp),%rax
movsd  0x8(%rax),%xmm1
mov    -0x8(%rbp),%rax
mulsd  0x8(%rax),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
call   1040 <sqrt@plt>
movaps %xmm0,%xmm1
movsd  0xdbe(%rip),%xmm0
subsd  %xmm0,%xmm1
movsd  0xdaa(%rip),%xmm0
mulsd  %xmm1,%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,0x8(%rax)
mov    -0x8(%rbp),%rax
movsd  0x10(%rax),%xmm0
mov    -0x10(%rbp),%rax
movsd  %xmm0,0x10(%rax)
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<helval>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
movsd  (%rdi),%xmm1
xorpd  %xmm0,%xmm0
ucomisd %xmm1,%xmm0
jbe    1158 <helval+0x38>
movsd  0x8(%rbx),%xmm0
divsd  %xmm1,%xmm0
call   1030 <atan@plt>
divsd  0xec2(%rip),%xmm0
addsd  0xec2(%rip),%xmm0
jmp    118f <helval+0x6f>
ucomisd %xmm0,%xmm1
movsd  0x8(%rbx),%xmm0
jbe    1176 <helval+0x56>
divsd  %xmm1,%xmm0
call   1030 <atan@plt>
divsd  0xe9c(%rip),%xmm0
jmp    118f <helval+0x6f>
xorpd  %xmm1,%xmm1
xor    %eax,%eax
ucomisd %xmm1,%xmm0
setae  %al
lea    0xe76(%rip),%rcx
movsd  (%rcx,%rax,8),%xmm0
mulsd  0xe89(%rip),%xmm0
addsd  0x10(%rbx),%xmm0
mulsd  0xe84(%rip),%xmm0
movsd  %xmm0,(%r14)
movsd  (%rbx),%xmm0
movsd  0x8(%rbx),%xmm1
mulsd  %xmm1,%xmm1
mulsd  %xmm0,%xmm0
addsd  %xmm1,%xmm0
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jb     11ce <helval+0xae>
sqrtsd %xmm0,%xmm0
jmp    11d3 <helval+0xb3>
call   1040 <sqrt@plt>
addsd  0xe55(%rip),%xmm0
mulsd  0xe45(%rip),%xmm0
movsd  %xmm0,0x8(%r14)
movsd  0x10(%rbx),%xmm0
movsd  %xmm0,0x10(%r14)
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define void @helval(double* %0, double* %1, i32 %2, i32 %3, i8* %4) {
%6 = alloca double*
%7 = alloca double*
%8 = alloca i32
%9 = alloca i32
%10 = alloca i8*
%11 = alloca double
store double* %0, double** %6
store double* %1, double** %7
store i32 %2, i32* %8
store i32 %3, i32* %9
store i8* %4, i8** %10
%12 = load double*, double** %6
%13 = getelementptr inbounds double, double* %12, i64 0
%14 = load double, double* %13
%15 = fcmp olt double %14, 0.000000e+00
br i1 %15, label %16, label %27
16: ; preds = %5
%17 = load double*, double** %6
%18 = getelementptr inbounds double, double* %17, i64 1
%19 = load double, double* %18
%20 = load double*, double** %6
%21 = getelementptr inbounds double, double* %20, i64 0
%22 = load double, double* %21
%23 = fdiv double %19, %22
%24 = call double @atan(double %23)
%25 = fdiv double %24, 0x401921FB54442D18
%26 = fadd double %25, 5.000000e-01
store double %26, double* %11
br label %50
27: ; preds = %5
%28 = load double*, double** %6
%29 = getelementptr inbounds double, double* %28, i64 0
%30 = load double, double* %29
%31 = fcmp olt double 0.000000e+00, %30
br i1 %31, label %32, label %42
32: ; preds = %27
%33 = load double*, double** %6
%34 = getelementptr inbounds double, double* %33, i64 1
%35 = load double, double* %34
%36 = load double*, double** %6
%37 = getelementptr inbounds double, double* %36, i64 0
%38 = load double, double* %37
%39 = fdiv double %35, %38
%40 = call double @atan(double %39)
%41 = fdiv double %40, 0x401921FB54442D18
store double %41, double* %11
br label %49
42: ; preds = %27
%43 = load double*, double** %6
%44 = getelementptr inbounds double, double* %43, i64 1
%45 = load double, double* %44
%46 = fcmp oge double %45, 0.000000e+00
%47 = zext i1 %46 to i64
%48 = select i1 %46, double 2.500000e-01, double -2.500000e-01
store double %48, double* %11
br label %49
49: ; preds = %42, %32
br label %50
50: ; preds = %49, %16
%51 = load double*, double** %6
%52 = getelementptr inbounds double, double* %51, i64 2
%53 = load double, double* %52
%54 = load double, double* %11
%55 = call double @llvm.fmuladd.f64(double -1.000000e+01, double %54, double %53)
%56 = fmul double 1.000000e+01, %55
%57 = load double*, double** %7
%58 = getelementptr inbounds double, double* %57, i64 0
store double %56, double* %58
%59 = load double*, double** %6
%60 = getelementptr inbounds double, double* %59, i64 0
%61 = load double, double* %60
%62 = load double*, double** %6
%63 = getelementptr inbounds double, double* %62, i64 0
%64 = load double, double* %63
%65 = load double*, double** %6
%66 = getelementptr inbounds double, double* %65, i64 1
%67 = load double, double* %66
%68 = load double*, double** %6
%69 = getelementptr inbounds double, double* %68, i64 1
%70 = load double, double* %69
%71 = fmul double %67, %70
%72 = call double @llvm.fmuladd.f64(double %61, double %64, double %71)
%73 = call double @sqrt(double %72)
%74 = fsub double %73, 1.000000e+00
%75 = fmul double 1.000000e+01, %74
%76 = load double*, double** %7
%77 = getelementptr inbounds double, double* %76, i64 1
store double %75, double* %77
%78 = load double*, double** %6
%79 = getelementptr inbounds double, double* %78, i64 2
%80 = load double, double* %79
%81 = load double*, double** %7
%82 = getelementptr inbounds double, double* %81, i64 2
store double %80, double* %82
ret void
}

LLVM IR (-O2):
define void @helval(double* nocapture %0, double* nocapture writeonly %1, i32 %2, i32 %3, i8* nocapture readnone %4) {
%6 = load double, double* %0
%7 = fcmp olt double %6, 0.000000e+00
br i1 %7, label %8, label %15
8: ; preds = %5
%9 = getelementptr inbounds double, double* %0, i64 1
%10 = load double, double* %9
%11 = fdiv double %10, %6
%12 = tail call double @atan(double %11)
%13 = fdiv double %12, 0x401921FB54442D18
%14 = fadd double %13, 5.000000e-01
br label %26
15: ; preds = %5
%16 = fcmp ogt double %6, 0.000000e+00
%17 = getelementptr inbounds double, double* %0, i64 1
%18 = load double, double* %17
br i1 %16, label %19, label %23
19: ; preds = %15
%20 = fdiv double %18, %6
%21 = tail call double @atan(double %20)
%22 = fdiv double %21, 0x401921FB54442D18
br label %26
23: ; preds = %15
%24 = fcmp oge double %18, 0.000000e+00
%25 = select i1 %24, double 2.500000e-01, double -2.500000e-01
br label %26
26: ; preds = %19, %23, %8
%27 = phi double [ %14, %8 ], [ %22, %19 ], [ %25, %23 ]
%28 = getelementptr inbounds double, double* %0, i64 2
%29 = load double, double* %28
%30 = tail call double @llvm.fmuladd.f64(double %27, double -1.000000e+01, double %29)
%31 = fmul double %30, 1.000000e+01
store double %31, double* %1
%32 = load double, double* %0
%33 = getelementptr inbounds double, double* %0, i64 1
%34 = load double, double* %33
%35 = fmul double %34, %34
%36 = tail call double @llvm.fmuladd.f64(double %32, double %32, double %35)
%37 = tail call double @sqrt(double %36)
%38 = fadd double %37, -1.000000e+00
%39 = fmul double %38, 1.000000e+01
%40 = getelementptr inbounds double, double* %1, i64 1
store double %39, double* %40
%41 = load double, double* %28
%42 = getelementptr inbounds double, double* %1, i64 2
store double %41, double* %42
ret void
}