#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*/ old_loc;

/* Variables and functions */
int /*<<< orphan*/ memmove(unsigned char *, unsigned char *, unsigned int);
unsigned char redupe_gf_inv(unsigned char);
unsigned char redupe_gf_mul(unsigned char, unsigned char const);
int /*<<< orphan*/ redupe_gf_poly_add(unsigned char *, unsigned int,
                                      unsigned char *, unsigned int,
                                      unsigned char *, unsigned int *);
int /*<<< orphan*/ redupe_gf_poly_scale(unsigned char *, unsigned int,
                                        unsigned char);
int redupe_find_error_locator(const unsigned char *synd, unsigned synd_sz,
                              unsigned nsym, unsigned char *out_err_loc,
                              unsigned *out_err_loc_sz) {
  unsigned char old_loc[256];
  unsigned old_loc_sz = 1;
  old_loc[0] = 1;
  unsigned char err_loc[256];
  unsigned err_loc_sz = 1;
  err_loc[0] = 1;
  unsigned synd_shift = 0;
  if (synd_sz > nsym) {
    synd_shift = synd_sz - nsym;
  }
  for (unsigned i = 0; i < nsym; ++i) {
    unsigned K = i + synd_shift;
    unsigned char delta = synd[K];
    for (unsigned j = 1; j < err_loc_sz; ++j) {
      delta ^= redupe_gf_mul(err_loc[err_loc_sz - (j + 1)], synd[K - j]);
    }
    old_loc[old_loc_sz] = 0;
    ++old_loc_sz;
    if (delta != 0) {
      if (old_loc_sz > err_loc_sz) {
        unsigned char new_loc[256];
        unsigned new_loc_sz = old_loc_sz;
        memmove(new_loc, old_loc, sizeof(old_loc));
        redupe_gf_poly_scale(new_loc, new_loc_sz, delta);
        old_loc_sz = err_loc_sz;
        memmove(old_loc, err_loc, new_loc_sz);
        unsigned char inv = redupe_gf_inv(delta);
        redupe_gf_poly_scale(old_loc, old_loc_sz, inv);
        err_loc_sz = new_loc_sz;
        memmove(err_loc, new_loc, new_loc_sz);
      }
      unsigned char tmp[256];
      unsigned tmp_sz = old_loc_sz;
      unsigned char tmp2[256];
      unsigned tmp2_sz = 0;
      memmove(tmp, old_loc, old_loc_sz);
      redupe_gf_poly_scale(tmp, tmp_sz, delta);
      redupe_gf_poly_add(err_loc, err_loc_sz, tmp, tmp_sz, tmp2, &tmp2_sz);
      err_loc_sz = tmp2_sz;
      memmove(err_loc, tmp2, tmp2_sz);
    }
  }
  unsigned shift;
  for (shift = 0; shift < err_loc_sz && err_loc[shift] == 0; ++shift)
    ;
  for (unsigned i = 0; i + shift < err_loc_sz; ++i) {
    out_err_loc[i] = err_loc[i + shift];
  }
  *out_err_loc_sz = err_loc_sz - shift;
  return (*out_err_loc_sz - 1) * 2 <= nsym ? 0 : -1;
}


