#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 M_PI;
double cos(double);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, int, double);
double sin(double);
int /*<<< orphan*/ stderr;
void ang2vec(double theta, double phi, double *vec) {
  double sz;
  double PI = M_PI;
  if (theta < 0. || theta > PI) {
    fprintf(stderr, "%s (%d): theta out of range: %f\n",
            "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
            "2022-01-22/02-19-57/repos/bkloppenborg/simtoi/refs/heads/master/"
            "lib/chealpix/ang2vec.c",
            44, theta);
    exit(0);
  }
  sz = sin(theta);
  vec[0] = sz * cos(phi);
  vec[1] = sz * sin(phi);
  vec[2] = cos(theta);
}


x86 assembly (clang, -O0):
<ang2vec>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movsd  %xmm0,-0x8(%rbp)
movsd  %xmm1,-0x10(%rbp)
mov    %rdi,-0x18(%rbp)
mov    0x2e8b(%rip),%rax
movsd  (%rax),%xmm0
movsd  %xmm0,-0x28(%rbp)
xorps  %xmm0,%xmm0
ucomisd -0x8(%rbp),%xmm0
ja     1184 <ang2vec+0x44>
movsd  -0x8(%rbp),%xmm0
ucomisd -0x28(%rbp),%xmm0
jbe    11b1 <ang2vec+0x71>
mov    0x2e4d(%rip),%rax
mov    (%rax),%edi
movsd  -0x8(%rbp),%xmm0
lea    0xe67(%rip),%rsi
lea    0xe81(%rip),%rdx
mov    $0x2c,%ecx
call   1030 <fprintf@plt>
xor    %edi,%edi
call   1060 <exit@plt>
movsd  -0x8(%rbp),%xmm0
call   1040 <sin@plt>
movsd  %xmm0,-0x20(%rbp)
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1050 <cos@plt>
movaps %xmm0,%xmm1
movsd  -0x38(%rbp),%xmm0
mulsd  %xmm1,%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,(%rax)
movsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x10(%rbp),%xmm0
call   1040 <sin@plt>
movaps %xmm0,%xmm1
movsd  -0x30(%rbp),%xmm0
mulsd  %xmm1,%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,0x8(%rax)
movsd  -0x8(%rbp),%xmm0
call   1050 <cos@plt>
mov    -0x18(%rbp),%rax
movsd  %xmm0,0x10(%rax)
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ang2vec>:
push   %rbx
sub    $0x20,%rsp
movsd  %xmm1,0x10(%rsp)
xorpd  %xmm1,%xmm1
ucomisd %xmm0,%xmm1
ja     11b7 <ang2vec+0x77>
mov    0x2e8c(%rip),%rax
ucomisd (%rax),%xmm0
ja     11b7 <ang2vec+0x77>
mov    %rdi,%rbx
movsd  %xmm0,0x18(%rsp)
call   1040 <sin@plt>
movsd  %xmm0,0x8(%rsp)
movsd  0x10(%rsp),%xmm0
call   1050 <cos@plt>
mulsd  0x8(%rsp),%xmm0
movsd  %xmm0,(%rbx)
movsd  0x10(%rsp),%xmm0
call   1040 <sin@plt>
mulsd  0x8(%rsp),%xmm0
movsd  %xmm0,0x8(%rbx)
movsd  0x18(%rsp),%xmm0
call   1050 <cos@plt>
movsd  %xmm0,0x10(%rbx)
add    $0x20,%rsp
pop    %rbx
ret
mov    0x2e1a(%rip),%rax
mov    (%rax),%edi
lea    0xe39(%rip),%rsi
lea    0xe53(%rip),%rdx
mov    $0x2c,%ecx
call   1030 <fprintf@plt>
xor    %edi,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@M_PI = global double 0.000000e+00
@stderr = global i32 0
@.str = [33 x i8] c"%s (%d): theta out of range: %f\0A\00"
@.str.1 = [151 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/bkloppenborg/simtoi/refs/heads/master/lib/chealpix/ang2vec.c\00"
define void @ang2vec(double %0, double %1, double* %2) {
%4 = alloca double
%5 = alloca double
%6 = alloca double*
%7 = alloca double
%8 = alloca double
store double %0, double* %4
store double %1, double* %5
store double* %2, double** %6
%9 = load double, double* @M_PI
store double %9, double* %8
%10 = load double, double* %4
%11 = fcmp olt double %10, 0.000000e+00
br i1 %11, label %16, label %12
12: ; preds = %3
%13 = load double, double* %4
%14 = load double, double* %8
%15 = fcmp ogt double %13, %14
br i1 %15, label %16, label %21
16: ; preds = %12, %3
%17 = load i32, i32* @stderr
%18 = load double, double* %4
%19 = call i32 @fprintf(i32 %17, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([151 x i8], [151 x i8]* @.str.1, i64 0, i64 0), i32 44, double %18)
%20 = call i32 @exit(i32 0)
unreachable
21: ; preds = %12
%22 = load double, double* %4
%23 = call double @sin(double %22)
store double %23, double* %7
%24 = load double, double* %7
%25 = load double, double* %5
%26 = call double @cos(double %25)
%27 = fmul double %24, %26
%28 = load double*, double** %6
%29 = getelementptr inbounds double, double* %28, i64 0
store double %27, double* %29
%30 = load double, double* %7
%31 = load double, double* %5
%32 = call double @sin(double %31)
%33 = fmul double %30, %32
%34 = load double*, double** %6
%35 = getelementptr inbounds double, double* %34, i64 1
store double %33, double* %35
%36 = load double, double* %4
%37 = call double @cos(double %36)
%38 = load double*, double** %6
%39 = getelementptr inbounds double, double* %38, i64 2
store double %37, double* %39
ret void
}

LLVM IR (-O2):
@M_PI = global double 0.000000e+00
@stderr = global i32 0
@.str = [33 x i8] c"%s (%d): theta out of range: %f\0A\00"
@.str.1 = [151 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/bkloppenborg/simtoi/refs/heads/master/lib/chealpix/ang2vec.c\00"
define void @ang2vec(double %0, double %1, double* nocapture writeonly %2) {
%4 = fcmp olt double %0, 0.000000e+00
%5 = load double, double* @M_PI
%6 = fcmp olt double %5, %0
%7 = select i1 %4, i1 true, i1 %6
br i1 %7, label %8, label %12
8: ; preds = %3
%9 = load i32, i32* @stderr
%10 = tail call i32 @fprintf(i32 %9, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([151 x i8], [151 x i8]* @.str.1, i64 0, i64 0), i32 44, double %0)
%11 = tail call i32 @exit(i32 0)
unreachable
12: ; preds = %3
%13 = tail call double @sin(double %0)
%14 = tail call double @cos(double %1)
%15 = fmul double %13, %14
store double %15, double* %2
%16 = tail call double @sin(double %1)
%17 = fmul double %13, %16
%18 = getelementptr inbounds double, double* %2, i64 1
store double %17, double* %18
%19 = tail call double @cos(double %0)
%20 = getelementptr inbounds double, double* %2, i64 2
store double %19, double* %20
ret void
}