#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 */
scalar_t__ abs(int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int n, digit;
  printf("Enter an integer > ");
  scanf("%d", &n);
  if (n == 0) {
    printf("\n0");
    printf("\nThat's all, have a nice day!\n");
    return (0);
  }
  while (abs(n) > 0) {
    if (n > 0 || (n < 0 && (n / 10.0) > 10.0)) {
      digit = n % 10;
      printf("\n%d", digit);
      n = n / 10.0;
    } else if (n < 0 && (n / 10.0) < 10.0) {
      digit = n % 10;
      printf("\n%d", digit);
      n = (n) / 10.0;
    }
  }
  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    0xec2(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xeeb(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1050 <scanf@plt>
cmpl   $0x0,-0x8(%rbp)
jne    118f <main+0x5f>
lea    0xeae(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xea3(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    129c <main+0x16c>
jmp    1194 <main+0x64>
mov    -0x8(%rbp),%edi
call   1030 <abs@plt>
cmp    $0x0,%rax
jle    1287 <main+0x157>
cmpl   $0x0,-0x8(%rbp)
jg     11dd <main+0xad>
cmpl   $0x0,-0x8(%rbp)
jge    1219 <main+0xe9>
cvtsi2sdl -0x8(%rbp),%xmm0
movsd  0xe39(%rip),%xmm1
divsd  %xmm1,%xmm0
movsd  0xe2d(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    1219 <main+0xe9>
mov    -0x8(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %edx,-0xc(%rbp)
mov    -0xc(%rbp),%esi
lea    0xe49(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
cvtsi2sdl -0x8(%rbp),%xmm0
movsd  0xdf7(%rip),%xmm1
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,-0x8(%rbp)
jmp    1282 <main+0x152>
cmpl   $0x0,-0x8(%rbp)
jge    127d <main+0x14d>
cvtsi2sdl -0x8(%rbp),%xmm1
movsd  0xdd0(%rip),%xmm0
divsd  %xmm0,%xmm1
movsd  0xdc4(%rip),%xmm0
ucomisd %xmm1,%xmm0
jbe    127d <main+0x14d>
mov    -0x8(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %edx,-0xc(%rbp)
mov    -0xc(%rbp),%esi
lea    0xde0(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
cvtsi2sdl -0x8(%rbp),%xmm0
movsd  0xd8e(%rip),%xmm1
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,-0x8(%rbp)
jmp    1282 <main+0x152>
jmp    1194 <main+0x64>
lea    0xd91(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
lea    0xebd(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xec7(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1060 <scanf@plt>
mov    0x4(%rsp),%edi
test   %edi,%edi
je     123c <main+0xfc>
call   1040 <abs@plt>
test   %rax,%rax
jle    124a <main+0x10a>
lea    0xe9b(%rip),%rbx
movsd  0xe74(%rip),%xmm1
mov    $0xcccccccd,%r14d
jmp    11bc <main+0x7c>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
xor    %edi,%edi
test   %esi,%esi
js     1207 <main+0xc7>
call   1040 <abs@plt>
movsd  0xe4d(%rip),%xmm1
test   %rax,%rax
jle    124a <main+0x10a>
mov    0x4(%rsp),%esi
test   %esi,%esi
jle    11a0 <main+0x60>
movslq %esi,%rax
imul   $0x66666667,%rax,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x22,%rax
add    %ecx,%eax
add    %eax,%eax
lea    (%rax,%rax,4),%eax
sub    %eax,%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
xorps  %xmm0,%xmm0
cvtsi2sdl 0x4(%rsp),%xmm0
divsd  0xe03(%rip),%xmm0
cvttsd2si %xmm0,%edi
mov    %edi,0x4(%rsp)
jmp    11a6 <main+0x66>
xorps  %xmm0,%xmm0
cvtsi2sd %esi,%xmm0
divsd  %xmm1,%xmm0
ucomisd %xmm1,%xmm0
ja     11c4 <main+0x84>
ucomisd %xmm0,%xmm1
jbe    1235 <main+0xf5>
mov    %esi,%eax
neg    %eax
imul   %r14,%rax
shr    $0x23,%rax
lea    (%rax,%rax,4),%eax
lea    (%rsi,%rax,2),%esi
mov    %rbx,%rdi
jmp    11e5 <main+0xa5>
mov    %esi,%edi
jmp    11a6 <main+0x66>
lea    0xdd9(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xdd2(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [20 x i8] c"Enter an integer > \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [3 x i8] c"\0A0\00"
@.str.3 = [31 x i8] c"\0AThat's all, have a nice day!\0A\00"
@.str.4 = [4 x i8] c"\0A%d\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
store i32 0, i32* %1
%4 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
%5 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%6 = load i32, i32* %2
%7 = icmp eq i32 %6, 0
br i1 %7, label %8, label %11
8: ; preds = %0
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0))
store i32 0, i32* %1
br label %57
11: ; preds = %0
br label %12
12: ; preds = %54, %11
%13 = load i32, i32* %2
%14 = call i64 @abs(i32 %13)
%15 = icmp sgt i64 %14, 0
br i1 %15, label %16, label %55
16: ; preds = %12
%17 = load i32, i32* %2
%18 = icmp sgt i32 %17, 0
br i1 %18, label %27, label %19
19: ; preds = %16
%20 = load i32, i32* %2
%21 = icmp slt i32 %20, 0
br i1 %21, label %22, label %36
22: ; preds = %19
%23 = load i32, i32* %2
%24 = sitofp i32 %23 to double
%25 = fdiv double %24, 1.000000e+01
%26 = fcmp ogt double %25, 1.000000e+01
br i1 %26, label %27, label %36
27: ; preds = %22, %16
%28 = load i32, i32* %2
%29 = srem i32 %28, 10
store i32 %29, i32* %3
%30 = load i32, i32* %3
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %30)
%32 = load i32, i32* %2
%33 = sitofp i32 %32 to double
%34 = fdiv double %33, 1.000000e+01
%35 = fptosi double %34 to i32
store i32 %35, i32* %2
br label %54
36: ; preds = %22, %19
%37 = load i32, i32* %2
%38 = icmp slt i32 %37, 0
br i1 %38, label %39, label %53
39: ; preds = %36
%40 = load i32, i32* %2
%41 = sitofp i32 %40 to double
%42 = fdiv double %41, 1.000000e+01
%43 = fcmp olt double %42, 1.000000e+01
br i1 %43, label %44, label %53
44: ; preds = %39
%45 = load i32, i32* %2
%46 = srem i32 %45, 10
store i32 %46, i32* %3
%47 = load i32, i32* %3
%48 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %47)
%49 = load i32, i32* %2
%50 = sitofp i32 %49 to double
%51 = fdiv double %50, 1.000000e+01
%52 = fptosi double %51 to i32
store i32 %52, i32* %2
br label %53
53: ; preds = %44, %39, %36
br label %54
54: ; preds = %53, %27
br label %12
55: ; preds = %12
%56 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.3, i64 0, i64 0))
store i32 0, i32* %1
br label %57
57: ; preds = %55, %8
%58 = load i32, i32* %1
ret i32 %58
}

LLVM IR (-O2):
@.str = [20 x i8] c"Enter an integer > \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [3 x i8] c"\0A0\00"
@.str.4 = [4 x i8] c"\0A%d\00"
@str.5 = [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 ([20 x i8], [20 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 %10, label %7
7: ; preds = %0
%8 = call i64 @abs(i32 %5)
%9 = icmp sgt i64 %8, 0
br i1 %9, label %12, label %43
10: ; preds = %0
%11 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
br label %43
12: ; preds = %7, %39
%13 = load i32, i32* %1
%14 = icmp sgt i32 %13, 0
br i1 %14, label %21, label %15
15: ; preds = %12
%16 = icmp slt i32 %13, 0
br i1 %16, label %17, label %39
17: ; preds = %15
%18 = sitofp i32 %13 to double
%19 = fdiv double %18, 1.000000e+01
%20 = fcmp ogt double %19, 1.000000e+01
br i1 %20, label %21, label %28
21: ; preds = %17, %12
%22 = srem i32 %13, 10
%23 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %22)
%24 = load i32, i32* %1
%25 = sitofp i32 %24 to double
%26 = fdiv double %25, 1.000000e+01
%27 = fptosi double %26 to i32
store i32 %27, i32* %1
br label %39
28: ; preds = %17
%29 = fcmp olt double %19, 1.000000e+01
br i1 %29, label %30, label %39
30: ; preds = %28
%31 = sub i32 0, %13
%32 = urem i32 %31, 10
%33 = sub nsw i32 0, %32
%34 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 %33)
%35 = load i32, i32* %1
%36 = sitofp i32 %35 to double
%37 = fdiv double %36, 1.000000e+01
%38 = fptosi double %37 to i32
store i32 %38, i32* %1
br label %39
39: ; preds = %15, %28, %30, %21
%40 = phi i32 [ 0, %15 ], [ %13, %28 ], [ %38, %30 ], [ %27, %21 ]
%41 = call i64 @abs(i32 %40)
%42 = icmp sgt i64 %41, 0
br i1 %42, label %12, label %43
43: ; preds = %39, %7, %10
%44 = phi i8* [ getelementptr inbounds ([30 x i8], [30 x i8]* @str.5, i64 0, i64 0), %10 ], [ getelementptr inbounds ([30 x i8], [30 x i8]* @str.5, i64 0, i64 0), %7 ], [ getelementptr inbounds ([30 x i8], [30 x i8]* @str.5, i64 0, i64 0), %39 ]
%45 = call i32 @puts(i8* dereferenceable(1) %44)
ret i32 0
}