#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 /*<<< orphan*/ scanf(char *, int *);
int main() {
  int num, n1, n2, n3, n4, n5;
  scanf("%d", &num);
  n5 = num % 10;
  n4 = ((num % 100) - n5) / 10;
  n3 = ((num % 1000) - n5 - (n4 * 10)) / 100;
  n2 = ((num % 10000) - n5 - (n4 * 10) - (n3 * 100)) / 1000;
  n1 = num / 10000;
  if (num >= 10000)
    printf("Reverse of %d is %d%d%d%d%d", num, n5, n4, n3, n2, n1);
  else if (num >= 1000)
    printf("Reverse of %d is %d%d%d%d", num, n5, n4, n3, n2);
  else if (num > 100)
    printf("Reverse of %d is %d%d%d", num, n5, n4, n3);
  else if (num >= 10)
    printf("Reverse of %d is %d%d", num, n5, n4);
  else if ((num == 10000) || (num == 1000) || (num == 100) || (num == 10))
    printf("Reverse of %d is 1", num);
  else
    printf("Reverse of %d is %d", num, n5);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xf52(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x8(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %edx,-0x1c(%rbp)
mov    -0x8(%rbp),%eax
mov    $0x64,%ecx
cltd
idiv   %ecx
mov    %edx,%eax
sub    -0x1c(%rbp),%eax
mov    $0xa,%ecx
cltd
idiv   %ecx
mov    %eax,-0x18(%rbp)
mov    -0x8(%rbp),%eax
mov    $0x3e8,%ecx
cltd
idiv   %ecx
mov    %edx,%eax
sub    -0x1c(%rbp),%eax
imul   $0xa,-0x18(%rbp),%ecx
sub    %ecx,%eax
mov    $0x64,%ecx
cltd
idiv   %ecx
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%eax
mov    $0x2710,%ecx
cltd
idiv   %ecx
mov    %edx,%eax
sub    -0x1c(%rbp),%eax
imul   $0xa,-0x18(%rbp),%ecx
sub    %ecx,%eax
imul   $0x64,-0x14(%rbp),%ecx
sub    %ecx,%eax
mov    $0x3e8,%ecx
cltd
idiv   %ecx
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%eax
mov    $0x2710,%ecx
cltd
idiv   %ecx
mov    %eax,-0xc(%rbp)
cmpl   $0x2710,-0x8(%rbp)
jl     11f5 <main+0xd5>
mov    -0x8(%rbp),%esi
mov    -0x1c(%rbp),%edx
mov    -0x18(%rbp),%ecx
mov    -0x14(%rbp),%r8d
mov    -0x10(%rbp),%r9d
mov    -0xc(%rbp),%eax
lea    0xe1a(%rip),%rdi
mov    %eax,(%rsp)
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12e2 <main+0x1c2>
cmpl   $0x3e8,-0x8(%rbp)
jl     1226 <main+0x106>
mov    -0x8(%rbp),%esi
mov    -0x1c(%rbp),%edx
mov    -0x18(%rbp),%ecx
mov    -0x14(%rbp),%r8d
mov    -0x10(%rbp),%r9d
lea    0xe02(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12dd <main+0x1bd>
cmpl   $0x64,-0x8(%rbp)
jle    1250 <main+0x130>
mov    -0x8(%rbp),%esi
mov    -0x1c(%rbp),%edx
mov    -0x18(%rbp),%ecx
mov    -0x14(%rbp),%r8d
lea    0xdf2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12d8 <main+0x1b8>
cmpl   $0xa,-0x8(%rbp)
jl     1276 <main+0x156>
mov    -0x8(%rbp),%esi
mov    -0x1c(%rbp),%edx
mov    -0x18(%rbp),%ecx
lea    0xde4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12d3 <main+0x1b3>
cmpl   $0x2710,-0x8(%rbp)
je     12a4 <main+0x184>
cmpl   $0x3e8,-0x8(%rbp)
je     12a4 <main+0x184>
cmpl   $0x64,-0x8(%rbp)
je     12a4 <main+0x184>
cmpl   $0xa,-0x8(%rbp)
jne    12ba <main+0x19a>
mov    -0x8(%rbp),%esi
lea    0xdb6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12ce <main+0x1ae>
mov    -0x8(%rbp),%esi
mov    -0x1c(%rbp),%edx
lea    0xdb0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12d3 <main+0x1b3>
jmp    12d8 <main+0x1b8>
jmp    12dd <main+0x1bd>
jmp    12e2 <main+0x1c2>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x18,%rsp
lea    0xf4a(%rip),%rdi
lea    0x14(%rsp),%rsi
call   1040 <scanf@plt>
movslq 0x14(%rsp),%rsi
imul   $0x66666667,%rsi,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x22,%rax
add    %ecx,%eax
add    %eax,%eax
lea    (%rax,%rax,4),%eax
mov    %esi,%edx
sub    %eax,%edx
imul   $0x51eb851f,%rsi,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x25,%rax
add    %ecx,%eax
imul   $0x64,%eax,%eax
mov    %esi,%ecx
sub    %eax,%ecx
sub    %edx,%ecx
movsbl %cl,%eax
imul   $0x67,%eax,%eax
movzwl %ax,%eax
movswl %ax,%ecx
shr    $0xf,%eax
shr    $0xa,%ecx
add    %al,%cl
movsbl %cl,%ecx
imul   $0x10624dd3,%rsi,%rax
mov    %rax,%rdi
shr    $0x3f,%rdi
sar    $0x26,%rax
add    %edi,%eax
imul   $0x3e8,%eax,%eax
mov    %esi,%edi
sub    %eax,%edi
lea    (%rcx,%rcx,4),%eax
lea    (%rdx,%rax,2),%r9d
sub    %r9d,%edi
movswl %di,%edi
imul   $0x147b,%edi,%edi
mov    %edi,%eax
shr    $0x1f,%eax
sar    $0x13,%edi
add    %eax,%edi
movswl %di,%r8d
imul   $0x68db8bad,%rsi,%rax
mov    %rax,%rdi
shr    $0x3f,%rdi
sar    $0x2c,%rax
add    %edi,%eax
imul   $0x2710,%eax,%eax
mov    %esi,%edi
sub    %eax,%edi
sub    %r9d,%edi
imul   $0xffffff9c,%r8d,%eax
add    %edi,%eax
movswl %ax,%edi
imul   $0xffff8313,%edi,%edi
shr    $0x10,%edi
add    %eax,%edi
movzwl %di,%eax
movswl %ax,%edi
shr    $0xf,%eax
sar    $0x9,%edi
add    %eax,%edi
movswl %di,%r9d
cmp    $0x2710,%rsi
jl     1235 <main+0x115>
mov    %esi,%eax
mov    $0xd1b71759,%edi
imul   %rax,%rdi
shr    $0x2d,%rdi
mov    %edi,(%rsp)
lea    0xdcd(%rip),%rdi
jmp    1244 <main+0x124>
cmp    $0x3e8,%esi
jl     1252 <main+0x132>
lea    0xdd8(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
ret
cmp    $0x65,%esi
jl     1267 <main+0x147>
lea    0xdd8(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
jmp    124b <main+0x12b>
cmp    $0xa,%esi
jl     127c <main+0x15c>
lea    0xddb(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
jmp    124b <main+0x12b>
lea    0xde1(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
jmp    124b <main+0x12b>

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@.str.1 = [28 x i8] c"Reverse of %d is %d%d%d%d%d\00"
@.str.2 = [26 x i8] c"Reverse of %d is %d%d%d%d\00"
@.str.3 = [24 x i8] c"Reverse of %d is %d%d%d\00"
@.str.4 = [22 x i8] c"Reverse of %d is %d%d\00"
@.str.5 = [19 x i8] c"Reverse of %d is 1\00"
@.str.6 = [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
store i32 0, i32* %1
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
%9 = load i32, i32* %2
%10 = srem i32 %9, 10
store i32 %10, i32* %7
%11 = load i32, i32* %2
%12 = srem i32 %11, 100
%13 = load i32, i32* %7
%14 = sub nsw i32 %12, %13
%15 = sdiv i32 %14, 10
store i32 %15, i32* %6
%16 = load i32, i32* %2
%17 = srem i32 %16, 1000
%18 = load i32, i32* %7
%19 = sub nsw i32 %17, %18
%20 = load i32, i32* %6
%21 = mul nsw i32 %20, 10
%22 = sub nsw i32 %19, %21
%23 = sdiv i32 %22, 100
store i32 %23, i32* %5
%24 = load i32, i32* %2
%25 = srem i32 %24, 10000
%26 = load i32, i32* %7
%27 = sub nsw i32 %25, %26
%28 = load i32, i32* %6
%29 = mul nsw i32 %28, 10
%30 = sub nsw i32 %27, %29
%31 = load i32, i32* %5
%32 = mul nsw i32 %31, 100
%33 = sub nsw i32 %30, %32
%34 = sdiv i32 %33, 1000
store i32 %34, i32* %4
%35 = load i32, i32* %2
%36 = sdiv i32 %35, 10000
store i32 %36, i32* %3
%37 = load i32, i32* %2
%38 = icmp sge i32 %37, 10000
br i1 %38, label %39, label %47
39: ; preds = %0
%40 = load i32, i32* %2
%41 = load i32, i32* %7
%42 = load i32, i32* %6
%43 = load i32, i32* %5
%44 = load i32, i32* %4
%45 = load i32, i32* %3
%46 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0), i32 %40, i32 %41, i32 %42, i32 %43, i32 %44, i32 %45)
br label %97
47: ; preds = %0
%48 = load i32, i32* %2
%49 = icmp sge i32 %48, 1000
br i1 %49, label %50, label %57
50: ; preds = %47
%51 = load i32, i32* %2
%52 = load i32, i32* %7
%53 = load i32, i32* %6
%54 = load i32, i32* %5
%55 = load i32, i32* %4
%56 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0), i32 %51, i32 %52, i32 %53, i32 %54, i32 %55)
br label %96
57: ; preds = %47
%58 = load i32, i32* %2
%59 = icmp sgt i32 %58, 100
br i1 %59, label %60, label %66
60: ; preds = %57
%61 = load i32, i32* %2
%62 = load i32, i32* %7
%63 = load i32, i32* %6
%64 = load i32, i32* %5
%65 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0), i32 %61, i32 %62, i32 %63, i32 %64)
br label %95
66: ; preds = %57
%67 = load i32, i32* %2
%68 = icmp sge i32 %67, 10
br i1 %68, label %69, label %74
69: ; preds = %66
%70 = load i32, i32* %2
%71 = load i32, i32* %7
%72 = load i32, i32* %6
%73 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.4, i64 0, i64 0), i32 %70, i32 %71, i32 %72)
br label %94
74: ; preds = %66
%75 = load i32, i32* %2
%76 = icmp eq i32 %75, 10000
br i1 %76, label %86, label %77
77: ; preds = %74
%78 = load i32, i32* %2
%79 = icmp eq i32 %78, 1000
br i1 %79, label %86, label %80
80: ; preds = %77
%81 = load i32, i32* %2
%82 = icmp eq i32 %81, 100
br i1 %82, label %86, label %83
83: ; preds = %80
%84 = load i32, i32* %2
%85 = icmp eq i32 %84, 10
br i1 %85, label %86, label %89
86: ; preds = %83, %80, %77, %74
%87 = load i32, i32* %2
%88 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.5, i64 0, i64 0), i32 %87)
br label %93
89: ; preds = %83
%90 = load i32, i32* %2
%91 = load i32, i32* %7
%92 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.6, i64 0, i64 0), i32 %90, i32 %91)
br label %93
93: ; preds = %89, %86
br label %94
94: ; preds = %93, %69
br label %95
95: ; preds = %94, %60
br label %96
96: ; preds = %95, %50
br label %97
97: ; preds = %96, %39
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@.str.1 = [28 x i8] c"Reverse of %d is %d%d%d%d%d\00"
@.str.2 = [26 x i8] c"Reverse of %d is %d%d%d%d\00"
@.str.3 = [24 x i8] c"Reverse of %d is %d%d%d\00"
@.str.4 = [22 x i8] c"Reverse of %d is %d%d\00"
@.str.6 = [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 = srem i32 %4, 10
%6 = srem i32 %4, 100
%7 = sub nsw i32 %6, %5
%8 = trunc i32 %7 to i8
%9 = sdiv i8 %8, 10
%10 = sext i8 %9 to i32
%11 = srem i32 %4, 1000
%12 = mul nsw i32 %10, 10
%13 = add nsw i32 %12, %5
%14 = sub nsw i32 %11, %13
%15 = trunc i32 %14 to i16
%16 = sdiv i16 %15, 100
%17 = sext i16 %16 to i32
%18 = srem i32 %4, 10000
%19 = sub nsw i32 %18, %13
%20 = mul nsw i32 %17, -100
%21 = add nsw i32 %19, %20
%22 = trunc i32 %21 to i16
%23 = sdiv i16 %22, 1000
%24 = sext i16 %23 to i32
%25 = icmp sgt i32 %4, 9999
br i1 %25, label %26, label %29
26: ; preds = %0
%27 = udiv i32 %4, 10000
%28 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0), i32 %4, i32 %5, i32 %10, i32 %17, i32 %24, i32 %27)
br label %43
29: ; preds = %0
%30 = icmp sgt i32 %4, 999
br i1 %30, label %31, label %33
31: ; preds = %29
%32 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0), i32 %4, i32 %5, i32 %10, i32 %17, i32 %24)
br label %43
33: ; preds = %29
%34 = icmp sgt i32 %4, 100
br i1 %34, label %35, label %37
35: ; preds = %33
%36 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0), i32 %4, i32 %5, i32 %10, i32 %17)
br label %43
37: ; preds = %33
%38 = icmp sgt i32 %4, 9
br i1 %38, label %39, label %41
39: ; preds = %37
%40 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.4, i64 0, i64 0), i32 %4, i32 %5, i32 %10)
br label %43
41: ; preds = %37
%42 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.6, i64 0, i64 0), i32 %4, i32 %5)
br label %43
43: ; preds = %31, %39, %41, %35, %26
ret i32 0
}