#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;
  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,-0x10(%rbp)
je     11b8 <main+0x78>
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    1192 <main+0x52>
jmp    11bd <main+0x7d>
mov    -0xc(%rbp),%eax
cmp    -0x18(%rbp),%eax
jg     12ab <main+0x16b>
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    1211 <main+0xd1>
cmpl   $0x1,-0xc(%rbp)
jne    1211 <main+0xd1>
mov    -0x1c(%rbp),%esi
lea    0xe13(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1294 <main+0x154>
cmpl   $0xa,-0x1c(%rbp)
jge    1225 <main+0xe5>
cmpl   $0x0,-0x1c(%rbp)
jne    128f <main+0x14f>
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    1279 <main+0x139>
cmpl   $0x0,-0x14(%rbp)
jge    1279 <main+0x139>
imul   $0xffffffff,-0x1c(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%esi
lea    0xdac(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    128a <main+0x14a>
mov    -0x1c(%rbp),%esi
lea    0xd96(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    128f <main+0x14f>
jmp    1294 <main+0x154>
mov    -0x8(%rbp),%eax
sub    -0x1c(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    11bd <main+0x7d>
lea    0xd6b(%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),%eax
mov    %eax,%ebp
neg    %ebp
mov    %eax,0x4(%rsp)
cmovs  %eax,%ebp
mov    %ebp,(%rsp)
jae    124a <main+0x10a>
mov    %ebp,%eax
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movslq %eax,%rcx
imul   $0x66666667,%rcx,%rax
mov    %rax,%rdx
shr    $0x3f,%rdx
sar    $0x22,%rax
add    %edx,%eax
add    $0x9,%ecx
add    $0xffffffff,%r14d
cmp    $0x13,%ecx
jae    1190 <main+0x50>
mov    %r14d,%r15d
neg    %r15d
not    %r14d
xor    %r12d,%r12d
jmp    11ed <main+0xad>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
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    0xdcc(%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 = [5 x i8] c"\0A%d\0A\00"
@.str.3 = [4 x i8] c"%d\0A\00"
@.str.4 = [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
br label %14
14: ; preds = %17, %0
%15 = load i32, i32* %4
%16 = icmp ne i32 %15, 0
br i1 %16, label %17, label %22
17: ; preds = %14
%18 = load i32, i32* %4
%19 = sdiv i32 %18, 10
store i32 %19, i32* %4
%20 = load i32, i32* %6
%21 = add nsw i32 %20, 1
store i32 %21, i32* %6
br label %14
22: ; preds = %14
br label %23
23: ; preds = %68, %22
%24 = load i32, i32* %3
%25 = load i32, i32* %6
%26 = icmp sle i32 %24, %25
br i1 %26, label %27, label %74
27: ; preds = %23
%28 = load i32, i32* %2
%29 = load i32, i32* %3
%30 = call i32 @pow(i32 10, i32 %29)
%31 = srem i32 %28, %30
store i32 %31, i32* %7
%32 = load i32, i32* %7
%33 = icmp slt i32 %32, 10
br i1 %33, label %34, label %40
34: ; preds = %27
%35 = load i32, i32* %3
%36 = icmp eq i32 %35, 1
br i1 %36, label %37, label %40
37: ; preds = %34
%38 = load i32, i32* %7
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 %38)
br label %68
40: ; preds = %34, %27
%41 = load i32, i32* %7
%42 = icmp sge i32 %41, 10
br i1 %42, label %46, label %43
43: ; preds = %40
%44 = load i32, i32* %7
%45 = icmp eq i32 %44, 0
br i1 %45, label %46, label %67
46: ; preds = %43, %40
%47 = load i32, i32* %7
%48 = load i32, i32* %3
%49 = sub nsw i32 %48, 1
%50 = call i32 @pow(i32 10, i32 %49)
%51 = sdiv i32 %47, %50
store i32 %51, i32* %7
%52 = load i32, i32* %3
%53 = load i32, i32* %6
%54 = icmp eq i32 %52, %53
br i1 %54, label %55, label %63
55: ; preds = %46
%56 = load i32, i32* %5
%57 = icmp slt i32 %56, 0
br i1 %57, label %58, label %63
58: ; preds = %55
%59 = load i32, i32* %7
%60 = mul nsw i32 %59, -1
store i32 %60, i32* %7
%61 = load i32, i32* %7
%62 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %61)
br label %66
63: ; preds = %55, %46
%64 = load i32, i32* %7
%65 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %64)
br label %66
66: ; preds = %63, %58
br label %67
67: ; preds = %66, %43
br label %68
68: ; preds = %67, %37
%69 = load i32, i32* %2
%70 = load i32, i32* %7
%71 = sub nsw i32 %69, %70
store i32 %71, i32* %2
%72 = load i32, i32* %3
%73 = add nsw i32 %72, 1
store i32 %73, i32* %3
br label %23
74: ; preds = %23
%75 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 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\0A\00"
@.str.3 = [4 x i8] c"%d\0A\00"
@str = [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 = icmp eq i32 %5, 0
br i1 %7, label %48, label %10
8: ; preds = %10
%9 = icmp slt i32 %5, 0
br label %17
10: ; preds = %0, %10
%11 = phi i32 [ %14, %10 ], [ 0, %0 ]
%12 = phi i32 [ %13, %10 ], [ %6, %0 ]
%13 = sdiv i32 %12, 10
%14 = add nuw nsw i32 %11, 1
%15 = add i32 %12, 9
%16 = icmp ult i32 %15, 19
br i1 %16, label %8, label %10
17: ; preds = %8, %42
%18 = phi i32 [ %6, %8 ], [ %45, %42 ]
%19 = phi i32 [ 1, %8 ], [ %46, %42 ]
%20 = call i32 @pow(i32 10, i32 %19)
%21 = srem i32 %18, %20
%22 = icmp slt i32 %21, 10
%23 = icmp eq i32 %19, 1
%24 = and i1 %22, %23
br i1 %24, label %25, label %27
25: ; preds = %17
%26 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 %21)
br label %42
27: ; preds = %17
%28 = icmp sgt i32 %21, 9
%29 = icmp eq i32 %21, 0
%30 = or i1 %28, %29
br i1 %30, label %31, label %42
31: ; preds = %27
%32 = add nsw i32 %19, -1
%33 = call i32 @pow(i32 10, i32 %32)
%34 = sdiv i32 %21, %33
%35 = icmp eq i32 %19, %14
%36 = select i1 %35, i1 %9, i1 false
br i1 %36, label %37, label %40
37: ; preds = %31
%38 = sub nsw i32 0, %34
%39 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %38)
br label %42
40: ; preds = %31
%41 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %34)
br label %42
42: ; preds = %27, %40, %37, %25
%43 = phi i32 [ %21, %25 ], [ %38, %37 ], [ %34, %40 ], [ %21, %27 ]
%44 = load i32, i32* %1
%45 = sub nsw i32 %44, %43
store i32 %45, i32* %1
%46 = add nuw i32 %19, 1
%47 = icmp eq i32 %19, %14
br i1 %47, label %48, label %17
48: ; preds = %42, %0
%49 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @str, i64 0, i64 0))
ret i32 0
}