#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 */
typedef int /*<<< orphan*/ tblock;
typedef int /*<<< orphan*/ errlocs;
typedef int /*<<< orphan*/ derrlocs;
typedef int /*<<< orphan*/ block;

/* Variables and functions */
int decode_rs_8(unsigned char *, int *, int, int /*<<< orphan*/);
int /*<<< orphan*/ encode_rs_8(unsigned char *, unsigned char *,
                               int /*<<< orphan*/);
scalar_t__ memcmp(unsigned char *, unsigned char *, int);
int /*<<< orphan*/ memcpy(unsigned char *, unsigned char *, int);
int /*<<< orphan*/ memset(int *, int /*<<< orphan*/, int);
int /*<<< orphan*/ printf(char *, ...);
int random();
int exercise_8(void) {
  int nn = 255;
  unsigned char block[nn], tblock[nn];
  int errlocs[nn], derrlocs[nn];
  int i;
  int errors;
  int derrors, kk;
  int errval, errloc;
  int erasures;
  int decoder_errors = 0;
  kk = 223;
  for (errors = 0; errors <= (nn - kk) / 2; errors++) {
    for (i = 0; i < kk; i++)
      block[i] = random() & nn;
    memcpy(tblock, block, sizeof(block));
    encode_rs_8(block, &block[kk], 0);
    memcpy(tblock, block, sizeof(block));
    memset(errlocs, 0, sizeof(errlocs));
    memset(derrlocs, 0, sizeof(derrlocs));
    erasures = 0;
    for (i = 0; i < errors; i++) {
      do {
        errval = random() & nn;
      } while (errval == 0);
      do {
        errloc = random() % nn;
      } while (errlocs[errloc] != 0);
      errlocs[errloc] = 1;
      tblock[errloc] ^= errval;
    }
    derrors = decode_rs_8(tblock, derrlocs, erasures, 0);
    if (derrors != errors) {
      printf("(%d,%d) decoder says %d errors, true number is %d\n", nn, kk,
             derrors, errors);
      decoder_errors++;
    }
    for (i = 0; i < derrors; i++) {
      if (errlocs[derrlocs[i]] == 0) {
        printf("(%d,%d) decoder indicates error in location %d without error\n",
               nn, kk, derrlocs[i]);
        decoder_errors++;
      }
    }
    if (memcmp(tblock, block, sizeof(tblock)) != 0) {
      printf("(%d,%d) decoder uncorrected errors! output ^ input:", nn, kk);
      decoder_errors++;
      for (i = 0; i < nn; i++)
        printf(" %02x", tblock[i] ^ block[i]);
      printf("\n");
    }
  }
  return decoder_errors;
}


