#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 /*<<< orphan*/ putchar(int);
void printd(int n) {
  if (n < 0) {
    putchar('-');
    n = -n;
  }
  if (n / 10) {
    printf("inside second check n = %d;\n", n);
    printd(n / 10);
  };
  printf("at this step n = %d;\n", n);
  putchar(n % 10 + '0');
  printf("\n\n");
}


x86 assembly (clang, -O0):
<printd>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
cmpl   $0x0,-0x4(%rbp)
jge    1157 <printd+0x27>
mov    $0x2d,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
sub    -0x4(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
cmp    $0x0,%eax
je     118e <printd+0x5e>
mov    -0x4(%rbp),%esi
lea    0xe8b(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x4(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,%edi
call   1040 <printd@plt>
mov    -0x4(%rbp),%esi
lea    0xe85(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x4(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %edx,%edi
add    $0x30,%edi
call   1030 <putchar@plt>
lea    0xe78(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printd>:
push   %r15
push   %r14
push   %rbx
mov    %edi,%ebx
test   %edi,%edi
jns    1157 <printd+0x17>
mov    $0x2d,%edi
call   1030 <putchar@plt>
neg    %ebx
mov    %ebx,%r15d
cmp    $0xa,%ebx
jb     1185 <printd+0x45>
mov    $0xcccccccd,%r14d
imul   %r15,%r14
shr    $0x23,%r14
lea    0xe8c(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %r14d,%edi
call   1040 <printd@plt>
lea    0xe91(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1060 <printf@plt>
mov    $0xcccccccd,%eax
imul   %r15,%rax
shr    $0x23,%rax
add    %eax,%eax
lea    (%rax,%rax,4),%eax
sub    %eax,%ebx
or     $0x30,%ebx
mov    %ebx,%edi
call   1030 <putchar@plt>
lea    0xe61(%rip),%rdi
pop    %rbx
pop    %r14
pop    %r15
jmp    1050 <puts@plt>

LLVM IR (-O0):
@.str = [29 x i8] c"inside second check n = %d;\0A\00"
@.str.1 = [22 x i8] c"at this step n = %d;\0A\00"
@.str.2 = [3 x i8] c"\0A\0A\00"
define void @printd(i32 %0) {
%2 = alloca i32
store i32 %0, i32* %2
%3 = load i32, i32* %2
%4 = icmp slt i32 %3, 0
br i1 %4, label %5, label %9
5: ; preds = %1
%6 = call i32 @putchar(i32 45)
%7 = load i32, i32* %2
%8 = sub nsw i32 0, %7
store i32 %8, i32* %2
br label %9
9: ; preds = %5, %1
%10 = load i32, i32* %2
%11 = sdiv i32 %10, 10
%12 = icmp ne i32 %11, 0
br i1 %12, label %13, label %18
13: ; preds = %9
%14 = load i32, i32* %2
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i32 %14)
%16 = load i32, i32* %2
%17 = sdiv i32 %16, 10
br label %18
18: ; preds = %13, %9
%19 = load i32, i32* %2
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i32 %19)
%21 = load i32, i32* %2
%22 = srem i32 %21, 10
%23 = add nsw i32 %22, 48
%24 = call i32 @putchar(i32 %23)
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [29 x i8] c"inside second check n = %d;\0A\00"
@.str.1 = [22 x i8] c"at this step n = %d;\0A\00"
@str = [2 x i8] c"\0A\00"
define void @printd(i32 %0) {
%2 = icmp slt i32 %0, 0
br i1 %2, label %3, label %6
3: ; preds = %1
%4 = tail call i32 @putchar(i32 45)
%5 = sub nsw i32 0, %0
br label %6
6: ; preds = %3, %1
%7 = phi i32 [ %5, %3 ], [ %0, %1 ]
%8 = icmp ult i32 %7, 10
br i1 %8, label %12, label %9
9: ; preds = %6
%10 = udiv i32 %7, 10
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0), i32 %7)
tail call void @printd(i32 %10)
br label %12
12: ; preds = %9, %6
%13 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i32 %7)
%14 = urem i32 %7, 10
%15 = or i32 %14, 48
%16 = tail call i32 @putchar(i32 %15)
%17 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @str, i64 0, i64 0))
ret void
}