#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 ((nn == 0) && (count == 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,-0x10(%rbp)
jne    11b4 <main+0x74>
cmpl   $0x0,-0x18(%rbp)
jne    11b4 <main+0x74>
lea    0xe6b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11b9 <main+0x79>
cmpl   $0x0,-0x10(%rbp)
je     11df <main+0x9f>
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    11b9 <main+0x79>
jmp    11e4 <main+0xa4>
mov    -0xc(%rbp),%eax
cmp    -0x18(%rbp),%eax
jg     12d2 <main+0x192>
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    1238 <main+0xf8>
cmpl   $0x1,-0xc(%rbp)
jne    1238 <main+0xf8>
mov    -0x1c(%rbp),%esi
lea    0xdf0(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    12bb <main+0x17b>
cmpl   $0xa,-0x1c(%rbp)
jge    124c <main+0x10c>
cmpl   $0x0,-0x1c(%rbp)
jne    12b6 <main+0x176>
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    12a0 <main+0x160>
cmpl   $0x0,-0x14(%rbp)
jge    12a0 <main+0x160>
imul   $0xffffffff,-0x1c(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%esi
lea    0xd89(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    12b1 <main+0x171>
mov    -0x1c(%rbp),%esi
lea    0xd73(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    12b6 <main+0x176>
jmp    12bb <main+0x17b>
mov    -0x8(%rbp),%eax
sub    -0x1c(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    11e4 <main+0xa4>
lea    0xd48(%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),%ecx
mov    %ecx,%eax
neg    %eax
mov    %ecx,0x4(%rsp)
cmovs  %ecx,%eax
mov    %eax,(%rsp)
jae    124a <main+0x10a>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
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    (%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     1256 <main+0x116>
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    0xde9(%rip),%rdi
call   1030 <puts@plt>
lea    0xdc0(%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* %4
%15 = icmp eq i32 %14, 0
br i1 %15, label %16, label %21
16: ; preds = %0
%17 = load i32, i32* %6
%18 = icmp eq i32 %17, 0
br i1 %18, label %19, label %21
19: ; preds = %16
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
br label %21
21: ; preds = %19, %16, %0
br label %22
22: ; preds = %25, %21
%23 = load i32, i32* %4
%24 = icmp ne i32 %23, 0
br i1 %24, label %25, label %30
25: ; preds = %22
%26 = load i32, i32* %4
%27 = sdiv i32 %26, 10
store i32 %27, i32* %4
%28 = load i32, i32* %6
%29 = add nsw i32 %28, 1
store i32 %29, i32* %6
br label %22
30: ; preds = %22
br label %31
31: ; preds = %76, %30
%32 = load i32, i32* %3
%33 = load i32, i32* %6
%34 = icmp sle i32 %32, %33
br i1 %34, label %35, label %82
35: ; preds = %31
%36 = load i32, i32* %2
%37 = load i32, i32* %3
%38 = call i32 @pow(i32 10, i32 %37)
%39 = srem i32 %36, %38
store i32 %39, i32* %7
%40 = load i32, i32* %7
%41 = icmp slt i32 %40, 10
br i1 %41, label %42, label %48
42: ; preds = %35
%43 = load i32, i32* %3
%44 = icmp eq i32 %43, 1
br i1 %44, label %45, label %48
45: ; preds = %42
%46 = load i32, i32* %7
%47 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32 %46)
br label %76
48: ; preds = %42, %35
%49 = load i32, i32* %7
%50 = icmp sge i32 %49, 10
br i1 %50, label %54, label %51
51: ; preds = %48
%52 = load i32, i32* %7
%53 = icmp eq i32 %52, 0
br i1 %53, label %54, label %75
54: ; preds = %51, %48
%55 = load i32, i32* %7
%56 = load i32, i32* %3
%57 = sub nsw i32 %56, 1
%58 = call i32 @pow(i32 10, i32 %57)
%59 = sdiv i32 %55, %58
store i32 %59, i32* %7
%60 = load i32, i32* %3
%61 = load i32, i32* %6
%62 = icmp eq i32 %60, %61
br i1 %62, label %63, label %71
63: ; preds = %54
%64 = load i32, i32* %5
%65 = icmp slt i32 %64, 0
br i1 %65, label %66, label %71
66: ; preds = %63
%67 = load i32, i32* %7
%68 = mul nsw i32 %67, -1
store i32 %68, i32* %7
%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 %74
71: ; preds = %63, %54
%72 = load i32, i32* %7
%73 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %72)
br label %74
74: ; preds = %71, %66
br label %75
75: ; preds = %74, %51
br label %76
76: ; preds = %75, %45
%77 = load i32, i32* %2
%78 = load i32, i32* %7
%79 = sub nsw i32 %77, %78
store i32 %79, i32* %2
%80 = load i32, i32* %3
%81 = add nsw i32 %80, 1
store i32 %81, i32* %3
br label %31
82: ; preds = %31
%83 = 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 = [29 x i8] c"That's all, have a nice day!\00"
@str.6 = [3 x i8] c"\0A0\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 %8, label %13
8: ; preds = %0
%9 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @str.6, i64 0, i64 0))
br label %51
10: ; preds = %13
%11 = icmp slt i32 %5, 0
%12 = load i32, i32* %1
br label %20
13: ; preds = %0, %13
%14 = phi i32 [ %17, %13 ], [ 0, %0 ]
%15 = phi i32 [ %16, %13 ], [ %6, %0 ]
%16 = sdiv i32 %15, 10
%17 = add nuw nsw i32 %14, 1
%18 = add i32 %15, 9
%19 = icmp ult i32 %18, 19
br i1 %19, label %10, label %13
20: ; preds = %10, %45
%21 = phi i32 [ %12, %10 ], [ %48, %45 ]
%22 = phi i32 [ 1, %10 ], [ %49, %45 ]
%23 = call i32 @pow(i32 10, i32 %22)
%24 = srem i32 %21, %23
%25 = icmp slt i32 %24, 10
%26 = icmp eq i32 %22, 1
%27 = and i1 %25, %26
br i1 %27, label %28, label %30
28: ; preds = %20
%29 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32 %24)
br label %45
30: ; preds = %20
%31 = icmp sgt i32 %24, 9
%32 = icmp eq i32 %24, 0
%33 = or i1 %31, %32
br i1 %33, label %34, label %45
34: ; preds = %30
%35 = add nsw i32 %22, -1
%36 = call i32 @pow(i32 10, i32 %35)
%37 = sdiv i32 %24, %36
%38 = icmp eq i32 %22, %17
%39 = select i1 %38, i1 %11, i1 false
br i1 %39, label %40, label %43
40: ; preds = %34
%41 = sub nsw i32 0, %37
%42 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %41)
br label %45
43: ; preds = %34
%44 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %37)
br label %45
45: ; preds = %30, %43, %40, %28
%46 = phi i32 [ %24, %28 ], [ %41, %40 ], [ %37, %43 ], [ %24, %30 ]
%47 = load i32, i32* %1
%48 = sub nsw i32 %47, %46
store i32 %48, i32* %1
%49 = add nuw i32 %22, 1
%50 = icmp eq i32 %22, %17
br i1 %50, label %51, label %20
51: ; preds = %45, %8
%52 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @str, i64 0, i64 0))
ret i32 0
}