#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 abs(int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int num;
  printf("Enter an integer > ");
  scanf("%d", &num);
  if (num < 0) {
    num = (abs(num));
    while (num > 10) {
      printf("%d\n", num % 10);
      num /= 10;
    }
    num = num - 2 * num;
    printf("%d\n", num);
  } else {
    while (num != 0) {
      printf("%d\n", num % 10);
      num /= 10;
    }
  }
  printf("That'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)
lea    0xeba(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xec0(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1050 <scanf@plt>
cmpl   $0x0,-0x8(%rbp)
jge    11ce <main+0x9e>
mov    -0x8(%rbp),%edi
call   1030 <abs@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0xa,-0x8(%rbp)
jle    11aa <main+0x7a>
mov    -0x8(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %edx,%esi
lea    0xe87(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,-0x8(%rbp)
jmp    1172 <main+0x42>
mov    -0x8(%rbp),%eax
mov    -0x8(%rbp),%ecx
shl    $0x1,%ecx
sub    %ecx,%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%esi
lea    0xe55(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1210 <main+0xe0>
jmp    11d3 <main+0xa3>
cmpl   $0x0,-0x8(%rbp)
je     120b <main+0xdb>
mov    -0x8(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %edx,%esi
lea    0xe26(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,-0x8(%rbp)
jmp    11d3 <main+0xa3>
jmp    1210 <main+0xe0>
lea    0xe04(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
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    0xecb(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1050 <scanf@plt>
mov    0x4(%rsp),%eax
test   %eax,%eax
js     11bf <main+0x8f>
je     1232 <main+0x102>
lea    0xeaf(%rip),%rbx
nopl   0x0(%rax,%rax,1)
movslq %eax,%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),%rcx
imul   $0x66666667,%rcx,%rax
mov    %rax,%rdx
shr    $0x3f,%rdx
sar    $0x22,%rax
add    %edx,%eax
mov    %eax,0x4(%rsp)
add    $0x9,%ecx
cmp    $0x12,%ecx
ja     1170 <main+0x40>
jmp    1232 <main+0x102>
mov    %eax,%esi
neg    %esi
mov    %esi,0x4(%rsp)
cmp    $0xfffffff5,%eax
ja     121e <main+0xee>
mov    $0xcccccccd,%r14d
lea    0xe3e(%rip),%rbx
nopl   0x0(%rax)
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 0x4(%rsp),%rax
imul   $0x66666667,%rax,%rsi
mov    %rsi,%rcx
shr    $0x3f,%rcx
sar    $0x22,%rsi
add    %ecx,%esi
mov    %esi,0x4(%rsp)
cmp    $0x6d,%rax
jg     11e0 <main+0xb0>
neg    %esi
mov    %esi,0x4(%rsp)
lea    0xdec(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xde2(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
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 = [30 x i8] c"That'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 slt i32 %5, 0
br i1 %6, label %7, label %26
7: ; preds = %0
%8 = load i32, i32* %2
%9 = call i32 @abs(i32 %8)
store i32 %9, i32* %2
br label %10
10: ; preds = %13, %7
%11 = load i32, i32* %2
%12 = icmp sgt i32 %11, 10
br i1 %12, label %13, label %19
13: ; preds = %10
%14 = load i32, i32* %2
%15 = srem i32 %14, 10
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %15)
%17 = load i32, i32* %2
%18 = sdiv i32 %17, 10
store i32 %18, i32* %2
br label %10
19: ; preds = %10
%20 = load i32, i32* %2
%21 = load i32, i32* %2
%22 = mul nsw i32 2, %21
%23 = sub nsw i32 %20, %22
store i32 %23, i32* %2
%24 = load i32, i32* %2
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %24)
br label %37
26: ; preds = %0
br label %27
27: ; preds = %30, %26
%28 = load i32, i32* %2
%29 = icmp ne i32 %28, 0
br i1 %29, label %30, label %36
30: ; preds = %27
%31 = load i32, i32* %2
%32 = srem i32 %31, 10
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %32)
%34 = load i32, i32* %2
%35 = sdiv i32 %34, 10
store i32 %35, i32* %2
br label %27
36: ; preds = %27
br label %37
37: ; preds = %36, %19
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.3, 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 = [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 %9, label %7
7: ; preds = %0
%8 = icmp eq i32 %5, 0
br i1 %8, label %31, label %23
9: ; preds = %0
%10 = sub nsw i32 0, %5
store i32 %10, i32* %1
%11 = icmp ult i32 %5, -10
br i1 %11, label %12, label %19
12: ; preds = %9, %12
%13 = phi i32 [ %17, %12 ], [ %10, %9 ]
%14 = urem i32 %13, 10
%15 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %14)
%16 = load i32, i32* %1
%17 = sdiv i32 %16, 10
store i32 %17, i32* %1
%18 = icmp sgt i32 %16, 109
br i1 %18, label %12, label %19
19: ; preds = %12, %9
%20 = phi i32 [ %10, %9 ], [ %17, %12 ]
%21 = sub nsw i32 0, %20
store i32 %21, i32* %1
%22 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %21)
br label %31
23: ; preds = %7, %23
%24 = phi i32 [ %28, %23 ], [ %5, %7 ]
%25 = srem i32 %24, 10
%26 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %25)
%27 = load i32, i32* %1
%28 = sdiv i32 %27, 10
store i32 %28, i32* %1
%29 = add i32 %27, 9
%30 = icmp ult i32 %29, 19
br i1 %30, label %31, label %23
31: ; preds = %23, %7, %19
%32 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @str, i64 0, i64 0))
ret i32 0
}