#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 */
int /*<<< orphan*/ abort();
int /*<<< orphan*/ ang2pix_nest(long, double, double, long *);
int /*<<< orphan*/ nest2ring(long, long, long *);
long nside2npix(long);
int /*<<< orphan*/ pix2ang_nest(long, long, double *, double *);
int /*<<< orphan*/ pix2vec_nest(long, long, double *);
int /*<<< orphan*/ printf(char *, long, long, long, ...);
int /*<<< orphan*/ ring2nest(long, long, long *);
int /*<<< orphan*/ vec2pix_nest(long, double *, long *);
void test1_helper1(long nside, long dpix) {
  double theta, phi;
  double vec[3];
  long ipix, npix, ip2, ip1;
  npix = nside2npix(nside);
  for (ipix = 0; ipix < npix; ipix += dpix) {
    nest2ring(nside, ipix, &ip2);
    ring2nest(nside, ip2, &ip1);
    if (ip1 != ipix) {
      printf("Error0: %ld %ld %ld %ld\n", nside, ipix, ip2, ip1);
      abort();
    }
  }
  for (ipix = 0; ipix < npix; ipix += dpix) {
    pix2ang_nest(nside, ipix, &theta, &phi);
    ang2pix_nest(nside, theta, phi, &ip1);
    if (ip1 != ipix) {
      printf("Error1: %ld %ld %ld\n", nside, ipix, ip1);
      abort();
    }
  }
  for (ipix = 0; ipix < npix; ipix += dpix) {
    pix2vec_nest(nside, ipix, vec);
    vec2pix_nest(nside, vec, &ip1);
    if (ip1 != ipix) {
      printf("Error1: %ld %ld %ld\n", nside, ipix, ip1);
      abort();
    }
  }
}


