#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*/ scanf(char *, int *);
int main() {
  int n, r, nn;
  printf("\nEnter an integer > ");
  scanf("%d", &n);
  while (n) {
    if (n < 0) {
      n = -n;
      while (n) {
        r = n % 10;
        nn = n / 10;
        if (n < 10) {
          printf("\n-%d", r);
        } else if (n >= 10) {
          printf("\n%d", r);
        }
        n = nn;
      }
    } else {
      r = n % 10;
      nn = n / 10;
      n = nn;
      printf("\n%d", r);
    }
  }
  printf("\nThat's all, have a nice day!\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xed7(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
cmpl   $0x0,-0x8(%rbp)
je     1217 <main+0xf7>
cmpl   $0x0,-0x8(%rbp)
jge    11df <main+0xbf>
xor    %eax,%eax
sub    -0x8(%rbp),%eax
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
je     11da <main+0xba>
mov    -0x8(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %edx,-0xc(%rbp)
mov    -0x8(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,-0x10(%rbp)
cmpl   $0xa,-0x8(%rbp)
jge    11af <main+0x8f>
mov    -0xc(%rbp),%esi
lea    0xe72(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11cf <main+0xaf>
cmpl   $0xa,-0x8(%rbp)
jl     11ca <main+0xaa>
mov    -0xc(%rbp),%esi
lea    0xe57(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11cf <main+0xaf>
mov    -0x10(%rbp),%eax
mov    %eax,-0x8(%rbp)
jmp    1169 <main+0x49>
jmp    1212 <main+0xf2>
mov    -0x8(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %edx,-0xc(%rbp)
mov    -0x8(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0xc(%rbp),%esi
lea    0xe0f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    114d <main+0x2d>
lea    0xe00(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x10,%rsp
lea    0xebc(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xec9(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1050 <scanf@plt>
mov    0xc(%rsp),%ebx
test   %ebx,%ebx
je     1204 <main+0xd4>
lea    0xea6(%rip),%r15
lea    0xea4(%rip),%r14
mov    $0xcccccccd,%r12d
jmp    11aa <main+0x7a>
xchg   %ax,%ax
mov    %ebx,%eax
imul   %r12,%rax
shr    $0x23,%rax
lea    (%rax,%rax,1),%ecx
lea    (%rcx,%rcx,4),%ecx
sub    %ecx,%ebx
mov    %eax,0xc(%rsp)
mov    %r14,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0xc(%rsp),%ebx
test   %ebx,%ebx
je     1204 <main+0xd4>
test   %ebx,%ebx
jns    1180 <main+0x50>
neg    %ebx
mov    %ebx,0xc(%rsp)
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movslq %ebx,%r13
imul   $0x66666667,%r13,%rbx
mov    %rbx,%rax
shr    $0x3f,%rax
sar    $0x22,%rbx
add    %eax,%ebx
lea    (%rbx,%rbx,1),%eax
lea    (%rax,%rax,4),%eax
mov    %r13d,%esi
sub    %eax,%esi
cmp    $0xa,%r13d
mov    %r14,%rdi
cmovl  %r15,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %ebx,0xc(%rsp)
add    $0x9,%r13d
cmp    $0x13,%r13d
jae    11c0 <main+0x90>
jmp    11a6 <main+0x76>
lea    0xe13(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [21 x i8] c"\0AEnter an integer > \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [5 x i8] c"\0A-%d\00"
@.str.3 = [4 x i8] c"\0A%d\00"
@.str.4 = [31 x i8] c"\0AThat's all, have a nice day!\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
br label %7
7: ; preds = %47, %0
%8 = load i32, i32* %2
%9 = icmp ne i32 %8, 0
br i1 %9, label %10, label %48
10: ; preds = %7
%11 = load i32, i32* %2
%12 = icmp slt i32 %11, 0
br i1 %12, label %13, label %39
13: ; preds = %10
%14 = load i32, i32* %2
%15 = sub nsw i32 0, %14
store i32 %15, i32* %2
br label %16
16: ; preds = %36, %13
%17 = load i32, i32* %2
%18 = icmp ne i32 %17, 0
br i1 %18, label %19, label %38
19: ; preds = %16
%20 = load i32, i32* %2
%21 = srem i32 %20, 10
store i32 %21, i32* %3
%22 = load i32, i32* %2
%23 = sdiv i32 %22, 10
store i32 %23, i32* %4
%24 = load i32, i32* %2
%25 = icmp slt i32 %24, 10
br i1 %25, label %26, label %29
26: ; preds = %19
%27 = load i32, i32* %3
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 %27)
br label %36
29: ; preds = %19
%30 = load i32, i32* %2
%31 = icmp sge i32 %30, 10
br i1 %31, label %32, label %35
32: ; preds = %29
%33 = load i32, i32* %3
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %33)
br label %35
35: ; preds = %32, %29
br label %36
36: ; preds = %35, %26
%37 = load i32, i32* %4
store i32 %37, i32* %2
br label %16
38: ; preds = %16
br label %47
39: ; preds = %10
%40 = load i32, i32* %2
%41 = srem i32 %40, 10
store i32 %41, i32* %3
%42 = load i32, i32* %2
%43 = sdiv i32 %42, 10
store i32 %43, i32* %4
%44 = load i32, i32* %4
store i32 %44, i32* %2
%45 = load i32, i32* %3
%46 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %45)
br label %47
47: ; preds = %39, %38
br label %7
48: ; preds = %7
%49 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.4, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str = [21 x i8] c"\0AEnter an integer > \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [5 x i8] c"\0A-%d\00"
@.str.3 = [4 x i8] c"\0A%d\00"
@str = [30 x i8] c"\0AThat's all, have a nice day!\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%5 = load i32, i32* %1
%6 = icmp eq i32 %5, 0
br i1 %6, label %29, label %7
7: ; preds = %0, %26
%8 = phi i32 [ %27, %26 ], [ %5, %0 ]
%9 = icmp slt i32 %8, 0
br i1 %9, label %10, label %21
10: ; preds = %7
%11 = sub nsw i32 0, %8
store i32 %11, i32* %1
br label %12
12: ; preds = %10, %12
%13 = phi i32 [ %15, %12 ], [ %11, %10 ]
%14 = srem i32 %13, 10
%15 = sdiv i32 %13, 10
%16 = icmp slt i32 %13, 10
%17 = select i1 %16, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0)
%18 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) %17, i32 %14)
store i32 %15, i32* %1
%19 = add i32 %13, 9
%20 = icmp ult i32 %19, 19
br i1 %20, label %26, label %12
21: ; preds = %7
%22 = urem i32 %8, 10
%23 = udiv i32 %8, 10
store i32 %23, i32* %1
%24 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %22)
%25 = load i32, i32* %1
br label %26
26: ; preds = %12, %21
%27 = phi i32 [ %25, %21 ], [ %15, %12 ]
%28 = icmp eq i32 %27, 0
br i1 %28, label %29, label %7
29: ; preds = %26, %0
%30 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @str, i64 0, i64 0))
ret i32 0
}