#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 gmult(int, int);
int compute_discrepancy(int lambda[], int S[], int L, int n) {
  int i, sum = 0;
  for (i = 0; i <= L; i++)
    sum ^= gmult(lambda[i], S[n - i]);
  return (sum);
}


x86 assembly (clang, -O0):
<compute_discrepancy>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
movl   $0x0,-0x20(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x14(%rbp),%eax
jg     1174 <compute_discrepancy+0x64>
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,4),%edi
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%ecx
sub    -0x1c(%rbp),%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,4),%esi
call   1030 <gmult@plt>
xor    -0x20(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1134 <compute_discrepancy+0x24>
mov    -0x20(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<compute_discrepancy>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
test   %edx,%edx
js     115d <compute_discrepancy+0x4d>
mov    %edx,%r15d
mov    %rdi,%r14
movslq %ecx,%rax
add    $0x1,%r15d
lea    (%rsi,%rax,4),%rbx
xor    %ebp,%ebp
xor    %r12d,%r12d
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    (%r14,%rbp,4),%edi
mov    (%rbx),%esi
call   1030 <gmult@plt>
xor    %eax,%r12d
add    $0x1,%rbp
add    $0xfffffffffffffffc,%rbx
cmp    %rbp,%r15
jne    1140 <compute_discrepancy+0x30>
jmp    1160 <compute_discrepancy+0x50>
xor    %r12d,%r12d
mov    %r12d,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @compute_discrepancy(i32* %0, i32* %1, i32 %2, i32 %3) {
%5 = alloca i32*
%6 = alloca i32*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
store i32* %0, i32** %5
store i32* %1, i32** %6
store i32 %2, i32* %7
store i32 %3, i32* %8
store i32 0, i32* %10
store i32 0, i32* %9
br label %11
11: ; preds = %31, %4
%12 = load i32, i32* %9
%13 = load i32, i32* %7
%14 = icmp sle i32 %12, %13
br i1 %14, label %15, label %34
15: ; preds = %11
%16 = load i32*, i32** %5
%17 = load i32, i32* %9
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds i32, i32* %16, i64 %18
%20 = load i32, i32* %19
%21 = load i32*, i32** %6
%22 = load i32, i32* %8
%23 = load i32, i32* %9
%24 = sub nsw i32 %22, %23
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds i32, i32* %21, i64 %25
%27 = load i32, i32* %26
%28 = call i32 @gmult(i32 %20, i32 %27)
%29 = load i32, i32* %10
%30 = xor i32 %29, %28
store i32 %30, i32* %10
br label %31
31: ; preds = %15
%32 = load i32, i32* %9
%33 = add nsw i32 %32, 1
store i32 %33, i32* %9
br label %11
34: ; preds = %11
%35 = load i32, i32* %10
ret i32 %35
}

LLVM IR (-O2):
define i32 @compute_discrepancy(i32* nocapture %0, i32* nocapture %1, i32 %2, i32 %3) {
%5 = icmp slt i32 %2, 0
br i1 %5, label %22, label %6
6: ; preds = %4
%7 = sext i32 %3 to i64
%8 = add nuw i32 %2, 1
%9 = zext i32 %8 to i64
br label %10
10: ; preds = %6, %10
%11 = phi i64 [ 0, %6 ], [ %20, %10 ]
%12 = phi i32 [ 0, %6 ], [ %19, %10 ]
%13 = getelementptr inbounds i32, i32* %0, i64 %11
%14 = load i32, i32* %13
%15 = sub nsw i64 %7, %11
%16 = getelementptr inbounds i32, i32* %1, i64 %15
%17 = load i32, i32* %16
%18 = tail call i32 @gmult(i32 %14, i32 %17)
%19 = xor i32 %18, %12
%20 = add nuw nsw i64 %11, 1
%21 = icmp eq i64 %20, %9
br i1 %21, label %22, label %10
22: ; preds = %10, %4
%23 = phi i32 [ 0, %4 ], [ %19, %10 ]
ret i32 %23
}