#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 */
typedef int int64_t;

/* Variables and functions */
int /*<<< orphan*/ nest2xyf64(int, int, int *, int *, int *);
int xyf2ring64(int, int, int, int);
void nest2ring64(int64_t nside, int64_t ipnest, int64_t *ipring) {
  int ix, iy, face_num;
  if ((nside & (nside - 1)) != 0) {
    *ipring = -1;
    return;
  }
  nest2xyf64(nside, ipnest, &ix, &iy, &face_num);
  *ipring = xyf2ring64(nside, ix, iy, face_num);
}


x86 assembly (clang, -O0):
<nest2ring64>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
mov    -0x4(%rbp),%eax
mov    -0x4(%rbp),%ecx
sub    $0x1,%ecx
and    %ecx,%eax
cmp    $0x0,%eax
je     1155 <nest2ring64+0x35>
mov    -0x10(%rbp),%rax
movl   $0xffffffff,(%rax)
jmp    1185 <nest2ring64+0x65>
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
lea    -0x14(%rbp),%rdx
lea    -0x18(%rbp),%rcx
lea    -0x1c(%rbp),%r8
call   1030 <nest2xyf64@plt>
mov    -0x4(%rbp),%edi
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
mov    -0x1c(%rbp),%ecx
call   1040 <xyf2ring64@plt>
mov    %eax,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<nest2ring64>:
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %rdx,%r14
mov    %edi,%ebx
lea    -0x1(%rbx),%ecx
mov    $0xffffffff,%eax
test   %ecx,%edi
jne    1161 <nest2ring64+0x41>
lea    0x14(%rsp),%rdx
lea    0x10(%rsp),%rcx
lea    0xc(%rsp),%r8
mov    %ebx,%edi
call   1030 <nest2xyf64@plt>
mov    0x14(%rsp),%esi
mov    0x10(%rsp),%edx
mov    0xc(%rsp),%ecx
mov    %ebx,%edi
call   1040 <xyf2ring64@plt>
mov    %eax,(%r14)
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define void @nest2ring64(i32 %0, i32 %1, i32* %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i32 %0, i32* %4
store i32 %1, i32* %5
store i32* %2, i32** %6
%10 = load i32, i32* %4
%11 = load i32, i32* %4
%12 = sub nsw i32 %11, 1
%13 = and i32 %10, %12
%14 = icmp ne i32 %13, 0
br i1 %14, label %15, label %17
15: ; preds = %3
%16 = load i32*, i32** %6
store i32 -1, i32* %16
br label %27
17: ; preds = %3
%18 = load i32, i32* %4
%19 = load i32, i32* %5
%20 = call i32 @nest2xyf64(i32 %18, i32 %19, i32* %7, i32* %8, i32* %9)
%21 = load i32, i32* %4
%22 = load i32, i32* %7
%23 = load i32, i32* %8
%24 = load i32, i32* %9
%25 = call i32 @xyf2ring64(i32 %21, i32 %22, i32 %23, i32 %24)
%26 = load i32*, i32** %6
store i32 %25, i32* %26
br label %27
27: ; preds = %17, %15
ret void
}

LLVM IR (-O2):
define void @nest2ring64(i32 %0, i32 %1, i32* nocapture writeonly %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = bitcast i32* %4 to i8*
%8 = bitcast i32* %5 to i8*
%9 = bitcast i32* %6 to i8*
%10 = tail call i32 @llvm.ctpop.i32(i32 %0)
%11 = icmp ult i32 %10, 2
br i1 %11, label %12, label %18
12: ; preds = %3
%13 = call i32 @nest2xyf64(i32 %0, i32 %1, i32* %4, i32* %5, i32* %6)
%14 = load i32, i32* %4
%15 = load i32, i32* %5
%16 = load i32, i32* %6
%17 = call i32 @xyf2ring64(i32 %0, i32 %14, i32 %15, i32 %16)
br label %18
18: ; preds = %3, %12
%19 = phi i32 [ %17, %12 ], [ -1, %3 ]
store i32 %19, i32* %2
ret void
}