#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 *, long long *);
int main(void) {
  long long int number, right_digit;
  printf("Enter a number\n");
  scanf("%lli", &number);
  while (number != 0) {
    right_digit = number % 10;
    printf("%lli", right_digit);
    number /= 10;
  }
  printf("\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeca(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xecc(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1040 <scanf@plt>
cmpq   $0x0,-0x10(%rbp)
je     1193 <main+0x73>
mov    -0x10(%rbp),%rax
mov    $0xa,%ecx
cqto
idiv   %rcx
mov    %rdx,-0x18(%rbp)
mov    -0x18(%rbp),%rsi
lea    0xe9b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%rax
mov    $0xa,%ecx
cqto
idiv   %rcx
mov    %rax,-0x10(%rbp)
jmp    114d <main+0x2d>
lea    0xe74(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
lea    0xeba(%rip),%rdi
call   1040 <puts@plt>
lea    0xea9(%rip),%rdi
mov    %rsp,%rsi
call   1060 <scanf@plt>
mov    (%rsp),%rsi
test   %rsi,%rsi
je     11d1 <main+0x91>
movabs $0x6666666666666667,%rbx
66 66 66
lea    0xe87(%rip),%r14
nopl   0x0(%rax)
mov    %rsi,%rax
imul   %rbx
mov    %rdx,%rax
shr    $0x3f,%rax
sar    $0x2,%rdx
add    %rax,%rdx
add    %rdx,%rdx
lea    (%rdx,%rdx,4),%rax
sub    %rax,%rsi
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    (%rsp),%rcx
mov    %rcx,%rax
imul   %rbx
mov    %rdx,%rsi
mov    %rdx,%rax
shr    $0x3f,%rax
sar    $0x2,%rsi
add    %rax,%rsi
mov    %rsi,(%rsp)
add    $0x9,%rcx
cmp    $0x12,%rcx
ja     1180 <main+0x40>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [16 x i8] c"Enter a number\0A\00"
@.str.1 = [5 x i8] c"%lli\00"
@.str.2 = [2 x i8] c"\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i64
%3 = alloca i64
store i32 0, i32* %1
%4 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
%5 = call i32 @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i64* %2)
br label %6
6: ; preds = %9, %0
%7 = load i64, i64* %2
%8 = icmp ne i64 %7, 0
br i1 %8, label %9, label %16
9: ; preds = %6
%10 = load i64, i64* %2
%11 = srem i64 %10, 10
store i64 %11, i64* %3
%12 = load i64, i64* %3
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i64 %12)
%14 = load i64, i64* %2
%15 = sdiv i64 %14, 10
store i64 %15, i64* %2
br label %6
16: ; preds = %6
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [5 x i8] c"%lli\00"
@str = [15 x i8] c"Enter a number\00"
define i32 @main() {
%1 = alloca i64
%2 = bitcast i64* %1 to i8*
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str, i64 0, i64 0))
%4 = call i32 @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i64* %1)
%5 = load i64, i64* %1
%6 = icmp eq i64 %5, 0
br i1 %6, label %15, label %7
7: ; preds = %0, %7
%8 = phi i64 [ %12, %7 ], [ %5, %0 ]
%9 = srem i64 %8, 10
%10 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i64 %9)
%11 = load i64, i64* %1
%12 = sdiv i64 %11, 10
store i64 %12, i64* %1
%13 = add i64 %11, 9
%14 = icmp ult i64 %13, 19
br i1 %14, label %15, label %7
15: ; preds = %7, %0
%16 = call i32 @putchar(i32 10)
ret i32 0
}