#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 < 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 (num != 0) {
    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   $0x0,-0x8(%rbp)
jge    1181 <main+0x61>
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     11ad <main+0x8d>
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    1187 <main+0x67>
mov    -0x8(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %edx,%esi
lea    0xe5f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0x20(%rbp),%eax
jge    1247 <main+0x127>
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    0xe1e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cvtsi2sdl -0x18(%rbp),%xmm0
movsd  0xdea(%rip),%xmm1
mulsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,-0x18(%rbp)
cvtsi2sdl -0x14(%rbp),%xmm0
movsd  0xdd2(%rip),%xmm1
mulsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    11cf <main+0xaf>
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   $0x0,-0x1c(%rbp)
je     12a4 <main+0x184>
cmpl   $0x1,-0x24(%rbp)
jne    128e <main+0x16e>
mov    -0x1c(%rbp),%esi
lea    0xd9d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    129f <main+0x17f>
mov    -0x1c(%rbp),%esi
lea    0xd88(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12a4 <main+0x184>
lea    0xd79(%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   %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
mov    %r14d,%esi
test   %r14d,%r14d
js     1226 <main+0xf6>
cmp    $0xa,%esi
jb     1238 <main+0x108>
mov    $0xffffffff,%r12d
mov    $0xcccccccd,%eax
mov    %esi,%ecx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %ecx,%edx
imul   %rax,%rdx
shr    $0x23,%rdx
add    $0x1,%r12d
cmp    $0x63,%ecx
mov    %edx,%ecx
ja     1190 <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
lea    0xe4e(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r12d,%eax
add    $0xffffffff,%eax
js     125e <main+0x12e>
mov    $0xa,%ebx
mov    $0x64,%ebp
lea    0xe2a(%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    11f0 <main+0xc0>
jmp    1268 <main+0x138>
mov    %r14d,%esi
neg    %esi
mov    %esi,0xc(%rsp)
cmp    $0xa,%esi
jae    1175 <main+0x45>
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    0xdc1(%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   %eax,%eax
je     12a1 <main+0x171>
test   %r14d,%r14d
lea    0xd8a(%rip),%rcx
lea    0xd84(%rip),%rdi
cmovs  %rcx,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xd74(%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 = [4 x i8] c"%d\0A\00"
@.str.3 = [5 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
%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 slt i32 %12, 0
br i1 %13, label %14, label %17
14: ; preds = %0
%15 = load i32, i32* %2
%16 = mul nsw i32 %15, -1
store i32 %16, i32* %2
store i32 1, i32* %9
br label %17
17: ; preds = %14, %0
%18 = load i32, i32* %2
store i32 %18, i32* %3
br label %19
19: ; preds = %22, %17
%20 = load i32, i32* %3
%21 = icmp sge i32 %20, 10
br i1 %21, label %22, label %27
22: ; preds = %19
%23 = load i32, i32* %3
%24 = sdiv i32 %23, 10
store i32 %24, i32* %3
%25 = load i32, i32* %8
%26 = add nsw i32 %25, 1
store i32 %26, i32* %8
br label %19
27: ; preds = %19
%28 = load i32, i32* %2
%29 = srem i32 %28, 10
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %29)
store i32 0, i32* %4
br label %31
31: ; preds = %55, %27
%32 = load i32, i32* %4
%33 = load i32, i32* %8
%34 = icmp slt i32 %32, %33
br i1 %34, label %35, label %58
35: ; preds = %31
%36 = load i32, i32* %2
%37 = load i32, i32* %6
%38 = srem i32 %36, %37
%39 = load i32, i32* %2
%40 = load i32, i32* %5
%41 = srem i32 %39, %40
%42 = sub nsw i32 %38, %41
%43 = load i32, i32* %5
%44 = sdiv i32 %42, %43
store i32 %44, i32* %7
%45 = load i32, i32* %7
%46 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %45)
%47 = load i32, i32* %6
%48 = sitofp i32 %47 to double
%49 = fmul double %48, 1.000000e+01
%50 = fptosi double %49 to i32
store i32 %50, i32* %6
%51 = load i32, i32* %5
%52 = sitofp i32 %51 to double
%53 = fmul double %52, 1.000000e+01
%54 = fptosi double %53 to i32
store i32 %54, i32* %5
br label %55
55: ; preds = %35
%56 = load i32, i32* %4
%57 = add nsw i32 %56, 1
store i32 %57, i32* %4
br label %31
58: ; preds = %31
%59 = load i32, i32* %2
%60 = load i32, i32* %6
%61 = srem i32 %59, %60
%62 = load i32, i32* %2
%63 = load i32, i32* %5
%64 = srem i32 %62, %63
%65 = sub nsw i32 %61, %64
%66 = load i32, i32* %5
%67 = sdiv i32 %65, %66
store i32 %67, i32* %7
%68 = load i32, i32* %7
%69 = icmp ne i32 %68, 0
br i1 %69, label %70, label %80
70: ; preds = %58
%71 = load i32, i32* %9
%72 = icmp eq i32 %71, 1
br i1 %72, label %73, label %76
73: ; preds = %70
%74 = load i32, i32* %7
%75 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i32 %74)
br label %79
76: ; preds = %70
%77 = load i32, i32* %7
%78 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %77)
br label %79
79: ; preds = %76, %73
br label %80
80: ; preds = %79, %58
%81 = 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.2 = [4 x i8] c"%d\0A\00"
@.str.3 = [5 x i8] c"-%d\0A\00"
@str = [29 x i8] c"That'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 slt i32 %5, 0
br i1 %6, label %7, label %9
7: ; preds = %0
%8 = sub nsw i32 0, %5
store i32 %8, i32* %1
br label %9
9: ; preds = %7, %0
%10 = phi i32 [ %8, %7 ], [ %5, %0 ]
%11 = icmp ugt i32 %10, 9
br i1 %11, label %17, label %12
12: ; preds = %9
%13 = trunc i32 %10 to i8
%14 = urem i8 %13, 10
%15 = zext i8 %14 to i32
%16 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %15)
br label %41
17: ; preds = %9, %17
%18 = phi i32 [ %21, %17 ], [ -1, %9 ]
%19 = phi i32 [ %20, %17 ], [ %10, %9 ]
%20 = udiv i32 %19, 10
%21 = add nsw i32 %18, 1
%22 = icmp ugt i32 %19, 99
br i1 %22, label %17, label %23
23: ; preds = %17
%24 = srem i32 %10, 10
%25 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %24)
%26 = icmp sgt i32 %18, -1
br i1 %26, label %27, label %41
27: ; preds = %23, %27
%28 = phi i32 [ %37, %27 ], [ 100, %23 ]
%29 = phi i32 [ %38, %27 ], [ 10, %23 ]
%30 = phi i32 [ %39, %27 ], [ 0, %23 ]
%31 = load i32, i32* %1
%32 = srem i32 %31, %28
%33 = srem i32 %31, %29
%34 = sub nsw i32 %32, %33
%35 = sdiv i32 %34, %29
%36 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %35)
%37 = mul i32 %28, 10
%38 = mul i32 %29, 10
%39 = add nuw nsw i32 %30, 1
%40 = icmp eq i32 %30, %18
br i1 %40, label %41, label %27
41: ; preds = %27, %12, %23
%42 = phi i32 [ 10, %23 ], [ 10, %12 ], [ %38, %27 ]
%43 = phi i32 [ 100, %23 ], [ 100, %12 ], [ %37, %27 ]
%44 = load i32, i32* %1
%45 = srem i32 %44, %43
%46 = srem i32 %44, %42
%47 = sub nsw i32 %45, %46
%48 = sdiv i32 %47, %42
%49 = icmp eq i32 %48, 0
br i1 %49, label %53, label %50
50: ; preds = %41
%51 = select i1 %6, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0)
%52 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) %51, i32 %48)
br label %53
53: ; preds = %50, %41
%54 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @str, i64 0, i64 0))
ret i32 0
}