#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*/ crcDecoder(char *, char *, int, int);
int /*<<< orphan*/ crcEncoder(char *, char *, char *, int, int);
int /*<<< orphan*/ printf(char *, ...);
int crcAlgorithm(char dataword[], int n, int k) {
  int i;
  char codeword[n];
  char divisor[n - k + 1];
  for (i = 0; i < n - k + 1; i++)
    divisor[i] = '1';
  divisor[2] = '0';
  printf("\nThis is divisor used :\n");
  for (i = 0; i < n - k + 1; i++)
    printf("%c", divisor[i]);
  printf("\n");
  crcEncoder(dataword, codeword, divisor, n, k);
  printf("\nThis is encoded string :\n");
  for (i = 0; i < n; i++)
    printf("%c", codeword[i]);
  printf("\n");
  crcDecoder(codeword, divisor, n, k);
}


x86 assembly (clang, -O0):
<crcAlgorithm>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %edx,-0x18(%rbp)
mov    -0x14(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x28(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x48(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x30(%rbp)
mov    -0x14(%rbp),%eax
mov    -0x18(%rbp),%ecx
sub    %ecx,%eax
add    $0x1,%eax
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x40(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x38(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    -0x14(%rbp),%ecx
sub    -0x18(%rbp),%ecx
add    $0x1,%ecx
cmp    %ecx,%eax
jge    11c4 <crcAlgorithm+0x94>
mov    -0x40(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movb   $0x31,(%rax,%rcx,1)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1196 <crcAlgorithm+0x66>
mov    -0x40(%rbp),%rax
movb   $0x30,0x2(%rax)
lea    0xe2d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    -0x14(%rbp),%ecx
sub    -0x18(%rbp),%ecx
add    $0x1,%ecx
cmp    %ecx,%eax
jge    121d <crcAlgorithm+0xed>
mov    -0x40(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsbl (%rax,%rcx,1),%esi
lea    0xe11(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11e1 <crcAlgorithm+0xb1>
lea    0xdf3(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x48(%rbp),%rsi
mov    -0x40(%rbp),%rdx
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%ecx
mov    -0x18(%rbp),%r8d
call   1050 <crcEncoder@plt>
lea    0xdd2(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    128c <crcAlgorithm+0x15c>
mov    -0x48(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsbl (%rax,%rcx,1),%esi
lea    0xda2(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1258 <crcAlgorithm+0x128>
lea    0xd84(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x48(%rbp),%rdi
mov    -0x40(%rbp),%rsi
mov    -0x14(%rbp),%edx
mov    -0x18(%rbp),%ecx
call   1030 <crcDecoder@plt>
mov    -0x28(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<crcAlgorithm>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %edx,%ebx
mov    %rdi,-0x30(%rbp)
mov    %esi,%eax
mov    %rsp,%r12
mov    %rax,-0x40(%rbp)
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r12
mov    %r12,%rsp
mov    %esi,-0x34(%rbp)
mov    %esi,%eax
sub    %edx,%eax
lea    0x1(%rax),%r13d
lea    0xf(%r13),%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%r14
sub    %rcx,%r14
mov    %r14,%rsp
test   %eax,%eax
js     11e5 <crcAlgorithm+0x95>
mov    %r14,%rdi
mov    $0x31,%esi
mov    %r13,%rdx
call   1060 <memset@plt>
movb   $0x30,0x2(%r14)
lea    0xe46(%rip),%rdi
call   1040 <puts@plt>
xor    %r15d,%r15d
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movsbl (%r14,%r15,1),%edi
call   1030 <putchar@plt>
add    $0x1,%r15
cmp    %r15,%r13
jne    11d0 <crcAlgorithm+0x80>
jmp    11f6 <crcAlgorithm+0xa6>
movb   $0x30,0x2(%r14)
lea    0xe0f(%rip),%rdi
call   1040 <puts@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    -0x30(%rbp),%rdi
mov    %r12,%rsi
mov    %r14,%rdx
mov    -0x34(%rbp),%r13d
mov    %r13d,%ecx
mov    %ebx,-0x30(%rbp)
mov    %ebx,%r8d
call   1070 <crcEncoder@plt>
lea    0xdf5(%rip),%rdi
call   1040 <puts@plt>
test   %r13d,%r13d
mov    -0x40(%rbp),%r15
jle    1253 <crcAlgorithm+0x103>
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movsbl (%r12,%rbx,1),%edi
call   1030 <putchar@plt>
add    $0x1,%rbx
cmp    %rbx,%r15
jne    1240 <crcAlgorithm+0xf0>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    %r12,%rdi
mov    %r14,%rsi
mov    %r13d,%edx
mov    -0x30(%rbp),%ecx
call   1050 <crcDecoder@plt>
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [25 x i8] c"\0AThis is divisor used :\0A\00"
@.str.1 = [3 x i8] c"%c\00"
@.str.2 = [2 x i8] c"\0A\00"
@.str.3 = [27 x i8] c"\0AThis is encoded string :\0A\00"
define i32 @crcAlgorithm(i8* %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i8*
%10 = alloca i64
%11 = alloca i64
store i8* %0, i8** %5
store i32 %1, i32* %6
store i32 %2, i32* %7
%12 = load i32, i32* %6
%13 = zext i32 %12 to i64
%14 = call i8* @llvm.stacksave()
store i8* %14, i8** %9
%15 = alloca i8, i64 %13
store i64 %13, i64* %10
%16 = load i32, i32* %6
%17 = load i32, i32* %7
%18 = sub nsw i32 %16, %17
%19 = add nsw i32 %18, 1
%20 = zext i32 %19 to i64
%21 = alloca i8, i64 %20
store i64 %20, i64* %11
store i32 0, i32* %8
br label %22
22: ; preds = %33, %3
%23 = load i32, i32* %8
%24 = load i32, i32* %6
%25 = load i32, i32* %7
%26 = sub nsw i32 %24, %25
%27 = add nsw i32 %26, 1
%28 = icmp slt i32 %23, %27
br i1 %28, label %29, label %36
29: ; preds = %22
%30 = load i32, i32* %8
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds i8, i8* %21, i64 %31
store i8 49, i8* %32
br label %33
33: ; preds = %29
%34 = load i32, i32* %8
%35 = add nsw i32 %34, 1
store i32 %35, i32* %8
br label %22
36: ; preds = %22
%37 = getelementptr inbounds i8, i8* %21, i64 2
store i8 48, i8* %37
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %8
br label %39
39: ; preds = %53, %36
%40 = load i32, i32* %8
%41 = load i32, i32* %6
%42 = load i32, i32* %7
%43 = sub nsw i32 %41, %42
%44 = add nsw i32 %43, 1
%45 = icmp slt i32 %40, %44
br i1 %45, label %46, label %56
46: ; preds = %39
%47 = load i32, i32* %8
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds i8, i8* %21, i64 %48
%50 = load i8, i8* %49
%51 = sext i8 %50 to i32
%52 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %51)
br label %53
53: ; preds = %46
%54 = load i32, i32* %8
%55 = add nsw i32 %54, 1
store i32 %55, i32* %8
br label %39
56: ; preds = %39
%57 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%58 = load i8*, i8** %5
%59 = load i32, i32* %6
%60 = load i32, i32* %7
%61 = call i32 @crcEncoder(i8* %58, i8* %15, i8* %21, i32 %59, i32 %60)
%62 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0))
store i32 0, i32* %8
br label %63
63: ; preds = %74, %56
%64 = load i32, i32* %8
%65 = load i32, i32* %6
%66 = icmp slt i32 %64, %65
br i1 %66, label %67, label %77
67: ; preds = %63
%68 = load i32, i32* %8
%69 = sext i32 %68 to i64
%70 = getelementptr inbounds i8, i8* %15, i64 %69
%71 = load i8, i8* %70
%72 = sext i8 %71 to i32
%73 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %72)
br label %74
74: ; preds = %67
%75 = load i32, i32* %8
%76 = add nsw i32 %75, 1
store i32 %76, i32* %8
br label %63
77: ; preds = %63
%78 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%79 = load i32, i32* %6
%80 = load i32, i32* %7
%81 = call i32 @crcDecoder(i8* %15, i8* %21, i32 %79, i32 %80)
%82 = load i8*, i8** %9
%83 = load i32, i32* %4
ret i32 %83
}

LLVM IR (-O2):
@str = [24 x i8] c"\0AThis is divisor used :\00"
@str.4 = [26 x i8] c"\0AThis is encoded string :\00"
define i32 @crcAlgorithm(i8* %0, i32 %1, i32 %2) {
%4 = zext i32 %1 to i64
%5 = alloca i8, i64 %4
%6 = sub nsw i32 %1, %2
%7 = add nsw i32 %6, 1
%8 = zext i32 %7 to i64
%9 = alloca i8, i64 %8
%10 = icmp slt i32 %6, 0
br i1 %10, label %11, label %14
11: ; preds = %3
%12 = getelementptr inbounds i8, i8* %9, i64 2
store i8 48, i8* %12
%13 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @str, i64 0, i64 0))
br label %31
14: ; preds = %3
%15 = add i32 %1, 1
%16 = sub i32 %15, %2
%17 = zext i32 %16 to i64
%18 = getelementptr inbounds i8, i8* %9, i64 2
store i8 48, i8* %18
%19 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @str, i64 0, i64 0))
%20 = add i32 %1, 1
%21 = sub i32 %20, %2
%22 = zext i32 %21 to i64
br label %23
23: ; preds = %14, %23
%24 = phi i64 [ 0, %14 ], [ %29, %23 ]
%25 = getelementptr inbounds i8, i8* %9, i64 %24
%26 = load i8, i8* %25
%27 = sext i8 %26 to i32
%28 = tail call i32 @putchar(i32 %27)
%29 = add nuw nsw i64 %24, 1
%30 = icmp eq i64 %29, %22
br i1 %30, label %31, label %23
31: ; preds = %23, %11
%32 = tail call i32 @putchar(i32 10)
%33 = call i32 @crcEncoder(i8* %0, i8* %5, i8* %9, i32 %1, i32 %2)
%34 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @str.4, i64 0, i64 0))
%35 = icmp sgt i32 %1, 0
br i1 %35, label %36, label %44
36: ; preds = %31, %36
%37 = phi i64 [ %42, %36 ], [ 0, %31 ]
%38 = getelementptr inbounds i8, i8* %5, i64 %37
%39 = load i8, i8* %38
%40 = sext i8 %39 to i32
%41 = call i32 @putchar(i32 %40)
%42 = add nuw nsw i64 %37, 1
%43 = icmp eq i64 %42, %4
br i1 %43, label %44, label %36
44: ; preds = %36, %31
%45 = call i32 @putchar(i32 10)
%46 = call i32 @crcDecoder(i8* %5, i8* %9, i32 %1, i32 %2)
ret i32 undef
}