#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 */
long Calculator(long, long **);
int /*<<< orphan*/ free(long *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, long *);
int main() {
  long N, num_steps;
  scanf("%ld", &N);
  long *steps;
  num_steps = Calculator(N, &steps);
  printf("%ld\n", num_steps);
  for (long m = 0; m <= num_steps; ++m) {
    printf("%ld ", steps[m]);
  }
  printf("\n");
  free(steps);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeaa(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1060 <scanf@plt>
mov    -0x10(%rbp),%rdi
lea    -0x20(%rbp),%rsi
call   1050 <Calculator@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rsi
lea    0xe89(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movq   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%rax
cmp    -0x18(%rbp),%rax
jg     11c3 <main+0x83>
mov    -0x20(%rbp),%rax
mov    -0x28(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
lea    0xe5e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
jmp    118a <main+0x4a>
lea    0xe3d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
lea    0xea0(%rip),%rdi
lea    0x8(%rsp),%rsi
call   1070 <scanf@plt>
mov    0x8(%rsp),%rdi
mov    %rsp,%rsi
call   1060 <Calculator@plt>
mov    %rax,%r15
lea    0xe83(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
test   %r15,%r15
js     11bb <main+0x6b>
add    $0x1,%r15
lea    0xe6e(%rip),%r14
xor    %ebx,%ebx
nopl   (%rax)
mov    (%rsp),%rax
mov    (%rax,%rbx,8),%rsi
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x1,%rbx
cmp    %rbx,%r15
jne    11a0 <main+0x50>
mov    $0xa,%edi
call   1040 <putchar@plt>
mov    (%rsp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%ld\00"
@.str.1 = [5 x i8] c"%ld\0A\00"
@.str.2 = [5 x i8] c"%ld \00"
@.str.3 = [2 x i8] c"\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i64
%3 = alloca i64
%4 = alloca i64*
%5 = alloca i64
store i32 0, i32* %1
%6 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i64* %2)
%7 = load i64, i64* %2
%8 = call i64 @Calculator(i64 %7, i64** %4)
store i64 %8, i64* %3
%9 = load i64, i64* %3
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i64 %9)
store i64 0, i64* %5
br label %11
11: ; preds = %21, %0
%12 = load i64, i64* %5
%13 = load i64, i64* %3
%14 = icmp sle i64 %12, %13
br i1 %14, label %15, label %24
15: ; preds = %11
%16 = load i64*, i64** %4
%17 = load i64, i64* %5
%18 = getelementptr inbounds i64, i64* %16, i64 %17
%19 = load i64, i64* %18
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i64 %19)
br label %21
21: ; preds = %15
%22 = load i64, i64* %5
%23 = add nsw i64 %22, 1
store i64 %23, i64* %5
br label %11
24: ; preds = %11
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%26 = load i64*, i64** %4
%27 = call i32 @free(i64* %26)
%28 = load i32, i32* %1
ret i32 %28
}

LLVM IR (-O2):
@.str = [4 x i8] c"%ld\00"
@.str.1 = [5 x i8] c"%ld\0A\00"
@.str.2 = [5 x i8] c"%ld \00"
define i32 @main() {
%1 = alloca i64
%2 = alloca i64*
%3 = bitcast i64* %1 to i8*
%4 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i64* %1)
%5 = bitcast i64** %2 to i8*
%6 = load i64, i64* %1
%7 = call i64 @Calculator(i64 %6, i64** %2)
%8 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i64 %7)
%9 = icmp slt i64 %7, 0
br i1 %9, label %10, label %14
10: ; preds = %14, %0
%11 = call i32 @putchar(i32 10)
%12 = load i64*, i64** %2
%13 = call i32 @free(i64* %12)
ret i32 0
14: ; preds = %0, %14
%15 = phi i64 [ %20, %14 ], [ 0, %0 ]
%16 = load i64*, i64** %2
%17 = getelementptr inbounds i64, i64* %16, i64 %15
%18 = load i64, i64* %17
%19 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i64 %18)
%20 = add nuw i64 %15, 1
%21 = icmp eq i64 %15, %7
br i1 %21, label %10, label %14
}