#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 fabs(int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int n, digit, neg;
  printf("\nEnter an integer > ");
  scanf("%d", &n);
  if (n < 1)
    neg = 1;
  digit = 0;
  while (n != 0) {
    digit = n % 10;
    {
      if ((neg) && (fabs(n) < 10))
        printf("\n%d", digit);
      if ((neg) && (fabs(n) >= 10))
        printf("\n%d", digit / (-1));
      if (!neg)
        printf("\n%d", digit);
    }
    n = (n - digit) / 10;
  }
  printf("\nThat's all, have a nice day!");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeba(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xec2(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1050 <scanf@plt>
cmpl   $0x1,-0x8(%rbp)
jge    116e <main+0x3e>
movl   $0x1,-0x10(%rbp)
movl   $0x0,-0xc(%rbp)
cmpl   $0x0,-0x8(%rbp)
je     1220 <main+0xf0>
mov    -0x8(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %edx,-0xc(%rbp)
cmpl   $0x0,-0x10(%rbp)
je     11b9 <main+0x89>
mov    -0x8(%rbp),%edi
call   1040 <fabs@plt>
cmp    $0xa,%eax
jge    11b9 <main+0x89>
mov    -0xc(%rbp),%esi
lea    0xe63(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0x0,-0x10(%rbp)
je     11ef <main+0xbf>
mov    -0x8(%rbp),%edi
call   1040 <fabs@plt>
cmp    $0xa,%eax
jl     11ef <main+0xbf>
mov    -0xc(%rbp),%eax
mov    $0xffffffff,%ecx
cltd
idiv   %ecx
mov    %eax,%esi
lea    0xe2d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0x0,-0x10(%rbp)
jne    120a <main+0xda>
mov    -0xc(%rbp),%esi
lea    0xe12(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
sub    -0xc(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,-0x8(%rbp)
jmp    1175 <main+0x45>
lea    0xdf2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
lea    0xec6(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xece(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1050 <scanf@plt>
mov    0x4(%rsp),%eax
test   %eax,%eax
je     11ed <main+0xbd>
lea    0xeb0(%rip),%rbx
jmp    1199 <main+0x69>
nopw   0x0(%rax,%rax,1)
mov    0x4(%rsp),%eax
sub    %ebp,%eax
movslq %eax,%rcx
imul   $0x66666667,%rcx,%rax
mov    %rax,%rdx
shr    $0x3f,%rdx
sar    $0x22,%rax
add    %edx,%eax
mov    %eax,0x4(%rsp)
add    $0x9,%ecx
cmp    $0x12,%ecx
jbe    11ed <main+0xbd>
movslq %eax,%rdi
imul   $0x66666667,%rdi,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x22,%rax
add    %ecx,%eax
add    %eax,%eax
lea    (%rax,%rax,4),%eax
mov    %edi,%ebp
sub    %eax,%ebp
call   1040 <fabs@plt>
cmp    $0x9,%eax
jg     11cf <main+0x9f>
mov    %rbx,%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x4(%rsp),%edi
call   1040 <fabs@plt>
cmp    $0xa,%eax
jl     1170 <main+0x40>
mov    %ebp,%esi
neg    %esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
jmp    1170 <main+0x40>
lea    0xe25(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
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 = [4 x i8] c"\0A%d\00"
@.str.3 = [30 x i8] c"\0AThat's all, have a nice day!\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%7 = load i32, i32* %2
%8 = icmp slt i32 %7, 1
br i1 %8, label %9, label %10
9: ; preds = %0
store i32 1, i32* %4
br label %10
10: ; preds = %9, %0
store i32 0, i32* %3
br label %11
11: ; preds = %43, %10
%12 = load i32, i32* %2
%13 = icmp ne i32 %12, 0
br i1 %13, label %14, label %48
14: ; preds = %11
%15 = load i32, i32* %2
%16 = srem i32 %15, 10
store i32 %16, i32* %3
%17 = load i32, i32* %4
%18 = icmp ne i32 %17, 0
br i1 %18, label %19, label %26
19: ; preds = %14
%20 = load i32, i32* %2
%21 = call i32 @fabs(i32 %20)
%22 = icmp slt i32 %21, 10
br i1 %22, label %23, label %26
23: ; preds = %19
%24 = load i32, i32* %3
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %24)
br label %26
26: ; preds = %23, %19, %14
%27 = load i32, i32* %4
%28 = icmp ne i32 %27, 0
br i1 %28, label %29, label %37
29: ; preds = %26
%30 = load i32, i32* %2
%31 = call i32 @fabs(i32 %30)
%32 = icmp sge i32 %31, 10
br i1 %32, label %33, label %37
33: ; preds = %29
%34 = load i32, i32* %3
%35 = sdiv i32 %34, -1
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %35)
br label %37
37: ; preds = %33, %29, %26
%38 = load i32, i32* %4
%39 = icmp ne i32 %38, 0
br i1 %39, label %43, label %40
40: ; preds = %37
%41 = load i32, i32* %3
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %41)
br label %43
43: ; preds = %40, %37
%44 = load i32, i32* %2
%45 = load i32, i32* %3
%46 = sub nsw i32 %44, %45
%47 = sdiv i32 %46, 10
store i32 %47, i32* %2
br label %11
48: ; preds = %11
%49 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.3, 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.2 = [4 x i8] c"\0A%d\00"
@.str.3 = [30 x i8] c"\0AThat'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 = load i32, i32* %1
%6 = icmp eq i32 %5, 0
br i1 %6, label %27, label %7
7: ; preds = %0, %21
%8 = phi i32 [ %24, %21 ], [ %5, %0 ]
%9 = srem i32 %8, 10
%10 = call i32 @fabs(i32 %8)
%11 = icmp slt i32 %10, 10
br i1 %11, label %12, label %14
12: ; preds = %7
%13 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %9)
br label %14
14: ; preds = %7, %12
%15 = load i32, i32* %1
%16 = call i32 @fabs(i32 %15)
%17 = icmp sgt i32 %16, 9
br i1 %17, label %18, label %21
18: ; preds = %14
%19 = sub nsw i32 0, %9
%20 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %19)
br label %21
21: ; preds = %14, %18
%22 = load i32, i32* %1
%23 = sub nsw i32 %22, %9
%24 = sdiv i32 %23, 10
store i32 %24, i32* %1
%25 = add i32 %23, 9
%26 = icmp ult i32 %25, 19
br i1 %26, label %27, label %7
27: ; preds = %21, %0
%28 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.3, i64 0, i64 0))
ret i32 0
}