#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;
  int rem;
  int negtemp;
  printf("\nEnter an integer > ");
  scanf("%d", &n);
  while (n >= 10) {
    rem = n % 10;
    n = n / 10;
    printf("\n%d", rem);
  }
  while (n <= -10) {
    rem = n % 10;
    n = n / 10;
    negtemp = fabs(rem);
    printf("\n%d", negtemp);
  }
  rem = n % 10;
  printf("\n%d", rem);
  printf("\nThat's all, have a nice day!\n");
  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   $0xa,-0x8(%rbp)
jl     1199 <main+0x69>
mov    -0x8(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %edx,-0xc(%rbp)
mov    -0x8(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,-0x8(%rbp)
mov    -0xc(%rbp),%esi
lea    0xe88(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    115d <main+0x2d>
jmp    119e <main+0x6e>
cmpl   $0xfffffff6,-0x8(%rbp)
jg     11e5 <main+0xb5>
mov    -0x8(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %edx,-0xc(%rbp)
mov    -0x8(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,-0x8(%rbp)
mov    -0xc(%rbp),%edi
call   1040 <fabs@plt>
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%esi
lea    0xe3c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    119e <main+0x6e>
mov    -0x8(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %edx,-0xc(%rbp)
mov    -0xc(%rbp),%esi
lea    0xe18(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe0e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
lea    0xeb5(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xebd(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1060 <scanf@plt>
mov    0x4(%rsp),%esi
cmp    $0xa,%esi
jl     11a9 <main+0x69>
mov    $0xcccccccd,%r14d
lea    0xe9c(%rip),%rbx
nopl   0x0(%rax)
mov    %esi,%eax
imul   %r14,%rax
shr    $0x23,%rax
lea    (%rax,%rax,1),%ecx
lea    (%rcx,%rcx,4),%ecx
sub    %ecx,%esi
mov    %eax,0x4(%rsp)
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x4(%rsp),%esi
cmp    $0x9,%esi
jg     1180 <main+0x40>
cmp    $0xfffffff6,%esi
jg     11f2 <main+0xb2>
mov    $0xcccccccd,%r14d
lea    0xe5a(%rip),%rbx
nopl   0x0(%rax,%rax,1)
mov    %esi,%eax
neg    %eax
imul   %r14,%rax
shr    $0x23,%rax
lea    (%rax,%rax,4),%ecx
lea    (%rsi,%rcx,2),%edi
neg    %eax
mov    %eax,0x4(%rsp)
call   1050 <fabs@plt>
mov    %rbx,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x4(%rsp),%esi
cmp    $0xfffffff7,%esi
jl     11c0 <main+0x80>
movslq %esi,%rsi
imul   $0x66666667,%rsi,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x22,%rax
add    %ecx,%eax
add    %eax,%eax
lea    (%rax,%rax,4),%eax
sub    %eax,%esi
lea    0xdfe(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xdf4(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x8,%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 = [4 x i8] c"\0A%d\00"
@.str.3 = [31 x i8] c"\0AThat's all, have a nice day!\0A\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)
br label %7
7: ; preds = %10, %0
%8 = load i32, i32* %2
%9 = icmp sge i32 %8, 10
br i1 %9, label %10, label %17
10: ; preds = %7
%11 = load i32, i32* %2
%12 = srem i32 %11, 10
store i32 %12, i32* %3
%13 = load i32, i32* %2
%14 = sdiv i32 %13, 10
store i32 %14, i32* %2
%15 = load i32, i32* %3
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %15)
br label %7
17: ; preds = %7
br label %18
18: ; preds = %21, %17
%19 = load i32, i32* %2
%20 = icmp sle i32 %19, -10
br i1 %20, label %21, label %30
21: ; preds = %18
%22 = load i32, i32* %2
%23 = srem i32 %22, 10
store i32 %23, i32* %3
%24 = load i32, i32* %2
%25 = sdiv i32 %24, 10
store i32 %25, i32* %2
%26 = load i32, i32* %3
%27 = call i32 @fabs(i32 %26)
store i32 %27, i32* %4
%28 = load i32, i32* %4
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %28)
br label %18
30: ; preds = %18
%31 = load i32, i32* %2
%32 = srem i32 %31, 10
store i32 %32, i32* %3
%33 = load i32, i32* %3
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %33)
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 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 = [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 sgt i32 %5, 9
br i1 %6, label %10, label %7
7: ; preds = %10, %0
%8 = phi i32 [ %5, %0 ], [ %15, %10 ]
%9 = icmp slt i32 %8, -9
br i1 %9, label %17, label %28
10: ; preds = %0, %10
%11 = phi i32 [ %15, %10 ], [ %5, %0 ]
%12 = urem i32 %11, 10
%13 = udiv i32 %11, 10
store i32 %13, i32* %1
%14 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %12)
%15 = load i32, i32* %1
%16 = icmp sgt i32 %15, 9
br i1 %16, label %10, label %7
17: ; preds = %7, %17
%18 = phi i32 [ %26, %17 ], [ %8, %7 ]
%19 = sub i32 0, %18
%20 = urem i32 %19, 10
%21 = sub nsw i32 0, %20
%22 = udiv i32 %19, 10
%23 = sub nsw i32 0, %22
store i32 %23, i32* %1
%24 = call i32 @fabs(i32 %21)
%25 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %24)
%26 = load i32, i32* %1
%27 = icmp slt i32 %26, -9
br i1 %27, label %17, label %28
28: ; preds = %17, %7
%29 = phi i32 [ %8, %7 ], [ %26, %17 ]
%30 = srem i32 %29, 10
%31 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %30)
%32 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @str, i64 0, i64 0))
ret i32 0
}