#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 num, revnum = 0, temp;
  scanf("%d", &num);
  temp = num;
  do {
    revnum = revnum * 10;
    revnum = revnum + temp % 10;
    temp = temp / 10;
  } while (temp != 0);
  printf("Reverse of %d is %d", num, revnum);
  return 0;
}


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)
imul   $0xa,-0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    -0x14(%rbp),%eax
add    %edx,%eax
mov    %eax,-0xc(%rbp)
mov    -0x10(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,-0x10(%rbp)
cmpl   $0x0,-0x10(%rbp)
jne    114c <main+0x2c>
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
lea    0xe6f(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%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>
xor    %edx,%edx
mov    0x4(%rsp),%esi
mov    %esi,%eax
nopw   0x0(%rax,%rax,1)
lea    (%rdx,%rdx,4),%r8d
movslq %eax,%rcx
imul   $0x66666667,%rcx,%rax
mov    %rax,%rdx
shr    $0x3f,%rdx
sar    $0x22,%rax
add    %edx,%eax
lea    (%rax,%rax,1),%edx
lea    (%rdx,%rdx,4),%edx
mov    %ecx,%edi
sub    %edx,%edi
lea    (%rdi,%r8,2),%edx
add    $0x9,%ecx
cmp    $0x12,%ecx
ja     1140 <main+0x20>
lea    0xe88(%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 = %16, %0
%8 = load i32, i32* %3
%9 = mul nsw i32 %8, 10
store i32 %9, i32* %3
%10 = load i32, i32* %3
%11 = load i32, i32* %4
%12 = srem i32 %11, 10
%13 = add nsw i32 %10, %12
store i32 %13, i32* %3
%14 = load i32, i32* %4
%15 = sdiv i32 %14, 10
store i32 %15, i32* %4
br label %16
16: ; preds = %7
%17 = load i32, i32* %4
%18 = icmp ne i32 %17, 0
br i1 %18, label %7, label %19
19: ; preds = %16
%20 = load i32, i32* %2
%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)
ret i32 0
}

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
br label %5
5: ; preds = %5, %0
%6 = phi i32 [ 0, %0 ], [ %10, %5 ]
%7 = phi i32 [ %4, %0 ], [ %11, %5 ]
%8 = mul nsw i32 %6, 10
%9 = srem i32 %7, 10
%10 = add nsw i32 %9, %8
%11 = sdiv i32 %7, 10
%12 = add i32 %7, 9
%13 = icmp ult i32 %12, 19
br i1 %13, label %14, label %5
14: ; preds = %5
%15 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i32 %4, i32 %10)
ret i32 0
}