#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);
void count(int n) {
  static int d = 1;
  printf("%d ", n);
  printf("%d ", d);
  d++;
  if (n > 1)
    count(n - 1);
  printf("%d ", d);
}


x86 assembly (clang, -O0):
<count>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%esi
lea    0xecb(%rip),%rdi
call   1040 <printf@plt>
mov    0x2ef0(%rip),%esi
lea    0xeb9(%rip),%rdi
call   1040 <printf@plt>
mov    0x2ede(%rip),%eax
add    $0x1,%eax
mov    %eax,0x2ed5(%rip)
cmpl   $0x1,-0x4(%rbp)
jle    1170 <count+0x50>
mov    -0x4(%rbp),%edi
sub    $0x1,%edi
call   1030 <count@plt>
mov    0x2eba(%rip),%esi
lea    0xe83(%rip),%rdi
call   1040 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<count>:
push   %r14
push   %rbx
push   %rax
mov    %edi,%ebx
lea    0xed3(%rip),%r14
mov    %r14,%rdi
mov    %ebx,%esi
call   1040 <printf@plt>
mov    0x2ef3(%rip),%esi
mov    %r14,%rdi
call   1040 <printf@plt>
mov    0x2ee5(%rip),%esi
add    $0x1,%esi
mov    %esi,0x2edc(%rip)
cmp    $0x2,%ebx
jl     1169 <count+0x49>
add    $0xffffffff,%ebx
mov    %ebx,%edi
call   1030 <count@plt>
mov    0x2ec7(%rip),%esi
lea    0xe90(%rip),%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1040 <printf@plt>

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

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