#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);
  if (n == 0)
    printf("\n0");
  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    0xeda(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
cmpl   $0x0,-0x8(%rbp)
jne    1165 <main+0x45>
lea    0xeb7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    116a <main+0x4a>
cmpl   $0x0,-0x8(%rbp)
je     1234 <main+0x114>
cmpl   $0x0,-0x8(%rbp)
jge    11fc <main+0xdc>
xor    %eax,%eax
sub    -0x8(%rbp),%eax
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
je     11f7 <main+0xd7>
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    11cc <main+0xac>
mov    -0xc(%rbp),%esi
lea    0xe58(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11ec <main+0xcc>
cmpl   $0xa,-0x8(%rbp)
jl     11e7 <main+0xc7>
mov    -0xc(%rbp),%esi
lea    0xe3d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11ec <main+0xcc>
mov    -0x10(%rbp),%eax
mov    %eax,-0x8(%rbp)
jmp    1186 <main+0x66>
jmp    122f <main+0x10f>
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    0xdf5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    116a <main+0x4a>
lea    0xde6(%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    0xecc(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1050 <scanf@plt>
mov    0xc(%rsp),%ebx
test   %ebx,%ebx
jne    117e <main+0x4e>
lea    0xeaa(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0xc(%rsp),%ebx
test   %ebx,%ebx
je     1224 <main+0xf4>
lea    0xe93(%rip),%r15
lea    0xe91(%rip),%r14
mov    $0xcccccccd,%r12d
jmp    11ca <main+0x9a>
cs nopw 0x0(%rax,%rax,1)
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     1224 <main+0xf4>
test   %ebx,%ebx
jns    11a0 <main+0x70>
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    11e0 <main+0xb0>
jmp    11c6 <main+0x96>
lea    0xdf6(%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 = [3 x i8] c"\0A0\00"
@.str.3 = [5 x i8] c"\0A-%d\00"
@.str.4 = [4 x i8] c"\0A%d\00"
@.str.5 = [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)
%7 = load i32, i32* %2
%8 = icmp eq i32 %7, 0
br i1 %8, label %9, label %11
9: ; preds = %0
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
br label %11
11: ; preds = %9, %0
br label %12
12: ; preds = %52, %11
%13 = load i32, i32* %2
%14 = icmp ne i32 %13, 0
br i1 %14, label %15, label %53
15: ; preds = %12
%16 = load i32, i32* %2
%17 = icmp slt i32 %16, 0
br i1 %17, label %18, label %44
18: ; preds = %15
%19 = load i32, i32* %2
%20 = sub nsw i32 0, %19
store i32 %20, i32* %2
br label %21
21: ; preds = %41, %18
%22 = load i32, i32* %2
%23 = icmp ne i32 %22, 0
br i1 %23, label %24, label %43
24: ; preds = %21
%25 = load i32, i32* %2
%26 = srem i32 %25, 10
store i32 %26, i32* %3
%27 = load i32, i32* %2
%28 = sdiv i32 %27, 10
store i32 %28, i32* %4
%29 = load i32, i32* %2
%30 = icmp slt i32 %29, 10
br i1 %30, label %31, label %34
31: ; preds = %24
%32 = load i32, i32* %3
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32 %32)
br label %41
34: ; preds = %24
%35 = load i32, i32* %2
%36 = icmp sge i32 %35, 10
br i1 %36, label %37, label %40
37: ; preds = %34
%38 = load i32, i32* %3
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %38)
br label %40
40: ; preds = %37, %34
br label %41
41: ; preds = %40, %31
%42 = load i32, i32* %4
store i32 %42, i32* %2
br label %21
43: ; preds = %21
br label %52
44: ; preds = %15
%45 = load i32, i32* %2
%46 = srem i32 %45, 10
store i32 %46, i32* %3
%47 = load i32, i32* %2
%48 = sdiv i32 %47, 10
store i32 %48, i32* %4
%49 = load i32, i32* %4
store i32 %49, i32* %2
%50 = load i32, i32* %3
%51 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %50)
br label %52
52: ; preds = %44, %43
br label %12
53: ; preds = %12
%54 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.5, 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 = [3 x i8] c"\0A0\00"
@.str.3 = [5 x i8] c"\0A-%d\00"
@.str.4 = [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 %7, label %11
7: ; preds = %0
%8 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%9 = load i32, i32* %1
%10 = icmp eq i32 %9, 0
br i1 %10, label %35, label %11
11: ; preds = %0, %7
%12 = phi i32 [ %5, %0 ], [ %9, %7 ]
br label %13
13: ; preds = %11, %32
%14 = phi i32 [ %33, %32 ], [ %12, %11 ]
%15 = icmp slt i32 %14, 0
br i1 %15, label %16, label %27
16: ; preds = %13
%17 = sub nsw i32 0, %14
store i32 %17, i32* %1
br label %18
18: ; preds = %16, %18
%19 = phi i32 [ %21, %18 ], [ %17, %16 ]
%20 = srem i32 %19, 10
%21 = sdiv i32 %19, 10
%22 = icmp slt i32 %19, 10
%23 = select i1 %22, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0)
%24 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) %23, i32 %20)
store i32 %21, i32* %1
%25 = add i32 %19, 9
%26 = icmp ult i32 %25, 19
br i1 %26, label %32, label %18
27: ; preds = %13
%28 = urem i32 %14, 10
%29 = udiv i32 %14, 10
store i32 %29, i32* %1
%30 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %28)
%31 = load i32, i32* %1
br label %32
32: ; preds = %18, %27
%33 = phi i32 [ %31, %27 ], [ %21, %18 ]
%34 = icmp eq i32 %33, 0
br i1 %34, label %35, label %13
35: ; preds = %32, %7
%36 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @str, i64 0, i64 0))
ret i32 0
}