#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 *);
main() {
  int data, i, j, r1, r2, a;
  printf("Enter the data to reverse the bits");
  scanf("%d", &data);
  for (i = 7, j = 0; i > j; i--, j++) {
    r1 = (data >> i) & 1;
    r2 = (data >> j) & 1;
    if (r1 != r2) {
      data ^= (1 << i);
      data ^= (1 << j);
    }
  }
  printf("%d\n", data);
}


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    0xedf(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
movl   $0x7,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x10(%rbp),%eax
jle    11cb <main+0xab>
mov    -0x8(%rbp),%eax
mov    -0xc(%rbp),%ecx
sar    %cl,%eax
and    $0x1,%eax
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%eax
mov    -0x10(%rbp),%ecx
sar    %cl,%eax
and    $0x1,%eax
mov    %eax,-0x18(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x18(%rbp),%eax
je     11af <main+0x8f>
mov    -0xc(%rbp),%ecx
mov    $0x1,%eax
shl    %cl,%eax
xor    -0x8(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x10(%rbp),%ecx
mov    $0x1,%eax
shl    %cl,%eax
xor    -0x8(%rbp),%eax
mov    %eax,-0x8(%rbp)
jmp    11b4 <main+0x94>
mov    -0xc(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0xc(%rbp)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    115b <main+0x3b>
mov    -0x8(%rbp),%esi
lea    0xe51(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xed8(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xeed(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1040 <scanf@plt>
mov    $0x7,%eax
mov    $0x1,%r9d
mov    0x4(%rsp),%esi
jmp    116f <main+0x4f>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
add    $0xffffffff,%eax
lea    0x1(%r9),%ecx
cmp    %r9d,%eax
mov    %ecx,%r9d
jle    119d <main+0x7d>
mov    %esi,%edx
mov    %eax,%ecx
shr    %cl,%edx
lea    -0x1(%r9),%r8d
mov    %esi,%edi
mov    %r8d,%ecx
shr    %cl,%edi
xor    %edx,%edi
test   $0x1,%dil
je     1160 <main+0x40>
mov    $0x1,%edx
mov    %eax,%ecx
shl    %cl,%edx
btc    %r8d,%edx
xor    %edx,%esi
mov    %esi,0x4(%rsp)
jmp    1160 <main+0x40>
lea    0xe82(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [35 x i8] c"Enter the data to reverse the bits\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [4 x i8] c"%d\0A\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 ([35 x i8], [35 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* %2)
store i32 7, i32* %3
store i32 0, i32* %4
br label %10
10: ; preds = %36, %0
%11 = load i32, i32* %3
%12 = load i32, i32* %4
%13 = icmp sgt i32 %11, %12
br i1 %13, label %14, label %41
14: ; preds = %10
%15 = load i32, i32* %2
%16 = load i32, i32* %3
%17 = ashr i32 %15, %16
%18 = and i32 %17, 1
store i32 %18, i32* %5
%19 = load i32, i32* %2
%20 = load i32, i32* %4
%21 = ashr i32 %19, %20
%22 = and i32 %21, 1
store i32 %22, i32* %6
%23 = load i32, i32* %5
%24 = load i32, i32* %6
%25 = icmp ne i32 %23, %24
br i1 %25, label %26, label %35
26: ; preds = %14
%27 = load i32, i32* %3
%28 = shl i32 1, %27
%29 = load i32, i32* %2
%30 = xor i32 %29, %28
store i32 %30, i32* %2
%31 = load i32, i32* %4
%32 = shl i32 1, %31
%33 = load i32, i32* %2
%34 = xor i32 %33, %32
store i32 %34, i32* %2
br label %35
35: ; preds = %26, %14
br label %36
36: ; preds = %35
%37 = load i32, i32* %3
%38 = add nsw i32 %37, -1
store i32 %38, i32* %3
%39 = load i32, i32* %4
%40 = add nsw i32 %39, 1
store i32 %40, i32* %4
br label %10
41: ; preds = %10
%42 = load i32, i32* %2
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %42)
%44 = load i32, i32* %1
ret i32 %44
}

LLVM IR (-O2):
@.str = [35 x i8] c"Enter the data to reverse the bits\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 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
br label %6
6: ; preds = %0, %20
%7 = phi i32 [ 7, %0 ], [ %22, %20 ]
%8 = phi i32 [ 0, %0 ], [ %23, %20 ]
%9 = phi i32 [ %5, %0 ], [ %21, %20 ]
%10 = lshr i32 %9, %7
%11 = lshr i32 %9, %8
%12 = xor i32 %10, %11
%13 = and i32 %12, 1
%14 = icmp eq i32 %13, 0
br i1 %14, label %20, label %15
15: ; preds = %6
%16 = shl nuw i32 1, %7
%17 = shl nuw i32 1, %8
%18 = xor i32 %16, %17
%19 = xor i32 %18, %9
store i32 %19, i32* %1
br label %20
20: ; preds = %6, %15
%21 = phi i32 [ %9, %6 ], [ %19, %15 ]
%22 = add nsw i32 %7, -1
%23 = add nuw nsw i32 %8, 1
%24 = icmp sgt i32 %22, %23
br i1 %24, label %6, label %25
25: ; preds = %20
%26 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %21)
ret i32 0
}