#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)
    printf("%d\n", 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)
jne    1178 <main+0x48>
mov    -0x8(%rbp),%esi
lea    0xea6(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
cmpl   $0x0,-0x8(%rbp)
jge    11e9 <main+0xb9>
mov    -0x8(%rbp),%edi
call   1030 <abs@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0xa,-0x8(%rbp)
jle    11c5 <main+0x95>
mov    -0x8(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %edx,%esi
lea    0xe6c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,-0x8(%rbp)
jmp    118d <main+0x5d>
mov    -0x8(%rbp),%eax
mov    -0x8(%rbp),%ecx
shl    $0x1,%ecx
sub    %ecx,%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%esi
lea    0xe3a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    122b <main+0xfb>
jmp    11ee <main+0xbe>
cmpl   $0x0,-0x8(%rbp)
je     1226 <main+0xf6>
mov    -0x8(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %edx,%esi
lea    0xe0b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,-0x8(%rbp)
jmp    11ee <main+0xbe>
jmp    122b <main+0xfb>
lea    0xde9(%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
je     11c2 <main+0x92>
test   %eax,%eax
js     11da <main+0xaa>
je     1252 <main+0x122>
lea    0xeab(%rip),%rbx
nopl   0x0(%rax)
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    1252 <main+0x122>
lea    0xe4e(%rip),%rdi
xor    %esi,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x4(%rsp),%eax
test   %eax,%eax
jns    115f <main+0x2f>
mov    %eax,%esi
neg    %esi
mov    %esi,0x4(%rsp)
cmp    $0xfffffff5,%eax
ja     123e <main+0x10e>
mov    $0xcccccccd,%r14d
lea    0xe23(%rip),%rbx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
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     1200 <main+0xd0>
neg    %esi
mov    %esi,0x4(%rsp)
lea    0xdcc(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xdc2(%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 eq i32 %5, 0
br i1 %6, label %7, label %10
7: ; preds = %0
%8 = load i32, i32* %2
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %8)
br label %10
10: ; preds = %7, %0
%11 = load i32, i32* %2
%12 = icmp slt i32 %11, 0
br i1 %12, label %13, label %32
13: ; preds = %10
%14 = load i32, i32* %2
%15 = call i32 @abs(i32 %14)
store i32 %15, i32* %2
br label %16
16: ; preds = %19, %13
%17 = load i32, i32* %2
%18 = icmp sgt i32 %17, 10
br i1 %18, label %19, label %25
19: ; preds = %16
%20 = load i32, i32* %2
%21 = srem i32 %20, 10
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %21)
%23 = load i32, i32* %2
%24 = sdiv i32 %23, 10
store i32 %24, i32* %2
br label %16
25: ; preds = %16
%26 = load i32, i32* %2
%27 = load i32, i32* %2
%28 = mul nsw i32 2, %27
%29 = sub nsw i32 %26, %28
store i32 %29, i32* %2
%30 = load i32, i32* %2
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %30)
br label %43
32: ; preds = %10
br label %33
33: ; preds = %36, %32
%34 = load i32, i32* %2
%35 = icmp ne i32 %34, 0
br i1 %35, label %36, label %42
36: ; preds = %33
%37 = load i32, i32* %2
%38 = srem i32 %37, 10
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %38)
%40 = load i32, i32* %2
%41 = sdiv i32 %40, 10
store i32 %41, i32* %2
br label %33
42: ; preds = %33
br label %43
43: ; preds = %42, %25
%44 = 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 eq i32 %5, 0
br i1 %6, label %7, label %10
7: ; preds = %0
%8 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 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 slt i32 %11, 0
br i1 %12, label %13, label %27
13: ; preds = %10
%14 = sub nsw i32 0, %11
store i32 %14, i32* %1
%15 = icmp ult i32 %11, -10
br i1 %15, label %16, label %23
16: ; preds = %13, %16
%17 = phi i32 [ %21, %16 ], [ %14, %13 ]
%18 = urem i32 %17, 10
%19 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %18)
%20 = load i32, i32* %1
%21 = sdiv i32 %20, 10
store i32 %21, i32* %1
%22 = icmp sgt i32 %20, 109
br i1 %22, label %16, label %23
23: ; preds = %16, %13
%24 = phi i32 [ %14, %13 ], [ %21, %16 ]
%25 = sub nsw i32 0, %24
store i32 %25, i32* %1
%26 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %25)
br label %37
27: ; preds = %10
%28 = icmp eq i32 %11, 0
br i1 %28, label %37, label %29
29: ; preds = %27, %29
%30 = phi i32 [ %34, %29 ], [ %11, %27 ]
%31 = srem i32 %30, 10
%32 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %31)
%33 = load i32, i32* %1
%34 = sdiv i32 %33, 10
store i32 %34, i32* %1
%35 = add i32 %33, 9
%36 = icmp ult i32 %35, 19
br i1 %36, label %37, label %29
37: ; preds = %29, %27, %23
%38 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @str, i64 0, i64 0))
ret i32 0
}