#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() {
  int p, q, r, n, R, N;
  printf("Enter the value of n");
  scanf("%d", &N);
  n = N;
  R = 0;
  while (n > 0) {
    R = R * 10;
    r = n % 10;
    R = R + r;
    q = n / 10;
    n = q;
  }
  printf("The reversed number is %d", R);
  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    0xee8(%rip),%rdi
lea    -0x1c(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
cmpl   $0x0,-0x14(%rbp)
jle    119b <main+0x7b>
imul   $0xa,-0x18(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x14(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %edx,-0x10(%rbp)
mov    -0x18(%rbp),%eax
add    -0x10(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x14(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x14(%rbp)
jmp    115a <main+0x3a>
mov    -0x18(%rbp),%esi
lea    0xe70(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
lea    0xed4(%rip),%rdi
xor    %ebx,%ebx
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xef0(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1040 <scanf@plt>
mov    0xc(%rsp),%eax
test   %eax,%eax
jle    1181 <main+0x61>
xor    %ebx,%ebx
mov    $0xcccccccd,%ecx
cs nopw 0x0(%rax,%rax,1)
nop
lea    (%rbx,%rbx,4),%edx
mov    %eax,%esi
imul   %rcx,%rsi
shr    $0x23,%rsi
lea    (%rsi,%rsi,1),%edi
lea    (%rdi,%rdi,4),%edi
mov    %eax,%ebx
sub    %edi,%ebx
lea    (%rbx,%rdx,2),%ebx
cmp    $0x9,%eax
mov    %esi,%eax
ja     1160 <main+0x40>
lea    0xe8d(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

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

LLVM IR (-O2):
@.str = [21 x i8] c"Enter the value of n\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [26 x i8] c"The reversed number is %d\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 = load i32, i32* %1
%6 = icmp sgt i32 %5, 0
br i1 %6, label %7, label %15
7: ; preds = %0, %7
%8 = phi i32 [ %12, %7 ], [ 0, %0 ]
%9 = phi i32 [ %13, %7 ], [ %5, %0 ]
%10 = mul nsw i32 %8, 10
%11 = urem i32 %9, 10
%12 = add nsw i32 %10, %11
%13 = udiv i32 %9, 10
%14 = icmp ult i32 %9, 10
br i1 %14, label %15, label %7
15: ; preds = %7, %0
%16 = phi i32 [ 0, %0 ], [ %12, %7 ]
%17 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0), i32 %16)
ret i32 0
}