#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*/ printf(char *, int);
int sumCountMirror(int number, int control) {
  int result = 0;
  printf("%d ", number);
  if (control > 1) {
    result = sumCountMirror(number - 1, control - 1);
  }
  printf("%d ", number);
  return (number * 2) + result;
}


x86 assembly (clang, -O0):
<sumCountMirror>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0x4(%rbp),%esi
lea    0xec1(%rip),%rdi
call   1040 <printf@plt>
cmpl   $0x1,-0x8(%rbp)
jle    1162 <sumCountMirror+0x42>
mov    -0x4(%rbp),%edi
sub    $0x1,%edi
mov    -0x8(%rbp),%esi
sub    $0x1,%esi
call   1030 <sumCountMirror@plt>
mov    %eax,-0xc(%rbp)
mov    -0x4(%rbp),%esi
lea    0xe94(%rip),%rdi
call   1040 <printf@plt>
mov    -0x4(%rbp),%eax
shl    $0x1,%eax
add    -0xc(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sumCountMirror>:
push   %rbp
push   %r14
push   %rbx
mov    %esi,%ebp
mov    %edi,%ebx
lea    0xed1(%rip),%rdi
mov    %ebx,%esi
call   1040 <printf@plt>
xor    %r14d,%r14d
cmp    $0x2,%ebp
jl     114e <sumCountMirror+0x2e>
lea    -0x1(%rbx),%edi
add    $0xffffffff,%ebp
mov    %ebp,%esi
call   1030 <sumCountMirror@plt>
mov    %eax,%r14d
lea    0xeab(%rip),%rdi
mov    %ebx,%esi
call   1040 <printf@plt>
lea    (%r14,%rbx,2),%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [4 x i8] c"%d \00"
define i32 @sumCountMirror(i32 %0, i32 %1) {
%3 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %0)
%4 = icmp sgt i32 %1, 1
br i1 %4, label %5, label %9
5: ; preds = %2
%6 = add nsw i32 %0, -1
%7 = add nsw i32 %1, -1
%8 = tail call i32 @sumCountMirror(i32 %6, i32 %7)
br label %9
9: ; preds = %5, %2
%10 = phi i32 [ %8, %5 ], [ 0, %2 ]
%11 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %0)
%12 = shl nsw i32 %0, 1
%13 = add nsw i32 %10, %12
ret i32 %13
}