x86 assembly (clang, -O0):
<redupe_find_error_locator>:
push   %rbp
mov    %rsp,%rbp
sub    $0x580,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %rcx,-0x18(%rbp)
mov    %r8,-0x20(%rbp)
movl   $0x1,-0x124(%rbp)
movb   $0x1,-0x120(%rbp)
movl   $0x1,-0x234(%rbp)
movb   $0x1,-0x230(%rbp)
movl   $0x0,-0x238(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x10(%rbp),%eax
jbe    11b1 <redupe_find_error_locator+0x61>
mov    -0xc(%rbp),%eax
sub    -0x10(%rbp),%eax
mov    %eax,-0x238(%rbp)
movl   $0x0,-0x23c(%rbp)
mov    -0x23c(%rbp),%eax
cmp    -0x10(%rbp),%eax
jae    140d <redupe_find_error_locator+0x2bd>
mov    -0x23c(%rbp),%eax
add    -0x238(%rbp),%eax
mov    %eax,-0x240(%rbp)
mov    -0x8(%rbp),%rax
mov    -0x240(%rbp),%ecx
mov    (%rax,%rcx,1),%al
mov    %al,-0x241(%rbp)
movl   $0x1,-0x248(%rbp)
mov    -0x248(%rbp),%eax
cmp    -0x234(%rbp),%eax
jae    1269 <redupe_find_error_locator+0x119>
mov    -0x234(%rbp),%eax
mov    -0x248(%rbp),%ecx
add    $0x1,%ecx
sub    %ecx,%eax
mov    %eax,%eax
mov    -0x230(%rbp,%rax,1),%dl
mov    -0x8(%rbp),%rax
mov    -0x240(%rbp),%ecx
sub    -0x248(%rbp),%ecx
mov    %ecx,%ecx
movzbl %dl,%edi
movzbl (%rax,%rcx,1),%esi
call   1070 <redupe_gf_mul@plt>
movzbl %al,%ecx
movzbl -0x241(%rbp),%eax
xor    %ecx,%eax
mov    %al,-0x241(%rbp)
mov    -0x248(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x248(%rbp)
jmp    11f9 <redupe_find_error_locator+0xa9>
mov    -0x124(%rbp),%eax
movb   $0x0,-0x120(%rbp,%rax,1)
mov    -0x124(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x124(%rbp)
movzbl -0x241(%rbp),%eax
cmp    $0x0,%eax
je     13f4 <redupe_find_error_locator+0x2a4>
mov    -0x124(%rbp),%eax
cmp    -0x234(%rbp),%eax
jbe    135a <redupe_find_error_locator+0x20a>
mov    -0x124(%rbp),%eax
mov    %eax,-0x354(%rbp)
lea    -0x350(%rbp),%rdi
lea    -0x120(%rbp),%rsi
mov    $0x100,%edx
call   1060 <memmove@plt>
lea    -0x350(%rbp),%rdi
mov    -0x354(%rbp),%esi
movzbl -0x241(%rbp),%edx
call   1040 <redupe_gf_poly_scale@plt>
mov    -0x234(%rbp),%eax
mov    %eax,-0x124(%rbp)
lea    -0x120(%rbp),%rdi
lea    -0x230(%rbp),%rsi
mov    -0x354(%rbp),%edx
call   1060 <memmove@plt>
movzbl -0x241(%rbp),%edi
call   1030 <redupe_gf_inv@plt>
mov    %al,-0x355(%rbp)
lea    -0x120(%rbp),%rdi
mov    -0x124(%rbp),%esi
movzbl -0x355(%rbp),%edx
call   1040 <redupe_gf_poly_scale@plt>
mov    -0x354(%rbp),%eax
mov    %eax,-0x234(%rbp)
lea    -0x230(%rbp),%rdi
lea    -0x350(%rbp),%rsi
mov    -0x354(%rbp),%edx
call   1060 <memmove@plt>
mov    -0x124(%rbp),%eax
mov    %eax,-0x464(%rbp)
movl   $0x0,-0x574(%rbp)
lea    -0x460(%rbp),%rdi
lea    -0x120(%rbp),%rsi
mov    -0x124(%rbp),%edx
call   1060 <memmove@plt>
lea    -0x460(%rbp),%rdi
mov    -0x464(%rbp),%esi
movzbl -0x241(%rbp),%edx
call   1040 <redupe_gf_poly_scale@plt>
lea    -0x230(%rbp),%rdi
mov    -0x234(%rbp),%esi
lea    -0x460(%rbp),%rdx
mov    -0x464(%rbp),%ecx
lea    -0x570(%rbp),%r8
lea    -0x574(%rbp),%r9
call   1050 <redupe_gf_poly_add@plt>
mov    -0x574(%rbp),%eax
mov    %eax,-0x234(%rbp)
lea    -0x230(%rbp),%rdi
lea    -0x570(%rbp),%rsi
mov    -0x574(%rbp),%edx
call   1060 <memmove@plt>
jmp    13f9 <redupe_find_error_locator+0x2a9>
mov    -0x23c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x23c(%rbp)
jmp    11bb <redupe_find_error_locator+0x6b>
movl   $0x0,-0x578(%rbp)
mov    -0x578(%rbp),%ecx
xor    %eax,%eax
cmp    -0x234(%rbp),%ecx
mov    %al,-0x57d(%rbp)
jae    144b <redupe_find_error_locator+0x2fb>
mov    -0x578(%rbp),%eax
movzbl -0x230(%rbp,%rax,1),%eax
ff
cmp    $0x0,%eax
sete   %al
mov    %al,-0x57d(%rbp)
mov    -0x57d(%rbp),%al
test   $0x1,%al
jne    145e <redupe_find_error_locator+0x30e>
jmp    1477 <redupe_find_error_locator+0x327>
jmp    1463 <redupe_find_error_locator+0x313>
mov    -0x578(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x578(%rbp)
jmp    1417 <redupe_find_error_locator+0x2c7>
movl   $0x0,-0x57c(%rbp)
mov    -0x57c(%rbp),%eax
add    -0x578(%rbp),%eax
cmp    -0x234(%rbp),%eax
jae    14cf <redupe_find_error_locator+0x37f>
mov    -0x57c(%rbp),%eax
add    -0x578(%rbp),%eax
mov    %eax,%eax
mov    -0x230(%rbp,%rax,1),%dl
mov    -0x18(%rbp),%rax
mov    -0x57c(%rbp),%ecx
mov    %dl,(%rax,%rcx,1)
mov    -0x57c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x57c(%rbp)
jmp    1481 <redupe_find_error_locator+0x331>
mov    -0x234(%rbp),%ecx
sub    -0x578(%rbp),%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x20(%rbp),%rax
mov    (%rax),%edx
sub    $0x1,%edx
shl    $0x1,%edx
mov    -0x10(%rbp),%esi
mov    $0xffffffff,%eax
xor    %ecx,%ecx
cmp    %esi,%edx
cmovbe %ecx,%eax
add    $0x580,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<redupe_find_error_locator>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x448,%rsp
mov    %r8,%r12
mov    %edx,%r15d
movb   $0x1,0x140(%rsp)
01
movb   $0x1,0x40(%rsp)
xor    %eax,%eax
mov    %esi,%edx
sub    %r15d,%edx
cmovb  %eax,%edx
mov    %rdx,0x38(%rsp)
test   %r15d,%r15d
mov    %rcx,0x20(%rsp)
je     1385 <redupe_find_error_locator+0x225>
mov    %rdi,%r14
mov    %r12,0x28(%rsp)
mov    %r15d,%eax
mov    %rax,0x30(%rsp)
cmp    %esi,%r15d
mov    %esi,%ecx
mov    %r15d,0x18(%rsp)
cmovb  %r15d,%ecx
not    %ecx
add    %esi,%ecx
mov    $0x1,%r13d
xor    %r12d,%r12d
mov    $0x1,%ebp
jmp    11fa <redupe_find_error_locator+0x9a>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    0x10(%rsp),%ebp
add    $0x1,%r12
mov    0x1c(%rsp),%ecx
add    $0x1,%ecx
cmp    0x30(%rsp),%r12
je     1371 <redupe_find_error_locator+0x211>
mov    0x38(%rsp),%rax
add    %r12d,%eax
mov    (%r14,%rax,1),%bl
cmp    $0x2,%ebp
mov    %ebp,0x10(%rsp)
mov    %ecx,0x1c(%rsp)
jb     1245 <redupe_find_error_locator+0xe5>
mov    %ebp,%ebp
mov    %ecx,%r15d
nopl   0x0(%rax,%rax,1)
lea    -0x2(%rbp),%eax
movzbl 0x40(%rsp,%rax,1),%edi
mov    %r15d,%eax
movzbl (%r14,%rax,1),%esi
call   1080 <redupe_gf_mul@plt>
xor    %al,%bl
add    $0xffffffff,%r15d
add    $0xffffffffffffffff,%rbp
cmp    $0x1,%rbp
jne    1220 <redupe_find_error_locator+0xc0>
mov    %r13d,%eax
movb   $0x0,0x140(%rsp,%rax,1)
add    $0x1,%r13d
test   %bl,%bl
je     11e0 <redupe_find_error_locator+0x80>
movzbl %bl,%eax
mov    %eax,0xc(%rsp)
mov    0x10(%rsp),%ebp
cmp    %ebp,%r13d
jbe    1300 <redupe_find_error_locator+0x1a0>
lea    0x240(%rsp),%r15
mov    %r15,%rdi
lea    0x140(%rsp),%rbx
mov    %rbx,%rsi
mov    $0x100,%edx
call   1070 <memmove@plt>
mov    %r15,%rdi
mov    %r13d,%esi
mov    0xc(%rsp),%r15d
mov    %r15d,%edx
call   1050 <redupe_gf_poly_scale@plt>
mov    %rbx,%rdi
lea    0x40(%rsp),%rbx
mov    %rbx,%rsi
mov    %r13d,%edx
call   1070 <memmove@plt>
mov    %r15d,%edi
call   1040 <redupe_gf_inv@plt>
movzbl %al,%edx
lea    0x140(%rsp),%rdi
mov    %ebp,%esi
call   1050 <redupe_gf_poly_scale@plt>
mov    %rbx,%rdi
lea    0x240(%rsp),%r15
mov    %r15,%rsi
mov    %r13d,%edx
call   1070 <memmove@plt>
lea    0x140(%rsp),%rsi
mov    %r15,%rdi
mov    %r13d,%r15d
mov    %ebp,%r13d
jmp    1318 <redupe_find_error_locator+0x1b8>
cs nopw 0x0(%rax,%rax,1)
nop
mov    %ebp,%r15d
lea    0x240(%rsp),%rdi
lea    0x140(%rsp),%rsi
lea    0x40(%rsp),%rbx
movl   $0x0,0x14(%rsp)
mov    %r13d,%edx
mov    %rdi,%rbp
call   1070 <memmove@plt>
mov    %rbp,%rdi
mov    %r13d,%esi
mov    0xc(%rsp),%edx
call   1050 <redupe_gf_poly_scale@plt>
mov    %rbx,%rdi
mov    %r15d,%esi
mov    %rbp,%rdx
mov    %r13d,%ecx
lea    0x340(%rsp),%r15
mov    %r15,%r8
lea    0x14(%rsp),%r9
call   1060 <redupe_gf_poly_add@plt>
mov    0x14(%rsp),%ebp
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %ebp,%edx
call   1070 <memmove@plt>
jmp    11e4 <redupe_find_error_locator+0x84>
test   %ebp,%ebp
mov    0x18(%rsp),%r15d
mov    0x28(%rsp),%r12
jne    138a <redupe_find_error_locator+0x22a>
xor    %eax,%eax
xor    %ebx,%ebx
jmp    13c8 <redupe_find_error_locator+0x268>
mov    $0x1,%ebp
mov    %ebp,%eax
mov    %ebp,%ebx
xor    %ebp,%ebp
cmpb   $0x0,0x40(%rsp,%rbp,1)
jne    13a2 <redupe_find_error_locator+0x242>
add    $0x1,%rbp
cmp    %rbp,%rbx
jne    1390 <redupe_find_error_locator+0x230>
jmp    13c8 <redupe_find_error_locator+0x268>
cmp    %ebp,%eax
jbe    13c6 <redupe_find_error_locator+0x266>
mov    %eax,%ecx
mov    %ebp,%eax
lea    (%rsp,%rax,1),%rsi
add    $0x40,%rsi
mov    %ebp,%edx
not    %edx
add    %ecx,%edx
add    $0x1,%rdx
mov    0x20(%rsp),%rdi
call   1030 <memcpy@plt>
mov    %ebp,%eax
sub    %eax,%ebx
mov    %ebx,(%r12)
lea    (%rbx,%rbx,1),%eax
add    $0xfffffffe,%eax
cmp    %eax,%r15d
sbb    %eax,%eax
add    $0x448,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @redupe_find_error_locator(i8* %0, i32 %1, i32 %2, i8* %3, i32* %4) {
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i8*
%10 = alloca i32*
%11 = alloca [256 x i8]
%12 = alloca i32
%13 = alloca [256 x i8]
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32
%18 = alloca i8
%19 = alloca i32
%20 = alloca [256 x i8]
%21 = alloca i32
%22 = alloca i8
%23 = alloca [256 x i8]
%24 = alloca i32
%25 = alloca [256 x i8]
%26 = alloca i32
%27 = alloca i32
%28 = alloca i32
store i8* %0, i8** %6
store i32 %1, i32* %7
store i32 %2, i32* %8
store i8* %3, i8** %9
store i32* %4, i32** %10
store i32 1, i32* %12
%29 = getelementptr inbounds [256 x i8], [256 x i8]* %11, i64 0, i64 0
store i8 1, i8* %29
store i32 1, i32* %14
%30 = getelementptr inbounds [256 x i8], [256 x i8]* %13, i64 0, i64 0
store i8 1, i8* %30
store i32 0, i32* %15
%31 = load i32, i32* %7
%32 = load i32, i32* %8
%33 = icmp ugt i32 %31, %32
br i1 %33, label %34, label %38
34: ; preds = %5
%35 = load i32, i32* %7
%36 = load i32, i32* %8
%37 = sub i32 %35, %36
store i32 %37, i32* %15
br label %38
38: ; preds = %34, %5
store i32 0, i32* %16
br label %39
39: ; preds = %140, %38
%40 = load i32, i32* %16
%41 = load i32, i32* %8
%42 = icmp ult i32 %40, %41
br i1 %42, label %43, label %143
43: ; preds = %39
%44 = load i32, i32* %16
%45 = load i32, i32* %15
%46 = add i32 %44, %45
store i32 %46, i32* %17
%47 = load i8*, i8** %6
%48 = load i32, i32* %17
%49 = zext i32 %48 to i64
%50 = getelementptr inbounds i8, i8* %47, i64 %49
%51 = load i8, i8* %50
store i8 %51, i8* %18
store i32 1, i32* %19
br label %52
52: ; preds = %77, %43
%53 = load i32, i32* %19
%54 = load i32, i32* %14
%55 = icmp ult i32 %53, %54
br i1 %55, label %56, label %80
56: ; preds = %52
%57 = load i32, i32* %14
%58 = load i32, i32* %19
%59 = add i32 %58, 1
%60 = sub i32 %57, %59
%61 = zext i32 %60 to i64
%62 = getelementptr inbounds [256 x i8], [256 x i8]* %13, i64 0, i64 %61
%63 = load i8, i8* %62
%64 = load i8*, i8** %6
%65 = load i32, i32* %17
%66 = load i32, i32* %19
%67 = sub i32 %65, %66
%68 = zext i32 %67 to i64
%69 = getelementptr inbounds i8, i8* %64, i64 %68
%70 = load i8, i8* %69
%71 = call zeroext i8 @redupe_gf_mul(i8 zeroext %63, i8 zeroext %70)
%72 = zext i8 %71 to i32
%73 = load i8, i8* %18
%74 = zext i8 %73 to i32
%75 = xor i32 %74, %72
%76 = trunc i32 %75 to i8
store i8 %76, i8* %18
br label %77
77: ; preds = %56
%78 = load i32, i32* %19
%79 = add i32 %78, 1
store i32 %79, i32* %19
br label %52
80: ; preds = %52
%81 = load i32, i32* %12
%82 = zext i32 %81 to i64
%83 = getelementptr inbounds [256 x i8], [256 x i8]* %11, i64 0, i64 %82
store i8 0, i8* %83
%84 = load i32, i32* %12
%85 = add i32 %84, 1
store i32 %85, i32* %12
%86 = load i8, i8* %18
%87 = zext i8 %86 to i32
%88 = icmp ne i32 %87, 0
br i1 %88, label %89, label %139
89: ; preds = %80
%90 = load i32, i32* %12
%91 = load i32, i32* %14
%92 = icmp ugt i32 %90, %91
br i1 %92, label %93, label %118
93: ; preds = %89
%94 = load i32, i32* %12
store i32 %94, i32* %21
%95 = getelementptr inbounds [256 x i8], [256 x i8]* %20, i64 0, i64 0
%96 = getelementptr inbounds [256 x i8], [256 x i8]* %11, i64 0, i64 0
%97 = call i32 @memmove(i8* %95, i8* %96, i32 256)
%98 = getelementptr inbounds [256 x i8], [256 x i8]* %20, i64 0, i64 0
%99 = load i32, i32* %21
%100 = load i8, i8* %18
%101 = call i32 @redupe_gf_poly_scale(i8* %98, i32 %99, i8 zeroext %100)
%102 = load i32, i32* %14
store i32 %102, i32* %12
%103 = getelementptr inbounds [256 x i8], [256 x i8]* %11, i64 0, i64 0
%104 = getelementptr inbounds [256 x i8], [256 x i8]* %13, i64 0, i64 0
%105 = load i32, i32* %21
%106 = call i32 @memmove(i8* %103, i8* %104, i32 %105)
%107 = load i8, i8* %18
%108 = call zeroext i8 @redupe_gf_inv(i8 zeroext %107)
store i8 %108, i8* %22
%109 = getelementptr inbounds [256 x i8], [256 x i8]* %11, i64 0, i64 0
%110 = load i32, i32* %12
%111 = load i8, i8* %22
%112 = call i32 @redupe_gf_poly_scale(i8* %109, i32 %110, i8 zeroext %111)
%113 = load i32, i32* %21
store i32 %113, i32* %14
%114 = getelementptr inbounds [256 x i8], [256 x i8]* %13, i64 0, i64 0
%115 = getelementptr inbounds [256 x i8], [256 x i8]* %20, i64 0, i64 0
%116 = load i32, i32* %21
%117 = call i32 @memmove(i8* %114, i8* %115, i32 %116)
br label %118
118: ; preds = %93, %89
%119 = load i32, i32* %12
store i32 %119, i32* %24
store i32 0, i32* %26
%120 = getelementptr inbounds [256 x i8], [256 x i8]* %23, i64 0, i64 0
%121 = getelementptr inbounds [256 x i8], [256 x i8]* %11, i64 0, i64 0
%122 = load i32, i32* %12
%123 = call i32 @memmove(i8* %120, i8* %121, i32 %122)
%124 = getelementptr inbounds [256 x i8], [256 x i8]* %23, i64 0, i64 0
%125 = load i32, i32* %24
%126 = load i8, i8* %18
%127 = call i32 @redupe_gf_poly_scale(i8* %124, i32 %125, i8 zeroext %126)
%128 = getelementptr inbounds [256 x i8], [256 x i8]* %13, i64 0, i64 0
%129 = load i32, i32* %14
%130 = getelementptr inbounds [256 x i8], [256 x i8]* %23, i64 0, i64 0
%131 = load i32, i32* %24
%132 = getelementptr inbounds [256 x i8], [256 x i8]* %25, i64 0, i64 0
%133 = call i32 @redupe_gf_poly_add(i8* %128, i32 %129, i8* %130, i32 %131, i8* %132, i32* %26)
%134 = load i32, i32* %26
store i32 %134, i32* %14
%135 = getelementptr inbounds [256 x i8], [256 x i8]* %13, i64 0, i64 0
%136 = getelementptr inbounds [256 x i8], [256 x i8]* %25, i64 0, i64 0
%137 = load i32, i32* %26
%138 = call i32 @memmove(i8* %135, i8* %136, i32 %137)
br label %139
139: ; preds = %118, %80
br label %140
140: ; preds = %139
%141 = load i32, i32* %16
%142 = add i32 %141, 1
store i32 %142, i32* %16
br label %39
143: ; preds = %39
store i32 0, i32* %27
br label %144
144: ; preds = %158, %143
%145 = load i32, i32* %27
%146 = load i32, i32* %14
%147 = icmp ult i32 %145, %146
br i1 %147, label %148, label %155
148: ; preds = %144
%149 = load i32, i32* %27
%150 = zext i32 %149 to i64
%151 = getelementptr inbounds [256 x i8], [256 x i8]* %13, i64 0, i64 %150
%152 = load i8, i8* %151
%153 = zext i8 %152 to i32
%154 = icmp eq i32 %153, 0
br label %155
155: ; preds = %148, %144
%156 = phi i1 [ false, %144 ], [ %154, %148 ]
br i1 %156, label %157, label %161
157: ; preds = %155
br label %158
158: ; preds = %157
%159 = load i32, i32* %27
%160 = add i32 %159, 1
store i32 %160, i32* %27
br label %144
161: ; preds = %155
store i32 0, i32* %28
br label %162
162: ; preds = %179, %161
%163 = load i32, i32* %28
%164 = load i32, i32* %27
%165 = add i32 %163, %164
%166 = load i32, i32* %14
%167 = icmp ult i32 %165, %166
br i1 %167, label %168, label %182
168: ; preds = %162
%169 = load i32, i32* %28
%170 = load i32, i32* %27
%171 = add i32 %169, %170
%172 = zext i32 %171 to i64
%173 = getelementptr inbounds [256 x i8], [256 x i8]* %13, i64 0, i64 %172
%174 = load i8, i8* %173
%175 = load i8*, i8** %9
%176 = load i32, i32* %28
%177 = zext i32 %176 to i64
%178 = getelementptr inbounds i8, i8* %175, i64 %177
store i8 %174, i8* %178
br label %179
179: ; preds = %168
%180 = load i32, i32* %28
%181 = add i32 %180, 1
store i32 %181, i32* %28
br label %162
182: ; preds = %162
%183 = load i32, i32* %14
%184 = load i32, i32* %27
%185 = sub i32 %183, %184
%186 = load i32*, i32** %10
store i32 %185, i32* %186
%187 = load i32*, i32** %10
%188 = load i32, i32* %187
%189 = sub i32 %188, 1
%190 = mul i32 %189, 2
%191 = load i32, i32* %8
%192 = icmp ule i32 %190, %191
%193 = zext i1 %192 to i64
%194 = select i1 %192, i32 0, i32 -1
ret i32 %194
}

LLVM IR (-O2):
define i32 @redupe_find_error_locator(i8* nocapture %0, i32 %1, i32 %2, i8* nocapture writeonly %3, i32* nocapture writeonly %4) {
%6 = alloca [256 x i8]
%7 = alloca [256 x i8]
%8 = alloca [256 x i8]
%9 = alloca [256 x i8]
%10 = alloca [256 x i8]
%11 = alloca i32
%12 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
store i8 1, i8* %12
%13 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 0
store i8 1, i8* %13
%14 = tail call i32 @llvm.usub.sat.i32(i32 %1, i32 %2)
%15 = icmp eq i32 %2, 0
br i1 %15, label %24, label %16
16: ; preds = %5
%17 = getelementptr inbounds [256 x i8], [256 x i8]* %8, i64 0, i64 0
%18 = getelementptr inbounds [256 x i8], [256 x i8]* %9, i64 0, i64 0
%19 = getelementptr inbounds [256 x i8], [256 x i8]* %10, i64 0, i64 0
%20 = bitcast i32* %11 to i8*
%21 = zext i32 %2 to i64
br label %27
22: ; preds = %79
%23 = icmp eq i32 %80, 0
br i1 %23, label %102, label %24
24: ; preds = %5, %22
%25 = phi i32 [ %80, %22 ], [ 1, %5 ]
%26 = zext i32 %25 to i64
br label %84
27: ; preds = %16, %79
%28 = phi i64 [ 0, %16 ], [ %82, %79 ]
%29 = phi i32 [ 1, %16 ], [ %81, %79 ]
%30 = phi i32 [ 1, %16 ], [ %80, %79 ]
%31 = trunc i64 %28 to i32
%32 = add i32 %14, %31
%33 = zext i32 %32 to i64
%34 = getelementptr inbounds i8, i8* %0, i64 %33
%35 = load i8, i8* %34
%36 = icmp ugt i32 %30, 1
br i1 %36, label %37, label %39
37: ; preds = %27
%38 = zext i32 %30 to i64
br label %45
39: ; preds = %45, %27
%40 = phi i8 [ %35, %27 ], [ %60, %45 ]
%41 = zext i32 %29 to i64
%42 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 %41
store i8 0, i8* %42
%43 = add i32 %29, 1
%44 = icmp eq i8 %40, 0
br i1 %44, label %79, label %62
45: ; preds = %37, %45
%46 = phi i64 [ 1, %37 ], [ %48, %45 ]
%47 = phi i8 [ %35, %37 ], [ %60, %45 ]
%48 = add nuw nsw i64 %46, 1
%49 = trunc i64 %48 to i32
%50 = sub i32 %30, %49
%51 = zext i32 %50 to i64
%52 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 %51
%53 = load i8, i8* %52
%54 = trunc i64 %46 to i32
%55 = sub i32 %32, %54
%56 = zext i32 %55 to i64
%57 = getelementptr inbounds i8, i8* %0, i64 %56
%58 = load i8, i8* %57
%59 = call zeroext i8 @redupe_gf_mul(i8 zeroext %53, i8 zeroext %58)
%60 = xor i8 %59, %47
%61 = icmp eq i64 %48, %38
br i1 %61, label %39, label %45
62: ; preds = %39
%63 = icmp ugt i32 %43, %30
br i1 %63, label %64, label %71
64: ; preds = %62
%65 = call i32 @memmove(i8* %17, i8* %12, i32 256)
%66 = call i32 @redupe_gf_poly_scale(i8* %17, i32 %43, i8 zeroext %40)
%67 = call i32 @memmove(i8* %12, i8* %13, i32 %43)
%68 = call zeroext i8 @redupe_gf_inv(i8 zeroext %40)
%69 = call i32 @redupe_gf_poly_scale(i8* %12, i32 %30, i8 zeroext %68)
%70 = call i32 @memmove(i8* %13, i8* %17, i32 %43)
br label %71
71: ; preds = %64, %62
%72 = phi i32 [ %43, %64 ], [ %30, %62 ]
%73 = phi i32 [ %30, %64 ], [ %43, %62 ]
store i32 0, i32* %11
%74 = call i32 @memmove(i8* %18, i8* %12, i32 %73)
%75 = call i32 @redupe_gf_poly_scale(i8* %18, i32 %73, i8 zeroext %40)
%76 = call i32 @redupe_gf_poly_add(i8* %13, i32 %72, i8* %18, i32 %73, i8* %19, i32* %11)
%77 = load i32, i32* %11
%78 = call i32 @memmove(i8* %13, i8* %19, i32 %77)
br label %79
79: ; preds = %71, %39
%80 = phi i32 [ %77, %71 ], [ %30, %39 ]
%81 = phi i32 [ %73, %71 ], [ %43, %39 ]
%82 = add nuw nsw i64 %28, 1
%83 = icmp eq i64 %82, %21
br i1 %83, label %22, label %27
84: ; preds = %24, %89
%85 = phi i64 [ 0, %24 ], [ %90, %89 ]
%86 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 %85
%87 = load i8, i8* %86
%88 = icmp eq i8 %87, 0
br i1 %88, label %89, label %92
89: ; preds = %84
%90 = add nuw nsw i64 %85, 1
%91 = icmp eq i64 %90, %26
br i1 %91, label %102, label %84
92: ; preds = %84
%93 = trunc i64 %85 to i32
%94 = icmp ugt i32 %25, %93
br i1 %94, label %95, label %102
95: ; preds = %92
%96 = and i64 %85, 4294967295
%97 = getelementptr [256 x i8], [256 x i8]* %7, i64 0, i64 %96
%98 = xor i32 %93, -1
%99 = add i32 %25, %98
%100 = zext i32 %99 to i64
%101 = add nuw nsw i64 %100, 1
br label %102
102: ; preds = %89, %22, %95, %92
%103 = phi i32 [ %93, %95 ], [ %93, %92 ], [ 0, %22 ], [ %25, %89 ]
%104 = phi i32 [ %25, %95 ], [ %25, %92 ], [ 0, %22 ], [ %25, %89 ]
%105 = sub i32 %104, %103
store i32 %105, i32* %4
%106 = shl i32 %105, 1
%107 = add i32 %106, -2
%108 = icmp ugt i32 %107, %2
%109 = sext i1 %108 to i32
ret i32 %109
}