#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 CHAR_BIT;
int checkCode(char *, int);
int decodeChar(char *, int);
int /*<<< orphan*/ encodeChar(char, char *, int);
int findBitPatternSize();
int /*<<< orphan*/ flipBit(int, char *, int);
int /*<<< orphan*/ free(char *);
char getchar();
scalar_t__ malloc(int);
int /*<<< orphan*/ printCharPattern(char);
int /*<<< orphan*/ printFullPattern(char *, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ putchar(char);
int /*<<< orphan*/ scanf(char *, int *);
int main(int argc, char **argv) {
  char toTrans;
  int myFlipBit = -1;
  int bitPatternSize = findBitPatternSize();
  char *code = (char *)malloc(bitPatternSize * sizeof(char));
  if (code == NULL) {
    printf("Memory could not be allocated");
    return -1;
  }
  printf("Please Input A Char To Be Transmitted:\n");
  toTrans = getchar();
  while (getchar() != '\n')
    continue;
  while (1) {
    printf("Please Input Bit You Wish To Flip (Between 1 and %d, 0 Means No "
           "Bits Flipped):\n",
           bitPatternSize);
    scanf("%d", &myFlipBit);
    while (getchar() != '\n')
      continue;
    if (myFlipBit >= 0 && myFlipBit <= bitPatternSize) {
      break;
    }
    printf("Error: You Must Input An Integer Between 0 and %d\n",
           bitPatternSize);
  }
  printf("Each Packet is %d bits\n", CHAR_BIT);
  printf("Full Transmission will require %d packets, totalling %d bits sent\n",
         bitPatternSize / CHAR_BIT, bitPatternSize);
  printf("Transmitting character '%c'\n", toTrans);
  encodeChar(toTrans, code, bitPatternSize);
  printf("Bit Pattern of '%c': ", toTrans);
  printCharPattern(decodeChar(code, bitPatternSize));
  putchar('\n');
  printf("Full Transmission Pattern: ");
  printFullPattern(code, bitPatternSize);
  putchar('\n');
  if (myFlipBit > 0) {
    printf("It is being corrupted by flipping bit %d\n", myFlipBit);
    flipBit(myFlipBit - 1, code, bitPatternSize);
    char corrupted = decodeChar(code, bitPatternSize);
    printf("The Corrupted Character is '%c'\n", corrupted);
    printf("Bit Pattern of '%c': ", corrupted);
    printCharPattern(corrupted);
    putchar('\n');
    printf("Full Transmission Pattern: ");
    printFullPattern(code, bitPatternSize);
    putchar('\n');
  } else {
    printf("No bit is being corrupted\n");
  }
  printf("Correcting Transmission...\n");
  int checkFlipBit = checkCode(code, bitPatternSize);
  if (checkFlipBit > 0) {
    flipBit(checkFlipBit - 1, code, bitPatternSize);
  }
  printf("The Correct Character is '%c'\n", decodeChar(code, bitPatternSize));
  free(code);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0xffffffff,-0x18(%rbp)
mov    $0x0,%al
call   1070 <findBitPatternSize@plt>
mov    %eax,-0x1c(%rbp)
movslq -0x1c(%rbp),%rax
shl    $0x0,%rax
mov    %eax,%edi
call   1090 <malloc@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    122f <main+0x5f>
lea    0xde4(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    148c <main+0x2bc>
lea    0xde8(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    $0x0,%al
call   1080 <getchar@plt>
mov    %al,-0x11(%rbp)
mov    $0x0,%al
call   1080 <getchar@plt>
movsbl %al,%eax
cmp    $0xa,%eax
je     125f <main+0x8f>
jmp    1247 <main+0x77>
jmp    1264 <main+0x94>
mov    -0x1c(%rbp),%esi
lea    0xdd8(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xe1a(%rip),%rdi
lea    -0x18(%rbp),%rsi
call   10d0 <scanf@plt>
mov    $0x0,%al
call   1080 <getchar@plt>
movsbl %al,%eax
cmp    $0xa,%eax
je     129d <main+0xcd>
jmp    1285 <main+0xb5>
cmpl   $0x0,-0x18(%rbp)
jl     12b8 <main+0xe8>
mov    -0x18(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jg     12b8 <main+0xe8>
jmp    12ce <main+0xfe>
mov    -0x1c(%rbp),%esi
lea    0xdd7(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    1264 <main+0x94>
mov    0x2d0b(%rip),%rax
mov    (%rax),%esi
lea    0xdee(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x1c(%rbp),%eax
mov    0x2cf1(%rip),%rcx
cltd
idivl  (%rcx)
mov    %eax,%esi
mov    -0x1c(%rbp),%edx
lea    0xde6(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movsbl -0x11(%rbp),%esi
lea    0xe17(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x11(%rbp),%al
mov    -0x28(%rbp),%rsi
mov    -0x1c(%rbp),%edx
movsbl %al,%edi
call   1050 <encodeChar@plt>
movsbl -0x11(%rbp),%esi
lea    0xe10(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x28(%rbp),%rdi
mov    -0x1c(%rbp),%esi
call   10b0 <decodeChar@plt>
movsbl %al,%edi
call   10f0 <printCharPattern@plt>
mov    $0xa,%edi
call   1040 <putchar@plt>
lea    0xdfa(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x28(%rbp),%rdi
mov    -0x1c(%rbp),%esi
call   10e0 <printFullPattern@plt>
mov    $0xa,%edi
call   1040 <putchar@plt>
cmpl   $0x0,-0x18(%rbp)
jle    1419 <main+0x249>
mov    -0x18(%rbp),%esi
lea    0xde5(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x18(%rbp),%edi
sub    $0x1,%edi
mov    -0x28(%rbp),%rsi
mov    -0x1c(%rbp),%edx
call   10a0 <flipBit@plt>
mov    -0x28(%rbp),%rdi
mov    -0x1c(%rbp),%esi
call   10b0 <decodeChar@plt>
mov    %al,-0x29(%rbp)
movsbl -0x29(%rbp),%esi
lea    0xddc(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movsbl -0x29(%rbp),%esi
lea    0xd6e(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movsbl -0x29(%rbp),%edi
call   10f0 <printCharPattern@plt>
mov    $0xa,%edi
call   1040 <putchar@plt>
lea    0xd63(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x28(%rbp),%rdi
mov    -0x1c(%rbp),%esi
call   10e0 <printFullPattern@plt>
mov    $0xa,%edi
call   1040 <putchar@plt>
jmp    1427 <main+0x257>
lea    0xda1(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xdae(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x28(%rbp),%rdi
mov    -0x1c(%rbp),%esi
call   10c0 <checkCode@plt>
mov    %eax,-0x30(%rbp)
cmpl   $0x0,-0x30(%rbp)
jle    1460 <main+0x290>
mov    -0x30(%rbp),%edi
sub    $0x1,%edi
mov    -0x28(%rbp),%rsi
mov    -0x1c(%rbp),%edx
call   10a0 <flipBit@plt>
mov    -0x28(%rbp),%rdi
mov    -0x1c(%rbp),%esi
call   10b0 <decodeChar@plt>
mov    %eax,%esi
lea    0xd83(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
movl   $0xffffffff,0x4(%rsp)
ff
xor    %eax,%eax
call   1080 <findBitPatternSize@plt>
mov    %eax,%ebp
mov    %eax,%edi
call   10a0 <malloc@plt>
test   %rax,%rax
je     13d1 <main+0x1f1>
mov    %rax,%r15
lea    0xfa2(%rip),%rdi
call   1060 <puts@plt>
xor    %eax,%eax
call   1090 <getchar@plt>
mov    %al,0x3(%rsp)
cs nopw 0x0(%rax,%rax,1)
xor    %eax,%eax
call   1090 <getchar@plt>
cmp    $0xa,%al
jne    1230 <main+0x50>
lea    0xddc(%rip),%r12
lea    0xe25(%rip),%r13
lea    0x4(%rsp),%rbx
lea    0xe1c(%rip),%r14
jmp    126c <main+0x8c>
nopw   0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1070 <printf@plt>
mov    %r12,%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1070 <printf@plt>
mov    %r13,%rdi
mov    %rbx,%rsi
call   10e0 <scanf@plt>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
xor    %eax,%eax
call   1090 <getchar@plt>
cmp    $0xa,%al
jne    1290 <main+0xb0>
mov    0x4(%rsp),%eax
test   %eax,%eax
js     1260 <main+0x80>
cmp    %ebp,%eax
jg     1260 <main+0x80>
mov    0x2d32(%rip),%rbx
mov    (%rbx),%esi
lea    0xded(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    %ebp,%eax
cltd
idivl  (%rbx)
lea    0xdf2(%rip),%rdi
mov    %eax,%esi
mov    %ebp,%edx
xor    %eax,%eax
call   1070 <printf@plt>
movsbl 0x3(%rsp),%ebx
lea    0xe1e(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1070 <printf@plt>
mov    %ebx,%edi
mov    %r15,%rsi
mov    %ebp,%edx
call   1050 <encodeChar@plt>
lea    0xe1f(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1070 <printf@plt>
mov    %r15,%rdi
mov    %ebp,%esi
call   10c0 <decodeChar@plt>
movsbl %al,%edi
call   1100 <printCharPattern@plt>
mov    $0xa,%edi
call   1040 <putchar@plt>
lea    0xe09(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    %r15,%rdi
mov    %ebp,%esi
call   10f0 <printFullPattern@plt>
mov    $0xa,%edi
call   1040 <putchar@plt>
mov    0x4(%rsp),%esi
test   %esi,%esi
jle    13e6 <main+0x206>
lea    0xdf7(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    0x4(%rsp),%edi
add    $0xffffffff,%edi
mov    %r15,%rsi
mov    %ebp,%edx
call   10b0 <flipBit@plt>
mov    %r15,%rdi
mov    %ebp,%esi
call   10c0 <decodeChar@plt>
lea    0xdf8(%rip),%rdi
movsbl %al,%ebx
mov    %ebx,%esi
xor    %eax,%eax
call   1070 <printf@plt>
lea    0xd89(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1070 <printf@plt>
mov    %ebx,%edi
call   1100 <printCharPattern@plt>
mov    $0xa,%edi
call   1040 <putchar@plt>
lea    0xd7e(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    %r15,%rdi
mov    %ebp,%esi
call   10f0 <printFullPattern@plt>
mov    $0xa,%edi
call   1040 <putchar@plt>
jmp    13f2 <main+0x212>
lea    0xc28(%rip),%rdi
xor    %eax,%eax
call   1070 <printf@plt>
mov    $0xffffffff,%ebx
jmp    143f <main+0x25f>
lea    0xdf2(%rip),%rdi
call   1060 <puts@plt>
lea    0xe00(%rip),%rdi
call   1060 <puts@plt>
mov    %r15,%rdi
mov    %ebp,%esi
call   10d0 <checkCode@plt>
test   %eax,%eax
jle    141b <main+0x23b>
add    $0xffffffff,%eax
mov    %eax,%edi
mov    %r15,%rsi
mov    %ebp,%edx
call   10b0 <flipBit@plt>
mov    %r15,%rdi
mov    %ebp,%esi
call   10c0 <decodeChar@plt>
lea    0xd6d(%rip),%rdi
xor    %ebx,%ebx
mov    %eax,%esi
xor    %eax,%eax
call   1070 <printf@plt>
mov    %r15,%rdi
call   1030 <free@plt>
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [30 x i8] c"Memory could not be allocated\00"
@.str.1 = [40 x i8] c"Please Input A Char To Be Transmitted:\0A\00"
@.str.2 = [80 x i8] c"Please Input Bit You Wish To Flip (Between 1 and %d, 0 Means No Bits Flipped):\0A\00"
@.str.3 = [3 x i8] c"%d\00"
@.str.4 = [51 x i8] c"Error: You Must Input An Integer Between 0 and %d\0A\00"
@.str.5 = [24 x i8] c"Each Packet is %d bits\0A\00"
@CHAR_BIT = global i32 0
@.str.6 = [67 x i8] c"Full Transmission will require %d packets, totalling %d bits sent\0A\00"
@.str.7 = [29 x i8] c"Transmitting character '%c'\0A\00"
@.str.8 = [22 x i8] c"Bit Pattern of '%c': \00"
@.str.9 = [28 x i8] c"Full Transmission Pattern: \00"
@.str.10 = [42 x i8] c"It is being corrupted by flipping bit %d\0A\00"
@.str.11 = [33 x i8] c"The Corrupted Character is '%c'\0A\00"
@.str.12 = [27 x i8] c"No bit is being corrupted\0A\00"
@.str.13 = [28 x i8] c"Correcting Transmission...\0A\00"
@.str.14 = [31 x i8] c"The Correct Character is '%c'\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8
%7 = alloca i32
%8 = alloca i32
%9 = alloca i8*
%10 = alloca i8
%11 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 -1, i32* %7
%12 = call i32 (...) @findBitPatternSize()
store i32 %12, i32* %8
%13 = load i32, i32* %8
%14 = sext i32 %13 to i64
%15 = mul i64 %14, 1
%16 = trunc i64 %15 to i32
%17 = call i64 @malloc(i32 %16)
%18 = inttoptr i64 %17 to i8*
store i8* %18, i8** %9
%19 = load i8*, i8** %9
%20 = icmp eq i8* %19, null
br i1 %20, label %21, label %23
21: ; preds = %2
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0))
store i32 -1, i32* %3
br label %131
23: ; preds = %2
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.1, i64 0, i64 0))
%25 = call signext i8 (...) @getchar()
store i8 %25, i8* %6
br label %26
26: ; preds = %30, %23
%27 = call signext i8 (...) @getchar()
%28 = sext i8 %27 to i32
%29 = icmp ne i32 %28, 10
br i1 %29, label %30, label %31
30: ; preds = %26
br label %26
31: ; preds = %26
br label %32
32: ; preds = %31, %49
%33 = load i32, i32* %8
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([80 x i8], [80 x i8]* @.str.2, i64 0, i64 0), i32 %33)
%35 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %7)
br label %36
36: ; preds = %40, %32
%37 = call signext i8 (...) @getchar()
%38 = sext i8 %37 to i32
%39 = icmp ne i32 %38, 10
br i1 %39, label %40, label %41
40: ; preds = %36
br label %36
41: ; preds = %36
%42 = load i32, i32* %7
%43 = icmp sge i32 %42, 0
br i1 %43, label %44, label %49
44: ; preds = %41
%45 = load i32, i32* %7
%46 = load i32, i32* %8
%47 = icmp sle i32 %45, %46
br i1 %47, label %48, label %49
48: ; preds = %44
br label %52
49: ; preds = %44, %41
%50 = load i32, i32* %8
%51 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.4, i64 0, i64 0), i32 %50)
br label %32
52: ; preds = %48
%53 = load i32, i32* @CHAR_BIT
%54 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.5, i64 0, i64 0), i32 %53)
%55 = load i32, i32* %8
%56 = load i32, i32* @CHAR_BIT
%57 = sdiv i32 %55, %56
%58 = load i32, i32* %8
%59 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([67 x i8], [67 x i8]* @.str.6, i64 0, i64 0), i32 %57, i32 %58)
%60 = load i8, i8* %6
%61 = sext i8 %60 to i32
%62 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.7, i64 0, i64 0), i32 %61)
%63 = load i8, i8* %6
%64 = load i8*, i8** %9
%65 = load i32, i32* %8
%66 = call i32 @encodeChar(i8 signext %63, i8* %64, i32 %65)
%67 = load i8, i8* %6
%68 = sext i8 %67 to i32
%69 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.8, i64 0, i64 0), i32 %68)
%70 = load i8*, i8** %9
%71 = load i32, i32* %8
%72 = call i32 @decodeChar(i8* %70, i32 %71)
%73 = trunc i32 %72 to i8
%74 = call i32 @printCharPattern(i8 signext %73)
%75 = call i32 @putchar(i8 signext 10)
%76 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.9, i64 0, i64 0))
%77 = load i8*, i8** %9
%78 = load i32, i32* %8
%79 = call i32 @printFullPattern(i8* %77, i32 %78)
%80 = call i32 @putchar(i8 signext 10)
%81 = load i32, i32* %7
%82 = icmp sgt i32 %81, 0
br i1 %82, label %83, label %109
83: ; preds = %52
%84 = load i32, i32* %7
%85 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.10, i64 0, i64 0), i32 %84)
%86 = load i32, i32* %7
%87 = sub nsw i32 %86, 1
%88 = load i8*, i8** %9
%89 = load i32, i32* %8
%90 = call i32 @flipBit(i32 %87, i8* %88, i32 %89)
%91 = load i8*, i8** %9
%92 = load i32, i32* %8
%93 = call i32 @decodeChar(i8* %91, i32 %92)
%94 = trunc i32 %93 to i8
store i8 %94, i8* %10
%95 = load i8, i8* %10
%96 = sext i8 %95 to i32
%97 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.11, i64 0, i64 0), i32 %96)
%98 = load i8, i8* %10
%99 = sext i8 %98 to i32
%100 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.8, i64 0, i64 0), i32 %99)
%101 = load i8, i8* %10
%102 = call i32 @printCharPattern(i8 signext %101)
%103 = call i32 @putchar(i8 signext 10)
%104 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.9, i64 0, i64 0))
%105 = load i8*, i8** %9
%106 = load i32, i32* %8
%107 = call i32 @printFullPattern(i8* %105, i32 %106)
%108 = call i32 @putchar(i8 signext 10)
br label %111
109: ; preds = %52
%110 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.12, i64 0, i64 0))
br label %111
111: ; preds = %109, %83
%112 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.13, i64 0, i64 0))
%113 = load i8*, i8** %9
%114 = load i32, i32* %8
%115 = call i32 @checkCode(i8* %113, i32 %114)
store i32 %115, i32* %11
%116 = load i32, i32* %11
%117 = icmp sgt i32 %116, 0
br i1 %117, label %118, label %124
118: ; preds = %111
%119 = load i32, i32* %11
%120 = sub nsw i32 %119, 1
%121 = load i8*, i8** %9
%122 = load i32, i32* %8
%123 = call i32 @flipBit(i32 %120, i8* %121, i32 %122)
br label %124
124: ; preds = %118, %111
%125 = load i8*, i8** %9
%126 = load i32, i32* %8
%127 = call i32 @decodeChar(i8* %125, i32 %126)
%128 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.14, i64 0, i64 0), i32 %127)
%129 = load i8*, i8** %9
%130 = call i32 @free(i8* %129)
store i32 0, i32* %3
br label %131
131: ; preds = %124, %21
%132 = load i32, i32* %3
ret i32 %132
}