x86 assembly (clang, -O0):
<exercise_8>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
movl   $0xff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    %rax,-0x90(%rbp)
mov    %rsp,%rcx
mov    %rcx,-0x10(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x88(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x18(%rbp)
mov    -0x4(%rbp),%eax
mov    %rax,-0x80(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x78(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x20(%rbp)
mov    -0x4(%rbp),%eax
mov    %rax,-0x70(%rbp)
lea    0xf(,%rax,4),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x68(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x28(%rbp)
mov    -0x4(%rbp),%eax
mov    %rax,-0x60(%rbp)
lea    0xf(,%rax,4),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x58(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x30(%rbp)
movl   $0x0,-0x50(%rbp)
movl   $0xdf,-0x40(%rbp)
movl   $0x0,-0x38(%rbp)
mov    -0x38(%rbp),%eax
mov    %eax,-0x94(%rbp)
mov    -0x4(%rbp),%eax
sub    -0x40(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x94(%rbp),%eax
cmp    %ecx,%eax
jg     14ed <exercise_8+0x37d>
movl   $0x0,-0x34(%rbp)
mov    -0x34(%rbp),%eax
cmp    -0x40(%rbp),%eax
jge    1296 <exercise_8+0x126>
mov    $0x0,%al
call   1080 <random@plt>
mov    %eax,%ecx
mov    -0x88(%rbp),%rax
and    -0x4(%rbp),%ecx
mov    %cl,%dl
movslq -0x34(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    1260 <exercise_8+0xf0>
mov    -0x88(%rbp),%rsi
mov    -0x78(%rbp),%rdi
mov    -0x90(%rbp),%rax
mov    %eax,%edx
call   1070 <memcpy@plt>
mov    -0x88(%rbp),%rdi
movslq -0x40(%rbp),%rax
mov    %rdi,%rsi
add    %rax,%rsi
xor    %edx,%edx
call   1090 <encode_rs_8@plt>
mov    -0x78(%rbp),%rdi
mov    -0x88(%rbp),%rsi
mov    -0x90(%rbp),%rax
mov    %eax,%edx
call   1070 <memcpy@plt>
mov    -0x68(%rbp),%rdi
mov    -0x70(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edx
xor    %esi,%esi
call   1040 <memset@plt>
mov    -0x58(%rbp),%rdi
mov    -0x60(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edx
xor    %esi,%esi
call   1040 <memset@plt>
movl   $0x0,-0x4c(%rbp)
movl   $0x0,-0x34(%rbp)
mov    -0x34(%rbp),%eax
cmp    -0x38(%rbp),%eax
jge    1396 <exercise_8+0x226>
jmp    1329 <exercise_8+0x1b9>
mov    $0x0,%al
call   1080 <random@plt>
and    -0x4(%rbp),%eax
mov    %eax,-0x44(%rbp)
cmpl   $0x0,-0x44(%rbp)
je     1329 <exercise_8+0x1b9>
jmp    1345 <exercise_8+0x1d5>
mov    $0x0,%al
call   1080 <random@plt>
cltd
idivl  -0x4(%rbp)
mov    %edx,-0x48(%rbp)
mov    -0x68(%rbp),%rax
movslq -0x48(%rbp),%rcx
cmpl   $0x0,(%rax,%rcx,4)
jne    1345 <exercise_8+0x1d5>
mov    -0x78(%rbp),%rax
mov    -0x68(%rbp),%rcx
movslq -0x48(%rbp),%rdx
movl   $0x1,(%rcx,%rdx,4)
mov    -0x44(%rbp),%esi
movslq -0x48(%rbp),%rcx
movzbl (%rax,%rcx,1),%edx
xor    %esi,%edx
mov    %dl,(%rax,%rcx,1)
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    1318 <exercise_8+0x1a8>
mov    -0x58(%rbp),%rsi
mov    -0x78(%rbp),%rdi
mov    -0x4c(%rbp),%edx
xor    %ecx,%ecx
call   1060 <decode_rs_8@plt>
mov    %eax,-0x3c(%rbp)
mov    -0x3c(%rbp),%eax
cmp    -0x38(%rbp),%eax
je     13db <exercise_8+0x26b>
mov    -0x4(%rbp),%esi
mov    -0x40(%rbp),%edx
mov    -0x3c(%rbp),%ecx
mov    -0x38(%rbp),%r8d
lea    0xc35(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x50(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x50(%rbp)
movl   $0x0,-0x34(%rbp)
mov    -0x34(%rbp),%eax
cmp    -0x3c(%rbp),%eax
jge    1443 <exercise_8+0x2d3>
mov    -0x68(%rbp),%rax
mov    -0x58(%rbp),%rcx
movslq -0x34(%rbp),%rdx
movslq (%rcx,%rdx,4),%rcx
cmpl   $0x0,(%rax,%rcx,4)
jne    1430 <exercise_8+0x2c0>
mov    -0x58(%rbp),%rax
mov    -0x4(%rbp),%esi
mov    -0x40(%rbp),%edx
movslq -0x34(%rbp),%rcx
mov    (%rax,%rcx,4),%ecx
lea    0xc13(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x50(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x50(%rbp)
jmp    1435 <exercise_8+0x2c5>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    13e2 <exercise_8+0x272>
mov    -0x88(%rbp),%rsi
mov    -0x78(%rbp),%rdi
mov    -0x80(%rbp),%rax
mov    %eax,%edx
call   1050 <memcmp@plt>
cmp    $0x0,%rax
je     14da <exercise_8+0x36a>
mov    -0x4(%rbp),%esi
mov    -0x40(%rbp),%edx
lea    0xc01(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x50(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x50(%rbp)
movl   $0x0,-0x34(%rbp)
mov    -0x34(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    14cc <exercise_8+0x35c>
mov    -0x88(%rbp),%rax
mov    -0x78(%rbp),%rcx
movslq -0x34(%rbp),%rdx
movzbl (%rcx,%rdx,1),%esi
movslq -0x34(%rbp),%rcx
movzbl (%rax,%rcx,1),%eax
xor    %eax,%esi
lea    0xbee(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    1487 <exercise_8+0x317>
lea    0xb5e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    14df <exercise_8+0x36f>
mov    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
jmp    1232 <exercise_8+0xc2>
mov    -0x50(%rbp),%eax
mov    -0x10(%rbp),%rcx
mov    %rcx,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<exercise_8>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xa08,%rsp
lea    0x100(%rsp),%rbp
mov    %rsp,%r15
lea    0xf02(%rip),%r14
xor    %r12d,%r12d
xor    %r13d,%r13d
jmp    11be <exercise_8+0x3e>
nopl   0x0(%rax,%rax,1)
add    $0x1,%r13d
cmp    $0x11,%r13d
je     13a8 <exercise_8+0x228>
xor    %ebx,%ebx
xor    %eax,%eax
call   1090 <random@plt>
mov    %al,(%rsp,%rbx,1)
add    $0x1,%rbx
cmp    $0xdf,%rbx
jne    11c0 <exercise_8+0x40>
mov    %rbp,%rdi
mov    %r15,%rsi
mov    $0xff,%edx
call   1080 <memcpy@plt>
mov    %r15,%rdi
lea    0xdf(%rsp),%rsi
xor    %edx,%edx
call   10a0 <encode_rs_8@plt>
mov    %rbp,%rdi
mov    %r15,%rsi
mov    $0xff,%edx
call   1080 <memcpy@plt>
lea    0x200(%rsp),%rdi
xor    %esi,%esi
mov    $0x3fc,%edx
call   1050 <memset@plt>
lea    0x600(%rsp),%rdi
xor    %esi,%esi
mov    $0x3fc,%edx
call   1050 <memset@plt>
test   %r13d,%r13d
je     12a1 <exercise_8+0x121>
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1090 <random@plt>
mov    %eax,%r15d
test   %r15b,%r15b
je     1240 <exercise_8+0xc0>
nop
xor    %eax,%eax
call   1090 <random@plt>
cltq
imul   $0xffffffff80808081,%rax,%rcx
shr    $0x20,%rcx
add    %eax,%ecx
mov    %ecx,%edx
shr    $0x1f,%edx
sar    $0x7,%ecx
add    %edx,%ecx
mov    %ecx,%edx
shl    $0x8,%edx
sub    %edx,%ecx
add    %eax,%ecx
movslq %ecx,%rax
cmpl   $0x0,0x200(%rsp,%rax,4)
jne    1250 <exercise_8+0xd0>
xor    %r15b,0x100(%rsp,%rax,1)
movl   $0x1,0x200(%rsp,%rax,4)
add    $0x1,%ebx
cmp    %r13d,%ebx
jne    1240 <exercise_8+0xc0>
mov    %rbp,%rdi
lea    0x600(%rsp),%rsi
xor    %edx,%edx
xor    %ecx,%ecx
call   1070 <decode_rs_8@plt>
mov    %eax,%ebx
cmp    %r13d,%eax
je     12dd <exercise_8+0x15d>
lea    0xd3d(%rip),%rdi
mov    $0xff,%esi
mov    $0xdf,%edx
mov    %ebx,%ecx
mov    %r13d,%r8d
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%r12d
mov    %rsp,%r15
test   %ebx,%ebx
jle    1330 <exercise_8+0x1b0>
mov    %ebx,%ebx
xor    %ebp,%ebp
jmp    12f9 <exercise_8+0x179>
nopw   0x0(%rax,%rax,1)
add    $0x1,%rbp
cmp    %rbp,%rbx
je     1330 <exercise_8+0x1b0>
movslq 0x600(%rsp,%rbp,4),%rcx
cmpl   $0x0,0x200(%rsp,%rcx,4)
jne    12f0 <exercise_8+0x170>
lea    0xd21(%rip),%rdi
mov    $0xff,%esi
mov    $0xdf,%edx
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%r12d
jmp    12f0 <exercise_8+0x170>
nopl   0x0(%rax)
lea    0x100(%rsp),%rbp
mov    %rbp,%rdi
mov    %r15,%rsi
mov    $0xff,%edx
call   1060 <memcmp@plt>
test   %rax,%rax
je     11b0 <exercise_8+0x30>
lea    0xd19(%rip),%rdi
mov    $0xff,%esi
mov    $0xdf,%edx
xor    %eax,%eax
call   1040 <printf@plt>
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
movzbl (%rsp,%rbx,1),%eax
xor    0x100(%rsp,%rbx,1),%al
movzbl %al,%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%rbx
cmp    $0xff,%rbx
jne    1370 <exercise_8+0x1f0>
add    $0x1,%r12d
mov    $0xa,%edi
call   1030 <putchar@plt>
jmp    11b0 <exercise_8+0x30>
mov    %r12d,%eax
add    $0xa08,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [51 x i8] c"(%d,%d) decoder says %d errors, true number is %d\0A\00"
@.str.1 = [62 x i8] c"(%d,%d) decoder indicates error in location %d without error\0A\00"
@.str.2 = [52 x i8] c"(%d,%d) decoder uncorrected errors! output ^ input:\00"
@.str.3 = [6 x i8] c" %02x\00"
@.str.4 = [2 x i8] c"\0A\00"
define i32 @exercise_8() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca i64
%4 = alloca i64
%5 = alloca i64
%6 = alloca i64
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
store i32 255, i32* %1
%15 = load i32, i32* %1
%16 = zext i32 %15 to i64
%17 = call i8* @llvm.stacksave()
store i8* %17, i8** %2
%18 = alloca i8, i64 %16
store i64 %16, i64* %3
%19 = load i32, i32* %1
%20 = zext i32 %19 to i64
%21 = alloca i8, i64 %20
store i64 %20, i64* %4
%22 = load i32, i32* %1
%23 = zext i32 %22 to i64
%24 = alloca i32, i64 %23
store i64 %23, i64* %5
%25 = load i32, i32* %1
%26 = zext i32 %25 to i64
%27 = alloca i32, i64 %26
store i64 %26, i64* %6
store i32 0, i32* %14
store i32 223, i32* %10
store i32 0, i32* %8
br label %28
28: ; preds = %179, %0
%29 = load i32, i32* %8
%30 = load i32, i32* %1
%31 = load i32, i32* %10
%32 = sub nsw i32 %30, %31
%33 = sdiv i32 %32, 2
%34 = icmp sle i32 %29, %33
br i1 %34, label %35, label %182
35: ; preds = %28
store i32 0, i32* %7
br label %36
36: ; preds = %48, %35
%37 = load i32, i32* %7
%38 = load i32, i32* %10
%39 = icmp slt i32 %37, %38
br i1 %39, label %40, label %51
40: ; preds = %36
%41 = call i32 (...) @random()
%42 = load i32, i32* %1
%43 = and i32 %41, %42
%44 = trunc i32 %43 to i8
%45 = load i32, i32* %7
%46 = sext i32 %45 to i64
%47 = getelementptr inbounds i8, i8* %18, i64 %46
store i8 %44, i8* %47
br label %48
48: ; preds = %40
%49 = load i32, i32* %7
%50 = add nsw i32 %49, 1
store i32 %50, i32* %7
br label %36
51: ; preds = %36
%52 = trunc i64 %16 to i32
%53 = call i32 @memcpy(i8* %21, i8* %18, i32 %52)
%54 = load i32, i32* %10
%55 = sext i32 %54 to i64
%56 = getelementptr inbounds i8, i8* %18, i64 %55
%57 = call i32 @encode_rs_8(i8* %18, i8* %56, i32 0)
%58 = trunc i64 %16 to i32
%59 = call i32 @memcpy(i8* %21, i8* %18, i32 %58)
%60 = mul nuw i64 4, %23
%61 = trunc i64 %60 to i32
%62 = call i32 @memset(i32* %24, i32 0, i32 %61)
%63 = mul nuw i64 4, %26
%64 = trunc i64 %63 to i32
%65 = call i32 @memset(i32* %27, i32 0, i32 %64)
store i32 0, i32* %13
store i32 0, i32* %7
br label %66
66: ; preds = %101, %51
%67 = load i32, i32* %7
%68 = load i32, i32* %8
%69 = icmp slt i32 %67, %68
br i1 %69, label %70, label %104
70: ; preds = %66
br label %71
71: ; preds = %75, %70
%72 = call i32 (...) @random()
%73 = load i32, i32* %1
%74 = and i32 %72, %73
store i32 %74, i32* %11
br label %75
75: ; preds = %71
%76 = load i32, i32* %11
%77 = icmp eq i32 %76, 0
br i1 %77, label %71, label %78
78: ; preds = %75
br label %79
79: ; preds = %83, %78
%80 = call i32 (...) @random()
%81 = load i32, i32* %1
%82 = srem i32 %80, %81
store i32 %82, i32* %12
br label %83
83: ; preds = %79
%84 = load i32, i32* %12
%85 = sext i32 %84 to i64
%86 = getelementptr inbounds i32, i32* %24, i64 %85
%87 = load i32, i32* %86
%88 = icmp ne i32 %87, 0
br i1 %88, label %79, label %89
89: ; preds = %83
%90 = load i32, i32* %12
%91 = sext i32 %90 to i64
%92 = getelementptr inbounds i32, i32* %24, i64 %91
store i32 1, i32* %92
%93 = load i32, i32* %11
%94 = load i32, i32* %12
%95 = sext i32 %94 to i64
%96 = getelementptr inbounds i8, i8* %21, i64 %95
%97 = load i8, i8* %96
%98 = zext i8 %97 to i32
%99 = xor i32 %98, %93
%100 = trunc i32 %99 to i8
store i8 %100, i8* %96
br label %101
101: ; preds = %89
%102 = load i32, i32* %7
%103 = add nsw i32 %102, 1
store i32 %103, i32* %7
br label %66
104: ; preds = %66
%105 = load i32, i32* %13
%106 = call i32 @decode_rs_8(i8* %21, i32* %27, i32 %105, i32 0)
store i32 %106, i32* %9
%107 = load i32, i32* %9
%108 = load i32, i32* %8
%109 = icmp ne i32 %107, %108
br i1 %109, label %110, label %118
110: ; preds = %104
%111 = load i32, i32* %1
%112 = load i32, i32* %10
%113 = load i32, i32* %9
%114 = load i32, i32* %8
%115 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str, i64 0, i64 0), i32 %111, i32 %112, i32 %113, i32 %114)
%116 = load i32, i32* %14
%117 = add nsw i32 %116, 1
store i32 %117, i32* %14
br label %118
118: ; preds = %110, %104
store i32 0, i32* %7
br label %119
119: ; preds = %143, %118
%120 = load i32, i32* %7
%121 = load i32, i32* %9
%122 = icmp slt i32 %120, %121
br i1 %122, label %123, label %146
123: ; preds = %119
%124 = load i32, i32* %7
%125 = sext i32 %124 to i64
%126 = getelementptr inbounds i32, i32* %27, i64 %125
%127 = load i32, i32* %126
%128 = sext i32 %127 to i64
%129 = getelementptr inbounds i32, i32* %24, i64 %128
%130 = load i32, i32* %129
%131 = icmp eq i32 %130, 0
br i1 %131, label %132, label %142
132: ; preds = %123
%133 = load i32, i32* %1
%134 = load i32, i32* %10
%135 = load i32, i32* %7
%136 = sext i32 %135 to i64
%137 = getelementptr inbounds i32, i32* %27, i64 %136
%138 = load i32, i32* %137
%139 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str.1, i64 0, i64 0), i32 %133, i32 %134, i32 %138)
%140 = load i32, i32* %14
%141 = add nsw i32 %140, 1
store i32 %141, i32* %14
br label %142
142: ; preds = %132, %123
br label %143
143: ; preds = %142
%144 = load i32, i32* %7
%145 = add nsw i32 %144, 1
store i32 %145, i32* %7
br label %119
146: ; preds = %119
%147 = trunc i64 %20 to i32
%148 = call i64 @memcmp(i8* %21, i8* %18, i32 %147)
%149 = icmp ne i64 %148, 0
br i1 %149, label %150, label %178
150: ; preds = %146
%151 = load i32, i32* %1
%152 = load i32, i32* %10
%153 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.2, i64 0, i64 0), i32 %151, i32 %152)
%154 = load i32, i32* %14
%155 = add nsw i32 %154, 1
store i32 %155, i32* %14
store i32 0, i32* %7
br label %156
156: ; preds = %173, %150
%157 = load i32, i32* %7
%158 = load i32, i32* %1
%159 = icmp slt i32 %157, %158
br i1 %159, label %160, label %176
160: ; preds = %156
%161 = load i32, i32* %7
%162 = sext i32 %161 to i64
%163 = getelementptr inbounds i8, i8* %21, i64 %162
%164 = load i8, i8* %163
%165 = zext i8 %164 to i32
%166 = load i32, i32* %7
%167 = sext i32 %166 to i64
%168 = getelementptr inbounds i8, i8* %18, i64 %167
%169 = load i8, i8* %168
%170 = zext i8 %169 to i32
%171 = xor i32 %165, %170
%172 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i32 %171)
br label %173
173: ; preds = %160
%174 = load i32, i32* %7
%175 = add nsw i32 %174, 1
store i32 %175, i32* %7
br label %156
176: ; preds = %156
%177 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
br label %178
178: ; preds = %176, %146
br label %179
179: ; preds = %178
%180 = load i32, i32* %8
%181 = add nsw i32 %180, 1
store i32 %181, i32* %8
br label %28
182: ; preds = %28
%183 = load i32, i32* %14
%184 = load i8*, i8** %2
ret i32 %183
}

LLVM IR (-O2):
@.str = [51 x i8] c"(%d,%d) decoder says %d errors, true number is %d\0A\00"
@.str.1 = [62 x i8] c"(%d,%d) decoder indicates error in location %d without error\0A\00"
@.str.2 = [52 x i8] c"(%d,%d) decoder uncorrected errors! output ^ input:\00"
@.str.3 = [6 x i8] c" %02x\00"
define i32 @exercise_8() {
%1 = alloca [255 x i8]
%2 = alloca [255 x i8]
%3 = alloca [255 x i32]
%4 = alloca [255 x i32]
%5 = getelementptr inbounds [255 x i32], [255 x i32]* %4, i64 0, i64 0
%6 = getelementptr inbounds [255 x i32], [255 x i32]* %3, i64 0, i64 0
%7 = getelementptr inbounds [255 x i8], [255 x i8]* %2, i64 0, i64 0
%8 = getelementptr inbounds [255 x i8], [255 x i8]* %1, i64 0, i64 0
%9 = getelementptr inbounds [255 x i8], [255 x i8]* %1, i64 0, i64 223
br label %10
10: ; preds = %0, %95
%11 = phi i32 [ 0, %0 ], [ %96, %95 ]
%12 = phi i32 [ 0, %0 ], [ %97, %95 ]
br label %13
13: ; preds = %10, %13
%14 = phi i64 [ 0, %10 ], [ %18, %13 ]
%15 = call i32 (...) @random()
%16 = trunc i32 %15 to i8
%17 = getelementptr inbounds [255 x i8], [255 x i8]* %1, i64 0, i64 %14
store i8 %16, i8* %17
%18 = add nuw nsw i64 %14, 1
%19 = icmp eq i64 %18, 223
br i1 %19, label %20, label %13
20: ; preds = %13
%21 = call i32 @memcpy(i8* %7, i8* %8, i32 255)
%22 = call i32 @encode_rs_8(i8* %8, i8* %9, i32 0)
%23 = call i32 @memcpy(i8* %7, i8* %8, i32 255)
%24 = call i32 @memset(i32* %6, i32 0, i32 1020)
%25 = call i32 @memset(i32* %5, i32 0, i32 1020)
%26 = icmp eq i32 %12, 0
br i1 %26, label %48, label %27
27: ; preds = %20, %40
%28 = phi i32 [ %46, %40 ], [ 0, %20 ]
br label %29
29: ; preds = %27, %29
%30 = call i32 (...) @random()
%31 = and i32 %30, 255
%32 = icmp eq i32 %31, 0
br i1 %32, label %29, label %33
33: ; preds = %29, %33
%34 = call i32 (...) @random()
%35 = srem i32 %34, 255
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds [255 x i32], [255 x i32]* %3, i64 0, i64 %36
%38 = load i32, i32* %37
%39 = icmp eq i32 %38, 0
br i1 %39, label %40, label %33
40: ; preds = %33
%41 = getelementptr inbounds [255 x i32], [255 x i32]* %3, i64 0, i64 %36
store i32 1, i32* %41
%42 = getelementptr inbounds [255 x i8], [255 x i8]* %2, i64 0, i64 %36
%43 = load i8, i8* %42
%44 = trunc i32 %30 to i8
%45 = xor i8 %43, %44
store i8 %45, i8* %42
%46 = add nuw nsw i32 %28, 1
%47 = icmp eq i32 %46, %12
br i1 %47, label %48, label %27
48: ; preds = %40, %20
%49 = call i32 @decode_rs_8(i8* %7, i32* %5, i32 0, i32 0)
%50 = icmp eq i32 %49, %12
br i1 %50, label %54, label %51
51: ; preds = %48
%52 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([51 x i8], [51 x i8]* @.str, i64 0, i64 0), i32 255, i32 223, i32 %49, i32 %12)
%53 = add nsw i32 %11, 1
br label %54
54: ; preds = %51, %48
%55 = phi i32 [ %53, %51 ], [ %11, %48 ]
%56 = icmp sgt i32 %49, 0
br i1 %56, label %57, label %75
57: ; preds = %54
%58 = zext i32 %49 to i64
br label %59
59: ; preds = %57, %71
%60 = phi i64 [ 0, %57 ], [ %73, %71 ]
%61 = phi i32 [ %55, %57 ], [ %72, %71 ]
%62 = getelementptr inbounds [255 x i32], [255 x i32]* %4, i64 0, i64 %60
%63 = load i32, i32* %62
%64 = sext i32 %63 to i64
%65 = getelementptr inbounds [255 x i32], [255 x i32]* %3, i64 0, i64 %64
%66 = load i32, i32* %65
%67 = icmp eq i32 %66, 0
br i1 %67, label %68, label %71
68: ; preds = %59
%69 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([62 x i8], [62 x i8]* @.str.1, i64 0, i64 0), i32 255, i32 223, i32 %63)
%70 = add nsw i32 %61, 1
br label %71
71: ; preds = %59, %68
%72 = phi i32 [ %70, %68 ], [ %61, %59 ]
%73 = add nuw nsw i64 %60, 1
%74 = icmp eq i64 %73, %58
br i1 %74, label %75, label %59
75: ; preds = %71, %54
%76 = phi i32 [ %55, %54 ], [ %72, %71 ]
%77 = call i64 @memcmp(i8* %7, i8* %8, i32 255)
%78 = icmp eq i64 %77, 0
br i1 %78, label %95, label %79
79: ; preds = %75
%80 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([52 x i8], [52 x i8]* @.str.2, i64 0, i64 0), i32 255, i32 223)
br label %81
81: ; preds = %79, %81
%82 = phi i64 [ 0, %79 ], [ %90, %81 ]
%83 = getelementptr inbounds [255 x i8], [255 x i8]* %2, i64 0, i64 %82
%84 = load i8, i8* %83
%85 = getelementptr inbounds [255 x i8], [255 x i8]* %1, i64 0, i64 %82
%86 = load i8, i8* %85
%87 = xor i8 %86, %84
%88 = zext i8 %87 to i32
%89 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0), i32 %88)
%90 = add nuw nsw i64 %82, 1
%91 = icmp eq i64 %90, 255
br i1 %91, label %92, label %81
92: ; preds = %81
%93 = add nsw i32 %76, 1
%94 = call i32 @putchar(i32 10)
br label %95
95: ; preds = %75, %92
%96 = phi i32 [ %93, %92 ], [ %76, %75 ]
%97 = add nuw nsw i32 %12, 1
%98 = icmp eq i32 %97, 17
br i1 %98, label %99, label %10
99: ; preds = %95
ret i32 %96
}