#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);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int x, y;
  int temp;
  printf("\nEnter an integer > ");
  scanf("%d", &y);
  while (1) {
    x = y % 10;
    if (abs(y) > 10) {
      printf("\n%d", abs(x));
    } else if (abs(y) >= 0 && abs(y) < 10) {
      printf("\n%d", x);
      printf("\nThat's all, have a nice day!\n");
      return 0;
    }
    x = y / 10;
    temp = x;
    x = y;
    y = temp;
  }
  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   1040 <printf@plt>
lea    0xec2(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1050 <scanf@plt>
mov    -0xc(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %edx,-0x8(%rbp)
mov    -0xc(%rbp),%edi
call   1030 <abs@plt>
cmp    $0xa,%eax
jle    1199 <main+0x69>
mov    -0x8(%rbp),%edi
call   1030 <abs@plt>
mov    %eax,%esi
lea    0xe88(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11e7 <main+0xb7>
mov    -0xc(%rbp),%edi
call   1030 <abs@plt>
cmp    $0x0,%eax
jl     11e2 <main+0xb2>
mov    -0xc(%rbp),%edi
call   1030 <abs@plt>
cmp    $0xa,%eax
jge    11e2 <main+0xb2>
mov    -0x8(%rbp),%esi
lea    0xe50(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe46(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret
jmp    11e7 <main+0xb7>
mov    -0xc(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x10(%rbp),%eax
mov    %eax,-0xc(%rbp)
jmp    115d <main+0x2d>

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
lea    0xec4(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xecc(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1050 <scanf@plt>
mov    0xc(%rsp),%eax
lea    0xeb6(%rip),%rbx
jmp    11a1 <main+0x71>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %esi,%eax
neg    %eax
cmovs  %esi,%eax
mov    %rbx,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0xc(%rsp),%eax
cltq
imul   $0x66666667,%rax,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x22,%rax
add    %ecx,%eax
mov    %eax,0xc(%rsp)
movslq %eax,%rdx
imul   $0x66666667,%rdx,%rcx
mov    %rcx,%rsi
shr    $0x3f,%rsi
sar    $0x22,%rcx
add    %esi,%ecx
add    %ecx,%ecx
lea    (%rcx,%rcx,4),%ecx
mov    %edx,%esi
sub    %ecx,%esi
mov    %edx,%ecx
neg    %ecx
cmovs  %edx,%ecx
cmp    $0xb,%ecx
jae    1170 <main+0x40>
cmp    $0xa,%ecx
je     1187 <main+0x57>
lea    0xe3c(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe32(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
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* %3)
br label %7
7: ; preds = %0, %30
%8 = load i32, i32* %3
%9 = srem i32 %8, 10
store i32 %9, i32* %2
%10 = load i32, i32* %3
%11 = call i32 @abs(i32 %10)
%12 = icmp sgt i32 %11, 10
br i1 %12, label %13, label %17
13: ; preds = %7
%14 = load i32, i32* %2
%15 = call i32 @abs(i32 %14)
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %15)
br label %30
17: ; preds = %7
%18 = load i32, i32* %3
%19 = call i32 @abs(i32 %18)
%20 = icmp sge i32 %19, 0
br i1 %20, label %21, label %29
21: ; preds = %17
%22 = load i32, i32* %3
%23 = call i32 @abs(i32 %22)
%24 = icmp slt i32 %23, 10
br i1 %24, label %25, label %29
25: ; preds = %21
%26 = load i32, i32* %2
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %26)
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0))
ret i32 0
29: ; preds = %21, %17
br label %30
30: ; preds = %29, %13
%31 = load i32, i32* %3
%32 = sdiv i32 %31, 10
store i32 %32, i32* %2
%33 = load i32, i32* %2
store i32 %33, i32* %4
%34 = load i32, i32* %3
store i32 %34, i32* %2
%35 = load i32, i32* %4
store i32 %35, i32* %3
br label %7
}

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
br label %6
6: ; preds = %20, %0
%7 = phi i32 [ %22, %20 ], [ %5, %0 ]
%8 = srem i32 %7, 10
%9 = call i32 @llvm.abs.i32(i32 %7, i1 true)
%10 = icmp ugt i32 %9, 10
br i1 %10, label %11, label %15
11: ; preds = %6
%12 = call i32 @llvm.abs.i32(i32 %8, i1 true)
%13 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %12)
%14 = load i32, i32* %1
br label %20
15: ; preds = %6
%16 = icmp eq i32 %9, 10
br i1 %16, label %20, label %17
17: ; preds = %15
%18 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %8)
%19 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @str, i64 0, i64 0))
ret i32 0
20: ; preds = %15, %11
%21 = phi i32 [ %7, %15 ], [ %14, %11 ]
%22 = sdiv i32 %21, 10
store i32 %22, i32* %1
br label %6
}