#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 dep(int, int);
int geometric_series(int, int);
int /*<<< orphan*/ search_tree(int, int /*<<< orphan*/, int, int, int *, int *,
                               int *);
void reverse_tree_info(int rank, int num_nodes, int width, int *parent,
                       int *num_children, int *depth, int *max_depth) {
  int max_children;
  int p, c;
  if (rank >= num_nodes) {
    *parent = -1;
    *num_children = -1;
    *depth = -1;
    *max_depth = -1;
    return;
  }
  *max_depth = dep(num_nodes, width);
  if (rank == 0) {
    *parent = -1;
    *num_children = num_nodes - 1;
    *depth = 0;
    return;
  }
  max_children = geometric_series(width, *max_depth);
  *depth = 0;
  search_tree(rank, 0, max_children, width, &p, &c, depth);
  if ((rank + c) >= num_nodes)
    c = num_nodes - rank - 1;
  *parent = p;
  *num_children = c;
  return;
}


x86 assembly (clang, -O0):
<reverse_tree_info>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    0x10(%rbp),%rax
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %rcx,-0x18(%rbp)
mov    %r8,-0x20(%rbp)
mov    %r9,-0x28(%rbp)
mov    -0x4(%rbp),%eax
cmp    -0x8(%rbp),%eax
jl     118a <reverse_tree_info+0x5a>
mov    -0x18(%rbp),%rax
movl   $0xffffffff,(%rax)
mov    -0x20(%rbp),%rax
movl   $0xffffffff,(%rax)
mov    -0x28(%rbp),%rax
movl   $0xffffffff,(%rax)
mov    0x10(%rbp),%rax
movl   $0xffffffff,(%rax)
jmp    1234 <reverse_tree_info+0x104>
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
call   1050 <dep@plt>
mov    %eax,%ecx
mov    0x10(%rbp),%rax
mov    %ecx,(%rax)
cmpl   $0x0,-0x4(%rbp)
jne    11cc <reverse_tree_info+0x9c>
mov    -0x18(%rbp),%rax
movl   $0xffffffff,(%rax)
mov    -0x8(%rbp),%ecx
sub    $0x1,%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x28(%rbp),%rax
movl   $0x0,(%rax)
jmp    1234 <reverse_tree_info+0x104>
mov    -0xc(%rbp),%edi
mov    0x10(%rbp),%rax
mov    (%rax),%esi
call   1030 <geometric_series@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x28(%rbp),%rax
movl   $0x0,(%rax)
mov    -0x4(%rbp),%edi
mov    -0x2c(%rbp),%edx
mov    -0xc(%rbp),%ecx
mov    -0x28(%rbp),%rax
xor    %esi,%esi
lea    -0x30(%rbp),%r8
lea    -0x34(%rbp),%r9
mov    %rax,(%rsp)
call   1040 <search_tree@plt>
mov    -0x4(%rbp),%eax
add    -0x34(%rbp),%eax
cmp    -0x8(%rbp),%eax
jl     1222 <reverse_tree_info+0xf2>
mov    -0x8(%rbp),%eax
sub    -0x4(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x34(%rbp)
mov    -0x30(%rbp),%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x34(%rbp),%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<reverse_tree_info>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %r9,%r12
mov    %rcx,%r15
mov    0x50(%rsp),%r14
cmp    %edi,%esi
jle    11bc <reverse_tree_info+0x8c>
mov    %edx,%r13d
mov    %esi,%ebp
mov    %edi,%ebx
mov    %r8,0x10(%rsp)
mov    %esi,%edi
mov    %edx,%esi
call   1050 <dep@plt>
mov    %eax,(%r14)
test   %ebx,%ebx
je     11db <reverse_tree_info+0xab>
mov    %r13d,%edi
mov    %eax,%esi
call   1030 <geometric_series@plt>
movl   $0x0,(%r12)
mov    %r12,(%rsp)
lea    0xc(%rsp),%r8
lea    0x8(%rsp),%r9
mov    %ebx,%edi
xor    %esi,%esi
mov    %eax,%edx
mov    %r13d,%ecx
call   1040 <search_tree@plt>
mov    0x8(%rsp),%eax
lea    (%rax,%rbx,1),%ecx
cmp    %ebp,%ecx
jl     11ac <reverse_tree_info+0x7c>
not    %ebx
add    %ebp,%ebx
mov    %ebx,0x8(%rsp)
mov    %ebx,%eax
mov    0xc(%rsp),%ecx
mov    %ecx,(%r15)
mov    0x10(%rsp),%rcx
mov    %eax,(%rcx)
jmp    11f4 <reverse_tree_info+0xc4>
movl   $0xffffffff,(%r15)
movl   $0xffffffff,(%r8)
movl   $0xffffffff,(%r12)
ff
movl   $0xffffffff,(%r14)
jmp    11f4 <reverse_tree_info+0xc4>
movl   $0xffffffff,(%r15)
add    $0xffffffff,%ebp
mov    0x10(%rsp),%rax
mov    %ebp,(%rax)
movl   $0x0,(%r12)
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @reverse_tree_info(i32 %0, i32 %1, i32 %2, i32* %3, i32* %4, i32* %5, i32* %6) {
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32*
%12 = alloca i32*
%13 = alloca i32*
%14 = alloca i32*
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32
store i32 %0, i32* %8
store i32 %1, i32* %9
store i32 %2, i32* %10
store i32* %3, i32** %11
store i32* %4, i32** %12
store i32* %5, i32** %13
store i32* %6, i32** %14
%18 = load i32, i32* %8
%19 = load i32, i32* %9
%20 = icmp sge i32 %18, %19
br i1 %20, label %21, label %26
21: ; preds = %7
%22 = load i32*, i32** %11
store i32 -1, i32* %22
%23 = load i32*, i32** %12
store i32 -1, i32* %23
%24 = load i32*, i32** %13
store i32 -1, i32* %24
%25 = load i32*, i32** %14
store i32 -1, i32* %25
br label %65
26: ; preds = %7
%27 = load i32, i32* %9
%28 = load i32, i32* %10
%29 = call i32 @dep(i32 %27, i32 %28)
%30 = load i32*, i32** %14
store i32 %29, i32* %30
%31 = load i32, i32* %8
%32 = icmp eq i32 %31, 0
br i1 %32, label %33, label %39
33: ; preds = %26
%34 = load i32*, i32** %11
store i32 -1, i32* %34
%35 = load i32, i32* %9
%36 = sub nsw i32 %35, 1
%37 = load i32*, i32** %12
store i32 %36, i32* %37
%38 = load i32*, i32** %13
store i32 0, i32* %38
br label %65
39: ; preds = %26
%40 = load i32, i32* %10
%41 = load i32*, i32** %14
%42 = load i32, i32* %41
%43 = call i32 @geometric_series(i32 %40, i32 %42)
store i32 %43, i32* %15
%44 = load i32*, i32** %13
store i32 0, i32* %44
%45 = load i32, i32* %8
%46 = load i32, i32* %15
%47 = load i32, i32* %10
%48 = load i32*, i32** %13
%49 = call i32 @search_tree(i32 %45, i32 0, i32 %46, i32 %47, i32* %16, i32* %17, i32* %48)
%50 = load i32, i32* %8
%51 = load i32, i32* %17
%52 = add nsw i32 %50, %51
%53 = load i32, i32* %9
%54 = icmp sge i32 %52, %53
br i1 %54, label %55, label %60
55: ; preds = %39
%56 = load i32, i32* %9
%57 = load i32, i32* %8
%58 = sub nsw i32 %56, %57
%59 = sub nsw i32 %58, 1
store i32 %59, i32* %17
br label %60
60: ; preds = %55, %39
%61 = load i32, i32* %16
%62 = load i32*, i32** %11
store i32 %61, i32* %62
%63 = load i32, i32* %17
%64 = load i32*, i32** %12
store i32 %63, i32* %64
br label %65
65: ; preds = %60, %33, %21
ret void
}

LLVM IR (-O2):
define void @reverse_tree_info(i32 %0, i32 %1, i32 %2, i32* nocapture writeonly %3, i32* nocapture writeonly %4, i32* %5, i32* nocapture writeonly %6) {
%8 = alloca i32
%9 = alloca i32
%10 = bitcast i32* %8 to i8*
%11 = bitcast i32* %9 to i8*
%12 = icmp sgt i32 %1, %0
br i1 %12, label %14, label %13
13: ; preds = %7
store i32 -1, i32* %3
store i32 -1, i32* %4
store i32 -1, i32* %5
store i32 -1, i32* %6
br label %31
14: ; preds = %7
%15 = tail call i32 @dep(i32 %1, i32 %2)
store i32 %15, i32* %6
%16 = icmp eq i32 %0, 0
br i1 %16, label %17, label %19
17: ; preds = %14
store i32 -1, i32* %3
%18 = add nsw i32 %1, -1
store i32 %18, i32* %4
store i32 0, i32* %5
br label %31
19: ; preds = %14
%20 = tail call i32 @geometric_series(i32 %2, i32 %15)
store i32 0, i32* %5
%21 = call i32 @search_tree(i32 %0, i32 0, i32 %20, i32 %2, i32* %8, i32* %9, i32* %5)
%22 = load i32, i32* %9
%23 = add nsw i32 %22, %0
%24 = icmp slt i32 %23, %1
br i1 %24, label %28, label %25
25: ; preds = %19
%26 = xor i32 %0, -1
%27 = add i32 %26, %1
store i32 %27, i32* %9
br label %28
28: ; preds = %25, %19
%29 = phi i32 [ %27, %25 ], [ %22, %19 ]
%30 = load i32, i32* %8
store i32 %30, i32* %3
store i32 %29, i32* %4
br label %31
31: ; preds = %28, %17, %13
ret void
}