#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;
int /*<<< orphan*/ ang2pix_nest(long, double, double, long *);
int /*<<< orphan*/ ang2pix_ring(long, double, double, long *);
int /*<<< orphan*/ nest2ring(long, long, long *);
long nside2npix(long);
int /*<<< orphan*/ pix2ang_nest(long, long, double *, double *);
int /*<<< orphan*/ pix2ang_ring(long, long, double *, double *);
int /*<<< orphan*/ printf(char *, long, ...);
int /*<<< orphan*/ ring2nest(long, long, long *);
int main(void) {
  double theta, phi;
  long nside = 8192;
  long ipix, jpix, npix, dpix;
  npix = nside2npix(nside);
  printf("Number of pixels in full map: %ld\n", npix);
  dpix = npix / 10000L;
  printf("dpix: %ld\n", dpix);
  for (ipix = 0; ipix < npix; ipix += dpix) {
    pix2ang_nest(nside, ipix, &theta, &phi);
    printf("%9ld %12.8f %12.8f", ipix, theta, phi);
    pix2ang_ring(nside, ipix, &theta, &phi);
    printf(" %12.8f %12.8f", theta, phi);
    ring2nest(nside, ipix, &jpix);
    printf(" %9ld", jpix);
    nest2ring(nside, ipix, &jpix);
    printf(" %9ld\n", jpix);
  }
  for (theta = 0.0; theta <= M_PI; theta += 0.1) {
    for (phi = 0.0; phi <= 2.0 * M_PI; phi += 0.1) {
      ang2pix_nest(nside, theta, phi, &ipix);
      printf("%12.8f %12.8f %9ld", theta, phi, ipix);
      ang2pix_ring(nside, theta, phi, &ipix);
      printf(" %9ld\n", ipix);
    }
  }
  printf("%ld\n", nside);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
movq   $0x2000,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
call   1080 <nside2npix@plt>
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rsi
lea    0xe61(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x38(%rbp),%rax
mov    $0x2710,%ecx
cqto
idiv   %rcx
mov    %rax,-0x40(%rbp)
mov    -0x40(%rbp),%rsi
lea    0xe60(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movq   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%rax
cmp    -0x38(%rbp),%rax
jge    12a6 <main+0x126>
mov    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%rsi
lea    -0x10(%rbp),%rdx
lea    -0x18(%rbp),%rcx
call   1040 <pix2ang_nest@plt>
mov    -0x28(%rbp),%rsi
movsd  -0x10(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
lea    0xe24(%rip),%rdi
mov    $0x2,%al
call   1050 <printf@plt>
mov    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%rsi
lea    -0x10(%rbp),%rdx
lea    -0x18(%rbp),%rcx
call   1030 <pix2ang_ring@plt>
cvttsd2si -0x10(%rbp),%rsi
movsd  -0x18(%rbp),%xmm0
lea    0xdfa(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
mov    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%rsi
lea    -0x30(%rbp),%rdx
call   1060 <ring2nest@plt>
mov    -0x30(%rbp),%rsi
lea    0xdfa(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%rsi
lea    -0x30(%rbp),%rdx
call   1070 <nest2ring@plt>
mov    -0x30(%rbp),%rsi
lea    0xdc3(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x40(%rbp),%rax
add    -0x28(%rbp),%rax
mov    %rax,-0x28(%rbp)
jmp    11e2 <main+0x62>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x10(%rbp)
movsd  -0x10(%rbp),%xmm1
mov    0x2d2e(%rip),%rax
movsd  (%rax),%xmm0
ucomisd %xmm1,%xmm0
jb     1382 <main+0x202>
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm1
movsd  0xd23(%rip),%xmm0
mov    0x2d04(%rip),%rax
mulsd  (%rax),%xmm0
ucomisd %xmm1,%xmm0
jb     1366 <main+0x1e6>
mov    -0x20(%rbp),%rdi
movsd  -0x10(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
lea    -0x28(%rbp),%rsi
call   10a0 <ang2pix_nest@plt>
cvttsd2si -0x10(%rbp),%rsi
movsd  -0x18(%rbp),%xmm0
mov    -0x28(%rbp),%rdx
lea    0xd39(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
mov    -0x20(%rbp),%rdi
movsd  -0x10(%rbp),%xmm0
movsd  -0x18(%rbp),%xmm1
lea    -0x28(%rbp),%rsi
call   1090 <ang2pix_ring@plt>
mov    -0x28(%rbp),%rsi
lea    0xd09(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movsd  0xcb1(%rip),%xmm0
addsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
jmp    12d0 <main+0x150>
jmp    136b <main+0x1eb>
movsd  0xc95(%rip),%xmm0
addsd  -0x10(%rbp),%xmm0
movsd  %xmm0,-0x10(%rbp)
jmp    12ae <main+0x12e>
mov    -0x20(%rbp),%rsi
lea    0xca1(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    $0x2000,%edi
call   1080 <nside2npix@plt>
mov    %rax,%r14
lea    0xe6e(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
movabs $0x346dc5d63886594b,%rcx
c5 6d 34
mov    %r14,%rax
imul   %rcx
mov    %rdx,%rbx
mov    %rdx,%rax
shr    $0x3f,%rax
sar    $0xb,%rbx
add    %rax,%rbx
lea    0xe5f(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
movq   $0x0,0x18(%rsp)
test   %r14,%r14
jle    12c5 <main+0x145>
lea    0x10(%rsp),%r15
lea    0x8(%rsp),%r12
lea    0x20(%rsp),%r13
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    $0x2000,%edi
mov    %rbp,%rsi
mov    %r15,%rdx
mov    %r12,%rcx
call   1040 <pix2ang_nest@plt>
movsd  0x10(%rsp),%xmm0
movsd  0x8(%rsp),%xmm1
lea    0xe08(%rip),%rdi
mov    %rbp,%rsi
mov    $0x2,%al
call   1050 <printf@plt>
mov    $0x2000,%edi
mov    %rbp,%rsi
mov    %r15,%rdx
mov    %r12,%rcx
call   1030 <pix2ang_ring@plt>
cvttsd2si 0x10(%rsp),%rsi
movsd  0x8(%rsp),%xmm0
lea    0xddb(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
mov    $0x2000,%edi
mov    %rbp,%rsi
mov    %r13,%rdx
call   1060 <ring2nest@plt>
mov    0x20(%rsp),%rsi
lea    0xddb(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0x2000,%edi
mov    %rbp,%rsi
mov    %r13,%rdx
call   1070 <nest2ring@plt>
mov    0x20(%rsp),%rsi
lea    0xda4(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
add    %rbx,%rbp
mov    %rbp,0x18(%rsp)
cmp    %r14,%rbp
jl     1210 <main+0x90>
movq   $0x0,0x10(%rsp)
mov    0x2d13(%rip),%rbp
movsd  0x0(%rbp),%xmm2
xorpd  %xmm0,%xmm0
ucomisd %xmm0,%xmm2
jae    1308 <main+0x188>
lea    0xd43(%rip),%rdi
mov    $0x2000,%esi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
movsd  0xcf0(%rip),%xmm3
lea    0x18(%rsp),%rbx
lea    0xd3c(%rip),%r14
lea    0xd2e(%rip),%r15
xorpd  %xmm0,%xmm0
jmp    1340 <main+0x1c0>
nopl   0x0(%rax)
addsd  %xmm3,%xmm0
movsd  %xmm0,0x10(%rsp)
ucomisd %xmm0,%xmm2
jb     12e4 <main+0x164>
movq   $0x0,0x8(%rsp)
movapd %xmm2,%xmm1
addsd  %xmm2,%xmm1
ucomisd 0xcaf(%rip),%xmm1
jb     1330 <main+0x1b0>
xorpd  %xmm1,%xmm1
nop
mov    $0x2000,%edi
mov    %rbx,%rsi
call   10a0 <ang2pix_nest@plt>
cvttsd2si 0x10(%rsp),%rsi
movsd  0x8(%rsp),%xmm0
mov    0x18(%rsp),%rdx
mov    %r14,%rdi
mov    $0x1,%al
call   1050 <printf@plt>
movsd  0x10(%rsp),%xmm0
movsd  0x8(%rsp),%xmm1
mov    $0x2000,%edi
mov    %rbx,%rsi
call   1090 <ang2pix_ring@plt>
mov    0x18(%rsp),%rsi
mov    %r15,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
movsd  0xc47(%rip),%xmm3
movsd  0x8(%rsp),%xmm1
addsd  %xmm3,%xmm1
movsd  %xmm1,0x8(%rsp)
movsd  0x0(%rbp),%xmm2
movapd %xmm2,%xmm0
addsd  %xmm2,%xmm0
ucomisd %xmm1,%xmm0
movsd  0x10(%rsp),%xmm0
jae    1360 <main+0x1e0>
jmp    1330 <main+0x1b0>

LLVM IR (-O0):
@.str = [35 x i8] c"Number of pixels in full map: %ld\0A\00"
@.str.1 = [11 x i8] c"dpix: %ld\0A\00"
@.str.2 = [19 x i8] c"%9ld %12.8f %12.8f\00"
@.str.3 = [15 x i8] c" %12.8f %12.8f\00"
@.str.4 = [6 x i8] c" %9ld\00"
@.str.5 = [7 x i8] c" %9ld\0A\00"
@M_PI = global double 0.000000e+00
@.str.6 = [19 x i8] c"%12.8f %12.8f %9ld\00"
@.str.7 = [5 x i8] c"%ld\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca double
%3 = alloca double
%4 = alloca i64
%5 = alloca i64
%6 = alloca i64
%7 = alloca i64
%8 = alloca i64
store i32 0, i32* %1
store i64 8192, i64* %4
%9 = load i64, i64* %4
%10 = call i64 @nside2npix(i64 %9)
store i64 %10, i64* %7
%11 = load i64, i64* %7
%12 = call i32 (i8*, i64, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0), i64 %11)
%13 = load i64, i64* %7
%14 = sdiv i64 %13, 10000
store i64 %14, i64* %8
%15 = load i64, i64* %8
%16 = call i32 (i8*, i64, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i64 %15)
store i64 0, i64* %5
br label %17
17: ; preds = %46, %0
%18 = load i64, i64* %5
%19 = load i64, i64* %7
%20 = icmp slt i64 %18, %19
br i1 %20, label %21, label %50
21: ; preds = %17
%22 = load i64, i64* %4
%23 = load i64, i64* %5
%24 = call i32 @pix2ang_nest(i64 %22, i64 %23, double* %2, double* %3)
%25 = load i64, i64* %5
%26 = load double, double* %2
%27 = load double, double* %3
%28 = call i32 (i8*, i64, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i64 %25, double %26, double %27)
%29 = load i64, i64* %4
%30 = load i64, i64* %5
%31 = call i32 @pix2ang_ring(i64 %29, i64 %30, double* %2, double* %3)
%32 = load double, double* %2
%33 = fptosi double %32 to i64
%34 = load double, double* %3
%35 = call i32 (i8*, i64, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0), i64 %33, double %34)
%36 = load i64, i64* %4
%37 = load i64, i64* %5
%38 = call i32 @ring2nest(i64 %36, i64 %37, i64* %6)
%39 = load i64, i64* %6
%40 = call i32 (i8*, i64, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i64 %39)
%41 = load i64, i64* %4
%42 = load i64, i64* %5
%43 = call i32 @nest2ring(i64 %41, i64 %42, i64* %6)
%44 = load i64, i64* %6
%45 = call i32 (i8*, i64, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0), i64 %44)
br label %46
46: ; preds = %21
%47 = load i64, i64* %8
%48 = load i64, i64* %5
%49 = add nsw i64 %48, %47
store i64 %49, i64* %5
br label %17
50: ; preds = %17
store double 0.000000e+00, double* %2
br label %51
51: ; preds = %81, %50
%52 = load double, double* %2
%53 = load double, double* @M_PI
%54 = fcmp ole double %52, %53
br i1 %54, label %55, label %84
55: ; preds = %51
store double 0.000000e+00, double* %3
br label %56
56: ; preds = %77, %55
%57 = load double, double* %3
%58 = load double, double* @M_PI
%59 = fmul double 2.000000e+00, %58
%60 = fcmp ole double %57, %59
br i1 %60, label %61, label %80
61: ; preds = %56
%62 = load i64, i64* %4
%63 = load double, double* %2
%64 = load double, double* %3
%65 = call i32 @ang2pix_nest(i64 %62, double %63, double %64, i64* %5)
%66 = load double, double* %2
%67 = fptosi double %66 to i64
%68 = load double, double* %3
%69 = load i64, i64* %5
%70 = call i32 (i8*, i64, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.6, i64 0, i64 0), i64 %67, double %68, i64 %69)
%71 = load i64, i64* %4
%72 = load double, double* %2
%73 = load double, double* %3
%74 = call i32 @ang2pix_ring(i64 %71, double %72, double %73, i64* %5)
%75 = load i64, i64* %5
%76 = call i32 (i8*, i64, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0), i64 %75)
br label %77
77: ; preds = %61
%78 = load double, double* %3
%79 = fadd double %78, 1.000000e-01
store double %79, double* %3
br label %56
80: ; preds = %56
br label %81
81: ; preds = %80
%82 = load double, double* %2
%83 = fadd double %82, 1.000000e-01
store double %83, double* %2
br label %51
84: ; preds = %51
%85 = load i64, i64* %4
%86 = call i32 (i8*, i64, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0), i64 %85)
ret i32 0
}

LLVM IR (-O2):
@.str = [35 x i8] c"Number of pixels in full map: %ld\0A\00"
@.str.1 = [11 x i8] c"dpix: %ld\0A\00"
@.str.2 = [19 x i8] c"%9ld %12.8f %12.8f\00"
@.str.3 = [15 x i8] c" %12.8f %12.8f\00"
@.str.4 = [6 x i8] c" %9ld\00"
@.str.5 = [7 x i8] c" %9ld\0A\00"
@M_PI = global double 0.000000e+00
@.str.6 = [19 x i8] c"%12.8f %12.8f %9ld\00"
@.str.7 = [5 x i8] c"%ld\0A\00"
define i32 @main() {
%1 = alloca double
%2 = alloca double
%3 = alloca i64
%4 = alloca i64
%5 = bitcast double* %1 to i8*
%6 = bitcast double* %2 to i8*
%7 = bitcast i64* %3 to i8*
%8 = bitcast i64* %4 to i8*
%9 = tail call i64 @nside2npix(i64 8192)
%10 = tail call i32 (i8*, i64, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0), i64 %9)
%11 = sdiv i64 %9, 10000
%12 = tail call i32 (i8*, i64, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i64 %11)
store i64 0, i64* %3
%13 = icmp sgt i64 %9, 0
br i1 %13, label %17, label %14
14: ; preds = %17, %0
store double 0.000000e+00, double* %1
%15 = load double, double* @M_PI
%16 = fcmp ult double %15, 0.000000e+00
br i1 %16, label %66, label %36
17: ; preds = %0, %17
%18 = phi i64 [ %34, %17 ], [ 0, %0 ]
%19 = call i32 @pix2ang_nest(i64 8192, i64 %18, double* %1, double* %2)
%20 = load double, double* %1
%21 = load double, double* %2
%22 = call i32 (i8*, i64, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i64 %18, double %20, double %21)
%23 = call i32 @pix2ang_ring(i64 8192, i64 %18, double* %1, double* %2)
%24 = load double, double* %1
%25 = fptosi double %24 to i64
%26 = load double, double* %2
%27 = call i32 (i8*, i64, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0), i64 %25, double %26)
%28 = call i32 @ring2nest(i64 8192, i64 %18, i64* %4)
%29 = load i64, i64* %4
%30 = call i32 (i8*, i64, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.4, i64 0, i64 0), i64 %29)
%31 = call i32 @nest2ring(i64 8192, i64 %18, i64* %4)
%32 = load i64, i64* %4
%33 = call i32 (i8*, i64, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0), i64 %32)
%34 = add nsw i64 %18, %11
store i64 %34, i64* %3
%35 = icmp slt i64 %34, %9
br i1 %35, label %17, label %14
36: ; preds = %14, %61
%37 = phi double [ %62, %61 ], [ %15, %14 ]
%38 = phi double [ %64, %61 ], [ 0.000000e+00, %14 ]
store double 0.000000e+00, double* %2
%39 = fmul double %37, 2.000000e+00
%40 = fcmp ult double %39, 0.000000e+00
br i1 %40, label %61, label %41
41: ; preds = %36, %41
%42 = phi double [ %60, %41 ], [ %38, %36 ]
%43 = phi double [ %56, %41 ], [ 0.000000e+00, %36 ]
%44 = call i32 @ang2pix_nest(i64 8192, double %42, double %43, i64* %3)
%45 = load double, double* %1
%46 = fptosi double %45 to i64
%47 = load double, double* %2
%48 = load i64, i64* %3
%49 = call i32 (i8*, i64, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.6, i64 0, i64 0), i64 %46, double %47, i64 %48)
%50 = load double, double* %1
%51 = load double, double* %2
%52 = call i32 @ang2pix_ring(i64 8192, double %50, double %51, i64* %3)
%53 = load i64, i64* %3
%54 = call i32 (i8*, i64, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0), i64 %53)
%55 = load double, double* %2
%56 = fadd double %55, 1.000000e-01
store double %56, double* %2
%57 = load double, double* @M_PI
%58 = fmul double %57, 2.000000e+00
%59 = fcmp ugt double %56, %58
%60 = load double, double* %1
br i1 %59, label %61, label %41
61: ; preds = %41, %36
%62 = phi double [ %37, %36 ], [ %57, %41 ]
%63 = phi double [ %38, %36 ], [ %60, %41 ]
%64 = fadd double %63, 1.000000e-01
store double %64, double* %1
%65 = fcmp ugt double %64, %62
br i1 %65, label %66, label %36
66: ; preds = %61, %14
%67 = call i32 (i8*, i64, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.7, i64 0, i64 0), i64 8192)
ret i32 0
}