#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 (i != 1)
      printf("%d\n", abs(digit));
    if (i == 1)
      printf("%d\n", digit);
    i--;
  }
  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    0xeaa(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xeb1(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1060 <scanf@plt>
lea    0xec4(%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     1294 <main+0x144>
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  0xdde(%rip),%xmm1
ucomisd %xmm1,%xmm0
jne    1237 <main+0xe7>
jp     1237 <main+0xe7>
jmp    124f <main+0xff>
mov    -0x10(%rbp),%edi
call   1030 <abs@plt>
mov    %eax,%esi
lea    0xde0(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movsd  -0x18(%rbp),%xmm0
movsd  0xda4(%rip),%xmm1
ucomisd %xmm1,%xmm0
jne    127d <main+0x12d>
jp     127d <main+0x12d>
mov    -0x10(%rbp),%esi
lea    0xdb2(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movsd  0xd83(%rip),%xmm0
addsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
jmp    11ef <main+0x9f>
lea    0xd91(%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    $0x28,%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>
call   1050 <ceil@plt>
mov    0xc(%rsp),%ecx
test   %ecx,%ecx
je     126c <main+0x10c>
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
movapd %xmm0,%xmm2
divsd  %xmm0,%xmm2
movsd  0xe38(%rip),%xmm3
movapd %xmm0,%xmm1
addsd  %xmm3,%xmm1
cmpeqsd %xmm3,%xmm2
andpd  %xmm2,%xmm1
andnpd %xmm0,%xmm2
orpd   %xmm1,%xmm2
lea    0xe40(%rip),%r14
jmp    1200 <main+0xa0>
nopw   0x0(%rax,%rax,1)
addsd  0xe10(%rip),%xmm2
mov    0xc(%rsp),%ecx
test   %ecx,%ecx
je     126c <main+0x10c>
movslq %ecx,%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 0xdd5(%rip),%xmm2
movapd %xmm2,0x10(%rsp)
jne    1235 <main+0xd5>
jnp    124c <main+0xec>
mov    %ebx,%esi
neg    %esi
cmovs  %ebx,%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
movapd 0x10(%rsp),%xmm2
ucomisd 0xdac(%rip),%xmm2
jne    11f0 <main+0x90>
jp     11f0 <main+0x90>
mov    %r14,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1060 <printf@plt>
movapd 0x10(%rsp),%xmm2
jmp    11f0 <main+0x90>
lea    0xdb9(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
add    $0x28,%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 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 = %45, %24
%26 = load i32, i32* %2
%27 = icmp ne i32 %26, 0
br i1 %27, label %28, label %48
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 double, double* %5
%34 = fcmp une double %33, 1.000000e+00
br i1 %34, label %35, label %39
35: ; preds = %28
%36 = load i32, i32* %4
%37 = call i32 @abs(i32 %36)
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %37)
br label %39
39: ; preds = %35, %28
%40 = load double, double* %5
%41 = fcmp oeq double %40, 1.000000e+00
br i1 %41, label %42, label %45
42: ; preds = %39
%43 = load i32, i32* %4
%44 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %43)
br label %45
45: ; preds = %42, %39
%46 = load double, double* %5
%47 = fadd double %46, -1.000000e+00
store double %47, double* %5
br label %25
48: ; preds = %25
%49 = 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 = trunc i64 %9 to i32
%11 = sitofp i32 %10 to double
%12 = load i32, i32* %1
%13 = icmp eq i32 %12, 0
br i1 %13, label %36, label %14
14: ; preds = %0
%15 = fdiv double %11, %11
%16 = fcmp oeq double %15, 1.000000e+00
%17 = fadd double %11, 1.000000e+00
%18 = select i1 %16, double %17, double %11
br label %19
19: ; preds = %14, %32
%20 = phi i32 [ %34, %32 ], [ %12, %14 ]
%21 = phi double [ %33, %32 ], [ %18, %14 ]
%22 = srem i32 %20, 10
%23 = sdiv i32 %20, 10
store i32 %23, i32* %1
%24 = fcmp une double %21, 1.000000e+00
br i1 %24, label %25, label %28
25: ; preds = %19
%26 = call i32 @llvm.abs.i32(i32 %22, i1 true)
%27 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %26)
br label %28
28: ; preds = %25, %19
%29 = fcmp oeq double %21, 1.000000e+00
br i1 %29, label %30, label %32
30: ; preds = %28
%31 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %22)
br label %32
32: ; preds = %30, %28
%33 = fadd double %21, -1.000000e+00
%34 = load i32, i32* %1
%35 = icmp eq i32 %34, 0
br i1 %35, label %36, label %19
36: ; preds = %32, %0
%37 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @str, i64 0, i64 0))
ret i32 0
}