#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 */
size_t toupper(char);
double *eigg_encode_kmer(double *encoded_kmer, double *encode_nt, char *kmer,
                         unsigned long kmer_len) {
  unsigned long i = 0;
  for (i = 0; i < kmer_len; ++i) {
    encoded_kmer[i] = encode_nt[toupper(kmer[i])];
  }
  return encoded_kmer;
}


x86 assembly (clang, -O0):
<eigg_encode_kmer>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
movq   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%rax
cmp    -0x20(%rbp),%rax
jae    1189 <eigg_encode_kmer+0x79>
mov    -0x10(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x18(%rbp),%rax
mov    -0x28(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1030 <toupper@plt>
mov    %rax,%rcx
mov    -0x30(%rbp),%rax
movsd  (%rax,%rcx,8),%xmm0
mov    -0x8(%rbp),%rax
mov    -0x28(%rbp),%rcx
movsd  %xmm0,(%rax,%rcx,8)
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
jmp    1138 <eigg_encode_kmer+0x28>
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<eigg_encode_kmer>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %rdi,%r13
test   %rcx,%rcx
je     1150 <eigg_encode_kmer+0x40>
mov    %rcx,%r15
mov    %rdx,%r14
mov    %rsi,%r12
xor    %ebx,%ebx
nopl   0x0(%rax)
movsbl (%r14,%rbx,1),%edi
call   1030 <toupper@plt>
movsd  (%r12,%rax,8),%xmm0
movsd  %xmm0,0x0(%r13,%rbx,8)
add    $0x1,%rbx
cmp    %rbx,%r15
jne    1130 <eigg_encode_kmer+0x20>
mov    %r13,%rax
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
define double* @eigg_encode_kmer(double* returned writeonly %0, double* nocapture %1, i8* nocapture %2, i64 %3) {
%5 = icmp eq i64 %3, 0
br i1 %5, label %16, label %6
6: ; preds = %4, %6
%7 = phi i64 [ %14, %6 ], [ 0, %4 ]
%8 = getelementptr inbounds i8, i8* %2, i64 %7
%9 = load i8, i8* %8
%10 = tail call i64 @toupper(i8 signext %9)
%11 = getelementptr inbounds double, double* %1, i64 %10
%12 = load double, double* %11
%13 = getelementptr inbounds double, double* %0, i64 %7
store double %12, double* %13
%14 = add nuw i64 %7, 1
%15 = icmp eq i64 %14, %3
br i1 %15, label %16, label %6
16: ; preds = %6, %4
ret double* %0
}