#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;
  printf("Enter an integer > ");
  scanf("%d", &num);
  if (num == 0) {
    printf("\n0\nThat's all, have a nice day!\n");
  }
  while (num < 0) {
    num = -num;
    printf("\n%d", num % 10);
    num = num / 10;
    if (num < 10) {
      printf("\n%dThat's all, have a nice day!\n", -num);
    }
  }
  while ((num <= 9999999999) && (num > 0)) {
    printf("\n%d", num % 10);
    num = num / 10;
    if (num == 0) {
      printf("\nThat's all, have a nice day!\n");
      break;
    }
  }
  return (0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xef2(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
cmpl   $0x0,-0x8(%rbp)
jne    1165 <main+0x45>
lea    0xeb6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    116a <main+0x4a>
cmpl   $0x0,-0x8(%rbp)
jge    11c7 <main+0xa7>
xor    %eax,%eax
sub    -0x8(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %edx,%esi
lea    0xea5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,-0x8(%rbp)
cmpl   $0xa,-0x8(%rbp)
jge    11c2 <main+0xa2>
xor    %esi,%esi
sub    -0x8(%rbp),%esi
lea    0xe7e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    116a <main+0x4a>
jmp    11cc <main+0xac>
movslq -0x8(%rbp),%rcx
xor    %eax,%eax
movabs $0x2540be3ff,%rdx
cmp    %rdx,%rcx
mov    %al,-0x9(%rbp)
jg     11f2 <main+0xd2>
cmpl   $0x0,-0x8(%rbp)
setg   %al
mov    %al,-0x9(%rbp)
mov    -0x9(%rbp),%al
test   $0x1,%al
jne    1202 <main+0xe2>
jmp    124d <main+0x12d>
mov    -0x8(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %edx,%esi
lea    0xe1f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jne    1248 <main+0x128>
lea    0xdda(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    124d <main+0x12d>
jmp    11cc <main+0xac>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
lea    0xec0(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xec7(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1050 <scanf@plt>
mov    0xc(%rsp),%esi
test   %esi,%esi
je     1169 <main+0x39>
test   %esi,%esi
jns    117d <main+0x4d>
jmp    11ec <main+0xbc>
lea    0xec9(%rip),%rdi
call   1030 <puts@plt>
mov    0xc(%rsp),%esi
test   %esi,%esi
js     11ec <main+0xbc>
mov    $0xcccccccd,%r14d
lea    0xe8a(%rip),%rbx
nopw   0x0(%rax,%rax,1)
test   %esi,%esi
jle    11e0 <main+0xb0>
mov    %esi,%eax
imul   %r14,%rax
shr    $0x23,%rax
add    %eax,%eax
lea    (%rax,%rax,4),%eax
sub    %eax,%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
movslq 0xc(%rsp),%rax
imul   $0x66666667,%rax,%rsi
mov    %rsi,%rcx
shr    $0x3f,%rcx
sar    $0x22,%rsi
add    %ecx,%esi
mov    %esi,0xc(%rsp)
add    $0x9,%eax
cmp    $0x12,%eax
ja     1190 <main+0x60>
lea    0xe60(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret
mov    $0xcccccccd,%r15d
lea    0xe1b(%rip),%rbx
lea    0xe18(%rip),%r14
jmp    1218 <main+0xe8>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
test   %esi,%esi
jns    117d <main+0x4d>
neg    %esi
mov    %esi,0xc(%rsp)
mov    %rsi,%rax
imul   %r15,%rax
shr    $0x23,%rax
add    %eax,%eax
lea    (%rax,%rax,4),%eax
sub    %eax,%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
movslq 0xc(%rsp),%rax
imul   $0x66666667,%rax,%rsi
mov    %rsi,%rcx
shr    $0x3f,%rcx
sar    $0x22,%rsi
add    %ecx,%esi
mov    %esi,0xc(%rsp)
cmp    $0x63,%rax
jg     1210 <main+0xe0>
neg    %esi
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0xc(%rsp),%esi
jmp    1210 <main+0xe0>

LLVM IR (-O0):
@.str = [20 x i8] c"Enter an integer > \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [33 x i8] c"\0A0\0AThat's all, have a nice day!\0A\00"
@.str.3 = [4 x i8] c"\0A%d\00"
@.str.4 = [33 x i8] c"\0A%dThat's all, have a nice day!\0A\00"
@.str.5 = [31 x i8] c"\0AThat's all, have a nice day!\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
store i32 0, i32* %1
%3 = call i32 (i8*, ...) @printf(i8* 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* %2)
%5 = load i32, i32* %2
%6 = icmp eq i32 %5, 0
br i1 %6, label %7, label %9
7: ; preds = %0
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.2, i64 0, i64 0))
br label %9
9: ; preds = %7, %0
br label %10
10: ; preds = %27, %9
%11 = load i32, i32* %2
%12 = icmp slt i32 %11, 0
br i1 %12, label %13, label %28
13: ; preds = %10
%14 = load i32, i32* %2
%15 = sub nsw i32 0, %14
store i32 %15, i32* %2
%16 = load i32, i32* %2
%17 = srem i32 %16, 10
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %17)
%19 = load i32, i32* %2
%20 = sdiv i32 %19, 10
store i32 %20, i32* %2
%21 = load i32, i32* %2
%22 = icmp slt i32 %21, 10
br i1 %22, label %23, label %27
23: ; preds = %13
%24 = load i32, i32* %2
%25 = sub nsw i32 0, %24
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.4, i64 0, i64 0), i32 %25)
br label %27
27: ; preds = %23, %13
br label %10
28: ; preds = %10
br label %29
29: ; preds = %48, %28
%30 = load i32, i32* %2
%31 = sext i32 %30 to i64
%32 = icmp sle i64 %31, 9999999999
br i1 %32, label %33, label %36
33: ; preds = %29
%34 = load i32, i32* %2
%35 = icmp sgt i32 %34, 0
br label %36
36: ; preds = %33, %29
%37 = phi i1 [ false, %29 ], [ %35, %33 ]
br i1 %37, label %38, label %49
38: ; preds = %36
%39 = load i32, i32* %2
%40 = srem i32 %39, 10
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %40)
%42 = load i32, i32* %2
%43 = sdiv i32 %42, 10
store i32 %43, i32* %2
%44 = load i32, i32* %2
%45 = icmp eq i32 %44, 0
br i1 %45, label %46, label %48
46: ; preds = %38
%47 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.5, i64 0, i64 0))
br label %49
48: ; preds = %38
br label %29
49: ; preds = %46, %36
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"\0A%d\00"
@.str.4 = [33 x i8] c"\0A%dThat's all, have a nice day!\0A\00"
@str = [30 x i8] c"\0AThat's all, have a nice day!\00"
@str.6 = [32 x i8] c"\0A0\0AThat'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 eq i32 %5, 0
br i1 %6, label %7, label %10
7: ; preds = %0
%8 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @str.6, i64 0, i64 0))
%9 = load i32, i32* %1
br label %10
10: ; preds = %7, %0
%11 = phi i32 [ %9, %7 ], [ %5, %0 ]
%12 = icmp slt i32 %11, 0
br i1 %12, label %13, label %28
13: ; preds = %10, %25
%14 = phi i32 [ %26, %25 ], [ %11, %10 ]
%15 = sub nsw i32 0, %14
store i32 %15, i32* %1
%16 = urem i32 %15, 10
%17 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %16)
%18 = load i32, i32* %1
%19 = sdiv i32 %18, 10
store i32 %19, i32* %1
%20 = icmp slt i32 %18, 100
br i1 %20, label %21, label %25
21: ; preds = %13
%22 = sub nsw i32 0, %19
%23 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.4, i64 0, i64 0), i32 %22)
%24 = load i32, i32* %1
br label %25
25: ; preds = %21, %13
%26 = phi i32 [ %24, %21 ], [ %19, %13 ]
%27 = icmp slt i32 %26, 0
br i1 %27, label %13, label %28
28: ; preds = %25, %10
%29 = phi i32 [ %11, %10 ], [ %26, %25 ]
br label %30
30: ; preds = %28, %33
%31 = phi i32 [ %37, %33 ], [ %29, %28 ]
%32 = icmp sgt i32 %31, 0
br i1 %32, label %33, label %42
33: ; preds = %30
%34 = urem i32 %31, 10
%35 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %34)
%36 = load i32, i32* %1
%37 = sdiv i32 %36, 10
store i32 %37, i32* %1
%38 = add i32 %36, 9
%39 = icmp ult i32 %38, 19
br i1 %39, label %40, label %30
40: ; preds = %33
%41 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @str, i64 0, i64 0))
br label %42
42: ; preds = %30, %40
ret i32 0
}