#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(void) {
  int integer, i, digit;
  printf("\nEnter an integer > ");
  scanf("\n%d", &integer);
  digit = 0;
  for (i = 1; i <= 10; i += 1) {
    digit = integer % 10;
    if (integer == 0) {
      printf("0\n");
      break;
    } else if (fabs(digit) < 10) {
      digit = fabs(digit);
      printf("%d\n", digit);
    }
    integer = integer / 10;
    if (fabs(integer) < 10 && integer != 0) {
      printf("%d\n", integer);
      break;
    }
  }
  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    0xec1(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1050 <scanf@plt>
movl   $0x0,-0x10(%rbp)
movl   $0x1,-0xc(%rbp)
cmpl   $0xa,-0xc(%rbp)
jg     1224 <main+0xf4>
mov    -0x8(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %edx,-0x10(%rbp)
cmpl   $0x0,-0x8(%rbp)
jne    11a0 <main+0x70>
lea    0xe85(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1224 <main+0xf4>
mov    -0x10(%rbp),%edi
call   1040 <fabs@plt>
cmp    $0xa,%eax
jge    11cd <main+0x9d>
mov    -0x10(%rbp),%edi
call   1040 <fabs@plt>
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%esi
lea    0xe56(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11d2 <main+0xa2>
mov    -0x8(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%edi
call   1040 <fabs@plt>
cmp    $0xa,%eax
jge    1211 <main+0xe1>
cmpl   $0x0,-0x8(%rbp)
je     1211 <main+0xe1>
mov    -0x8(%rbp),%esi
lea    0xe17(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1224 <main+0xf4>
jmp    1216 <main+0xe6>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    116b <main+0x3b>
lea    0xdf5(%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   %r14
push   %rbx
sub    $0x10,%rsp
lea    0xeb1(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xeb8(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1060 <scanf@plt>
mov    $0xa,%ebp
mov    0xc(%rsp),%esi
lea    0xea2(%rip),%r14
jmp    1189 <main+0x49>
nopl   0x0(%rax)
add    $0xffffffff,%ebp
je     1215 <main+0xd5>
test   %esi,%esi
je     1209 <main+0xc9>
movslq %esi,%rbx
imul   $0x66666667,%rbx,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x22,%rax
add    %ecx,%eax
add    %eax,%eax
lea    (%rax,%rax,4),%eax
sub    %eax,%ebx
mov    %ebx,%edi
call   1050 <fabs@plt>
cmp    $0x9,%eax
jg     11ca <main+0x8a>
mov    %ebx,%edi
call   1050 <fabs@plt>
mov    %r14,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
movslq 0xc(%rsp),%rax
imul   $0x66666667,%rax,%rdi
mov    %rdi,%rax
shr    $0x3f,%rax
sar    $0x22,%rdi
add    %eax,%edi
mov    %edi,0xc(%rsp)
call   1050 <fabs@plt>
mov    0xc(%rsp),%esi
cmp    $0x9,%eax
jg     1180 <main+0x40>
test   %esi,%esi
je     1180 <main+0x40>
lea    0xe19(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    1215 <main+0xd5>
lea    0xe2b(%rip),%rdi
call   1030 <puts@plt>
lea    0xe01(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [21 x i8] c"\0AEnter an integer > \00"
@.str.1 = [4 x i8] c"\0A%d\00"
@.str.2 = [3 x i8] c"0\0A\00"
@.str.3 = [4 x i8] c"%d\0A\00"
@.str.4 = [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 ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32* %2)
store i32 0, i32* %4
store i32 1, i32* %3
br label %7
7: ; preds = %40, %0
%8 = load i32, i32* %3
%9 = icmp sle i32 %8, 10
br i1 %9, label %10, label %43
10: ; preds = %7
%11 = load i32, i32* %2
%12 = srem i32 %11, 10
store i32 %12, i32* %4
%13 = load i32, i32* %2
%14 = icmp eq i32 %13, 0
br i1 %14, label %15, label %17
15: ; preds = %10
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
br label %43
17: ; preds = %10
%18 = load i32, i32* %4
%19 = call i32 @fabs(i32 %18)
%20 = icmp slt i32 %19, 10
br i1 %20, label %21, label %26
21: ; preds = %17
%22 = load i32, i32* %4
%23 = call i32 @fabs(i32 %22)
store i32 %23, i32* %4
%24 = load i32, i32* %4
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %24)
br label %26
26: ; preds = %21, %17
br label %27
27: ; preds = %26
%28 = load i32, i32* %2
%29 = sdiv i32 %28, 10
store i32 %29, i32* %2
%30 = load i32, i32* %2
%31 = call i32 @fabs(i32 %30)
%32 = icmp slt i32 %31, 10
br i1 %32, label %33, label %39
33: ; preds = %27
%34 = load i32, i32* %2
%35 = icmp ne i32 %34, 0
br i1 %35, label %36, label %39
36: ; preds = %33
%37 = load i32, i32* %2
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %37)
br label %43
39: ; preds = %33, %27
br label %40
40: ; preds = %39
%41 = load i32, i32* %3
%42 = add nsw i32 %41, 1
store i32 %42, i32* %3
br label %7
43: ; preds = %36, %15, %7
%44 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 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 = [4 x i8] c"\0A%d\00"
@.str.3 = [4 x i8] c"%d\0A\00"
@str = [30 x i8] c"\0AThat's all, have a nice day!\00"
@str.5 = [2 x i8] c"0\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 ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%5 = load i32, i32* %1
br label %9
6: ; preds = %22
%7 = add nuw nsw i32 %11, 1
%8 = icmp eq i32 %7, 11
br i1 %8, label %32, label %9
9: ; preds = %0, %6
%10 = phi i32 [ %5, %0 ], [ %27, %6 ]
%11 = phi i32 [ 1, %0 ], [ %7, %6 ]
%12 = srem i32 %10, 10
%13 = icmp eq i32 %10, 0
br i1 %13, label %14, label %16
14: ; preds = %9
%15 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([2 x i8], [2 x i8]* @str.5, i64 0, i64 0))
br label %32
16: ; preds = %9
%17 = call i32 @fabs(i32 %12)
%18 = icmp slt i32 %17, 10
br i1 %18, label %19, label %22
19: ; preds = %16
%20 = call i32 @fabs(i32 %12)
%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 = %16, %19
%23 = load i32, i32* %1
%24 = sdiv i32 %23, 10
store i32 %24, i32* %1
%25 = call i32 @fabs(i32 %24)
%26 = icmp slt i32 %25, 10
%27 = load i32, i32* %1
%28 = icmp ne i32 %27, 0
%29 = select i1 %26, i1 %28, i1 false
br i1 %29, label %30, label %6
30: ; preds = %22
%31 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %27)
br label %32
32: ; preds = %6, %30, %14
%33 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @str, i64 0, i64 0))
ret i32 0
}