int main() {
  int n, digit;
  printf("Enter an integer > ");
  scanf("%d", &n);
  if (n == 0) {
    printf("\n0");
    printf("\nThat's all, have a nice day!\n");
    return (0);
  }
  while (abs(n) > 0) {
    if (n > 0) {
      digit = n % 10;
      printf("\n%d", digit);
      n = n / 10.0;
    } else if (n < 0 && (n / 10.0) < (-1.0)) {
      digit = abs(n % 10);
      printf("\n%d", digit);
      n = n / 10.0;
    } else if (n < 0 && (n / 10.0) > (-1.0)) {
      digit = n % 10;
      printf("\n%d", digit);
      n = (n) / 10.0;
    }
  }
  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   1040 <printf@plt>
lea    0xef3(%rip),%rdi
lea    -0x8(%rbp),%rsi
mov    $0x0,%al
call   1050 <scanf@plt>
cmpl   $0x0,-0x8(%rbp)
jne    1191 <main+0x61>
lea    0xeb4(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xea9(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    12e5 <main+0x1b5>
jmp    1196 <main+0x66>
mov    -0x8(%rbp),%edi
call   1030 <abs@plt>
cmp    $0x0,%eax
jle    12d0 <main+0x1a0>
cmpl   $0x0,-0x8(%rbp)
jle    11ed <main+0xbd>
mov    -0x8(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %edx,-0xc(%rbp)
mov    -0xc(%rbp),%esi
lea    0xe7d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
cvtsi2sdl -0x8(%rbp),%xmm0
movsd  0xe2b(%rip),%xmm1
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,-0x8(%rbp)
jmp    12cb <main+0x19b>
cmpl   $0x0,-0x8(%rbp)
jge    125d <main+0x12d>
cvtsi2sdl -0x8(%rbp),%xmm1
movsd  0xe04(%rip),%xmm0
divsd  %xmm0,%xmm1
movsd  0xdf0(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    125d <main+0x12d>
mov    -0x8(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %edx,%edi
call   1030 <abs@plt>
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%esi
lea    0xe0d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
cvtsi2sdl -0x8(%rbp),%xmm0
movsd  0xdbb(%rip),%xmm1
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,-0x8(%rbp)
jmp    12c6 <main+0x196>
cmpl   $0x0,-0x8(%rbp)
jge    12c1 <main+0x191>
cvtsi2sdl -0x8(%rbp),%xmm0
movsd  0xd94(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  0xd80(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    12c1 <main+0x191>
mov    -0x8(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %edx,-0xc(%rbp)
mov    -0xc(%rbp),%esi
lea    0xda4(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
cvtsi2sdl -0x8(%rbp),%xmm0
movsd  0xd52(%rip),%xmm1
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,-0x8(%rbp)
jmp    12c6 <main+0x196>
jmp    12cb <main+0x19b>
jmp    1196 <main+0x66>
lea    0xd50(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
lea    0xed5(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xedf(%rip),%rdi
lea    0x4(%rsp),%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
mov    0x4(%rsp),%esi
test   %esi,%esi
je     1207 <main+0xd7>
mov    $0xcccccccd,%r14d
lea    0xeb9(%rip),%rbx
movsd  0xe8a(%rip),%xmm1
movsd  0xe8a(%rip),%xmm2
xchg   %ax,%ax
test   %esi,%esi
jle    1190 <main+0x60>
mov    %esi,%eax
jmp    11a6 <main+0x76>
nopl   0x0(%rax,%rax,1)
xorps  %xmm0,%xmm0
cvtsi2sd %esi,%xmm0
divsd  %xmm1,%xmm0
ucomisd %xmm0,%xmm2
jbe    11ea <main+0xba>
neg    %esi
mov    %rsi,%rax
imul   %r14,%rax
shr    $0x23,%rax
add    %eax,%eax
lea    (%rax,%rax,4),%eax
sub    %eax,%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
movsd  0xe41(%rip),%xmm2
movsd  0xe31(%rip),%xmm1
xorps  %xmm0,%xmm0
cvtsi2sdl 0x4(%rsp),%xmm0
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%esi
mov    %esi,0x4(%rsp)
test   %esi,%esi
jne    1180 <main+0x50>
jmp    1215 <main+0xe5>
ucomisd %xmm2,%xmm0
jbe    11e4 <main+0xb4>
mov    %esi,%eax
neg    %eax
imul   %r14,%rax
shr    $0x23,%rax
lea    (%rax,%rax,4),%eax
lea    (%rsi,%rax,2),%esi
mov    %rbx,%rdi
jmp    11b8 <main+0x88>
lea    0xe16(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe0f(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [20 x i8] c"Enter an integer > \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [3 x i8] c"\0A0\00"
@.str.3 = [31 x i8] c"\0AThat's all, have a nice day!\0A\00"
@.str.4 = [4 x i8] c"\0A%d\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
store i32 0, i32* %1
%4 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
%5 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%6 = load i32, i32* %2
%7 = icmp eq i32 %6, 0
br i1 %7, label %8, label %11
8: ; preds = %0
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0))
store i32 0, i32* %1
br label %68
11: ; preds = %0
br label %12
12: ; preds = %65, %11
%13 = load i32, i32* %2
%14 = call i32 @abs(i32 %13)
%15 = icmp sgt i32 %14, 0
br i1 %15, label %16, label %66
16: ; preds = %12
%17 = load i32, i32* %2
%18 = icmp sgt i32 %17, 0
br i1 %18, label %19, label %28
19: ; preds = %16
%20 = load i32, i32* %2
%21 = srem i32 %20, 10
store i32 %21, i32* %3
%22 = load i32, i32* %3
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %22)
%24 = load i32, i32* %2
%25 = sitofp i32 %24 to double
%26 = fdiv double %25, 1.000000e+01
%27 = fptosi double %26 to i32
store i32 %27, i32* %2
br label %65
28: ; preds = %16
%29 = load i32, i32* %2
%30 = icmp slt i32 %29, 0
br i1 %30, label %31, label %46
31: ; preds = %28
%32 = load i32, i32* %2
%33 = sitofp i32 %32 to double
%34 = fdiv double %33, 1.000000e+01
%35 = fcmp olt double %34, -1.000000e+00
br i1 %35, label %36, label %46
36: ; preds = %31
%37 = load i32, i32* %2
%38 = srem i32 %37, 10
%39 = call i32 @abs(i32 %38)
store i32 %39, i32* %3
%40 = load i32, i32* %3
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %40)
%42 = load i32, i32* %2
%43 = sitofp i32 %42 to double
%44 = fdiv double %43, 1.000000e+01
%45 = fptosi double %44 to i32
store i32 %45, i32* %2
br label %64
46: ; preds = %31, %28
%47 = load i32, i32* %2
%48 = icmp slt i32 %47, 0
br i1 %48, label %49, label %63
49: ; preds = %46
%50 = load i32, i32* %2
%51 = sitofp i32 %50 to double
%52 = fdiv double %51, 1.000000e+01
%53 = fcmp ogt double %52, -1.000000e+00
br i1 %53, label %54, label %63
54: ; preds = %49
%55 = load i32, i32* %2
%56 = srem i32 %55, 10
store i32 %56, i32* %3
%57 = load i32, i32* %3
%58 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %57)
%59 = load i32, i32* %2
%60 = sitofp i32 %59 to double
%61 = fdiv double %60, 1.000000e+01
%62 = fptosi double %61 to i32
store i32 %62, i32* %2
br label %63
63: ; preds = %54, %49, %46
br label %64
64: ; preds = %63, %36
br label %65
65: ; preds = %64, %19
br label %12
66: ; preds = %12
%67 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0))
store i32 0, i32* %1
br label %68
68: ; preds = %66, %8
%69 = load i32, i32* %1
ret i32 %69
}

LLVM IR (-O2):
@.str = [20 x i8] c"Enter an integer > \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [3 x i8] c"\0A0\00"
@.str.4 = [4 x i8] c"\0A%d\00"
@str.5 = [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 ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
%4 = call i32 (i8*, ...) @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 %9
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))
br label %45
9: ; preds = %0, %42
%10 = phi i32 [ %43, %42 ], [ %5, %0 ]
%11 = icmp sgt i32 %10, 0
br i1 %11, label %12, label %19
12: ; preds = %9
%13 = urem i32 %10, 10
%14 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %13)
%15 = load i32, i32* %1
%16 = sitofp i32 %15 to double
%17 = fdiv double %16, 1.000000e+01
%18 = fptosi double %17 to i32
store i32 %18, i32* %1
br label %42
19: ; preds = %9
%20 = sitofp i32 %10 to double
%21 = fdiv double %20, 1.000000e+01
%22 = fcmp olt double %21, -1.000000e+00
br i1 %22, label %23, label %31
23: ; preds = %19
%24 = sub i32 0, %10
%25 = urem i32 %24, 10
%26 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %25)
%27 = load i32, i32* %1
%28 = sitofp i32 %27 to double
%29 = fdiv double %28, 1.000000e+01
%30 = fptosi double %29 to i32
store i32 %30, i32* %1
br label %42
31: ; preds = %19
%32 = fcmp ogt double %21, -1.000000e+00
br i1 %32, label %33, label %42
33: ; preds = %31
%34 = sub i32 0, %10
%35 = urem i32 %34, 10
%36 = sub nsw i32 0, %35
%37 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %36)
%38 = load i32, i32* %1
%39 = sitofp i32 %38 to double
%40 = fdiv double %39, 1.000000e+01
%41 = fptosi double %40 to i32
store i32 %41, i32* %1
br label %42
42: ; preds = %23, %33, %31, %12
%43 = phi i32 [ %30, %23 ], [ %41, %33 ], [ %10, %31 ], [ %18, %12 ]
%44 = icmp eq i32 %43, 0
br i1 %44, label %45, label %9
45: ; preds = %42, %7
%46 = phi i8* [ getelementptr inbounds ([30 x i8], [30 x i8]* @str.5, i64 0, i64 0), %7 ], [ getelementptr inbounds ([30 x i8], [30 x i8]* @str.5, i64 0, i64 0), %42 ]
%47 = call i32 @puts(i8* dereferenceable(1) %46)
ret i32 0
}