#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 x, a, b, c, y;
  printf("Enter an integer > ");
  scanf("%d", &b);
  a = b / 10;
  c = b % 10;
  if (c > 0) {
    printf("\n%d\n", c);
  } else if (c < 0) {
    y = c * (-1);
    printf("%d\n", y);
  }
  if (a > 0) {
    while (a > 0) {
      x = a % 10;
      a = a / 10;
      printf("%d\n", x);
      if (a < 10) {
        printf("%d\nThat's all, have a nice day!\n", a);
        return 0;
      }
    }
  } else if (a < 0) {
    a = a * (-1);
    while (a > 0) {
      x = a % 10;
      a = a / 10;
      printf("%d\n", x);
      if (a < 10) {
        a = a * (-1);
        printf("%d\nTHat's all, have a nice day~\n", a);
      }
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xed0(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x10(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,-0xc(%rbp)
mov    -0x10(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %edx,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jle    1189 <main+0x69>
mov    -0x14(%rbp),%esi
lea    0xe9a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11b0 <main+0x90>
cmpl   $0x0,-0x14(%rbp)
jge    11ab <main+0x8b>
imul   $0xffffffff,-0x14(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%esi
lea    0xe74(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11b0 <main+0x90>
cmpl   $0x0,-0xc(%rbp)
jle    1227 <main+0x107>
jmp    11bf <main+0x9f>
cmpl   $0x0,-0xc(%rbp)
jle    1222 <main+0x102>
mov    -0xc(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %edx,-0x8(%rbp)
mov    -0xc(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%esi
lea    0xe29(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0xa,-0xc(%rbp)
jge    121d <main+0xfd>
mov    -0xc(%rbp),%esi
lea    0xe12(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    12a7 <main+0x187>
jmp    11bf <main+0x9f>
jmp    12a0 <main+0x180>
cmpl   $0x0,-0xc(%rbp)
jge    129b <main+0x17b>
imul   $0xffffffff,-0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0xc(%rbp)
jle    1296 <main+0x176>
mov    -0xc(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %edx,-0x8(%rbp)
mov    -0xc(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%esi
lea    0xdb0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0xa,-0xc(%rbp)
jge    1291 <main+0x171>
imul   $0xffffffff,-0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%esi
lea    0xdb3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1238 <main+0x118>
jmp    129b <main+0x17b>
jmp    12a0 <main+0x180>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
lea    0xed2(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xed8(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1040 <scanf@plt>
movslq 0x4(%rsp),%r14
imul   $0x66666667,%r14,%rbx
mov    %rbx,%rax
shr    $0x3f,%rax
sar    $0x22,%rbx
add    %eax,%ebx
lea    (%rbx,%rbx,1),%eax
lea    (%rax,%rax,4),%eax
mov    %r14d,%esi
sub    %eax,%esi
test   %esi,%esi
jle    117e <main+0x5e>
lea    0xea2(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
jmp    1184 <main+0x64>
js     1234 <main+0x114>
cmp    $0xa,%r14d
jl     11db <main+0xbb>
lea    0xe87(%rip),%r14
cs nopw 0x0(%rax,%rax,1)
nopl   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,%esi
sub    %eax,%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
cmp    $0x63,%r15d
jg     11a0 <main+0x80>
lea    0xe43(%rip),%rdi
jmp    121e <main+0xfe>
cmp    $0xfffffff6,%r14d
jg     1227 <main+0x107>
neg    %ebx
mov    $0xcccccccd,%r15d
lea    0xe28(%rip),%r14
mov    %ebx,%ebp
mov    %ebx,%ebx
imul   %r15,%rbx
shr    $0x23,%rbx
lea    (%rbx,%rbx,1),%eax
lea    (%rax,%rax,4),%eax
mov    %ebp,%esi
sub    %eax,%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
cmp    $0x63,%ebp
ja     11f0 <main+0xd0>
neg    %ebx
lea    0xe1f(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
neg    %esi
lea    0xddb(%rip),%rdi
jmp    1175 <main+0x55>

LLVM IR (-O0):
@.str = [20 x i8] c"Enter an integer > \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [5 x i8] c"\0A%d\0A\00"
@.str.3 = [4 x i8] c"%d\0A\00"
@.str.4 = [33 x i8] c"%d\0AThat's all, have a nice day!\0A\00"
@.str.5 = [33 x i8] c"%d\0ATHat'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
store i32 0, i32* %1
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %4)
%9 = load i32, i32* %4
%10 = sdiv i32 %9, 10
store i32 %10, i32* %3
%11 = load i32, i32* %4
%12 = srem i32 %11, 10
store i32 %12, i32* %5
%13 = load i32, i32* %5
%14 = icmp sgt i32 %13, 0
br i1 %14, label %15, label %18
15: ; preds = %0
%16 = load i32, i32* %5
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 %16)
br label %27
18: ; preds = %0
%19 = load i32, i32* %5
%20 = icmp slt i32 %19, 0
br i1 %20, label %21, label %26
21: ; preds = %18
%22 = load i32, i32* %5
%23 = mul nsw i32 %22, -1
store i32 %23, i32* %6
%24 = load i32, i32* %6
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %24)
br label %26
26: ; preds = %21, %18
br label %27
27: ; preds = %26, %15
%28 = load i32, i32* %3
%29 = icmp sgt i32 %28, 0
br i1 %29, label %30, label %48
30: ; preds = %27
br label %31
31: ; preds = %46, %30
%32 = load i32, i32* %3
%33 = icmp sgt i32 %32, 0
br i1 %33, label %34, label %47
34: ; preds = %31
%35 = load i32, i32* %3
%36 = srem i32 %35, 10
store i32 %36, i32* %2
%37 = load i32, i32* %3
%38 = sdiv i32 %37, 10
store i32 %38, i32* %3
%39 = load i32, i32* %2
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %39)
%41 = load i32, i32* %3
%42 = icmp slt i32 %41, 10
br i1 %42, label %43, label %46
43: ; preds = %34
%44 = load i32, i32* %3
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.4, i64 0, i64 0), i32 %44)
store i32 0, i32* %1
br label %75
46: ; preds = %34
br label %31
47: ; preds = %31
br label %74
48: ; preds = %27
%49 = load i32, i32* %3
%50 = icmp slt i32 %49, 0
br i1 %50, label %51, label %73
51: ; preds = %48
%52 = load i32, i32* %3
%53 = mul nsw i32 %52, -1
store i32 %53, i32* %3
br label %54
54: ; preds = %71, %51
%55 = load i32, i32* %3
%56 = icmp sgt i32 %55, 0
br i1 %56, label %57, label %72
57: ; preds = %54
%58 = load i32, i32* %3
%59 = srem i32 %58, 10
store i32 %59, i32* %2
%60 = load i32, i32* %3
%61 = sdiv i32 %60, 10
store i32 %61, i32* %3
%62 = load i32, i32* %2
%63 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %62)
%64 = load i32, i32* %3
%65 = icmp slt i32 %64, 10
br i1 %65, label %66, label %71
66: ; preds = %57
%67 = load i32, i32* %3
%68 = mul nsw i32 %67, -1
store i32 %68, i32* %3
%69 = load i32, i32* %3
%70 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.5, i64 0, i64 0), i32 %69)
br label %71
71: ; preds = %66, %57
br label %54
72: ; preds = %54
br label %73
73: ; preds = %72, %48
br label %74
74: ; preds = %73, %47
store i32 0, i32* %1
br label %75
75: ; preds = %74, %43
%76 = load i32, i32* %1
ret i32 %76
}

LLVM IR (-O2):
@.str = [20 x i8] c"Enter an integer > \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [5 x i8] c"\0A%d\0A\00"
@.str.3 = [4 x i8] c"%d\0A\00"
@.str.4 = [33 x i8] c"%d\0AThat's all, have a nice day!\0A\00"
@.str.5 = [33 x i8] c"%d\0ATHat's all, have a nice day~\0A\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 = sdiv i32 %5, 10
%7 = srem i32 %5, 10
%8 = icmp sgt i32 %7, 0
br i1 %8, label %9, label %11
9: ; preds = %0
%10 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 %7)
br label %16
11: ; preds = %0
%12 = icmp slt i32 %7, 0
br i1 %12, label %13, label %16
13: ; preds = %11
%14 = sub nsw i32 0, %7
%15 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %14)
br label %16
16: ; preds = %11, %13, %9
%17 = icmp sgt i32 %5, 9
br i1 %17, label %18, label %26
18: ; preds = %16, %18
%19 = phi i32 [ %21, %18 ], [ %6, %16 ]
%20 = srem i32 %19, 10
%21 = sdiv i32 %19, 10
%22 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %20)
%23 = icmp slt i32 %19, 100
br i1 %23, label %24, label %18
24: ; preds = %18
%25 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.4, i64 0, i64 0), i32 %21)
br label %39
26: ; preds = %16
%27 = icmp slt i32 %5, -9
br i1 %27, label %28, label %39
28: ; preds = %26
%29 = sub nsw i32 0, %6
br label %30
30: ; preds = %30, %28
%31 = phi i32 [ %33, %30 ], [ %29, %28 ]
%32 = urem i32 %31, 10
%33 = udiv i32 %31, 10
%34 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %32)
%35 = icmp ult i32 %31, 100
br i1 %35, label %36, label %30
36: ; preds = %30
%37 = sub nsw i32 0, %33
%38 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.5, i64 0, i64 0), i32 %37)
br label %39
39: ; preds = %36, %26, %24
ret i32 0
}