#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*/ putchar(char);
int /*<<< orphan*/ scanf(char *, char *);
int /*<<< orphan*/ showBinary(char);
int main(int argc, char *argv[]) {
  char test;
  printf("Please enter a character: ");
  scanf("%c", &test);
  showBinary(test);
  putchar('\n');
  char leftS = (test << 4), rightS = (test >> 4);
  char result = (leftS | rightS);
  printf("Swapped bits --> %c\n", result);
  showBinary(result);
  putchar('\n');
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xeaa(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xeb7(%rip),%rdi
lea    -0x11(%rbp),%rsi
call   1060 <scanf@plt>
movsbl -0x11(%rbp),%edi
call   1050 <showBinary@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
movsbl -0x11(%rbp),%eax
shl    $0x4,%eax
mov    %al,-0x12(%rbp)
movsbl -0x11(%rbp),%eax
sar    $0x4,%eax
mov    %al,-0x13(%rbp)
movsbl -0x12(%rbp),%eax
movsbl -0x13(%rbp),%ecx
or     %ecx,%eax
mov    %al,-0x14(%rbp)
movsbl -0x14(%rbp),%esi
lea    0xe72(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movsbl -0x14(%rbp),%edi
call   1050 <showBinary@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
lea    0xeb4(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xec1(%rip),%rdi
lea    0xf(%rsp),%rsi
call   1060 <scanf@plt>
movsbl 0xf(%rsp),%edi
call   1050 <showBinary@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    0xf(%rsp),%al
mov    %eax,%ecx
shl    $0x4,%cl
sar    $0x4,%al
or     %cl,%al
movsbl %al,%ebx
lea    0xe8e(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %ebx,%edi
call   1050 <showBinary@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [27 x i8] c"Please enter a character: \00"
@.str.1 = [3 x i8] c"%c\00"
@.str.2 = [21 x i8] c"Swapped bits --> %c\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8**
%5 = alloca i8
%6 = alloca i8
%7 = alloca i8
%8 = alloca i8
store i32 %0, i32* %3
store i8** %1, i8*** %4
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0))
%10 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %5)
%11 = load i8, i8* %5
%12 = call i32 @showBinary(i8 signext %11)
%13 = call i32 @putchar(i8 signext 10)
%14 = load i8, i8* %5
%15 = sext i8 %14 to i32
%16 = shl i32 %15, 4
%17 = trunc i32 %16 to i8
store i8 %17, i8* %6
%18 = load i8, i8* %5
%19 = sext i8 %18 to i32
%20 = ashr i32 %19, 4
%21 = trunc i32 %20 to i8
store i8 %21, i8* %7
%22 = load i8, i8* %6
%23 = sext i8 %22 to i32
%24 = load i8, i8* %7
%25 = sext i8 %24 to i32
%26 = or i32 %23, %25
%27 = trunc i32 %26 to i8
store i8 %27, i8* %8
%28 = load i8, i8* %8
%29 = sext i8 %28 to i32
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i32 %29)
%31 = load i8, i8* %8
%32 = call i32 @showBinary(i8 signext %31)
%33 = call i32 @putchar(i8 signext 10)
ret i32 0
}

LLVM IR (-O2):
@.str = [27 x i8] c"Please enter a character: \00"
@.str.1 = [3 x i8] c"%c\00"
@.str.2 = [21 x i8] c"Swapped bits --> %c\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i8
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0))
%5 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %3)
%6 = load i8, i8* %3
%7 = call i32 @showBinary(i8 signext %6)
%8 = call i32 @putchar(i8 signext 10)
%9 = load i8, i8* %3
%10 = shl i8 %9, 4
%11 = ashr i8 %9, 4
%12 = or i8 %10, %11
%13 = sext i8 %12 to i32
%14 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i32 %13)
%15 = call i32 @showBinary(i8 signext %12)
%16 = call i32 @putchar(i8 signext 10)
ret i32 0
}