LLVM IR (-O2):
@.str = [30 x i8] c"Memory could not be allocated\00"
@.str.2 = [80 x i8] c"Please Input Bit You Wish To Flip (Between 1 and %d, 0 Means No Bits Flipped):\0A\00"
@.str.3 = [3 x i8] c"%d\00"
@.str.4 = [51 x i8] c"Error: You Must Input An Integer Between 0 and %d\0A\00"
@.str.5 = [24 x i8] c"Each Packet is %d bits\0A\00"
@CHAR_BIT = global i32 0
@.str.6 = [67 x i8] c"Full Transmission will require %d packets, totalling %d bits sent\0A\00"
@.str.7 = [29 x i8] c"Transmitting character '%c'\0A\00"
@.str.8 = [22 x i8] c"Bit Pattern of '%c': \00"
@.str.9 = [28 x i8] c"Full Transmission Pattern: \00"
@.str.10 = [42 x i8] c"It is being corrupted by flipping bit %d\0A\00"
@.str.11 = [33 x i8] c"The Corrupted Character is '%c'\0A\00"
@.str.14 = [31 x i8] c"The Correct Character is '%c'\0A\00"
@str = [39 x i8] c"Please Input A Char To Be Transmitted:\00"
@str.15 = [26 x i8] c"No bit is being corrupted\00"
@str.16 = [27 x i8] c"Correcting Transmission...\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
store i32 -1, i32* %3
%5 = tail call i32 (...) @findBitPatternSize()
%6 = tail call i64 @malloc(i32 %5)
%7 = inttoptr i64 %6 to i8*
%8 = icmp eq i64 %6, 0
br i1 %8, label %9, label %11
9: ; preds = %2
%10 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0))
br label %78
11: ; preds = %2
%12 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @str, i64 0, i64 0))
%13 = tail call signext i8 (...) @getchar()
br label %14
14: ; preds = %14, %11
%15 = tail call signext i8 (...) @getchar()
%16 = icmp eq i8 %15, 10
br i1 %16, label %17, label %14
17: ; preds = %14, %28
%18 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([80 x i8], [80 x i8]* @.str.2, i64 0, i64 0), i32 %5)
%19 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %3)
br label %20
20: ; preds = %20, %17
%21 = call signext i8 (...) @getchar()
%22 = icmp eq i8 %21, 10
br i1 %22, label %23, label %20
23: ; preds = %20
%24 = load i32, i32* %3
%25 = icmp slt i32 %24, 0
%26 = icmp sgt i32 %24, %5
%27 = or i1 %25, %26
br i1 %27, label %28, label %30
28: ; preds = %23
%29 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([51 x i8], [51 x i8]* @.str.4, i64 0, i64 0), i32 %5)
br label %17
30: ; preds = %23
%31 = load i32, i32* @CHAR_BIT
%32 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.5, i64 0, i64 0), i32 %31)
%33 = load i32, i32* @CHAR_BIT
%34 = sdiv i32 %5, %33
%35 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([67 x i8], [67 x i8]* @.str.6, i64 0, i64 0), i32 %34, i32 %5)
%36 = sext i8 %13 to i32
%37 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.7, i64 0, i64 0), i32 %36)
%38 = call i32 @encodeChar(i8 signext %13, i8* %7, i32 %5)
%39 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.8, i64 0, i64 0), i32 %36)
%40 = call i32 @decodeChar(i8* %7, i32 %5)
%41 = trunc i32 %40 to i8
%42 = call i32 @printCharPattern(i8 signext %41)
%43 = call i32 @putchar(i8 signext 10)
%44 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.9, i64 0, i64 0))
%45 = call i32 @printFullPattern(i8* %7, i32 %5)
%46 = call i32 @putchar(i8 signext 10)
%47 = load i32, i32* %3
%48 = icmp sgt i32 %47, 0
br i1 %48, label %49, label %65
49: ; preds = %30
%50 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @.str.10, i64 0, i64 0), i32 %47)
%51 = load i32, i32* %3
%52 = add nsw i32 %51, -1
%53 = call i32 @flipBit(i32 %52, i8* %7, i32 %5)
%54 = call i32 @decodeChar(i8* %7, i32 %5)
%55 = trunc i32 %54 to i8
%56 = shl i32 %54, 24
%57 = ashr exact i32 %56, 24
%58 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.11, i64 0, i64 0), i32 %57)
%59 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.8, i64 0, i64 0), i32 %57)
%60 = call i32 @printCharPattern(i8 signext %55)
%61 = call i32 @putchar(i8 signext 10)
%62 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.9, i64 0, i64 0))
%63 = call i32 @printFullPattern(i8* %7, i32 %5)
%64 = call i32 @putchar(i8 signext 10)
br label %67
65: ; preds = %30
%66 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @str.15, i64 0, i64 0))
br label %67
67: ; preds = %65, %49
%68 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str.16, i64 0, i64 0))
%69 = call i32 @checkCode(i8* %7, i32 %5)
%70 = icmp sgt i32 %69, 0
br i1 %70, label %71, label %74
71: ; preds = %67
%72 = add nsw i32 %69, -1
%73 = call i32 @flipBit(i32 %72, i8* %7, i32 %5)
br label %74
74: ; preds = %71, %67
%75 = call i32 @decodeChar(i8* %7, i32 %5)
%76 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.14, i64 0, i64 0), i32 %75)
%77 = call i32 @free(i8* %7)
br label %78
78: ; preds = %74, %9
%79 = phi i32 [ -1, %9 ], [ 0, %74 ]
ret i32 %79
}