#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 pow(int, int);
int /*<<< orphan*/ printf(char *, int, int);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  int a, b, c, d = 10, e, f, g, h = 0, i, j = 0, k, l;
  double m, n;
  scanf("%d", &a);
  l = a;
  for (c = 100; c >= 1;) {
    c = a / d;
    d = d * 10;
    h = h + 1;
  }
  k = h;
  for (i = 1; i <= h; i = i + 1) {
    b = a % 10;
    a = a - b;
    a = a / 10;
    m = b * pow(10, k - 1);
    j = j + m;
    k = k - 1;
  }
  printf("Reverse of %d is %d", l, j);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0xa,-0x14(%rbp)
movl   $0x0,-0x24(%rbp)
movl   $0x0,-0x2c(%rbp)
lea    0xeb6(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x8(%rbp),%eax
mov    %eax,-0x34(%rbp)
movl   $0x64,-0x10(%rbp)
cmpl   $0x1,-0x10(%rbp)
jl     119a <main+0x6a>
mov    -0x8(%rbp),%eax
cltd
idivl  -0x14(%rbp)
mov    %eax,-0x10(%rbp)
imul   $0xa,-0x14(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1171 <main+0x41>
mov    -0x24(%rbp),%eax
mov    %eax,-0x30(%rbp)
movl   $0x1,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x24(%rbp),%eax
jg     1227 <main+0xf7>
mov    -0x8(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %edx,-0xc(%rbp)
mov    -0x8(%rbp),%eax
sub    -0xc(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,-0x8(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x4c(%rbp)
mov    -0x30(%rbp),%esi
sub    $0x1,%esi
mov    $0xa,%edi
call   1050 <pow@plt>
mov    %eax,%ecx
mov    -0x4c(%rbp),%eax
imul   %ecx,%eax
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x40(%rbp)
cvtsi2sdl -0x2c(%rbp),%xmm0
addsd  -0x40(%rbp),%xmm0
cvttsd2si %xmm0,%eax
mov    %eax,-0x2c(%rbp)
mov    -0x30(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x30(%rbp)
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    11a7 <main+0x77>
mov    -0x34(%rbp),%esi
mov    -0x2c(%rbp),%edx
lea    0xdcc(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
lea    0xece(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1040 <scanf@plt>
mov    $0xa,%ecx
mov    $0xfffffffe,%r12d
mov    0xc(%rsp),%r14d
nopl   (%rax)
mov    %r14d,%eax
cltd
idiv   %ecx
add    %ecx,%ecx
lea    (%rcx,%rcx,4),%ecx
add    $0x1,%r12d
test   %eax,%eax
jg     1160 <main+0x30>
lea    0x1(%r12),%r15d
xor    %ebx,%ebx
mov    %r14d,%eax
nopl   (%rax)
movslq %eax,%rbp
imul   $0x66666667,%rbp,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x22,%rax
add    %ecx,%eax
lea    (%rax,%rax,1),%ecx
lea    (%rcx,%rcx,4),%ecx
sub    %ecx,%ebp
mov    %eax,0xc(%rsp)
mov    $0xa,%edi
mov    %r15d,%esi
call   1050 <pow@plt>
imul   %ebp,%eax
cltq
movslq %ebx,%rbx
add    %rax,%rbx
cmp    $0xffffffff,%r12d
je     11cf <main+0x9f>
mov    0xc(%rsp),%eax
add    $0xffffffff,%r15d
add    $0xffffffff,%r12d
jmp    1180 <main+0x50>
lea    0xe2a(%rip),%rdi
mov    %r14d,%esi
mov    %ebx,%edx
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
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
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca double
%15 = alloca double
store i32 0, i32* %1
store i32 10, i32* %5
store i32 0, i32* %9
store i32 0, i32* %11
%16 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
%17 = load i32, i32* %2
store i32 %17, i32* %13
store i32 100, i32* %4
br label %18
18: ; preds = %21, %0
%19 = load i32, i32* %4
%20 = icmp sge i32 %19, 1
br i1 %20, label %21, label %29
21: ; preds = %18
%22 = load i32, i32* %2
%23 = load i32, i32* %5
%24 = sdiv i32 %22, %23
store i32 %24, i32* %4
%25 = load i32, i32* %5
%26 = mul nsw i32 %25, 10
store i32 %26, i32* %5
%27 = load i32, i32* %9
%28 = add nsw i32 %27, 1
store i32 %28, i32* %9
br label %18
29: ; preds = %18
%30 = load i32, i32* %9
store i32 %30, i32* %12
store i32 1, i32* %10
br label %31
31: ; preds = %56, %29
%32 = load i32, i32* %10
%33 = load i32, i32* %9
%34 = icmp sle i32 %32, %33
br i1 %34, label %35, label %59
35: ; preds = %31
%36 = load i32, i32* %2
%37 = srem i32 %36, 10
store i32 %37, i32* %3
%38 = load i32, i32* %2
%39 = load i32, i32* %3
%40 = sub nsw i32 %38, %39
store i32 %40, i32* %2
%41 = load i32, i32* %2
%42 = sdiv i32 %41, 10
store i32 %42, i32* %2
%43 = load i32, i32* %3
%44 = load i32, i32* %12
%45 = sub nsw i32 %44, 1
%46 = call i32 @pow(i32 10, i32 %45)
%47 = mul nsw i32 %43, %46
%48 = sitofp i32 %47 to double
store double %48, double* %14
%49 = load i32, i32* %11
%50 = sitofp i32 %49 to double
%51 = load double, double* %14
%52 = fadd double %50, %51
%53 = fptosi double %52 to i32
store i32 %53, i32* %11
%54 = load i32, i32* %12
%55 = sub nsw i32 %54, 1
store i32 %55, i32* %12
br label %56
56: ; preds = %35
%57 = load i32, i32* %10
%58 = add nsw i32 %57, 1
store i32 %58, i32* %10
br label %31
59: ; preds = %31
%60 = load i32, i32* %13
%61 = load i32, i32* %11
%62 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i32 %60, i32 %61)
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 %7
5: ; preds = %7
%6 = add nuw i32 %9, 1
br label %14
7: ; preds = %0, %7
%8 = phi i32 [ 10, %0 ], [ %11, %7 ]
%9 = phi i32 [ 0, %0 ], [ %12, %7 ]
%10 = sdiv i32 %4, %8
%11 = mul nsw i32 %8, 10
%12 = add nuw nsw i32 %9, 1
%13 = icmp sgt i32 %10, 0
br i1 %13, label %7, label %5
14: ; preds = %29, %5
%15 = phi i32 [ %4, %5 ], [ %31, %29 ]
%16 = phi i32 [ %12, %5 ], [ %21, %29 ]
%17 = phi i64 [ 0, %5 ], [ %27, %29 ]
%18 = phi i32 [ 1, %5 ], [ %30, %29 ]
%19 = srem i32 %15, 10
%20 = sdiv i32 %15, 10
store i32 %20, i32* %1
%21 = add nsw i32 %16, -1
%22 = call i32 @pow(i32 10, i32 %21)
%23 = mul nsw i32 %22, %19
%24 = sext i32 %23 to i64
%25 = shl i64 %17, 32
%26 = ashr exact i64 %25, 32
%27 = add nsw i64 %26, %24
%28 = icmp eq i32 %18, %6
br i1 %28, label %32, label %29
29: ; preds = %14
%30 = add nuw i32 %18, 1
%31 = load i32, i32* %1
br label %14
32: ; preds = %14
%33 = trunc i64 %27 to i32
%34 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i32 %4, i32 %33)
ret i32 0
}