#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 *, int *);
int main(void) {
  int x, y, i;
  int step1 = 10, step2 = 100;
  int num;
  int max = -1;
  int neg = 0;
  printf("Enter an integer > ");
  scanf("%d", &x);
  if (x <= -2147483647) {
    printf("-2147483647\n");
    return (0);
  }
  if (x < 0) {
    x = x * -1;
    neg = 1;
  }
  y = x;
  while (y >= 10) {
    y /= 10;
    max++;
  }
  printf("%d\n", x % 10);
  for (i = 0; i < max; i++) {
    num = ((x % step2 - x % step1) / step1);
    printf("%d\n", num);
    step2 *= 10.00000000000;
    ;
    step1 *= 10.00000000000;
    ;
  }
  num = ((x % step2 - x % step1) / step1);
  if (neg == 1) {
    printf("-%d\n", num);
  } else {
    printf("%d\n", num);
  }
  printf("That's all, have a nice day!\n");
  return (0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0xa,-0x14(%rbp)
movl   $0x64,-0x18(%rbp)
movl   $0xffffffff,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
lea    0xeb6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xebc(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
cmpl   $0x80000001,-0x8(%rbp)
jg     1190 <main+0x70>
lea    0xea2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    12d1 <main+0x1b1>
cmpl   $0x0,-0x8(%rbp)
jge    11a8 <main+0x88>
imul   $0xffffffff,-0x8(%rbp),%eax
mov    %eax,-0x8(%rbp)
movl   $0x1,-0x24(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0xc(%rbp)
cmpl   $0xa,-0xc(%rbp)
jl     11d4 <main+0xb4>
mov    -0xc(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,-0xc(%rbp)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    11ae <main+0x8e>
mov    -0x8(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %edx,%esi
lea    0xe45(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0x20(%rbp),%eax
jge    126e <main+0x14e>
mov    -0x8(%rbp),%eax
cltd
idivl  -0x18(%rbp)
mov    %edx,-0x28(%rbp)
mov    -0x8(%rbp),%eax
cltd
idivl  -0x14(%rbp)
mov    -0x28(%rbp),%eax
sub    %edx,%eax
cltd
idivl  -0x14(%rbp)
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%esi
lea    0xe04(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cvtsi2sdl -0x18(%rbp),%xmm0
movsd  0xdc3(%rip),%xmm1
mulsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,-0x18(%rbp)
cvtsi2sdl -0x14(%rbp),%xmm0
movsd  0xdab(%rip),%xmm1
mulsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    11f6 <main+0xd6>
mov    -0x8(%rbp),%eax
cltd
idivl  -0x18(%rbp)
mov    %edx,-0x2c(%rbp)
mov    -0x8(%rbp),%eax
cltd
idivl  -0x14(%rbp)
mov    -0x2c(%rbp),%eax
sub    %edx,%eax
cltd
idivl  -0x14(%rbp)
mov    %eax,-0x1c(%rbp)
cmpl   $0x1,-0x24(%rbp)
jne    12ab <main+0x18b>
mov    -0x1c(%rbp),%esi
lea    0xd8d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12bc <main+0x19c>
mov    -0x1c(%rbp),%esi
lea    0xd78(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xd6e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
lea    0xebd(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xec3(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1050 <scanf@plt>
mov    0xc(%rsp),%r14d
cmp    $0x80000002,%r14d
jge    1175 <main+0x45>
lea    0xec9(%rip),%rdi
jmp    12b4 <main+0x184>
mov    %r14d,%esi
test   %r14d,%r14d
js     1236 <main+0x106>
cmp    $0xa,%esi
jb     1248 <main+0x118>
mov    $0xffffffff,%r12d
mov    $0xcccccccd,%eax
mov    %esi,%ecx
nopw   0x0(%rax,%rax,1)
mov    %ecx,%edx
imul   %rax,%rdx
shr    $0x23,%rdx
add    $0x1,%r12d
cmp    $0x63,%ecx
mov    %edx,%ecx
ja     11a0 <main+0x70>
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
lea    0xe3e(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r12d,%eax
add    $0xffffffff,%eax
js     126e <main+0x13e>
mov    $0xa,%ebx
mov    $0x64,%ebp
lea    0xe1a(%rip),%r15
xchg   %ax,%ax
mov    0xc(%rsp),%ecx
mov    %ecx,%eax
cltd
idiv   %ebp
mov    %edx,%esi
mov    %ecx,%eax
cltd
idiv   %ebx
sub    %edx,%esi
mov    %esi,%eax
cltd
idiv   %ebx
mov    %r15,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
add    %ebp,%ebp
lea    0x0(%rbp,%rbp,4),%ebp
add    %ebx,%ebx
lea    (%rbx,%rbx,4),%ebx
add    $0xffffffff,%r12d
jne    1200 <main+0xd0>
jmp    1278 <main+0x148>
mov    %r14d,%esi
neg    %esi
mov    %esi,0xc(%rsp)
cmp    $0xa,%esi
jae    118a <main+0x5a>
movzbl %sil,%eax
imul   $0xcd,%eax,%ecx
shr    $0xa,%ecx
and    $0xfffffffe,%ecx
lea    (%rcx,%rcx,4),%ecx
sub    %cl,%al
movzbl %al,%esi
lea    0xdb1(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x64,%ebp
mov    $0xa,%ebx
mov    0xc(%rsp),%ecx
mov    %ecx,%eax
cltd
idiv   %ebp
mov    %edx,%esi
mov    %ecx,%eax
cltd
idiv   %ebx
sub    %edx,%esi
mov    %esi,%eax
cltd
idiv   %ebx
test   %r14d,%r14d
lea    0xd7e(%rip),%rcx
lea    0xd78(%rip),%rdi
cmovs  %rcx,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xd68(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [20 x i8] c"Enter an integer > \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [13 x i8] c"-2147483647\0A\00"
@.str.3 = [4 x i8] c"%d\0A\00"
@.str.4 = [5 x i8] c"-%d\0A\00"
@.str.5 = [30 x i8] c"That's all, have a nice day!\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i32 0, i32* %1
store i32 10, i32* %5
store i32 100, i32* %6
store i32 -1, i32* %8
store i32 0, i32* %9
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
%11 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%12 = load i32, i32* %2
%13 = icmp sle i32 %12, -2147483647
br i1 %13, label %14, label %16
14: ; preds = %0
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %1
br label %83
16: ; preds = %0
%17 = load i32, i32* %2
%18 = icmp slt i32 %17, 0
br i1 %18, label %19, label %22
19: ; preds = %16
%20 = load i32, i32* %2
%21 = mul nsw i32 %20, -1
store i32 %21, i32* %2
store i32 1, i32* %9
br label %22
22: ; preds = %19, %16
%23 = load i32, i32* %2
store i32 %23, i32* %3
br label %24
24: ; preds = %27, %22
%25 = load i32, i32* %3
%26 = icmp sge i32 %25, 10
br i1 %26, label %27, label %32
27: ; preds = %24
%28 = load i32, i32* %3
%29 = sdiv i32 %28, 10
store i32 %29, i32* %3
%30 = load i32, i32* %8
%31 = add nsw i32 %30, 1
store i32 %31, i32* %8
br label %24
32: ; preds = %24
%33 = load i32, i32* %2
%34 = srem i32 %33, 10
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %34)
store i32 0, i32* %4
br label %36
36: ; preds = %60, %32
%37 = load i32, i32* %4
%38 = load i32, i32* %8
%39 = icmp slt i32 %37, %38
br i1 %39, label %40, label %63
40: ; preds = %36
%41 = load i32, i32* %2
%42 = load i32, i32* %6
%43 = srem i32 %41, %42
%44 = load i32, i32* %2
%45 = load i32, i32* %5
%46 = srem i32 %44, %45
%47 = sub nsw i32 %43, %46
%48 = load i32, i32* %5
%49 = sdiv i32 %47, %48
store i32 %49, i32* %7
%50 = load i32, i32* %7
%51 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %50)
%52 = load i32, i32* %6
%53 = sitofp i32 %52 to double
%54 = fmul double %53, 1.000000e+01
%55 = fptosi double %54 to i32
store i32 %55, i32* %6
%56 = load i32, i32* %5
%57 = sitofp i32 %56 to double
%58 = fmul double %57, 1.000000e+01
%59 = fptosi double %58 to i32
store i32 %59, i32* %5
br label %60
60: ; preds = %40
%61 = load i32, i32* %4
%62 = add nsw i32 %61, 1
store i32 %62, i32* %4
br label %36
63: ; preds = %36
%64 = load i32, i32* %2
%65 = load i32, i32* %6
%66 = srem i32 %64, %65
%67 = load i32, i32* %2
%68 = load i32, i32* %5
%69 = srem i32 %67, %68
%70 = sub nsw i32 %66, %69
%71 = load i32, i32* %5
%72 = sdiv i32 %70, %71
store i32 %72, i32* %7
%73 = load i32, i32* %9
%74 = icmp eq i32 %73, 1
br i1 %74, label %75, label %78
75: ; preds = %63
%76 = load i32, i32* %7
%77 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i32 %76)
br label %81
78: ; preds = %63
%79 = load i32, i32* %7
%80 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %79)
br label %81
81: ; preds = %78, %75
%82 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.5, i64 0, i64 0))
store i32 0, i32* %1
br label %83
83: ; preds = %81, %14
%84 = load i32, i32* %1
ret i32 %84
}

LLVM IR (-O2):
@.str = [20 x i8] c"Enter an integer > \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.3 = [4 x i8] c"%d\0A\00"
@.str.4 = [5 x i8] c"-%d\0A\00"
@str = [29 x i8] c"That's all, have a nice day!\00"
@str.6 = [12 x i8] c"-2147483647\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 slt i32 %5, -2147483646
br i1 %6, label %53, label %7
7: ; preds = %0
%8 = icmp slt i32 %5, 0
br i1 %8, label %9, label %11
9: ; preds = %7
%10 = sub nsw i32 0, %5
store i32 %10, i32* %1
br label %11
11: ; preds = %9, %7
%12 = phi i32 [ %10, %9 ], [ %5, %7 ]
%13 = icmp ugt i32 %12, 9
br i1 %13, label %19, label %14
14: ; preds = %11
%15 = trunc i32 %12 to i8
%16 = urem i8 %15, 10
%17 = zext i8 %16 to i32
%18 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %17)
br label %43
19: ; preds = %11, %19
%20 = phi i32 [ %23, %19 ], [ -1, %11 ]
%21 = phi i32 [ %22, %19 ], [ %12, %11 ]
%22 = udiv i32 %21, 10
%23 = add nsw i32 %20, 1
%24 = icmp ugt i32 %21, 99
br i1 %24, label %19, label %25
25: ; preds = %19
%26 = srem i32 %12, 10
%27 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %26)
%28 = icmp sgt i32 %20, -1
br i1 %28, label %29, label %43
29: ; preds = %25, %29
%30 = phi i32 [ %39, %29 ], [ 100, %25 ]
%31 = phi i32 [ %40, %29 ], [ 10, %25 ]
%32 = phi i32 [ %41, %29 ], [ 0, %25 ]
%33 = load i32, i32* %1
%34 = srem i32 %33, %30
%35 = srem i32 %33, %31
%36 = sub nsw i32 %34, %35
%37 = sdiv i32 %36, %31
%38 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %37)
%39 = mul i32 %30, 10
%40 = mul i32 %31, 10
%41 = add nuw nsw i32 %32, 1
%42 = icmp eq i32 %32, %20
br i1 %42, label %43, label %29
43: ; preds = %29, %14, %25
%44 = phi i32 [ 10, %25 ], [ 10, %14 ], [ %40, %29 ]
%45 = phi i32 [ 100, %25 ], [ 100, %14 ], [ %39, %29 ]
%46 = load i32, i32* %1
%47 = srem i32 %46, %45
%48 = srem i32 %46, %44
%49 = sub nsw i32 %47, %48
%50 = sdiv i32 %49, %44
%51 = select i1 %8, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0)
%52 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) %51, i32 %50)
br label %53
53: ; preds = %0, %43
%54 = phi i8* [ getelementptr inbounds ([29 x i8], [29 x i8]* @str, i64 0, i64 0), %43 ], [ getelementptr inbounds ([12 x i8], [12 x i8]* @str.6, i64 0, i64 0), %0 ]
%55 = call i32 @puts(i8* dereferenceable(1) %54)
ret i32 0
}