#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, int);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int n, m = 0;
  int old;
  scanf("%d", &n);
  old = n;
  while (n > 0) {
    m = m * 10;
    m = m + n % 10;
    n /= 10;
  }
  printf("Reverse of %d is %d", old, m);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0xc(%rbp)
lea    0xed4(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x8(%rbp),%eax
mov    %eax,-0x10(%rbp)
cmpl   $0x0,-0x8(%rbp)
jle    1189 <main+0x69>
imul   $0xa,-0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    -0x14(%rbp),%eax
add    %edx,%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,-0x8(%rbp)
jmp    114c <main+0x2c>
mov    -0x10(%rbp),%esi
mov    -0xc(%rbp),%edx
lea    0xe6a(%rip),%rdi
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xee9(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1040 <scanf@plt>
mov    0x4(%rsp),%esi
xor    %edx,%edx
test   %esi,%esi
jle    1177 <main+0x57>
mov    $0xcccccccd,%r8d
mov    %esi,%ecx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %ecx,%edi
lea    (%rdx,%rdx,4),%r9d
mov    %ecx,%ecx
imul   %r8,%rcx
shr    $0x23,%rcx
lea    (%rcx,%rcx,1),%eax
lea    (%rax,%rax,4),%eax
mov    %edi,%edx
sub    %eax,%edx
lea    (%rdx,%r9,2),%edx
cmp    $0x9,%edi
ja     1150 <main+0x30>
mov    %ecx,0x4(%rsp)
lea    0xe82(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@.str.1 = [20 x i8] c"Reverse of %d is %d\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %3
%5 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
%6 = load i32, i32* %2
store i32 %6, i32* %4
br label %7
7: ; preds = %10, %0
%8 = load i32, i32* %2
%9 = icmp sgt i32 %8, 0
br i1 %9, label %10, label %19
10: ; preds = %7
%11 = load i32, i32* %3
%12 = mul nsw i32 %11, 10
store i32 %12, i32* %3
%13 = load i32, i32* %3
%14 = load i32, i32* %2
%15 = srem i32 %14, 10
%16 = add nsw i32 %13, %15
store i32 %16, i32* %3
%17 = load i32, i32* %2
%18 = sdiv i32 %17, 10
store i32 %18, i32* %2
br label %7
19: ; preds = %7
%20 = load i32, i32* %4
%21 = load i32, i32* %3
%22 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i32 %20, i32 %21)
%23 = load i32, i32* %1
ret i32 %23
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@.str.1 = [20 x i8] c"Reverse of %d is %d\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
%4 = load i32, i32* %1
%5 = icmp sgt i32 %4, 0
br i1 %5, label %6, label %15
6: ; preds = %0, %6
%7 = phi i32 [ %11, %6 ], [ 0, %0 ]
%8 = phi i32 [ %12, %6 ], [ %4, %0 ]
%9 = mul nsw i32 %7, 10
%10 = urem i32 %8, 10
%11 = add nsw i32 %9, %10
%12 = udiv i32 %8, 10
%13 = icmp ult i32 %8, 10
br i1 %13, label %14, label %6
14: ; preds = %6
store i32 %12, i32* %1
br label %15
15: ; preds = %14, %0
%16 = phi i32 [ %11, %14 ], [ 0, %0 ]
%17 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i32 %4, i32 %16)
ret i32 0
}