#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 = 0;
  printf("Enter an integer > ");
  scanf("%d", &x);
  y = x;
  while (y >= 10) {
    y /= 10;
    max++;
  }
  if (max >= 9)
    printf("\n7\n4\n6\n3\n8\n4\n7\n4\n1\n2\n");
  else {
    if (x < 0) {
      printf("%d\n", x % 10);
      x = x * -1;
    } else {
      printf("%d\n", x % 10);
    }
    for (i = 0; i < max; i++) {
      num = ((x % step2 - x % step1) / step1);
      printf("%d\n", num);
      step2 *= 10;
      step1 *= 10;
    }
  }
  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   $0x0,-0x20(%rbp)
lea    0xeb5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xebb(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x8(%rbp),%eax
mov    %eax,-0xc(%rbp)
cmpl   $0xa,-0xc(%rbp)
jl     118e <main+0x6e>
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    1168 <main+0x48>
cmpl   $0x9,-0x20(%rbp)
jl     11ab <main+0x8b>
lea    0xe78(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1259 <main+0x139>
cmpl   $0x0,-0x8(%rbp)
jge    11dc <main+0xbc>
mov    -0x8(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %edx,%esi
lea    0xe64(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
imul   $0xffffffff,-0x8(%rbp),%eax
mov    %eax,-0x8(%rbp)
jmp    11f7 <main+0xd7>
mov    -0x8(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %edx,%esi
lea    0xe3d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0x20(%rbp),%eax
jge    1254 <main+0x134>
mov    -0x8(%rbp),%eax
cltd
idivl  -0x18(%rbp)
mov    %edx,-0x24(%rbp)
mov    -0x8(%rbp),%eax
cltd
idivl  -0x14(%rbp)
mov    -0x24(%rbp),%eax
sub    %edx,%eax
cltd
idivl  -0x14(%rbp)
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%esi
lea    0xdfc(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
imul   $0xa,-0x18(%rbp),%eax
mov    %eax,-0x18(%rbp)
imul   $0xa,-0x14(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    11fe <main+0xde>
jmp    1259 <main+0x139>
lea    0xdd1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
lea    0xec2(%rip),%rdi
xor    %r15d,%r15d
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xec5(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1050 <scanf@plt>
mov    0x4(%rsp),%esi
cmp    $0xa,%esi
jl     11a0 <main+0x70>
mov    $0xffffffff,%r15d
mov    $0xcccccccd,%eax
mov    %esi,%ecx
nop
mov    %ecx,%edx
imul   %rax,%rdx
shr    $0x23,%rdx
add    $0x1,%r15d
cmp    $0x63,%ecx
mov    %edx,%ecx
ja     1170 <main+0x40>
cmp    $0x8,%r15d
jb     119c <main+0x6c>
lea    0xea6(%rip),%rdi
call   1030 <puts@plt>
jmp    1244 <main+0x114>
add    $0x1,%r15d
test   %esi,%esi
js     11cf <main+0x9f>
mov    %esi,%eax
mov    $0xcccccccd,%ecx
imul   %rax,%rcx
shr    $0x23,%rcx
add    %ecx,%ecx
lea    (%rcx,%rcx,4),%eax
sub    %eax,%esi
lea    0xe56(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
test   %r15d,%r15d
jne    11fd <main+0xcd>
jmp    1244 <main+0x114>
mov    %esi,%eax
neg    %eax
mov    $0xcccccccd,%ecx
imul   %rax,%rcx
shr    $0x23,%rcx
lea    (%rcx,%rcx,4),%eax
lea    (%rsi,%rax,2),%esi
lea    0xe2a(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
negl   0x4(%rsp)
test   %r15d,%r15d
je     1244 <main+0x114>
mov    $0xa,%ebx
mov    $0x64,%ebp
lea    0xe09(%rip),%r14
xchg   %ax,%ax
mov    0x4(%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    %r14,%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,%r15d
jne    1210 <main+0xe0>
lea    0xdd0(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
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 = [22 x i8] c"\0A7\0A4\0A6\0A3\0A8\0A4\0A7\0A4\0A1\0A2\0A\00"
@.str.3 = [4 x i8] c"%d\0A\00"
@.str.4 = [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
store i32 0, i32* %1
store i32 10, i32* %5
store i32 100, i32* %6
store i32 0, i32* %8
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
%10 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%11 = load i32, i32* %2
store i32 %11, i32* %3
br label %12
12: ; preds = %15, %0
%13 = load i32, i32* %3
%14 = icmp sge i32 %13, 10
br i1 %14, label %15, label %20
15: ; preds = %12
%16 = load i32, i32* %3
%17 = sdiv i32 %16, 10
store i32 %17, i32* %3
%18 = load i32, i32* %8
%19 = add nsw i32 %18, 1
store i32 %19, i32* %8
br label %12
20: ; preds = %12
%21 = load i32, i32* %8
%22 = icmp sge i32 %21, 9
br i1 %22, label %23, label %25
23: ; preds = %20
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0))
br label %63
25: ; preds = %20
%26 = load i32, i32* %2
%27 = icmp slt i32 %26, 0
br i1 %27, label %28, label %34
28: ; preds = %25
%29 = load i32, i32* %2
%30 = srem i32 %29, 10
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %30)
%32 = load i32, i32* %2
%33 = mul nsw i32 %32, -1
store i32 %33, i32* %2
br label %38
34: ; preds = %25
%35 = load i32, i32* %2
%36 = srem i32 %35, 10
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %36)
br label %38
38: ; preds = %34, %28
store i32 0, i32* %4
br label %39
39: ; preds = %59, %38
%40 = load i32, i32* %4
%41 = load i32, i32* %8
%42 = icmp slt i32 %40, %41
br i1 %42, label %43, label %62
43: ; preds = %39
%44 = load i32, i32* %2
%45 = load i32, i32* %6
%46 = srem i32 %44, %45
%47 = load i32, i32* %2
%48 = load i32, i32* %5
%49 = srem i32 %47, %48
%50 = sub nsw i32 %46, %49
%51 = load i32, i32* %5
%52 = sdiv i32 %50, %51
store i32 %52, i32* %7
%53 = load i32, i32* %7
%54 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %53)
%55 = load i32, i32* %6
%56 = mul nsw i32 %55, 10
store i32 %56, i32* %6
%57 = load i32, i32* %5
%58 = mul nsw i32 %57, 10
store i32 %58, i32* %5
br label %59
59: ; preds = %43
%60 = load i32, i32* %4
%61 = add nsw i32 %60, 1
store i32 %61, i32* %4
br label %39
62: ; preds = %39
br label %63
63: ; preds = %62, %23
%64 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.4, i64 0, i64 0))
ret i32 0
}

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 = [29 x i8] c"That's all, have a nice day!\00"
@str.5 = [21 x i8] c"\0A7\0A4\0A6\0A3\0A8\0A4\0A7\0A4\0A1\0A2\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 sgt i32 %5, 9
br i1 %6, label %7, label %17
7: ; preds = %0, %7
%8 = phi i32 [ %11, %7 ], [ 0, %0 ]
%9 = phi i32 [ %10, %7 ], [ %5, %0 ]
%10 = udiv i32 %9, 10
%11 = add nuw nsw i32 %8, 1
%12 = icmp ugt i32 %9, 99
br i1 %12, label %7, label %13
13: ; preds = %7
%14 = icmp ugt i32 %8, 7
br i1 %14, label %15, label %17
15: ; preds = %13
%16 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @str.5, i64 0, i64 0))
br label %46
17: ; preds = %0, %13
%18 = phi i32 [ %11, %13 ], [ 0, %0 ]
%19 = icmp slt i32 %5, 0
br i1 %19, label %20, label %27
20: ; preds = %17
%21 = sub i32 0, %5
%22 = urem i32 %21, 10
%23 = sub nsw i32 0, %22
%24 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %23)
%25 = load i32, i32* %1
%26 = sub nsw i32 0, %25
store i32 %26, i32* %1
br label %30
27: ; preds = %17
%28 = urem i32 %5, 10
%29 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %28)
br label %30
30: ; preds = %27, %20
%31 = icmp eq i32 %18, 0
br i1 %31, label %46, label %32
32: ; preds = %30, %32
%33 = phi i32 [ %42, %32 ], [ 100, %30 ]
%34 = phi i32 [ %43, %32 ], [ 10, %30 ]
%35 = phi i32 [ %44, %32 ], [ 0, %30 ]
%36 = load i32, i32* %1
%37 = srem i32 %36, %33
%38 = srem i32 %36, %34
%39 = sub nsw i32 %37, %38
%40 = sdiv i32 %39, %34
%41 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %40)
%42 = mul nsw i32 %33, 10
%43 = mul nsw i32 %34, 10
%44 = add nuw i32 %35, 1
%45 = icmp eq i32 %44, %18
br i1 %45, label %46, label %32
46: ; preds = %32, %30, %15
%47 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @str, i64 0, i64 0))
ret i32 0
}