#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);
double 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 = ceil(i);
  while (n != 0) {
    digit = n % 10;
    n = n / 10;
    if (i != 1)
      printf("%d\n", abs(digit));
    if (i == 1)
      printf("%d\n", digit);
    i -= 1.00;
  }
  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>
movsd  %xmm0,-0x18(%rbp)
cmpl   $0x0,-0x8(%rbp)
je     125b <main+0x10b>
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)
movsd  -0x18(%rbp),%xmm0
movsd  0xe1b(%rip),%xmm1
ucomisd %xmm1,%xmm0
jne    11fa <main+0xaa>
jp     11fa <main+0xaa>
jmp    1212 <main+0xc2>
mov    -0x10(%rbp),%edi
call   1030 <abs@plt>
mov    %eax,%esi
lea    0xe15(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movsd  -0x18(%rbp),%xmm0
movsd  0xde1(%rip),%xmm1
ucomisd %xmm1,%xmm0
jne    1240 <main+0xf0>
jp     1240 <main+0xf0>
mov    -0x10(%rbp),%esi
lea    0xde7(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movsd  -0x18(%rbp),%xmm0
movsd  0xdb3(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
jmp    11b2 <main+0x62>
lea    0xdc2(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x18,%rsp
lea    0xea2(%rip),%rdi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xea9(%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>
mov    0xc(%rsp),%ebx
test   %ebx,%ebx
je     123c <main+0xdc>
call   1050 <ceil@plt>
lea    0xe70(%rip),%r14
jmp    11d0 <main+0x70>
nopw   0x0(%rax,%rax,1)
addsd  0xe40(%rip),%xmm0
mov    0xc(%rsp),%ebx
test   %ebx,%ebx
je     123c <main+0xdc>
movslq %ebx,%rbx
imul   $0x66666667,%rbx,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x22,%rax
add    %ecx,%eax
lea    (%rax,%rax,1),%ecx
lea    (%rcx,%rcx,4),%ecx
sub    %ecx,%ebx
mov    %eax,0xc(%rsp)
ucomisd 0xe05(%rip),%xmm0
movsd  %xmm0,0x10(%rsp)
jne    1205 <main+0xa5>
jnp    121c <main+0xbc>
mov    %ebx,%esi
neg    %esi
cmovs  %ebx,%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
movsd  0x10(%rsp),%xmm0
ucomisd 0xddc(%rip),%xmm0
jne    11c0 <main+0x60>
jp     11c0 <main+0x60>
mov    %r14,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1060 <printf@plt>
movsd  0x10(%rsp),%xmm0
jmp    11c0 <main+0x60>
lea    0xde9(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
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 double @llvm.ceil.f64(double %13)
store double %14, double* %5
br label %15
15: ; preds = %35, %0
%16 = load i32, i32* %2
%17 = icmp ne i32 %16, 0
br i1 %17, label %18, label %38
18: ; preds = %15
%19 = load i32, i32* %2
%20 = srem i32 %19, 10
store i32 %20, i32* %4
%21 = load i32, i32* %2
%22 = sdiv i32 %21, 10
store i32 %22, i32* %2
%23 = load double, double* %5
%24 = fcmp une double %23, 1.000000e+00
br i1 %24, label %25, label %29
25: ; preds = %18
%26 = load i32, i32* %4
%27 = call i32 @abs(i32 %26)
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %27)
br label %29
29: ; preds = %25, %18
%30 = load double, double* %5
%31 = fcmp oeq double %30, 1.000000e+00
br i1 %31, label %32, label %35
32: ; preds = %29
%33 = load i32, i32* %4
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %33)
br label %35
35: ; preds = %32, %29
%36 = load double, double* %5
%37 = fsub double %36, 1.000000e+00
store double %37, double* %5
br label %15
38: ; preds = %15
%39 = 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 = load i32, i32* %1
%10 = icmp eq i32 %9, 0
br i1 %10, label %30, label %11
11: ; preds = %0
%12 = call double @llvm.ceil.f64(double %8)
br label %13
13: ; preds = %11, %26
%14 = phi i32 [ %28, %26 ], [ %9, %11 ]
%15 = phi double [ %27, %26 ], [ %12, %11 ]
%16 = srem i32 %14, 10
%17 = sdiv i32 %14, 10
store i32 %17, i32* %1
%18 = fcmp une double %15, 1.000000e+00
br i1 %18, label %19, label %22
19: ; preds = %13
%20 = call i32 @llvm.abs.i32(i32 %16, i1 true)
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %20)
br label %22
22: ; preds = %19, %13
%23 = fcmp oeq double %15, 1.000000e+00
br i1 %23, label %24, label %26
24: ; preds = %22
%25 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %16)
br label %26
26: ; preds = %24, %22
%27 = fadd double %15, -1.000000e+00
%28 = load i32, i32* %1
%29 = icmp eq i32 %28, 0
br i1 %29, label %30, label %13
30: ; preds = %26, %0
%31 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @str, i64 0, i64 0))
ret i32 0
}