#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 strlen(char *);
char translate_codon(char *);
void translate_sequence(char *aaseq, char *ntseq) {
  int i, j = 0;
  char mycodon[4];
  for (i = 0; i < strlen(ntseq) / 3; i++) {
    mycodon[0] = ntseq[3 * i];
    mycodon[1] = ntseq[3 * i + 1];
    mycodon[2] = ntseq[3 * i + 2];
    mycodon[3] = 0;
    aaseq[j++] = translate_codon(mycodon);
  }
  aaseq[j++] = 0;
}


x86 assembly (clang, -O0):
<translate_sequence>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    $0x3,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x20(%rbp),%eax
cmp    %ecx,%eax
jge    11cd <translate_sequence+0xad>
mov    -0x10(%rbp),%rax
imul   $0x3,-0x14(%rbp),%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,1),%al
mov    %al,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
imul   $0x3,-0x14(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,1),%al
mov    %al,-0x1b(%rbp)
mov    -0x10(%rbp),%rax
imul   $0x3,-0x14(%rbp),%ecx
add    $0x2,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,1),%al
mov    %al,-0x1a(%rbp)
movb   $0x0,-0x19(%rbp)
lea    -0x1c(%rbp),%rdi
call   1040 <translate_codon@plt>
mov    %al,%dl
mov    -0x8(%rbp),%rax
mov    -0x18(%rbp),%ecx
mov    %ecx,%esi
add    $0x1,%esi
mov    %esi,-0x18(%rbp)
movslq %ecx,%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    113e <translate_sequence+0x1e>
mov    -0x8(%rbp),%rax
mov    -0x18(%rbp),%ecx
mov    %ecx,%edx
add    $0x1,%edx
mov    %edx,-0x18(%rbp)
movslq %ecx,%rcx
movb   $0x0,(%rax,%rcx,1)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<translate_sequence>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%r12
mov    %rdi,%r14
mov    %rsi,%rdi
call   1030 <strlen@plt>
cmp    $0x3,%eax
jl     11a7 <translate_sequence+0x87>
lea    0x2(%r12),%rbx
xor    %r13d,%r13d
lea    0xc(%rsp),%r15
nopl   (%rax)
movzbl -0x2(%rbx),%eax
mov    %al,0xc(%rsp)
movzbl -0x1(%rbx),%eax
mov    %al,0xd(%rsp)
movzbl (%rbx),%eax
mov    %al,0xe(%rsp)
movb   $0x0,0xf(%rsp)
mov    %r15,%rdi
call   1040 <translate_codon@plt>
mov    %al,(%r14,%r13,1)
add    $0x1,%r13
mov    %r12,%rdi
call   1030 <strlen@plt>
cltq
imul   $0x55555556,%rax,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
shr    $0x20,%rax
add    %ecx,%eax
cltq
add    $0x3,%rbx
cmp    %rax,%r13
jl     1150 <translate_sequence+0x30>
jmp    11aa <translate_sequence+0x8a>
xor    %r13d,%r13d
movb   $0x0,(%r14,%r13,1)
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @translate_sequence(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
%7 = alloca [4 x i8]
store i8* %0, i8** %3
store i8* %1, i8** %4
store i32 0, i32* %6
store i32 0, i32* %5
br label %8
8: ; preds = %46, %2
%9 = load i32, i32* %5
%10 = load i8*, i8** %4
%11 = call i32 @strlen(i8* %10)
%12 = sdiv i32 %11, 3
%13 = icmp slt i32 %9, %12
br i1 %13, label %14, label %49
14: ; preds = %8
%15 = load i8*, i8** %4
%16 = load i32, i32* %5
%17 = mul nsw i32 3, %16
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds i8, i8* %15, i64 %18
%20 = load i8, i8* %19
%21 = getelementptr inbounds [4 x i8], [4 x i8]* %7, i64 0, i64 0
store i8 %20, i8* %21
%22 = load i8*, i8** %4
%23 = load i32, i32* %5
%24 = mul nsw i32 3, %23
%25 = add nsw i32 %24, 1
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds i8, i8* %22, i64 %26
%28 = load i8, i8* %27
%29 = getelementptr inbounds [4 x i8], [4 x i8]* %7, i64 0, i64 1
store i8 %28, i8* %29
%30 = load i8*, i8** %4
%31 = load i32, i32* %5
%32 = mul nsw i32 3, %31
%33 = add nsw i32 %32, 2
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds i8, i8* %30, i64 %34
%36 = load i8, i8* %35
%37 = getelementptr inbounds [4 x i8], [4 x i8]* %7, i64 0, i64 2
store i8 %36, i8* %37
%38 = getelementptr inbounds [4 x i8], [4 x i8]* %7, i64 0, i64 3
store i8 0, i8* %38
%39 = getelementptr inbounds [4 x i8], [4 x i8]* %7, i64 0, i64 0
%40 = call signext i8 @translate_codon(i8* %39)
%41 = load i8*, i8** %3
%42 = load i32, i32* %6
%43 = add nsw i32 %42, 1
store i32 %43, i32* %6
%44 = sext i32 %42 to i64
%45 = getelementptr inbounds i8, i8* %41, i64 %44
store i8 %40, i8* %45
br label %46
46: ; preds = %14
%47 = load i32, i32* %5
%48 = add nsw i32 %47, 1
store i32 %48, i32* %5
br label %8
49: ; preds = %8
%50 = load i8*, i8** %3
%51 = load i32, i32* %6
%52 = add nsw i32 %51, 1
store i32 %52, i32* %6
%53 = sext i32 %51 to i64
%54 = getelementptr inbounds i8, i8* %50, i64 %53
store i8 0, i8* %54
ret void
}

