#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 a;
  scanf("%d", &a);
  int b = 0;
  for (int i = a; i != 0; i = i / 10) {
    int rem = i % 10;
    b = b * 10 + rem;
  }
  printf("Reverse of %d is %d", a, b);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xedb(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
movl   $0x0,-0xc(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x10(%rbp)
cmpl   $0x0,-0x10(%rbp)
je     1181 <main+0x61>
mov    -0x10(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %edx,-0x14(%rbp)
imul   $0xa,-0xc(%rbp),%eax
add    -0x14(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0x10(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,-0x10(%rbp)
jmp    114c <main+0x2c>
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
lea    0xe72(%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>
mov    0x4(%rsp),%esi
xor    %edx,%edx
test   %esi,%esi
je     1171 <main+0x51>
mov    %esi,%eax
xchg   %ax,%ax
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    $0x13,%ecx
jae    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
%5 = alloca i32
store i32 0, i32* %1
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
store i32 0, i32* %3
%7 = load i32, i32* %2
store i32 %7, i32* %4
br label %8
8: ; preds = %18, %0
%9 = load i32, i32* %4
%10 = icmp ne i32 %9, 0
br i1 %10, label %11, label %21
11: ; preds = %8
%12 = load i32, i32* %4
%13 = srem i32 %12, 10
store i32 %13, i32* %5
%14 = load i32, i32* %3
%15 = mul nsw i32 %14, 10
%16 = load i32, i32* %5
%17 = add nsw i32 %15, %16
store i32 %17, i32* %3
br label %18
18: ; preds = %11
%19 = load i32, i32* %4
%20 = sdiv i32 %19, 10
store i32 %20, i32* %4
br label %8
21: ; preds = %8
%22 = load i32, i32* %2
%23 = load i32, i32* %3
%24 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i32 %22, i32 %23)
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
%5 = icmp eq i32 %4, 0
br i1 %5, label %6, label %9
6: ; preds = %9, %0
%7 = phi i32 [ 0, %0 ], [ %14, %9 ]
%8 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i32 %4, i32 %7)
ret i32 0
9: ; preds = %0, %9
%10 = phi i32 [ %14, %9 ], [ 0, %0 ]
%11 = phi i32 [ %15, %9 ], [ %4, %0 ]
%12 = srem i32 %11, 10
%13 = mul nsw i32 %10, 10
%14 = add nsw i32 %13, %12
%15 = sdiv i32 %11, 10
%16 = add i32 %11, 9
%17 = icmp ult i32 %16, 19
br i1 %17, label %6, label %9
}