#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 n, i, j;
  printf("\nEnter an integer > ");
  scanf("%i", &n);
  printf("\n");
  i = n;
  if (n == 0)
    printf("%i\n", n);
  if (n < -2147483647)
    printf("%i\n", i);
  while (i != 0) {
    j = i % 10;
    i = i / 10;
    if (n < 0 && n == 0)
      printf("%i\n", -j);
    else
      printf("%i\n", j);
  }
  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    0xeca(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xed1(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
lea    0xee4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0x8(%rbp)
jne    117c <main+0x5c>
mov    -0x8(%rbp),%esi
lea    0xea3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0x80000001,-0x8(%rbp)
jge    119a <main+0x7a>
mov    -0xc(%rbp),%esi
lea    0xe85(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    119f <main+0x7f>
cmpl   $0x0,-0xc(%rbp)
je     1207 <main+0xe7>
mov    -0xc(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %edx,-0x10(%rbp)
mov    -0xc(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0x8(%rbp)
jge    11f1 <main+0xd1>
cmpl   $0x0,-0x8(%rbp)
jne    11f1 <main+0xd1>
xor    %esi,%esi
sub    -0x10(%rbp),%esi
lea    0xe33(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1202 <main+0xe2>
mov    -0x10(%rbp),%esi
lea    0xe1d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    119f <main+0x7f>
lea    0xe0e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
lea    0xeb0(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xeb7(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1060 <scanf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    0xc(%rsp),%ebx
mov    %ebx,%eax
test   %ebx,%ebx
je     1189 <main+0x49>
cmp    $0x80000000,%eax
je     11a4 <main+0x64>
test   %ebx,%ebx
jne    11b8 <main+0x78>
jmp    11f6 <main+0xb6>
lea    0xe88(%rip),%rdi
xor    %esi,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0xc(%rsp),%eax
cmp    $0x80000000,%eax
jne    1183 <main+0x43>
lea    0xe6d(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1050 <printf@plt>
test   %ebx,%ebx
je     11f6 <main+0xb6>
lea    0xe59(%rip),%r14
nop
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   1050 <printf@plt>
add    $0x9,%r15d
cmp    $0x12,%r15d
ja     11c0 <main+0x80>
lea    0xe1f(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [21 x i8] c"\0AEnter an integer > \00"
@.str.1 = [3 x i8] c"%i\00"
@.str.2 = [2 x i8] c"\0A\00"
@.str.3 = [4 x i8] c"%i\0A\00"
@.str.4 = [30 x i8] c"That's all, have a nice day!\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%8 = load i32, i32* %2
store i32 %8, i32* %3
%9 = load i32, i32* %2
%10 = icmp eq i32 %9, 0
br i1 %10, label %11, label %14
11: ; preds = %0
%12 = load i32, i32* %2
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %12)
br label %14
14: ; preds = %11, %0
%15 = load i32, i32* %2
%16 = icmp slt i32 %15, -2147483647
br i1 %16, label %17, label %20
17: ; preds = %14
%18 = load i32, i32* %3
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %18)
br label %20
20: ; preds = %17, %14
br label %21
21: ; preds = %41, %20
%22 = load i32, i32* %3
%23 = icmp ne i32 %22, 0
br i1 %23, label %24, label %42
24: ; preds = %21
%25 = load i32, i32* %3
%26 = srem i32 %25, 10
store i32 %26, i32* %4
%27 = load i32, i32* %3
%28 = sdiv i32 %27, 10
store i32 %28, i32* %3
%29 = load i32, i32* %2
%30 = icmp slt i32 %29, 0
br i1 %30, label %31, label %38
31: ; preds = %24
%32 = load i32, i32* %2
%33 = icmp eq i32 %32, 0
br i1 %33, label %34, label %38
34: ; preds = %31
%35 = load i32, i32* %4
%36 = sub nsw i32 0, %35
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %36)
br label %41
38: ; preds = %31, %24
%39 = load i32, i32* %4
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %39)
br label %41
41: ; preds = %38, %34
br label %21
42: ; preds = %21
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.4, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str = [21 x i8] c"\0AEnter an integer > \00"
@.str.1 = [3 x i8] c"%i\00"
@.str.3 = [4 x i8] c"%i\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 ([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 = call i32 @putchar(i32 10)
%6 = load i32, i32* %1
%7 = icmp eq i32 %6, 0
br i1 %7, label %8, label %11
8: ; preds = %0
%9 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 0)
%10 = load i32, i32* %1
br label %11
11: ; preds = %8, %0
%12 = phi i32 [ %10, %8 ], [ %6, %0 ]
%13 = icmp eq i32 %12, -2147483648
br i1 %13, label %14, label %16
14: ; preds = %11
%15 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %6)
br label %16
16: ; preds = %14, %11
br i1 %7, label %24, label %17
17: ; preds = %16, %17
%18 = phi i32 [ %19, %17 ], [ %6, %16 ]
%19 = sdiv i32 %18, 10
%20 = srem i32 %18, 10
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 %20)
%22 = add i32 %18, 9
%23 = icmp ult i32 %22, 19
br i1 %23, label %24, label %17
24: ; preds = %17, %16
%25 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @str, i64 0, i64 0))
ret i32 0
}