LLVM IR (-O2):
define void @translate_sequence(i8* nocapture writeonly %0, i8* %1) {
%3 = alloca [4 x i8]
%4 = getelementptr inbounds [4 x i8], [4 x i8]* %3, i64 0, i64 0
%5 = call i32 @strlen(i8* %1)
%6 = icmp sgt i32 %5, 2
br i1 %6, label %7, label %31
7: ; preds = %2
%8 = getelementptr inbounds [4 x i8], [4 x i8]* %3, i64 0, i64 1
%9 = getelementptr inbounds [4 x i8], [4 x i8]* %3, i64 0, i64 2
%10 = getelementptr inbounds [4 x i8], [4 x i8]* %3, i64 0, i64 3
br label %11
11: ; preds = %7, %11
%12 = phi i64 [ 0, %7 ], [ %23, %11 ]
%13 = mul nuw nsw i64 %12, 3
%14 = getelementptr inbounds i8, i8* %1, i64 %13
%15 = load i8, i8* %14
store i8 %15, i8* %4
%16 = add nuw nsw i64 %13, 1
%17 = getelementptr inbounds i8, i8* %1, i64 %16
%18 = load i8, i8* %17
store i8 %18, i8* %8
%19 = add nuw nsw i64 %13, 2
%20 = getelementptr inbounds i8, i8* %1, i64 %19
%21 = load i8, i8* %20
store i8 %21, i8* %9
store i8 0, i8* %10
%22 = call signext i8 @translate_codon(i8* %4)
%23 = add nuw nsw i64 %12, 1
%24 = getelementptr inbounds i8, i8* %0, i64 %12
store i8 %22, i8* %24
%25 = call i32 @strlen(i8* %1)
%26 = sdiv i32 %25, 3
%27 = sext i32 %26 to i64
%28 = icmp slt i64 %23, %27
br i1 %28, label %11, label %29
29: ; preds = %11
%30 = and i64 %23, 4294967295
br label %31
31: ; preds = %29, %2
%32 = phi i64 [ 0, %2 ], [ %30, %29 ]
%33 = getelementptr inbounds i8, i8* %0, i64 %32
store i8 0, i8* %33
ret void
}