#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 toupper(char);
int SeqGCGCheckSum(char *seq, int len) {
  int i;
  long check;
  for (i = 0, check = 0; i < len; i++, seq++)
    check += ((i % 57) + 1) * toupper(*seq);
  return (check % 10000);
}


x86 assembly (clang, -O0):
<SeqGCGCheckSum>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1183 <SeqGCGCheckSum+0x73>
mov    -0x10(%rbp),%eax
mov    $0x39,%ecx
cltd
idiv   %ecx
add    $0x1,%edx
mov    %edx,-0x1c(%rbp)
mov    -0x8(%rbp),%rax
movsbl (%rax),%edi
call   1030 <toupper@plt>
mov    %eax,%ecx
mov    -0x1c(%rbp),%eax
imul   %ecx,%eax
cltq
add    -0x18(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    112e <SeqGCGCheckSum+0x1e>
mov    -0x18(%rbp),%rax
mov    $0x2710,%ecx
cqto
idiv   %rcx
mov    %edx,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<SeqGCGCheckSum>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
test   %esi,%esi
jle    119b <SeqGCGCheckSum+0x8b>
mov    %esi,%r15d
mov    %rdi,%r12
xor    %r14d,%r14d
mov    $0x1,%r13d
xor    %ebx,%ebx
mov    %ebx,%eax
imul   $0x1f7047dd,%rax,%rax
shr    $0x20,%rax
mov    %ebx,%ecx
sub    %eax,%ecx
shr    %ecx
add    %eax,%ecx
shr    $0x5,%ecx
imul   $0x39,%ecx,%eax
mov    %r13d,%ebp
sub    %eax,%ebp
movsbl (%r12),%edi
call   1030 <toupper@plt>
imul   %ebp,%eax
cltq
add    %rax,%r14
add    $0x1,%ebx
add    $0x1,%r12
add    $0x1,%r13d
add    $0xffffffff,%r15d
jne    1130 <SeqGCGCheckSum+0x20>
movabs $0x346dc5d63886594b,%rcx
c5 6d 34
mov    %r14,%rax
imul   %rcx
mov    %rdx,%rax
shr    $0x3f,%rax
shr    $0xb,%rdx
add    %eax,%edx
imul   $0x2710,%edx,%eax
sub    %eax,%r14d
jmp    119e <SeqGCGCheckSum+0x8e>
xor    %r14d,%r14d
mov    %r14d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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