#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*/ extended_bottom_up_cut_rod(int *, int, int *, int *);
int /*<<< orphan*/ printf(char *, ...);
void print_cut_rod_solution(int *p, int n) {
  int r[n], s[n];
  extended_bottom_up_cut_rod(p, n, r, s);
  while (n - 1 > 0) {
    printf("%d ", s[n - 1]);
    n = n - s[n - 1];
  }
  printf("\n");
}


x86 assembly (clang, -O0):
<print_cut_rod_solution>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x18(%rbp)
lea    0xf(,%rax,4),%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%rdx
sub    %rcx,%rdx
mov    %rdx,%rsp
mov    %rax,-0x20(%rbp)
mov    -0xc(%rbp),%eax
lea    0xf(,%rax,4),%rsi
and    $0xfffffffffffffff0,%rsi
mov    %rsp,%rcx
sub    %rsi,%rcx
mov    %rcx,-0x30(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x28(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
call   1040 <extended_bottom_up_cut_rod@plt>
mov    -0xc(%rbp),%eax
sub    $0x1,%eax
cmp    $0x0,%eax
jle    11c6 <print_cut_rod_solution+0xa6>
mov    -0x30(%rbp),%rax
mov    -0xc(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,4),%esi
lea    0xe5c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x30(%rbp),%rcx
mov    -0xc(%rbp),%eax
mov    -0xc(%rbp),%edx
sub    $0x1,%edx
movslq %edx,%rdx
sub    (%rcx,%rdx,4),%eax
mov    %eax,-0xc(%rbp)
jmp    117e <print_cut_rod_solution+0x5e>
lea    0xe37(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%rax
mov    %rax,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_cut_rod_solution>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %esi,%ebx
mov    %esi,%eax
mov    %rsp,%rdx
lea    0xf(,%rax,4),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rdx
mov    %rdx,%rsp
mov    %rsp,%r14
sub    %rax,%r14
mov    %r14,%rsp
mov    %r14,%rcx
call   1050 <extended_bottom_up_cut_rod@plt>
cmp    $0x2,%ebx
jl     119b <print_cut_rod_solution+0x6b>
lea    0xe8f(%rip),%r15
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
lea    -0x1(%rbx),%r12d
mov    (%r14,%r12,4),%esi
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
sub    (%r14,%r12,4),%ebx
cmp    $0x1,%ebx
jg     1180 <print_cut_rod_solution+0x50>
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    -0x20(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%d \00"
@.str.1 = [2 x i8] c"\0A\00"
define void @print_cut_rod_solution(i32* %0, i32 %1) {
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i64
%7 = alloca i64
store i32* %0, i32** %3
store i32 %1, i32* %4
%8 = load i32, i32* %4
%9 = zext i32 %8 to i64
%10 = call i8* @llvm.stacksave()
store i8* %10, i8** %5
%11 = alloca i32, i64 %9
store i64 %9, i64* %6
%12 = load i32, i32* %4
%13 = zext i32 %12 to i64
%14 = alloca i32, i64 %13
store i64 %13, i64* %7
%15 = load i32*, i32** %3
%16 = load i32, i32* %4
%17 = call i32 @extended_bottom_up_cut_rod(i32* %15, i32 %16, i32* %11, i32* %14)
br label %18
18: ; preds = %22, %2
%19 = load i32, i32* %4
%20 = sub nsw i32 %19, 1
%21 = icmp sgt i32 %20, 0
br i1 %21, label %22, label %36
22: ; preds = %18
%23 = load i32, i32* %4
%24 = sub nsw i32 %23, 1
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds i32, i32* %14, i64 %25
%27 = load i32, i32* %26
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %27)
%29 = load i32, i32* %4
%30 = load i32, i32* %4
%31 = sub nsw i32 %30, 1
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds i32, i32* %14, i64 %32
%34 = load i32, i32* %33
%35 = sub nsw i32 %29, %34
store i32 %35, i32* %4
br label %18
36: ; preds = %18
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%38 = load i8*, i8** %5
ret void
}

LLVM IR (-O2):
@.str = [4 x i8] c"%d \00"
define void @print_cut_rod_solution(i32* %0, i32 %1) {
%3 = zext i32 %1 to i64
%4 = alloca i32, i64 %3
%5 = alloca i32, i64 %3
%6 = call i32 @extended_bottom_up_cut_rod(i32* %0, i32 %1, i32* %4, i32* %5)
%7 = icmp sgt i32 %1, 1
br i1 %7, label %8, label %18
8: ; preds = %2, %8
%9 = phi i32 [ %16, %8 ], [ %1, %2 ]
%10 = add nsw i32 %9, -1
%11 = zext i32 %10 to i64
%12 = getelementptr inbounds i32, i32* %5, i64 %11
%13 = load i32, i32* %12
%14 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %13)
%15 = load i32, i32* %12
%16 = sub nsw i32 %9, %15
%17 = icmp sgt i32 %16, 1
br i1 %17, label %8, label %18
18: ; preds = %8, %2
%19 = call i32 @putchar(i32 10)
ret void
}