#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*/ freopen(char *, char *, int /*<<< orphan*/);
int log(int);
int pow(int, int);
int /*<<< orphan*/ printf(char *, int, int, int);
int /*<<< orphan*/ scanf(char *, int *);
int /*<<< orphan*/ stdin;
int main() {
  freopen("input.txt", "r", stdin);
  int n;
  scanf("%d", &n);
  printf("depth = %d\ntotal nodes = %d\nleaf nodes = %d\n",
         (int)(log(n) / log(2)) + 1, n,
         (int)(n - pow(2, (int)(log(n) / log(2)))) + 1);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2e82(%rip),%rax
mov    (%rax),%edx
lea    0xe91(%rip),%rdi
lea    0xe94(%rip),%rsi
call   1040 <freopen@plt>
lea    0xe8a(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1050 <scanf@plt>
mov    -0x8(%rbp),%edi
call   1060 <log@plt>
mov    %eax,-0x1c(%rbp)
mov    $0x2,%edi
call   1060 <log@plt>
mov    %eax,%ecx
mov    -0x1c(%rbp),%eax
cltd
idiv   %ecx
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%edi
call   1060 <log@plt>
mov    %eax,-0x18(%rbp)
mov    $0x2,%edi
call   1060 <log@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%eax
cltd
idiv   %ecx
mov    %eax,%esi
mov    $0x2,%edi
call   1070 <pow@plt>
mov    -0x14(%rbp),%ecx
mov    -0x10(%rbp),%esi
mov    -0xc(%rbp),%edx
sub    %eax,%ecx
add    $0x1,%ecx
lea    0xe17(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    0x2e89(%rip),%rax
mov    (%rax),%edx
lea    0xe98(%rip),%rdi
lea    0xe9b(%rip),%rsi
call   1040 <freopen@plt>
lea    0xe91(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1050 <scanf@plt>
mov    0xc(%rsp),%edi
call   1060 <log@plt>
mov    %eax,%ebx
mov    $0x2,%edi
call   1060 <log@plt>
mov    %eax,%ecx
mov    %ebx,%eax
cltd
idiv   %ecx
lea    0x1(%rax),%r14d
mov    0xc(%rsp),%ebp
mov    %ebp,%edi
call   1060 <log@plt>
mov    %eax,%ebx
mov    $0x2,%edi
call   1060 <log@plt>
mov    %eax,%ecx
mov    %ebx,%eax
cltd
idiv   %ecx
mov    $0x2,%edi
mov    %eax,%esi
call   1070 <pow@plt>
mov    %ebp,%ecx
sub    %eax,%ecx
add    $0x1,%ecx
lea    0xe32(%rip),%rdi
mov    %r14d,%esi
mov    %ebp,%edx
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [10 x i8] c"input.txt\00"
@.str.1 = [2 x i8] c"r\00"
@stdin = global i32 0
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [45 x i8] c"depth = %d\0Atotal nodes = %d\0Aleaf nodes = %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
store i32 0, i32* %1
%3 = load i32, i32* @stdin
%4 = call i32 @freopen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i32 %3)
%5 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %2)
%6 = load i32, i32* %2
%7 = call i32 @log(i32 %6)
%8 = call i32 @log(i32 2)
%9 = sdiv i32 %7, %8
%10 = add nsw i32 %9, 1
%11 = load i32, i32* %2
%12 = load i32, i32* %2
%13 = load i32, i32* %2
%14 = call i32 @log(i32 %13)
%15 = call i32 @log(i32 2)
%16 = sdiv i32 %14, %15
%17 = call i32 @pow(i32 2, i32 %16)
%18 = sub nsw i32 %12, %17
%19 = add nsw i32 %18, 1
%20 = call i32 @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.3, i64 0, i64 0), i32 %10, i32 %11, i32 %19)
ret i32 0
}

LLVM IR (-O2):
@.str = [10 x i8] c"input.txt\00"
@.str.1 = [2 x i8] c"r\00"
@stdin = global i32 0
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [45 x i8] c"depth = %d\0Atotal nodes = %d\0Aleaf nodes = %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = load i32, i32* @stdin
%3 = tail call i32 @freopen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i32 %2)
%4 = bitcast i32* %1 to i8*
%5 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %1)
%6 = load i32, i32* %1
%7 = call i32 @log(i32 %6)
%8 = call i32 @log(i32 2)
%9 = sdiv i32 %7, %8
%10 = add nsw i32 %9, 1
%11 = load i32, i32* %1
%12 = call i32 @log(i32 %11)
%13 = call i32 @log(i32 2)
%14 = sdiv i32 %12, %13
%15 = call i32 @pow(i32 2, i32 %14)
%16 = add i32 %11, 1
%17 = sub i32 %16, %15
%18 = call i32 @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.3, i64 0, i64 0), i32 %10, i32 %11, i32 %17)
ret i32 0
}