#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 scm_page_col(long long);
long long scm_page_index(int /*<<< orphan*/, scalar_t__, int, int);
scalar_t__ scm_page_level(long long);
int /*<<< orphan*/ scm_page_root(long long);
int scm_page_row(long long);
long long scm_page_child(long long i, long long k) {
  return scm_page_index(scm_page_root(i), scm_page_level(i) + 1,
                        scm_page_row(i) * 2 + k / 2,
                        scm_page_col(i) * 2 + k % 2);
}


x86 assembly (clang, -O0):
<scm_page_child>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <scm_page_root@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <scm_page_level@plt>
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
mov    -0x8(%rbp),%rdi
call   1060 <scm_page_row@plt>
shl    $0x1,%eax
cltq
mov    %rax,-0x38(%rbp)
mov    -0x10(%rbp),%rax
mov    $0x2,%ecx
cqto
idiv   %rcx
mov    %rax,%rcx
mov    -0x38(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%rdi
call   1070 <scm_page_col@plt>
mov    -0x2c(%rbp),%edi
mov    -0x28(%rbp),%rsi
shl    $0x1,%eax
cltq
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    $0x2,%ecx
cqto
idiv   %rcx
mov    -0x20(%rbp),%rax
mov    %rdx,%rcx
mov    -0x14(%rbp),%edx
add    %rcx,%rax
mov    %eax,%ecx
call   1040 <scm_page_index@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<scm_page_child>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r13
mov    %rdi,%rbp
call   1030 <scm_page_root@plt>
mov    %eax,%r14d
mov    %rbp,%rdi
call   1050 <scm_page_level@plt>
lea    0x1(%rax),%r15
mov    %rbp,%rdi
call   1060 <scm_page_row@plt>
mov    %r13,%rbx
shr    $0x3f,%rbx
add    %r13,%rbx
shr    %rbx
lea    (%rbx,%rax,2),%r12d
mov    %rbp,%rdi
call   1070 <scm_page_col@plt>
add    %ebx,%ebx
sub    %ebx,%r13d
lea    0x0(%r13,%rax,2),%ecx
mov    %r14d,%edi
mov    %r15,%rsi
mov    %r12d,%edx
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <scm_page_index@plt>

LLVM IR (-O0):
define i64 @scm_page_child(i64 %0, i64 %1) {
%3 = alloca i64
%4 = alloca i64
store i64 %0, i64* %3
store i64 %1, i64* %4
%5 = load i64, i64* %3
%6 = call i32 @scm_page_root(i64 %5)
%7 = load i64, i64* %3
%8 = call i64 @scm_page_level(i64 %7)
%9 = add nsw i64 %8, 1
%10 = load i64, i64* %3
%11 = call i32 @scm_page_row(i64 %10)
%12 = mul nsw i32 %11, 2
%13 = sext i32 %12 to i64
%14 = load i64, i64* %4
%15 = sdiv i64 %14, 2
%16 = add nsw i64 %13, %15
%17 = trunc i64 %16 to i32
%18 = load i64, i64* %3
%19 = call i32 @scm_page_col(i64 %18)
%20 = mul nsw i32 %19, 2
%21 = sext i32 %20 to i64
%22 = load i64, i64* %4
%23 = srem i64 %22, 2
%24 = add nsw i64 %21, %23
%25 = trunc i64 %24 to i32
%26 = call i64 @scm_page_index(i32 %6, i64 %9, i32 %17, i32 %25)
ret i64 %26
}

LLVM IR (-O2):
define i64 @scm_page_child(i64 %0, i64 %1) {
%3 = tail call i32 @scm_page_root(i64 %0)
%4 = tail call i64 @scm_page_level(i64 %0)
%5 = add nsw i64 %4, 1
%6 = tail call i32 @scm_page_row(i64 %0)
%7 = shl nsw i32 %6, 1
%8 = sdiv i64 %1, 2
%9 = trunc i64 %8 to i32
%10 = add i32 %7, %9
%11 = tail call i32 @scm_page_col(i64 %0)
%12 = shl nsw i32 %11, 1
%13 = srem i64 %1, 2
%14 = trunc i64 %13 to i32
%15 = add i32 %12, %14
%16 = tail call i64 @scm_page_index(i32 %3, i64 %5, i32 %10, i32 %15)
ret i64 %16
}