#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);
  if (i / i == 1)
    i += 1.00;
  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)
movsd  -0x18(%rbp),%xmm0
divsd  -0x18(%rbp),%xmm0
movsd  0xe3c(%rip),%xmm1
ucomisd %xmm1,%xmm0
jne    11e6 <main+0x96>
jp     11e6 <main+0x96>
movsd  0xe24(%rip),%xmm0
addsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
jmp    11eb <main+0x9b>
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  0xde2(%rip),%xmm1
ucomisd %xmm1,%xmm0
jne    1233 <main+0xe3>
jp     1233 <main+0xe3>
jmp    124b <main+0xfb>
mov    -0x10(%rbp),%edi
call   1030 <abs@plt>
mov    %eax,%esi
lea    0xddc(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movsd  -0x18(%rbp),%xmm0
movsd  0xda8(%rip),%xmm1
ucomisd %xmm1,%xmm0
jne    1279 <main+0x129>
jp     1279 <main+0x129>
mov    -0x10(%rbp),%esi
lea    0xdae(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movsd  -0x18(%rbp),%xmm0
movsd  0xd7a(%rip),%xmm1
subsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
jmp    11eb <main+0x9b>
lea    0xd89(%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),%eax
test   %eax,%eax
je     126c <main+0x10c>
movapd %xmm0,%xmm2
divsd  %xmm0,%xmm2
movsd  0xe3f(%rip),%xmm3
movapd %xmm0,%xmm1
addsd  %xmm3,%xmm1
cmpeqsd %xmm3,%xmm2
andpd  %xmm2,%xmm1
andnpd %xmm0,%xmm2
orpd   %xmm1,%xmm2
lea    0xe47(%rip),%r14
jmp    1200 <main+0xa0>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
addsd  0xe10(%rip),%xmm2
mov    0xc(%rsp),%eax
test   %eax,%eax
je     126c <main+0x10c>
movslq %eax,%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 double @llvm.ceil.f64(double %13)
store double %14, double* %5
%15 = load double, double* %5
%16 = load double, double* %5
%17 = fdiv double %15, %16
%18 = fcmp oeq double %17, 1.000000e+00
br i1 %18, label %19, label %22
19: ; preds = %0
%20 = load double, double* %5
%21 = fadd double %20, 1.000000e+00
store double %21, double* %5
br label %22
22: ; preds = %19, %0
br label %23
23: ; preds = %43, %22
%24 = load i32, i32* %2
%25 = icmp ne i32 %24, 0
br i1 %25, label %26, label %46
26: ; preds = %23
%27 = load i32, i32* %2
%28 = srem i32 %27, 10
store i32 %28, i32* %4
%29 = load i32, i32* %2
%30 = sdiv i32 %29, 10
store i32 %30, i32* %2
%31 = load double, double* %5
%32 = fcmp une double %31, 1.000000e+00
br i1 %32, label %33, label %37
33: ; preds = %26
%34 = load i32, i32* %4
%35 = call i32 @abs(i32 %34)
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %35)
br label %37
37: ; preds = %33, %26
%38 = load double, double* %5
%39 = fcmp oeq double %38, 1.000000e+00
br i1 %39, label %40, label %43
40: ; preds = %37
%41 = load i32, i32* %4
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %41)
br label %43
43: ; preds = %40, %37
%44 = load double, double* %5
%45 = fsub double %44, 1.000000e+00
store double %45, double* %5
br label %23
46: ; preds = %23
%47 = 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 double @llvm.ceil.f64(double %8)
%10 = load i32, i32* %1
%11 = icmp eq i32 %10, 0
br i1 %11, label %34, label %12
12: ; preds = %0
%13 = fdiv double %9, %9
%14 = fcmp oeq double %13, 1.000000e+00
%15 = fadd double %9, 1.000000e+00
%16 = select i1 %14, double %15, double %9
br label %17
17: ; preds = %12, %30
%18 = phi i32 [ %32, %30 ], [ %10, %12 ]
%19 = phi double [ %31, %30 ], [ %16, %12 ]
%20 = srem i32 %18, 10
%21 = sdiv i32 %18, 10
store i32 %21, i32* %1
%22 = fcmp une double %19, 1.000000e+00
br i1 %22, label %23, label %26
23: ; preds = %17
%24 = call i32 @llvm.abs.i32(i32 %20, i1 true)
%25 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %24)
br label %26
26: ; preds = %23, %17
%27 = fcmp oeq double %19, 1.000000e+00
br i1 %27, label %28, label %30
28: ; preds = %26
%29 = 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 %30
30: ; preds = %28, %26
%31 = fadd double %19, -1.000000e+00
%32 = load i32, i32* %1
%33 = icmp eq i32 %32, 0
br i1 %33, label %34, label %17
34: ; preds = %30, %0
%35 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @str, i64 0, i64 0))
ret i32 0
}