#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 abs(int);
int pow(int, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
int main(void) {
  int n, a, nn, nnn, count, digit;
  printf("\nEnter an integer > ");
  scanf("%d", &n);
  nnn = n;
  n = abs(n);
  nn = n;
  a = 1;
  count = 0;
  if (n == 0)
    ;
  printf("\n0\n");
  while (nn != 0) {
    nn = nn / 10;
    count = count + 1;
  }
  while (a <= count) {
    digit = n % (int)pow(10, a);
    if ((digit < 10) && (a == 1))
      printf("\n%d\n", digit);
    else if ((digit >= 10) || (digit == 0)) {
      digit = digit / pow(10, a - 1);
      if ((((a) == count)) && (nnn < 0)) {
        digit = digit * -1;
        printf("%d\n", digit);
      } else
        printf("%d\n", digit);
    }
    n = n - digit;
    a = a + 1;
  }
  printf("That's all, have a nice day!\n");
  return (0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeaa(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xeb1(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1050 <scanf@plt>
mov    -0x8(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%edi
call   1030 <abs@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x10(%rbp)
movl   $0x1,-0xc(%rbp)
movl   $0x0,-0x18(%rbp)
cmpl   $0x0,-0x8(%rbp)
jne    11a1 <main+0x61>
jmp    11a1 <main+0x61>
lea    0xe70(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
cmpl   $0x0,-0x10(%rbp)
je     11d5 <main+0x95>
mov    -0x10(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,-0x10(%rbp)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    11af <main+0x6f>
jmp    11da <main+0x9a>
mov    -0xc(%rbp),%eax
cmp    -0x18(%rbp),%eax
jg     12c8 <main+0x188>
mov    -0x8(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0xc(%rbp),%esi
mov    $0xa,%edi
call   1060 <pow@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%eax
cltd
idiv   %ecx
mov    %edx,-0x1c(%rbp)
cmpl   $0xa,-0x1c(%rbp)
jge    122e <main+0xee>
cmpl   $0x1,-0xc(%rbp)
jne    122e <main+0xee>
mov    -0x1c(%rbp),%esi
lea    0xdfa(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    12b1 <main+0x171>
cmpl   $0xa,-0x1c(%rbp)
jge    1242 <main+0x102>
cmpl   $0x0,-0x1c(%rbp)
jne    12ac <main+0x16c>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0xc(%rbp),%esi
sub    $0x1,%esi
mov    $0xa,%edi
call   1060 <pow@plt>
mov    %eax,%ecx
mov    -0x24(%rbp),%eax
cltd
idiv   %ecx
mov    %eax,-0x1c(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x18(%rbp),%eax
jne    1296 <main+0x156>
cmpl   $0x0,-0x14(%rbp)
jge    1296 <main+0x156>
imul   $0xffffffff,-0x1c(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%esi
lea    0xd93(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    12a7 <main+0x167>
mov    -0x1c(%rbp),%esi
lea    0xd7d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    12ac <main+0x16c>
jmp    12b1 <main+0x171>
mov    -0x8(%rbp),%eax
sub    -0x1c(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    11da <main+0x9a>
lea    0xd52(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0xeae(%rip),%rdi
xor    %r14d,%r14d
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xeb2(%rip),%rdi
mov    %rsp,%rsi
call   1050 <scanf@plt>
mov    (%rsp),%ebp
mov    %ebp,%ebx
neg    %ebx
cmovs  %ebp,%ebx
mov    %ebx,(%rsp)
lea    0xe9e(%rip),%rdi
call   1030 <puts@plt>
mov    %ebp,0x4(%rsp)
test   %ebp,%ebp
je     124a <main+0x10a>
movslq %ebx,%rax
imul   $0x66666667,%rax,%rbx
mov    %rbx,%rcx
shr    $0x3f,%rcx
sar    $0x22,%rbx
add    %ecx,%ebx
add    $0x9,%eax
add    $0xffffffff,%r14d
cmp    $0x13,%eax
jae    1190 <main+0x50>
mov    (%rsp),%ebp
mov    %r14d,%r15d
neg    %r15d
not    %r14d
xor    %r12d,%r12d
jmp    11ed <main+0xad>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
lea    0xe41(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    (%rsp),%ebp
sub    %ebx,%ebp
mov    %ebp,(%rsp)
cmp    %r12d,%r15d
je     124a <main+0x10a>
mov    %r12d,%r13d
lea    0x1(%r13),%r12d
mov    $0xa,%edi
mov    %r12d,%esi
call   1060 <pow@plt>
mov    %eax,%ecx
mov    %ebp,%eax
cltd
idiv   %ecx
mov    %edx,%ebx
cmp    $0x9,%edx
jg     1214 <main+0xd4>
test   %r13d,%r13d
je     11d0 <main+0x90>
cmp    $0x9,%ebx
jg     121d <main+0xdd>
test   %ebx,%ebx
jne    11e0 <main+0xa0>
mov    $0xa,%edi
mov    %r13d,%esi
call   1060 <pow@plt>
mov    %eax,%ecx
mov    %ebx,%eax
cltd
idiv   %ecx
mov    %eax,%ebx
cmp    %r13d,%r14d
jne    1241 <main+0x101>
cmpl   $0x0,0x4(%rsp)
jns    1241 <main+0x101>
neg    %ebx
lea    0xdd1(%rip),%rdi
jmp    11d7 <main+0x97>
lea    0xdcf(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [21 x i8] c"\0AEnter an integer > \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [4 x i8] c"\0A0\0A\00"
@.str.3 = [5 x i8] c"\0A%d\0A\00"
@.str.4 = [4 x i8] c"%d\0A\00"
@.str.5 = [30 x i8] c"That's all, have a nice day!\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32 0, i32* %1
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%10 = load i32, i32* %2
store i32 %10, i32* %5
%11 = load i32, i32* %2
%12 = call i32 @abs(i32 %11)
store i32 %12, i32* %2
%13 = load i32, i32* %2
store i32 %13, i32* %4
store i32 1, i32* %3
store i32 0, i32* %6
%14 = load i32, i32* %2
%15 = icmp eq i32 %14, 0
br i1 %15, label %16, label %17
16: ; preds = %0
br label %17
17: ; preds = %16, %0
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
br label %19
19: ; preds = %22, %17
%20 = load i32, i32* %4
%21 = icmp ne i32 %20, 0
br i1 %21, label %22, label %27
22: ; preds = %19
%23 = load i32, i32* %4
%24 = sdiv i32 %23, 10
store i32 %24, i32* %4
%25 = load i32, i32* %6
%26 = add nsw i32 %25, 1
store i32 %26, i32* %6
br label %19
27: ; preds = %19
br label %28
28: ; preds = %73, %27
%29 = load i32, i32* %3
%30 = load i32, i32* %6
%31 = icmp sle i32 %29, %30
br i1 %31, label %32, label %79
32: ; preds = %28
%33 = load i32, i32* %2
%34 = load i32, i32* %3
%35 = call i32 @pow(i32 10, i32 %34)
%36 = srem i32 %33, %35
store i32 %36, i32* %7
%37 = load i32, i32* %7
%38 = icmp slt i32 %37, 10
br i1 %38, label %39, label %45
39: ; preds = %32
%40 = load i32, i32* %3
%41 = icmp eq i32 %40, 1
br i1 %41, label %42, label %45
42: ; preds = %39
%43 = load i32, i32* %7
%44 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32 %43)
br label %73
45: ; preds = %39, %32
%46 = load i32, i32* %7
%47 = icmp sge i32 %46, 10
br i1 %47, label %51, label %48
48: ; preds = %45
%49 = load i32, i32* %7
%50 = icmp eq i32 %49, 0
br i1 %50, label %51, label %72
51: ; preds = %48, %45
%52 = load i32, i32* %7
%53 = load i32, i32* %3
%54 = sub nsw i32 %53, 1
%55 = call i32 @pow(i32 10, i32 %54)
%56 = sdiv i32 %52, %55
store i32 %56, i32* %7
%57 = load i32, i32* %3
%58 = load i32, i32* %6
%59 = icmp eq i32 %57, %58
br i1 %59, label %60, label %68
60: ; preds = %51
%61 = load i32, i32* %5
%62 = icmp slt i32 %61, 0
br i1 %62, label %63, label %68
63: ; preds = %60
%64 = load i32, i32* %7
%65 = mul nsw i32 %64, -1
store i32 %65, i32* %7
%66 = load i32, i32* %7
%67 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %66)
br label %71
68: ; preds = %60, %51
%69 = load i32, i32* %7
%70 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %69)
br label %71
71: ; preds = %68, %63
br label %72
72: ; preds = %71, %48
br label %73
73: ; preds = %72, %42
%74 = load i32, i32* %2
%75 = load i32, i32* %7
%76 = sub nsw i32 %74, %75
store i32 %76, i32* %2
%77 = load i32, i32* %3
%78 = add nsw i32 %77, 1
store i32 %78, i32* %3
br label %28
79: ; preds = %28
%80 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 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.3 = [5 x i8] c"\0A%d\0A\00"
@.str.4 = [4 x i8] c"%d\0A\00"
@str = [3 x i8] c"\0A0\00"
@str.6 = [29 x i8] c"That'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 = call i32 @llvm.abs.i32(i32 %5, i1 true)
store i32 %6, i32* %1
%7 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @str, i64 0, i64 0))
%8 = icmp eq i32 %5, 0
br i1 %8, label %50, label %12
9: ; preds = %12
%10 = icmp slt i32 %5, 0
%11 = load i32, i32* %1
br label %19
12: ; preds = %0, %12
%13 = phi i32 [ %16, %12 ], [ 0, %0 ]
%14 = phi i32 [ %15, %12 ], [ %6, %0 ]
%15 = sdiv i32 %14, 10
%16 = add nuw nsw i32 %13, 1
%17 = add i32 %14, 9
%18 = icmp ult i32 %17, 19
br i1 %18, label %9, label %12
19: ; preds = %9, %44
%20 = phi i32 [ %11, %9 ], [ %47, %44 ]
%21 = phi i32 [ 1, %9 ], [ %48, %44 ]
%22 = call i32 @pow(i32 10, i32 %21)
%23 = srem i32 %20, %22
%24 = icmp slt i32 %23, 10
%25 = icmp eq i32 %21, 1
%26 = and i1 %24, %25
br i1 %26, label %27, label %29
27: ; preds = %19
%28 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32 %23)
br label %44
29: ; preds = %19
%30 = icmp sgt i32 %23, 9
%31 = icmp eq i32 %23, 0
%32 = or i1 %30, %31
br i1 %32, label %33, label %44
33: ; preds = %29
%34 = add nsw i32 %21, -1
%35 = call i32 @pow(i32 10, i32 %34)
%36 = sdiv i32 %23, %35
%37 = icmp eq i32 %21, %16
%38 = select i1 %37, i1 %10, i1 false
br i1 %38, label %39, label %42
39: ; preds = %33
%40 = sub nsw i32 0, %36
%41 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %40)
br label %44
42: ; preds = %33
%43 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %36)
br label %44
44: ; preds = %29, %42, %39, %27
%45 = phi i32 [ %23, %27 ], [ %40, %39 ], [ %36, %42 ], [ %23, %29 ]
%46 = load i32, i32* %1
%47 = sub nsw i32 %46, %45
store i32 %47, i32* %1
%48 = add nuw i32 %21, 1
%49 = icmp eq i32 %21, %16
br i1 %49, label %50, label %19
50: ; preds = %44, %0
%51 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @str.6, i64 0, i64 0))
ret i32 0
}