#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 */
unsigned char gf256_exp(unsigned char, int);
unsigned char gf256_multiply(unsigned char, unsigned char);
int rs_syndrome(unsigned char *syndrome, unsigned char *word) {
  int is_all_zero;
  int i, j;
  unsigned char z, zi, zij, ev;
  for (i = 0; i < 224 - 1; ++i) {
    syndrome[i] = 0;
  }
  is_all_zero = 1;
  z = 2;
  for (i = 1; i < 224; ++i) {
    ev = 0;
    zi = gf256_exp(z, i);
    for (j = 0; j < 255; ++j) {
      zij = gf256_exp(zi, j);
      ev ^= gf256_multiply(word[j], zij);
    }
    syndrome[i - 1] = ev;
    is_all_zero = is_all_zero & (ev == 0);
  }
  return is_all_zero;
}


x86 assembly (clang, -O0):
<rs_syndrome>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x18(%rbp)
cmpl   $0xdf,-0x18(%rbp)
jge    115e <rs_syndrome+0x3e>
mov    -0x8(%rbp),%rax
movslq -0x18(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1137 <rs_syndrome+0x17>
movl   $0x1,-0x14(%rbp)
movb   $0x2,-0x1d(%rbp)
movl   $0x1,-0x18(%rbp)
cmpl   $0xe0,-0x18(%rbp)
jge    1221 <rs_syndrome+0x101>
movb   $0x0,-0x20(%rbp)
mov    -0x1d(%rbp),%al
mov    -0x18(%rbp),%esi
movzbl %al,%edi
call   1040 <gf256_exp@plt>
mov    %al,-0x1e(%rbp)
movl   $0x0,-0x1c(%rbp)
cmpl   $0xff,-0x1c(%rbp)
jge    11e8 <rs_syndrome+0xc8>
mov    -0x1e(%rbp),%al
mov    -0x1c(%rbp),%esi
movzbl %al,%edi
call   1040 <gf256_exp@plt>
mov    %al,-0x1f(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,1),%al
movzbl %al,%edi
movzbl -0x1f(%rbp),%esi
call   1030 <gf256_multiply@plt>
movzbl %al,%ecx
movzbl -0x20(%rbp),%eax
xor    %ecx,%eax
mov    %al,-0x20(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1199 <rs_syndrome+0x79>
mov    -0x20(%rbp),%dl
mov    -0x8(%rbp),%rax
mov    -0x18(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x14(%rbp),%eax
movzbl -0x20(%rbp),%ecx
cmp    $0x0,%ecx
sete   %cl
and    $0x1,%cl
movzbl %cl,%ecx
and    %ecx,%eax
mov    %eax,-0x14(%rbp)
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1170 <rs_syndrome+0x50>
mov    -0x14(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rs_syndrome>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r13
xorps  %xmm0,%xmm0
movups %xmm0,0xcf(%rdi)
movups %xmm0,0xc0(%rdi)
movups %xmm0,0xb0(%rdi)
movups %xmm0,0xa0(%rdi)
movups %xmm0,0x90(%rdi)
movups %xmm0,0x80(%rdi)
movups %xmm0,0x70(%rdi)
movups %xmm0,0x60(%rdi)
movups %xmm0,0x50(%rdi)
movups %xmm0,0x40(%rdi)
movups %xmm0,0x30(%rdi)
movups %xmm0,0x20(%rdi)
movups %xmm0,0x10(%rdi)
mov    %rdi,%rax
mov    %rdi,(%rsp)
movups %xmm0,(%rdi)
mov    $0x1,%r15d
mov    $0x1,%r12d
nopl   (%rax)
mov    $0x2,%edi
mov    %r12d,%esi
call   1040 <gf256_exp@plt>
mov    %eax,%ebx
xor    %ebp,%ebp
xor    %r14d,%r14d
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movzbl %bl,%edi
mov    %ebp,%esi
call   1040 <gf256_exp@plt>
movzbl 0x0(%r13,%rbp,1),%edi
movzbl %al,%esi
call   1030 <gf256_multiply@plt>
xor    %al,%r14b
add    $0x1,%rbp
cmp    $0xff,%rbp
jne    11b0 <rs_syndrome+0x90>
mov    (%rsp),%rax
mov    %r14b,-0x1(%r12,%rax,1)
xor    %eax,%eax
test   %r14b,%r14b
sete   %al
and    %eax,%r15d
add    $0x1,%r12
cmp    $0xe0,%r12
jne    1190 <rs_syndrome+0x70>
mov    %r15d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @rs_syndrome(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i8
%9 = alloca i8
%10 = alloca i8
%11 = alloca i8
store i8* %0, i8** %3
store i8* %1, i8** %4
store i32 0, i32* %6
br label %12
12: ; preds = %20, %2
%13 = load i32, i32* %6
%14 = icmp slt i32 %13, 223
br i1 %14, label %15, label %23
15: ; preds = %12
%16 = load i8*, i8** %3
%17 = load i32, i32* %6
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds i8, i8* %16, i64 %18
store i8 0, i8* %19
br label %20
20: ; preds = %15
%21 = load i32, i32* %6
%22 = add nsw i32 %21, 1
store i32 %22, i32* %6
br label %12
23: ; preds = %12
store i32 1, i32* %5
store i8 2, i8* %8
store i32 1, i32* %6
br label %24
24: ; preds = %66, %23
%25 = load i32, i32* %6
%26 = icmp slt i32 %25, 224
br i1 %26, label %27, label %69
27: ; preds = %24
store i8 0, i8* %11
%28 = load i8, i8* %8
%29 = load i32, i32* %6
%30 = call zeroext i8 @gf256_exp(i8 zeroext %28, i32 %29)
store i8 %30, i8* %9
store i32 0, i32* %7
br label %31
31: ; preds = %50, %27
%32 = load i32, i32* %7
%33 = icmp slt i32 %32, 255
br i1 %33, label %34, label %53
34: ; preds = %31
%35 = load i8, i8* %9
%36 = load i32, i32* %7
%37 = call zeroext i8 @gf256_exp(i8 zeroext %35, i32 %36)
store i8 %37, i8* %10
%38 = load i8*, i8** %4
%39 = load i32, i32* %7
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds i8, i8* %38, i64 %40
%42 = load i8, i8* %41
%43 = load i8, i8* %10
%44 = call zeroext i8 @gf256_multiply(i8 zeroext %42, i8 zeroext %43)
%45 = zext i8 %44 to i32
%46 = load i8, i8* %11
%47 = zext i8 %46 to i32
%48 = xor i32 %47, %45
%49 = trunc i32 %48 to i8
store i8 %49, i8* %11
br label %50
50: ; preds = %34
%51 = load i32, i32* %7
%52 = add nsw i32 %51, 1
store i32 %52, i32* %7
br label %31
53: ; preds = %31
%54 = load i8, i8* %11
%55 = load i8*, i8** %3
%56 = load i32, i32* %6
%57 = sub nsw i32 %56, 1
%58 = sext i32 %57 to i64
%59 = getelementptr inbounds i8, i8* %55, i64 %58
store i8 %54, i8* %59
%60 = load i32, i32* %5
%61 = load i8, i8* %11
%62 = zext i8 %61 to i32
%63 = icmp eq i32 %62, 0
%64 = zext i1 %63 to i32
%65 = and i32 %60, %64
store i32 %65, i32* %5
br label %66
66: ; preds = %53
%67 = load i32, i32* %6
%68 = add nsw i32 %67, 1
store i32 %68, i32* %6
br label %24
69: ; preds = %24
%70 = load i32, i32* %5
ret i32 %70
}

LLVM IR (-O2):
define i32 @rs_syndrome(i8* nocapture writeonly %0, i8* nocapture %1) {
br label %3
3: ; preds = %2, %19
%4 = phi i64 [ 1, %2 ], [ %25, %19 ]
%5 = phi i32 [ 1, %2 ], [ %24, %19 ]
%6 = trunc i64 %4 to i32
%7 = tail call zeroext i8 @gf256_exp(i8 zeroext 2, i32 %6)
br label %8
8: ; preds = %3, %8
%9 = phi i64 [ 0, %3 ], [ %17, %8 ]
%10 = phi i8 [ 0, %3 ], [ %16, %8 ]
%11 = trunc i64 %9 to i32
%12 = tail call zeroext i8 @gf256_exp(i8 zeroext %7, i32 %11)
%13 = getelementptr inbounds i8, i8* %1, i64 %9
%14 = load i8, i8* %13
%15 = tail call zeroext i8 @gf256_multiply(i8 zeroext %14, i8 zeroext %12)
%16 = xor i8 %15, %10
%17 = add nuw nsw i64 %9, 1
%18 = icmp eq i64 %17, 255
br i1 %18, label %19, label %8
19: ; preds = %8
%20 = add nsw i64 %4, -1
%21 = getelementptr inbounds i8, i8* %0, i64 %20
store i8 %16, i8* %21
%22 = icmp eq i8 %16, 0
%23 = zext i1 %22 to i32
%24 = and i32 %5, %23
%25 = add nuw nsw i64 %4, 1
%26 = icmp eq i64 %25, 224
br i1 %26, label %27, label %3
27: ; preds = %19
ret i32 %24
}