#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 redupe_gf_poly_eval(unsigned char const *, unsigned int,
                                  int /*<<< orphan*/);
int /*<<< orphan*/ redupe_gf_pow(int, unsigned int);
void redupe_calc_syndromes(const unsigned char *msg, unsigned msg_sz,
                           unsigned nsym, unsigned char *buf,
                           unsigned *buf_sz) {
  buf[0] = 0;
  *buf_sz = nsym + 1;
  for (unsigned i = 0; i < nsym; ++i) {
    buf[i + 1] = redupe_gf_poly_eval(msg, msg_sz, redupe_gf_pow(2, i));
  }
}


x86 assembly (clang, -O0):
<redupe_calc_syndromes>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %rcx,-0x18(%rbp)
mov    %r8,-0x20(%rbp)
mov    -0x18(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x10(%rbp),%ecx
add    $0x1,%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x10(%rbp),%eax
jae    11a8 <redupe_calc_syndromes+0x88>
mov    -0x8(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x28(%rbp)
mov    -0x24(%rbp),%esi
mov    $0x2,%edi
call   1030 <redupe_gf_pow@plt>
mov    -0x30(%rbp),%rdi
mov    -0x28(%rbp),%esi
mov    %eax,%edx
call   1040 <redupe_gf_poly_eval@plt>
mov    %al,%dl
mov    -0x18(%rbp),%rax
mov    -0x24(%rbp),%ecx
add    $0x1,%ecx
mov    %ecx,%ecx
mov    %dl,(%rax,%rcx,1)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1154 <redupe_calc_syndromes+0x34>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<redupe_calc_syndromes>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
movb   $0x0,(%rcx)
lea    0x1(%rdx),%eax
mov    %eax,(%r8)
test   %edx,%edx
je     1177 <redupe_calc_syndromes+0x57>
mov    %rcx,%r15
mov    %esi,%r14d
mov    %rdi,%r12
mov    %edx,%ebp
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    $0x2,%edi
mov    %ebx,%esi
call   1030 <redupe_gf_pow@plt>
mov    %r12,%rdi
mov    %r14d,%esi
mov    %eax,%edx
call   1040 <redupe_gf_poly_eval@plt>
mov    %al,0x1(%r15,%rbx,1)
add    $0x1,%rbx
cmp    %rbx,%rbp
jne    1150 <redupe_calc_syndromes+0x30>
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @redupe_calc_syndromes(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 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
%12 = load i8*, i8** %9
%13 = getelementptr inbounds i8, i8* %12, i64 0
store i8 0, i8* %13
%14 = load i32, i32* %8
%15 = add i32 %14, 1
%16 = load i32*, i32** %10
store i32 %15, i32* %16
store i32 0, i32* %11
br label %17
17: ; preds = %32, %5
%18 = load i32, i32* %11
%19 = load i32, i32* %8
%20 = icmp ult i32 %18, %19
br i1 %20, label %21, label %35
21: ; preds = %17
%22 = load i8*, i8** %6
%23 = load i32, i32* %7
%24 = load i32, i32* %11
%25 = call i32 @redupe_gf_pow(i32 2, i32 %24)
%26 = call zeroext i8 @redupe_gf_poly_eval(i8* %22, i32 %23, i32 %25)
%27 = load i8*, i8** %9
%28 = load i32, i32* %11
%29 = add i32 %28, 1
%30 = zext i32 %29 to i64
%31 = getelementptr inbounds i8, i8* %27, i64 %30
store i8 %26, i8* %31
br label %32
32: ; preds = %21
%33 = load i32, i32* %11
%34 = add i32 %33, 1
store i32 %34, i32* %11
br label %17
35: ; preds = %17
ret void
}

LLVM IR (-O2):
define void @redupe_calc_syndromes(i8* %0, i32 %1, i32 %2, i8* nocapture writeonly %3, i32* nocapture writeonly %4) {
store i8 0, i8* %3
%6 = add i32 %2, 1
store i32 %6, i32* %4
%7 = icmp eq i32 %2, 0
br i1 %7, label %10, label %8
8: ; preds = %5
%9 = zext i32 %2 to i64
br label %11
10: ; preds = %11, %5
ret void
11: ; preds = %8, %11
%12 = phi i64 [ 0, %8 ], [ %16, %11 ]
%13 = trunc i64 %12 to i32
%14 = tail call i32 @redupe_gf_pow(i32 2, i32 %13)
%15 = tail call zeroext i8 @redupe_gf_poly_eval(i8* %0, i32 %1, i32 %14)
%16 = add nuw nsw i64 %12, 1
%17 = getelementptr inbounds i8, i8* %3, i64 %16
store i8 %15, i8* %17
%18 = icmp eq i64 %16, %9
br i1 %18, label %10, label %11
}