#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() {
  int num = 0, rem = 0, count = 1;
  char sign = '\0';
  printf("\nEnter an integer > \n");
  scanf("%d", &num);
  if (num < 0) {
    sign = '-';
    num = num * (-1);
  }
  while (count <= 10 && num != 0) {
    rem = num % 10;
    num = num - rem;
    num = num / 10;
    count++;
    if (num == 0 && sign != '\0') {
      printf("%c%d\n", sign, rem);
    } else {
      printf("%d\n", rem);
    }
  }
  if (num == 0 && count == 1) {
    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    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x1,-0x10(%rbp)
movb   $0x0,-0x11(%rbp)
lea    0xeb1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeb9(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
cmpl   $0x0,-0x8(%rbp)
jge    117b <main+0x5b>
movb   $0x2d,-0x11(%rbp)
imul   $0xffffffff,-0x8(%rbp),%eax
mov    %eax,-0x8(%rbp)
jmp    1180 <main+0x60>
xor    %eax,%eax
cmpl   $0xa,-0x10(%rbp)
mov    %al,-0x12(%rbp)
jg     1199 <main+0x79>
cmpl   $0x0,-0x8(%rbp)
setne  %al
mov    %al,-0x12(%rbp)
mov    -0x12(%rbp),%al
test   $0x1,%al
jne    11a9 <main+0x89>
jmp    121e <main+0xfe>
mov    -0x8(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %edx,-0xc(%rbp)
mov    -0x8(%rbp),%eax
sub    -0xc(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,-0x8(%rbp)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
cmpl   $0x0,-0x8(%rbp)
jne    1208 <main+0xe8>
movsbl -0x11(%rbp),%eax
cmp    $0x0,%eax
je     1208 <main+0xe8>
movsbl -0x11(%rbp),%esi
mov    -0xc(%rbp),%edx
lea    0xe1d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1219 <main+0xf9>
mov    -0xc(%rbp),%esi
lea    0xe09(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1180 <main+0x60>
cmpl   $0x0,-0x8(%rbp)
jne    1243 <main+0x123>
cmpl   $0x1,-0x10(%rbp)
jne    1243 <main+0x123>
mov    -0x8(%rbp),%esi
lea    0xddf(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xdd5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
movl   $0x0,0xc(%rsp)
lea    0xebe(%rip),%rdi
call   1030 <puts@plt>
lea    0xea9(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1050 <scanf@plt>
mov    0xc(%rsp),%ebp
test   %ebp,%ebp
js     1187 <main+0x57>
xor    %r12d,%r12d
mov    %ebp,%eax
test   %ebp,%ebp
jne    1191 <main+0x61>
lea    0xe8c(%rip),%rdi
xor    %esi,%esi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    121c <main+0xec>
mov    %ebp,%eax
neg    %eax
mov    $0x2d,%r12d
mov    $0x1,%ebx
lea    0xe66(%rip),%r14
lea    0xe61(%rip),%r15
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
cltq
imul   $0x66666667,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x22,%rcx
add    %edx,%ecx
lea    (%rcx,%rcx,1),%edx
lea    (%rdx,%rdx,4),%esi
mov    %eax,%edx
sub    %esi,%edx
mov    %ecx,0xc(%rsp)
add    $0x9,%eax
cmp    $0x12,%eax
ja     1200 <main+0xd0>
test   %ebp,%ebp
jns    1200 <main+0xd0>
mov    %r14,%rdi
mov    %r12d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
cmp    $0x9,%ebx
jbe    1211 <main+0xe1>
jmp    121c <main+0xec>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r15,%rdi
mov    %edx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
cmp    $0x9,%ebx
ja     121c <main+0xec>
add    $0x1,%ebx
mov    0xc(%rsp),%eax
test   %eax,%eax
jne    11b0 <main+0x80>
lea    0xdfb(%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 = [22 x i8] c"\0AEnter an integer > \0A\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [6 x i8] c"%c%d\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 i8
store i32 0, i32* %1
store i32 0, i32* %2
store i32 0, i32* %3
store i32 1, i32* %4
store i8 0, i8* %5
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%8 = load i32, i32* %2
%9 = icmp slt i32 %8, 0
br i1 %9, label %10, label %13
10: ; preds = %0
store i8 45, i8* %5
%11 = load i32, i32* %2
%12 = mul nsw i32 %11, -1
store i32 %12, i32* %2
br label %13
13: ; preds = %10, %0
br label %14
14: ; preds = %46, %13
%15 = load i32, i32* %4
%16 = icmp sle i32 %15, 10
br i1 %16, label %17, label %20
17: ; preds = %14
%18 = load i32, i32* %2
%19 = icmp ne i32 %18, 0
br label %20
20: ; preds = %17, %14
%21 = phi i1 [ false, %14 ], [ %19, %17 ]
br i1 %21, label %22, label %47
22: ; preds = %20
%23 = load i32, i32* %2
%24 = srem i32 %23, 10
store i32 %24, i32* %3
%25 = load i32, i32* %2
%26 = load i32, i32* %3
%27 = sub nsw i32 %25, %26
store i32 %27, i32* %2
%28 = load i32, i32* %2
%29 = sdiv i32 %28, 10
store i32 %29, i32* %2
%30 = load i32, i32* %4
%31 = add nsw i32 %30, 1
store i32 %31, i32* %4
%32 = load i32, i32* %2
%33 = icmp eq i32 %32, 0
br i1 %33, label %34, label %43
34: ; preds = %22
%35 = load i8, i8* %5
%36 = sext i8 %35 to i32
%37 = icmp ne i32 %36, 0
br i1 %37, label %38, label %43
38: ; preds = %34
%39 = load i8, i8* %5
%40 = sext i8 %39 to i32
%41 = load i32, i32* %3
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 %40, i32 %41)
br label %46
43: ; preds = %34, %22
%44 = load i32, i32* %3
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %44)
br label %46
46: ; preds = %43, %38
br label %14
47: ; preds = %20
%48 = load i32, i32* %2
%49 = icmp eq i32 %48, 0
br i1 %49, label %50, label %56
50: ; preds = %47
%51 = load i32, i32* %4
%52 = icmp eq i32 %51, 1
br i1 %52, label %53, label %56
53: ; preds = %50
%54 = load i32, i32* %2
%55 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %54)
br label %56
56: ; preds = %53, %50, %47
%57 = 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.1 = [3 x i8] c"%d\00"
@.str.2 = [6 x i8] c"%c%d\0A\00"
@.str.3 = [4 x i8] c"%d\0A\00"
@str = [21 x i8] c"\0AEnter an integer > \00"
@str.5 = [29 x i8] c"That's all, have a nice day!\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
store i32 0, i32* %1
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 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
br label %11
9: ; preds = %0
%10 = icmp eq i32 %5, 0
br i1 %10, label %32, label %11
11: ; preds = %7, %9
%12 = phi i32 [ 45, %7 ], [ 0, %9 ]
%13 = phi i32 [ %8, %7 ], [ %5, %9 ]
br label %14
14: ; preds = %11, %27
%15 = phi i32 [ %29, %27 ], [ %13, %11 ]
%16 = phi i32 [ %19, %27 ], [ 1, %11 ]
%17 = srem i32 %15, 10
%18 = sdiv i32 %15, 10
store i32 %18, i32* %1
%19 = add nuw nsw i32 %16, 1
%20 = add i32 %15, 9
%21 = icmp ult i32 %20, 19
%22 = select i1 %21, i1 %6, i1 false
br i1 %22, label %23, label %25
23: ; preds = %14
%24 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i32 %12, i32 %17)
br label %27
25: ; preds = %14
%26 = 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 %27
27: ; preds = %25, %23
%28 = icmp ult i32 %16, 10
%29 = load i32, i32* %1
%30 = icmp ne i32 %29, 0
%31 = select i1 %28, i1 %30, i1 false
br i1 %31, label %14, label %34
32: ; preds = %9
%33 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 0)
br label %34
34: ; preds = %27, %32
%35 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @str.5, i64 0, i64 0))
ret i32 0
}