#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 sre_toupper(int);
int GCGchecksum(char *seq, int len) {
  int i;
  int chk = 0;
  for (i = 0; i < len; i++)
    chk = (chk + (i % 57 + 1) * (sre_toupper((int)seq[i]))) % 10000;
  return chk;
}


x86 assembly (clang, -O0):
<GCGchecksum>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1187 <GCGchecksum+0x77>
mov    -0x14(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%eax
mov    $0x39,%ecx
cltd
idiv   %ecx
add    $0x1,%edx
mov    %edx,-0x1c(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1030 <sre_toupper@plt>
mov    -0x1c(%rbp),%ecx
mov    %eax,%edx
mov    -0x18(%rbp),%eax
imul   %edx,%ecx
add    %ecx,%eax
mov    $0x2710,%ecx
cltd
idiv   %ecx
mov    %edx,-0x14(%rbp)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    112d <GCGchecksum+0x1d>
mov    -0x14(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<GCGchecksum>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
test   %esi,%esi
jle    118f <GCGchecksum+0x7f>
mov    %rdi,%r14
mov    %esi,%r15d
xor    %r12d,%r12d
mov    $0x1,%r13d
xor    %ebx,%ebx
mov    %r12d,%eax
imul   $0x1f7047dd,%rax,%rax
shr    $0x20,%rax
mov    %r12d,%ecx
sub    %eax,%ecx
shr    %ecx
add    %eax,%ecx
shr    $0x5,%ecx
imul   $0x39,%ecx,%eax
mov    %r13d,%ebp
sub    %eax,%ebp
movsbl (%r14,%r12,1),%edi
call   1030 <sre_toupper@plt>
imul   %ebp,%eax
add    %ebx,%eax
movslq %eax,%rbx
imul   $0x68db8bad,%rbx,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x2c,%rax
add    %ecx,%eax
imul   $0x2710,%eax,%eax
sub    %eax,%ebx
add    $0x1,%r12
add    $0x1,%r13d
cmp    %r12,%r15
jne    1130 <GCGchecksum+0x20>
jmp    1191 <GCGchecksum+0x81>
xor    %ebx,%ebx
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @GCGchecksum(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i8* %0, i8** %3
store i32 %1, i32* %4
store i32 0, i32* %6
store i32 0, i32* %5
br label %7
7: ; preds = %26, %2
%8 = load i32, i32* %5
%9 = load i32, i32* %4
%10 = icmp slt i32 %8, %9
br i1 %10, label %11, label %29
11: ; preds = %7
%12 = load i32, i32* %6
%13 = load i32, i32* %5
%14 = srem i32 %13, 57
%15 = add nsw i32 %14, 1
%16 = load i8*, i8** %3
%17 = load i32, i32* %5
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds i8, i8* %16, i64 %18
%20 = load i8, i8* %19
%21 = sext i8 %20 to i32
%22 = call i32 @sre_toupper(i32 %21)
%23 = mul nsw i32 %15, %22
%24 = add nsw i32 %12, %23
%25 = srem i32 %24, 10000
store i32 %25, i32* %6
br label %26
26: ; preds = %11
%27 = load i32, i32* %5
%28 = add nsw i32 %27, 1
store i32 %28, i32* %5
br label %7
29: ; preds = %7
%30 = load i32, i32* %6
ret i32 %30
}

LLVM IR (-O2):
define i32 @GCGchecksum(i8* nocapture %0, i32 %1) {
%3 = icmp sgt i32 %1, 0
br i1 %3, label %4, label %21
4: ; preds = %2
%5 = zext i32 %1 to i64
br label %6
6: ; preds = %4, %6
%7 = phi i64 [ 0, %4 ], [ %19, %6 ]
%8 = phi i32 [ 0, %4 ], [ %18, %6 ]
%9 = trunc i64 %7 to i32
%10 = urem i32 %9, 57
%11 = add nuw nsw i32 %10, 1
%12 = getelementptr inbounds i8, i8* %0, i64 %7
%13 = load i8, i8* %12
%14 = sext i8 %13 to i32
%15 = tail call i32 @sre_toupper(i32 %14)
%16 = mul nsw i32 %15, %11
%17 = add nsw i32 %16, %8
%18 = srem i32 %17, 10000
%19 = add nuw nsw i64 %7, 1
%20 = icmp eq i64 %19, %5
br i1 %20, label %21, label %6
21: ; preds = %6, %2
%22 = phi i32 [ 0, %2 ], [ %18, %6 ]
ret i32 %22
}