#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 /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, double *);
int main() {
  double overflow;
  int digit, n, m;
  printf("\nEnter an integer > ");
  scanf("%lf", &overflow);
  digit = overflow;
  if (overflow > 2147483647) {
    printf("\n7\n4\n6\n3\n8\n4\n7\n4\n1\n2");
    printf("\nThat's all, have a nice day!\n");
    return 0;
  }
  if (overflow < -2147483647) {
    printf("\n-2147483647");
    printf("\nThat's all, have a nice day!\n");
    return 0;
  }
  if (digit == 0)
    printf("\n0");
  while (digit != 0) {
    n = digit % 10;
    m = n;
    if (digit < -10)
      m = n * -1;
    digit = (digit - n) / 10;
    printf("\n%d", m);
  }
  printf("\nThat's all, have a nice day!\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeda(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xee1(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1040 <scanf@plt>
cvttsd2si -0x10(%rbp),%eax
mov    %eax,-0x14(%rbp)
movsd  -0x10(%rbp),%xmm0
movsd  0xe9e(%rip),%xmm1
ucomisd %xmm1,%xmm0
jbe    1194 <main+0x74>
lea    0xeb6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xebd(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1257 <main+0x137>
movsd  0xe6c(%rip),%xmm0
ucomisd -0x10(%rbp),%xmm0
jbe    11cf <main+0xaf>
lea    0xeaf(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe82(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1257 <main+0x137>
cmpl   $0x0,-0x14(%rbp)
jne    11e7 <main+0xc7>
lea    0xe8a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11ec <main+0xcc>
cmpl   $0x0,-0x14(%rbp)
je     1242 <main+0x122>
mov    -0x14(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %edx,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    %eax,-0x1c(%rbp)
cmpl   $0xfffffff6,-0x14(%rbp)
jge    121b <main+0xfb>
imul   $0xffffffff,-0x18(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x14(%rbp),%eax
sub    -0x18(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,-0x14(%rbp)
mov    -0x1c(%rbp),%esi
lea    0xe37(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11ec <main+0xcc>
lea    0xdf5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
lea    0xed0(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xed7(%rip),%rdi
lea    0x8(%rsp),%rsi
call   1050 <scanf@plt>
movsd  0x8(%rsp),%xmm0
ucomisd 0xe9a(%rip),%xmm0
jbe    1171 <main+0x41>
lea    0xeba(%rip),%rdi
jmp    11ea <main+0xba>
movsd  0xe8f(%rip),%xmm1
ucomisd %xmm0,%xmm1
jbe    1188 <main+0x58>
lea    0xeb8(%rip),%rdi
jmp    11ea <main+0xba>
cvttsd2si %xmm0,%ebx
test   %ebx,%ebx
je     11e3 <main+0xb3>
lea    0xeb7(%rip),%r14
nopw   0x0(%rax,%rax,1)
movslq %ebx,%r15
imul   $0x66666667,%r15,%rbx
mov    %rbx,%rax
shr    $0x3f,%rax
sar    $0x22,%rbx
add    %eax,%ebx
lea    (%rbx,%rbx,1),%eax
lea    (%rax,%rax,4),%eax
mov    %r15d,%ecx
sub    %eax,%ecx
mov    %ecx,%esi
neg    %esi
cmp    $0xfffffff6,%r15d
cmovge %ecx,%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x9,%r15d
cmp    $0x13,%r15d
jae    11a0 <main+0x70>
jmp    11f1 <main+0xc1>
lea    0xe61(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe5a(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [21 x i8] c"\0AEnter an integer > \00"
@.str.1 = [4 x i8] c"%lf\00"
@.str.2 = [21 x i8] c"\0A7\0A4\0A6\0A3\0A8\0A4\0A7\0A4\0A1\0A2\00"
@.str.3 = [31 x i8] c"\0AThat's all, have a nice day!\0A\00"
@.str.4 = [13 x i8] c"\0A-2147483647\00"
@.str.5 = [3 x i8] c"\0A0\00"
@.str.6 = [4 x i8] c"\0A%d\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca double
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
%7 = call i32 @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), double* %2)
%8 = load double, double* %2
%9 = fptosi double %8 to i32
store i32 %9, i32* %3
%10 = load double, double* %2
%11 = fcmp ogt double %10, 0x41DFFFFFFFC00000
br i1 %11, label %12, label %15
12: ; preds = %0
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0))
%14 = 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 %48
15: ; preds = %0
%16 = load double, double* %2
%17 = fcmp olt double %16, 0xC1DFFFFFFFC00000
br i1 %17, label %18, label %21
18: ; preds = %15
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0))
%20 = 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 %48
21: ; preds = %15
%22 = load i32, i32* %3
%23 = icmp eq i32 %22, 0
br i1 %23, label %24, label %26
24: ; preds = %21
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0))
br label %26
26: ; preds = %24, %21
br label %27
27: ; preds = %39, %26
%28 = load i32, i32* %3
%29 = icmp ne i32 %28, 0
br i1 %29, label %30, label %46
30: ; preds = %27
%31 = load i32, i32* %3
%32 = srem i32 %31, 10
store i32 %32, i32* %4
%33 = load i32, i32* %4
store i32 %33, i32* %5
%34 = load i32, i32* %3
%35 = icmp slt i32 %34, -10
br i1 %35, label %36, label %39
36: ; preds = %30
%37 = load i32, i32* %4
%38 = mul nsw i32 %37, -1
store i32 %38, i32* %5
br label %39
39: ; preds = %36, %30
%40 = load i32, i32* %3
%41 = load i32, i32* %4
%42 = sub nsw i32 %40, %41
%43 = sdiv i32 %42, 10
store i32 %43, i32* %3
%44 = load i32, i32* %5
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i32 %44)
br label %27
46: ; preds = %27
%47 = 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 %48
48: ; preds = %46, %18, %12
%49 = load i32, i32* %1
ret i32 %49
}

LLVM IR (-O2):
@.str = [21 x i8] c"\0AEnter an integer > \00"
@.str.1 = [4 x i8] c"%lf\00"
@.str.2 = [21 x i8] c"\0A7\0A4\0A6\0A3\0A8\0A4\0A7\0A4\0A1\0A2\00"
@.str.4 = [13 x i8] c"\0A-2147483647\00"
@.str.5 = [3 x i8] c"\0A0\00"
@.str.6 = [4 x i8] c"\0A%d\00"
@str.8 = [30 x i8] c"\0AThat's all, have a nice day!\00"
define i32 @main() {
%1 = alloca double
%2 = bitcast double* %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), double* %1)
%5 = load double, double* %1
%6 = fptosi double %5 to i32
%7 = fcmp ogt double %5, 0x41DFFFFFFFC00000
br i1 %7, label %22, label %8
8: ; preds = %0
%9 = fcmp olt double %5, 0xC1DFFFFFFFC00000
br i1 %9, label %22, label %10
10: ; preds = %8
%11 = icmp eq i32 %6, 0
br i1 %11, label %22, label %12
12: ; preds = %10, %12
%13 = phi i32 [ %18, %12 ], [ %6, %10 ]
%14 = srem i32 %13, 10
%15 = icmp slt i32 %13, -10
%16 = sub nsw i32 0, %14
%17 = select i1 %15, i32 %16, i32 %14
%18 = sdiv i32 %13, 10
%19 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i32 %17)
%20 = add i32 %13, 9
%21 = icmp ult i32 %20, 19
br i1 %21, label %26, label %12
22: ; preds = %10, %8, %0
%23 = phi i8* [ getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), %0 ], [ getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0), %8 ], [ getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), %10 ]
%24 = phi i8* [ getelementptr inbounds ([30 x i8], [30 x i8]* @str.8, i64 0, i64 0), %0 ], [ getelementptr inbounds ([30 x i8], [30 x i8]* @str.8, i64 0, i64 0), %8 ], [ getelementptr inbounds ([30 x i8], [30 x i8]* @str.8, i64 0, i64 0), %10 ]
%25 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) %23)
br label %26
26: ; preds = %12, %22
%27 = phi i8* [ %24, %22 ], [ getelementptr inbounds ([30 x i8], [30 x i8]* @str.8, i64 0, i64 0), %12 ]
%28 = call i32 @puts(i8* dereferenceable(1) %27)
ret i32 0
}