#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(double, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int digit, n, power = 0, i;
  printf("\nEnter an integer > ");
  scanf("%d", &digit);
  printf("\n");
  if (digit >= 0) {
    for (i = 1; i <= 10 && power <= digit; i++) {
      power = pow(10.0, i);
      n = (digit % power) / (power / 10);
      printf("%d\n", n);
    }
  } else if (digit < 0) {
    for (i = 1; i <= 10 && power <= abs(digit); i++) {
      power = pow(10.0, i);
      n = (digit % power);
      if (n <= digit) {
        n = n;
      } else {
        n = abs(n);
      }
      n = n / (power / 10);
      printf("%d\n", n);
    }
  }
  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)
movl   $0x0,-0x10(%rbp)
lea    0xeab(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xeb2(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1050 <scanf@plt>
lea    0xec5(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
cmpl   $0x0,-0x8(%rbp)
jl     1215 <main+0xd5>
movl   $0x1,-0x14(%rbp)
xor    %eax,%eax
cmpl   $0xa,-0x14(%rbp)
mov    %al,-0x15(%rbp)
jg     11ae <main+0x6e>
mov    -0x10(%rbp),%eax
cmp    -0x8(%rbp),%eax
setle  %al
mov    %al,-0x15(%rbp)
mov    -0x15(%rbp),%al
test   $0x1,%al
jne    11be <main+0x7e>
jmp    1210 <main+0xd0>
mov    -0x14(%rbp),%edi
movsd  0xe37(%rip),%xmm0
call   1060 <pow@plt>
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%eax
cltd
idivl  -0x10(%rbp)
mov    %edx,-0x1c(%rbp)
mov    -0x10(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x1c(%rbp),%eax
cltd
idiv   %ecx
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%esi
lea    0xe25(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1193 <main+0x53>
jmp    12e4 <main+0x1a4>
cmpl   $0x0,-0x8(%rbp)
jge    12df <main+0x19f>
movl   $0x1,-0x14(%rbp)
xor    %eax,%eax
cmpl   $0xa,-0x14(%rbp)
mov    %al,-0x1d(%rbp)
jg     1250 <main+0x110>
mov    -0x10(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x8(%rbp),%edi
call   1030 <abs@plt>
mov    %eax,%ecx
mov    -0x24(%rbp),%eax
cmp    %ecx,%eax
setle  %al
mov    %al,-0x1d(%rbp)
mov    -0x1d(%rbp),%al
test   $0x1,%al
jne    1260 <main+0x120>
jmp    12da <main+0x19a>
mov    -0x14(%rbp),%edi
movsd  0xd95(%rip),%xmm0
call   1060 <pow@plt>
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%eax
cltd
idivl  -0x10(%rbp)
mov    %edx,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jg     1294 <main+0x154>
mov    -0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
jmp    129f <main+0x15f>
mov    -0xc(%rbp),%edi
call   1030 <abs@plt>
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    -0x10(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x28(%rbp),%eax
cltd
idiv   %ecx
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%esi
lea    0xd5b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1226 <main+0xe6>
jmp    12df <main+0x19f>
jmp    12e4 <main+0x1a4>
lea    0xd39(%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   %r14
push   %rbx
sub    $0x10,%rsp
lea    0xea9(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xeb0(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1060 <scanf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
cmpl   $0x0,0xc(%rsp)
js     11f0 <main+0xa0>
mov    $0x1,%ebx
lea    0xe8c(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movsd  0xe58(%rip),%xmm0
mov    %ebx,%edi
call   1070 <pow@plt>
mov    %eax,%ebp
mov    0xc(%rsp),%eax
cltd
idiv   %ebp
mov    %edx,%eax
movslq %ebp,%rcx
imul   $0x66666667,%rcx,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x22,%rcx
add    %edx,%ecx
cltd
idiv   %ecx
mov    %r14,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
cmp    $0x9,%ebx
ja     1263 <main+0x113>
add    $0x1,%ebx
cmp    0xc(%rsp),%ebp
jle    11a0 <main+0x50>
jmp    1263 <main+0x113>
mov    $0x1,%ebx
lea    0xe24(%rip),%r14
nopl   0x0(%rax)
movsd  0xdf8(%rip),%xmm0
mov    %ebx,%edi
call   1070 <pow@plt>
mov    %eax,%ebp
mov    0xc(%rsp),%ecx
mov    %ecx,%eax
cltd
idiv   %ebp
mov    %edx,%eax
neg    %eax
cmovs  %edx,%eax
cmp    %ecx,%edx
cmovle %edx,%eax
movslq %ebp,%rcx
imul   $0x66666667,%rcx,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x22,%rcx
add    %edx,%ecx
cltd
idiv   %ecx
mov    %r14,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
cmp    $0xa,%ebx
je     1263 <main+0x113>
mov    0xc(%rsp),%eax
mov    %eax,%ecx
neg    %ecx
cmovs  %eax,%ecx
add    $0x1,%ebx
cmp    %ecx,%ebp
jle    1200 <main+0xb0>
lea    0xdba(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
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 = [2 x i8] c"\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
store i32 0, i32* %1
store i32 0, i32* %4
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%9 = load i32, i32* %2
%10 = icmp sge i32 %9, 0
br i1 %10, label %11, label %36
11: ; preds = %0
store i32 1, i32* %5
br label %12
12: ; preds = %32, %11
%13 = load i32, i32* %5
%14 = icmp sle i32 %13, 10
br i1 %14, label %15, label %19
15: ; preds = %12
%16 = load i32, i32* %4
%17 = load i32, i32* %2
%18 = icmp sle i32 %16, %17
br label %19
19: ; preds = %15, %12
%20 = phi i1 [ false, %12 ], [ %18, %15 ]
br i1 %20, label %21, label %35
21: ; preds = %19
%22 = load i32, i32* %5
%23 = call i32 @pow(double 1.000000e+01, i32 %22)
store i32 %23, i32* %4
%24 = load i32, i32* %2
%25 = load i32, i32* %4
%26 = srem i32 %24, %25
%27 = load i32, i32* %4
%28 = sdiv i32 %27, 10
%29 = sdiv i32 %26, %28
store i32 %29, i32* %3
%30 = load i32, i32* %3
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %30)
br label %32
32: ; preds = %21
%33 = load i32, i32* %5
%34 = add nsw i32 %33, 1
store i32 %34, i32* %5
br label %12
35: ; preds = %19
br label %76
36: ; preds = %0
%37 = load i32, i32* %2
%38 = icmp slt i32 %37, 0
br i1 %38, label %39, label %75
39: ; preds = %36
store i32 1, i32* %5
br label %40
40: ; preds = %71, %39
%41 = load i32, i32* %5
%42 = icmp sle i32 %41, 10
br i1 %42, label %43, label %48
43: ; preds = %40
%44 = load i32, i32* %4
%45 = load i32, i32* %2
%46 = call i32 @abs(i32 %45)
%47 = icmp sle i32 %44, %46
br label %48
48: ; preds = %43, %40
%49 = phi i1 [ false, %40 ], [ %47, %43 ]
br i1 %49, label %50, label %74
50: ; preds = %48
%51 = load i32, i32* %5
%52 = call i32 @pow(double 1.000000e+01, i32 %51)
store i32 %52, i32* %4
%53 = load i32, i32* %2
%54 = load i32, i32* %4
%55 = srem i32 %53, %54
store i32 %55, i32* %3
%56 = load i32, i32* %3
%57 = load i32, i32* %2
%58 = icmp sle i32 %56, %57
br i1 %58, label %59, label %61
59: ; preds = %50
%60 = load i32, i32* %3
store i32 %60, i32* %3
br label %64
61: ; preds = %50
%62 = load i32, i32* %3
%63 = call i32 @abs(i32 %62)
store i32 %63, i32* %3
br label %64
64: ; preds = %61, %59
%65 = load i32, i32* %3
%66 = load i32, i32* %4
%67 = sdiv i32 %66, 10
%68 = sdiv i32 %65, %67
store i32 %68, i32* %3
%69 = load i32, i32* %3
%70 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %69)
br label %71
71: ; preds = %64
%72 = load i32, i32* %5
%73 = add nsw i32 %72, 1
store i32 %73, i32* %5
br label %40
74: ; preds = %48
br label %75
75: ; preds = %74, %36
br label %76
76: ; preds = %75, %35
%77 = 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.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 = call i32 @putchar(i32 10)
%6 = load i32, i32* %1
%7 = icmp sgt i32 %6, -1
br i1 %7, label %8, label %21
8: ; preds = %0, %8
%9 = phi i32 [ %16, %8 ], [ 1, %0 ]
%10 = call i32 @pow(double 1.000000e+01, i32 %9)
%11 = load i32, i32* %1
%12 = srem i32 %11, %10
%13 = sdiv i32 %10, 10
%14 = sdiv i32 %12, %13
%15 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %14)
%16 = add nuw nsw i32 %9, 1
%17 = icmp ult i32 %9, 10
%18 = load i32, i32* %1
%19 = icmp sle i32 %10, %18
%20 = select i1 %17, i1 %19, i1 false
br i1 %20, label %8, label %38
21: ; preds = %0, %34
%22 = phi i32 [ %32, %34 ], [ 1, %0 ]
%23 = call i32 @pow(double 1.000000e+01, i32 %22)
%24 = load i32, i32* %1
%25 = srem i32 %24, %23
%26 = icmp sgt i32 %25, %24
%27 = call i32 @llvm.abs.i32(i32 %25, i1 true)
%28 = select i1 %26, i32 %27, i32 %25
%29 = sdiv i32 %23, 10
%30 = sdiv i32 %28, %29
%31 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %30)
%32 = add nuw nsw i32 %22, 1
%33 = icmp eq i32 %32, 11
br i1 %33, label %38, label %34
34: ; preds = %21
%35 = load i32, i32* %1
%36 = call i32 @llvm.abs.i32(i32 %35, i1 true)
%37 = icmp sgt i32 %23, %36
br i1 %37, label %38, label %21
38: ; preds = %21, %34, %8
%39 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @str, i64 0, i64 0))
ret i32 0
}