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


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xea2(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xea9(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1060 <scanf@plt>
lea    0xebc(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x8(%rbp),%edi
call   1030 <abs@plt>
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%edi
call   1070 <log10@plt>
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
call   1040 <ceil@plt>
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x18(%rbp)
movsd  -0x18(%rbp),%xmm0
divsd  -0x18(%rbp),%xmm0
movsd  0xe38(%rip),%xmm1
ucomisd %xmm1,%xmm0
jne    11ea <main+0x9a>
jp     11ea <main+0x9a>
movsd  0xe20(%rip),%xmm0
addsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
jmp    11ef <main+0x9f>
cmpl   $0x0,-0x8(%rbp)
je     1252 <main+0x102>
mov    -0x8(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %edx,-0x10(%rbp)
mov    -0x8(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jne    1235 <main+0xe5>
mov    -0x10(%rbp),%esi
lea    0xdf7(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    124d <main+0xfd>
mov    -0x10(%rbp),%edi
call   1030 <abs@plt>
mov    %eax,%esi
lea    0xdda(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    11ef <main+0x9f>
lea    0xdcb(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
lea    0xe94(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xe9b(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1070 <scanf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    0xc(%rsp),%eax
mov    %eax,%edi
neg    %edi
cmovs  %eax,%edi
call   1080 <log10@plt>
call   1050 <ceil@plt>
mov    0xc(%rsp),%eax
test   %eax,%eax
je     1206 <main+0xa6>
lea    0xe66(%rip),%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
cltq
imul   $0x66666667,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x22,%rcx
add    %edx,%ecx
lea    (%rcx,%rcx,1),%edx
lea    (%rdx,%rdx,4),%edx
mov    %eax,%edi
sub    %edx,%edi
add    $0x9,%eax
mov    %edi,%esi
neg    %esi
cmovs  %edi,%esi
mov    %ecx,0xc(%rsp)
cmp    $0x13,%eax
cmovb  %edi,%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0xc(%rsp),%eax
test   %eax,%eax
jne    11c0 <main+0x60>
lea    0xe0f(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
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 double
store i32 0, i32* %1
%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 = call i32 @abs(i32 %9)
store i32 %10, i32* %3
%11 = load i32, i32* %3
%12 = call double @log10(i32 %11)
store double %12, double* %5
%13 = load double, double* %5
%14 = call i64 @ceil(double %13)
%15 = trunc i64 %14 to i32
%16 = sitofp i32 %15 to double
store double %16, double* %5
%17 = load double, double* %5
%18 = load double, double* %5
%19 = fdiv double %17, %18
%20 = fcmp oeq double %19, 1.000000e+00
br i1 %20, label %21, label %24
21: ; preds = %0
%22 = load double, double* %5
%23 = fadd double %22, 1.000000e+00
store double %23, double* %5
br label %24
24: ; preds = %21, %0
br label %25
25: ; preds = %42, %24
%26 = load i32, i32* %2
%27 = icmp ne i32 %26, 0
br i1 %27, label %28, label %43
28: ; preds = %25
%29 = load i32, i32* %2
%30 = srem i32 %29, 10
store i32 %30, i32* %4
%31 = load i32, i32* %2
%32 = sdiv i32 %31, 10
store i32 %32, i32* %2
%33 = load i32, i32* %2
%34 = icmp eq i32 %33, 0
br i1 %34, label %35, label %38
35: ; preds = %28
%36 = load i32, i32* %4
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %36)
br label %42
38: ; preds = %28
%39 = load i32, i32* %4
%40 = call i32 @abs(i32 %39)
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %40)
br label %42
42: ; preds = %38, %35
br label %25
43: ; preds = %25
%44 = 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 = call i32 @llvm.abs.i32(i32 %6, i1 true)
%8 = call double @log10(i32 %7)
%9 = call i64 @ceil(double %8)
%10 = load i32, i32* %1
%11 = icmp eq i32 %10, 0
br i1 %11, label %23, label %12
12: ; preds = %0, %12
%13 = phi i32 [ %21, %12 ], [ %10, %0 ]
%14 = srem i32 %13, 10
%15 = sdiv i32 %13, 10
store i32 %15, i32* %1
%16 = add i32 %13, 9
%17 = icmp ult i32 %16, 19
%18 = call i32 @llvm.abs.i32(i32 %14, i1 true)
%19 = select i1 %17, i32 %14, i32 %18
%20 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %19)
%21 = load i32, i32* %1
%22 = icmp eq i32 %21, 0
br i1 %22, label %23, label %12
23: ; preds = %12, %0
%24 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @str, i64 0, i64 0))
ret i32 0
}