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


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0xc(%rbp)
lea    0xec3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeed(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
cmpl   $0x0,-0x8(%rbp)
jne    116f <main+0x4f>
mov    -0xc(%rbp),%esi
lea    0xead(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0x0,-0x8(%rbp)
jle    11c4 <main+0xa4>
jmp    117e <main+0x5e>
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   $0x0,-0x8(%rbp)
jg     117e <main+0x5e>
lea    0xe60(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    125a <main+0x13a>
cmpl   $0x0,-0x8(%rbp)
jge    1255 <main+0x135>
jmp    11d3 <main+0xb3>
cmpl   $0xfffffff6,-0x8(%rbp)
jge    120f <main+0xef>
mov    -0x8(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
imul   $0xffffffff,%edx,%esi
lea    0xe42(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,-0x8(%rbp)
jmp    1238 <main+0x118>
mov    -0x8(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %edx,%esi
lea    0xe14(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,-0x8(%rbp)
jmp    123d <main+0x11d>
cmpl   $0x0,-0x8(%rbp)
jl     11d3 <main+0xb3>
lea    0xdca(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    125a <main+0x13a>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
lea    0xec5(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xeef(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1050 <scanf@plt>
mov    0x4(%rsp),%esi
test   %esi,%esi
je     11c9 <main+0x99>
test   %esi,%esi
jle    11e5 <main+0xb5>
lea    0xecd(%rip),%rbx
nopw   0x0(%rax,%rax,1)
movslq %esi,%rsi
imul   $0x66666667,%rsi,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x22,%rax
add    %ecx,%eax
add    %eax,%eax
lea    (%rax,%rax,4),%eax
sub    %eax,%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
movslq 0x4(%rsp),%rax
imul   $0x66666667,%rax,%rsi
mov    %rsi,%rcx
shr    $0x3f,%rcx
sar    $0x22,%rsi
add    %ecx,%esi
mov    %esi,0x4(%rsp)
cmp    $0x9,%rax
jg     1170 <main+0x40>
lea    0xe79(%rip),%rdi
call   1030 <puts@plt>
jmp    11e7 <main+0xb7>
lea    0xe45(%rip),%rdi
xor    %esi,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x4(%rsp),%esi
test   %esi,%esi
jg     1163 <main+0x33>
js     11f1 <main+0xc1>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
mov    $0xcccccccd,%r14d
lea    0xe39(%rip),%rbx
jmp    124f <main+0x11f>
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
mov    %rbx,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
movslq 0x4(%rsp),%rax
imul   $0x66666667,%rax,%rsi
mov    %rsi,%rcx
shr    $0x3f,%rcx
sar    $0x22,%rsi
add    %ecx,%esi
mov    %esi,0x4(%rsp)
cmp    $0xfffffffffffffff7,%rax
jge    11bb <main+0x8b>
cmp    $0xfffffff5,%esi
jg     1200 <main+0xd0>
neg    %esi
mov    %rsi,%rax
imul   %r14,%rax
shr    $0x23,%rax
jmp    1217 <main+0xe7>

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

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