x86 assembly (clang, -O0):
<test1_helper1>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1080 <nside2npix@plt>
mov    %rax,-0x50(%rbp)
movq   $0x0,-0x48(%rbp)
mov    -0x48(%rbp),%rax
cmp    -0x50(%rbp),%rax
jge    122e <test1_helper1+0x9e>
mov    -0x8(%rbp),%rdi
mov    -0x48(%rbp),%rsi
lea    -0x58(%rbp),%rdx
call   1070 <nest2ring@plt>
mov    -0x8(%rbp),%rdi
mov    -0x58(%rbp),%rsi
lea    -0x60(%rbp),%rdx
call   1060 <ring2nest@plt>
mov    -0x60(%rbp),%rax
cmp    -0x48(%rbp),%rax
je     1218 <test1_helper1+0x88>
mov    -0x8(%rbp),%rsi
mov    -0x48(%rbp),%rdx
mov    -0x58(%rbp),%rcx
mov    -0x60(%rbp),%r8
lea    0xdf6(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0x0,%al
call   1030 <abort@plt>
jmp    121d <test1_helper1+0x8d>
mov    -0x10(%rbp),%rax
add    -0x48(%rbp),%rax
mov    %rax,-0x48(%rbp)
jmp    11b5 <test1_helper1+0x25>
movq   $0x0,-0x48(%rbp)
mov    -0x48(%rbp),%rax
cmp    -0x50(%rbp),%rax
jge    12b5 <test1_helper1+0x125>
mov    -0x8(%rbp),%rdi
mov    -0x48(%rbp),%rsi
lea    -0x18(%rbp),%rdx
lea    -0x20(%rbp),%rcx
call   1040 <pix2ang_nest@plt>
mov    -0x8(%rbp),%rdi
movsd  -0x18(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
lea    -0x60(%rbp),%rsi
call   10b0 <ang2pix_nest@plt>
mov    -0x60(%rbp),%rax
cmp    -0x48(%rbp),%rax
je     129f <test1_helper1+0x10f>
mov    -0x8(%rbp),%rsi
mov    -0x48(%rbp),%rdx
mov    -0x60(%rbp),%rcx
lea    0xd88(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0x0,%al
call   1030 <abort@plt>
jmp    12a4 <test1_helper1+0x114>
mov    -0x10(%rbp),%rax
add    -0x48(%rbp),%rax
mov    %rax,-0x48(%rbp)
jmp    1236 <test1_helper1+0xa6>
movq   $0x0,-0x48(%rbp)
mov    -0x48(%rbp),%rax
cmp    -0x50(%rbp),%rax
jge    1332 <test1_helper1+0x1a2>
mov    -0x8(%rbp),%rdi
mov    -0x48(%rbp),%rsi
lea    -0x40(%rbp),%rdx
call   1090 <pix2vec_nest@plt>
mov    -0x8(%rbp),%rdi
lea    -0x40(%rbp),%rsi
lea    -0x60(%rbp),%rdx
call   10a0 <vec2pix_nest@plt>
mov    -0x60(%rbp),%rax
cmp    -0x48(%rbp),%rax
je     131c <test1_helper1+0x18c>
mov    -0x8(%rbp),%rsi
mov    -0x48(%rbp),%rdx
mov    -0x60(%rbp),%rcx
lea    0xd0b(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0x0,%al
call   1030 <abort@plt>
jmp    1321 <test1_helper1+0x191>
mov    -0x10(%rbp),%rax
add    -0x48(%rbp),%rax
mov    %rax,-0x48(%rbp)
jmp    12bd <test1_helper1+0x12d>
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test1_helper1>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    %rsi,%r14
mov    %rdi,%r12
call   1080 <nside2npix@plt>
test   %rax,%rax
jle    128d <test1_helper1+0xfd>
mov    %rax,%r15
xor    %ebx,%ebx
lea    0x8(%rsp),%r13
mov    %rsp,%rbp
nop
mov    %r12,%rdi
mov    %rbx,%rsi
mov    %r13,%rdx
call   1070 <nest2ring@plt>
mov    0x8(%rsp),%rsi
mov    %r12,%rdi
mov    %rbp,%rdx
call   1060 <ring2nest@plt>
mov    (%rsp),%r8
cmp    %r8,%rbx
jne    129c <test1_helper1+0x10c>
add    %r14,%rbx
cmp    %r15,%rbx
jl     11c0 <test1_helper1+0x30>
test   %r15,%r15
jle    128d <test1_helper1+0xfd>
xor    %ebx,%ebx
lea    0x10(%rsp),%rbp
mov    %rsp,%r13
cs nopw 0x0(%rax,%rax,1)
mov    %r12,%rdi
mov    %rbx,%rsi
lea    0x18(%rsp),%rdx
mov    %rbp,%rcx
call   1040 <pix2ang_nest@plt>
movsd  0x18(%rsp),%xmm0
movsd  0x10(%rsp),%xmm1
mov    %r12,%rdi
mov    %r13,%rsi
call   10b0 <ang2pix_nest@plt>
mov    (%rsp),%rcx
cmp    %rcx,%rbx
jne    12bc <test1_helper1+0x12c>
add    %r14,%rbx
cmp    %r15,%rbx
jl     1210 <test1_helper1+0x80>
test   %r15,%r15
jle    128d <test1_helper1+0xfd>
xor    %ebx,%ebx
lea    0x20(%rsp),%rbp
mov    %rsp,%r13
nopw   0x0(%rax,%rax,1)
mov    %r12,%rdi
mov    %rbx,%rsi
mov    %rbp,%rdx
call   1090 <pix2vec_nest@plt>
mov    %r12,%rdi
mov    %rbp,%rsi
mov    %r13,%rdx
call   10a0 <vec2pix_nest@plt>
mov    (%rsp),%rcx
cmp    %rcx,%rbx
jne    12bc <test1_helper1+0x12c>
add    %r14,%rbx
cmp    %r15,%rbx
jl     1260 <test1_helper1+0xd0>
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x8(%rsp),%rcx
lea    0xd58(%rip),%rdi
mov    %r12,%rsi
mov    %rbx,%rdx
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
call   1030 <abort@plt>
lea    0xd56(%rip),%rdi
mov    %r12,%rsi
mov    %rbx,%rdx
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
call   1030 <abort@plt>

LLVM IR (-O0):
@.str = [25 x i8] c"Error0: %ld %ld %ld %ld\0A\00"
@.str.1 = [21 x i8] c"Error1: %ld %ld %ld\0A\00"
define void @test1_helper1(i64 %0, i64 %1) {
%3 = alloca i64
%4 = alloca i64
%5 = alloca double
%6 = alloca double
%7 = alloca [3 x double]
%8 = alloca i64
%9 = alloca i64
%10 = alloca i64
%11 = alloca i64
store i64 %0, i64* %3
store i64 %1, i64* %4
%12 = load i64, i64* %3
%13 = call i64 @nside2npix(i64 %12)
store i64 %13, i64* %9
store i64 0, i64* %8
br label %14
14: ; preds = %36, %2
%15 = load i64, i64* %8
%16 = load i64, i64* %9
%17 = icmp slt i64 %15, %16
br i1 %17, label %18, label %40
18: ; preds = %14
%19 = load i64, i64* %3
%20 = load i64, i64* %8
%21 = call i32 @nest2ring(i64 %19, i64 %20, i64* %10)
%22 = load i64, i64* %3
%23 = load i64, i64* %10
%24 = call i32 @ring2nest(i64 %22, i64 %23, i64* %11)
%25 = load i64, i64* %11
%26 = load i64, i64* %8
%27 = icmp ne i64 %25, %26
br i1 %27, label %28, label %35
28: ; preds = %18
%29 = load i64, i64* %3
%30 = load i64, i64* %8
%31 = load i64, i64* %10
%32 = load i64, i64* %11
%33 = call i32 (i8*, i64, i64, i64, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i64 %29, i64 %30, i64 %31, i64 %32)
%34 = call i32 (...) @abort()
unreachable
35: ; preds = %18
br label %36
36: ; preds = %35
%37 = load i64, i64* %4
%38 = load i64, i64* %8
%39 = add nsw i64 %38, %37
store i64 %39, i64* %8
br label %14
40: ; preds = %14
store i64 0, i64* %8
br label %41
41: ; preds = %63, %40
%42 = load i64, i64* %8
%43 = load i64, i64* %9
%44 = icmp slt i64 %42, %43
br i1 %44, label %45, label %67
45: ; preds = %41
%46 = load i64, i64* %3
%47 = load i64, i64* %8
%48 = call i32 @pix2ang_nest(i64 %46, i64 %47, double* %5, double* %6)
%49 = load i64, i64* %3
%50 = load double, double* %5
%51 = load double, double* %6
%52 = call i32 @ang2pix_nest(i64 %49, double %50, double %51, i64* %11)
%53 = load i64, i64* %11
%54 = load i64, i64* %8
%55 = icmp ne i64 %53, %54
br i1 %55, label %56, label %62
56: ; preds = %45
%57 = load i64, i64* %3
%58 = load i64, i64* %8
%59 = load i64, i64* %11
%60 = call i32 (i8*, i64, i64, i64, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i64 %57, i64 %58, i64 %59)
%61 = call i32 (...) @abort()
unreachable
62: ; preds = %45
br label %63
63: ; preds = %62
%64 = load i64, i64* %4
%65 = load i64, i64* %8
%66 = add nsw i64 %65, %64
store i64 %66, i64* %8
br label %41
67: ; preds = %41
store i64 0, i64* %8
br label %68
68: ; preds = %90, %67
%69 = load i64, i64* %8
%70 = load i64, i64* %9
%71 = icmp slt i64 %69, %70
br i1 %71, label %72, label %94
72: ; preds = %68
%73 = load i64, i64* %3
%74 = load i64, i64* %8
%75 = getelementptr inbounds [3 x double], [3 x double]* %7, i64 0, i64 0
%76 = call i32 @pix2vec_nest(i64 %73, i64 %74, double* %75)
%77 = load i64, i64* %3
%78 = getelementptr inbounds [3 x double], [3 x double]* %7, i64 0, i64 0
%79 = call i32 @vec2pix_nest(i64 %77, double* %78, i64* %11)
%80 = load i64, i64* %11
%81 = load i64, i64* %8
%82 = icmp ne i64 %80, %81
br i1 %82, label %83, label %89
83: ; preds = %72
%84 = load i64, i64* %3
%85 = load i64, i64* %8
%86 = load i64, i64* %11
%87 = call i32 (i8*, i64, i64, i64, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i64 %84, i64 %85, i64 %86)
%88 = call i32 (...) @abort()
unreachable
89: ; preds = %72
br label %90
90: ; preds = %89
%91 = load i64, i64* %4
%92 = load i64, i64* %8
%93 = add nsw i64 %92, %91
store i64 %93, i64* %8
br label %68
94: ; preds = %68
ret void
}

LLVM IR (-O2):
@.str = [25 x i8] c"Error0: %ld %ld %ld %ld\0A\00"
@.str.1 = [21 x i8] c"Error1: %ld %ld %ld\0A\00"
define void @test1_helper1(i64 %0, i64 %1) {
%3 = alloca double
%4 = alloca double
%5 = alloca [3 x double]
%6 = alloca i64
%7 = alloca i64
%8 = bitcast double* %3 to i8*
%9 = bitcast double* %4 to i8*
%10 = bitcast [3 x double]* %5 to i8*
%11 = bitcast i64* %6 to i8*
%12 = bitcast i64* %7 to i8*
%13 = tail call i64 @nside2npix(i64 %0)
%14 = icmp sgt i64 %13, 0
br i1 %14, label %16, label %59
15: ; preds = %27
br i1 %14, label %33, label %59
16: ; preds = %2, %27
%17 = phi i64 [ %28, %27 ], [ 0, %2 ]
%18 = call i32 @nest2ring(i64 %0, i64 %17, i64* %6)
%19 = load i64, i64* %6
%20 = call i32 @ring2nest(i64 %0, i64 %19, i64* %7)
%21 = load i64, i64* %7
%22 = icmp eq i64 %21, %17
br i1 %22, label %27, label %23
23: ; preds = %16
%24 = load i64, i64* %6
%25 = call i32 (i8*, i64, i64, i64, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i64 %0, i64 %17, i64 %24, i64 %21)
%26 = call i32 (...) @abort()
unreachable
27: ; preds = %16
%28 = add nsw i64 %17, %1
%29 = icmp slt i64 %28, %13
br i1 %29, label %16, label %15
30: ; preds = %44
br i1 %14, label %31, label %59
31: ; preds = %30
%32 = getelementptr inbounds [3 x double], [3 x double]* %5, i64 0, i64 0
br label %47
33: ; preds = %15, %44
%34 = phi i64 [ %45, %44 ], [ 0, %15 ]
%35 = call i32 @pix2ang_nest(i64 %0, i64 %34, double* %3, double* %4)
%36 = load double, double* %3
%37 = load double, double* %4
%38 = call i32 @ang2pix_nest(i64 %0, double %36, double %37, i64* %7)
%39 = load i64, i64* %7
%40 = icmp eq i64 %39, %34
br i1 %40, label %44, label %41
41: ; preds = %33
%42 = call i32 (i8*, i64, i64, i64, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i64 %0, i64 %34, i64 %39)
%43 = call i32 (...) @abort()
unreachable
44: ; preds = %33
%45 = add nsw i64 %34, %1
%46 = icmp slt i64 %45, %13
br i1 %46, label %33, label %30
47: ; preds = %31, %56
%48 = phi i64 [ 0, %31 ], [ %57, %56 ]
%49 = call i32 @pix2vec_nest(i64 %0, i64 %48, double* %32)
%50 = call i32 @vec2pix_nest(i64 %0, double* %32, i64* %7)
%51 = load i64, i64* %7
%52 = icmp eq i64 %51, %48
br i1 %52, label %56, label %53
53: ; preds = %47
%54 = call i32 (i8*, i64, i64, i64, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i64 %0, i64 %48, i64 %51)
%55 = call i32 (...) @abort()
unreachable
56: ; preds = %47
%57 = add nsw i64 %48, %1
%58 = icmp slt i64 %57, %13
br i1 %58, label %47, label %59
59: ; preds = %56, %2, %15, %30
ret void
}