#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int AminoAsChar(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
void save_amino_seq(FILE *fp, int *seq, int length) {
  int i;
  for (i = 0; i < length; i++) {
    fprintf(fp, "%c", AminoAsChar(seq[i]));
    if (i % 60 == 59)
      fprintf(fp, "\n");
  }
}


x86 assembly (clang, -O0):
<save_amino_seq>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    11ab <save_amino_seq+0x8b>
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,4),%edi
call   1040 <AminoAsChar@plt>
mov    -0x20(%rbp),%rdi
mov    %eax,%edx
lea    0xe95(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    -0x18(%rbp),%eax
mov    $0x3c,%ecx
cltd
idiv   %ecx
cmp    $0x3b,%edx
jne    1198 <save_amino_seq+0x78>
mov    -0x8(%rbp),%rdi
lea    0xe72(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
jmp    119d <save_amino_seq+0x7d>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    113a <save_amino_seq+0x1a>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<save_amino_seq>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,(%rsp)
test   %edx,%edx
jle    119d <save_amino_seq+0x7d>
mov    %rdi,%r12
mov    %edx,%r15d
shl    $0x2,%r15
mov    $0x3b,%ebp
xor    %ebx,%ebx
xor    %r13d,%r13d
jmp    115f <save_amino_seq+0x3f>
nopl   0x0(%rax)
add    $0x4,%r13
add    $0xffffffff,%ebp
add    $0x1,%ebx
cmp    %r13,%r15
je     119d <save_amino_seq+0x7d>
mov    %ebx,%eax
mov    $0x88888889,%ecx
imul   %rcx,%rax
shr    $0x25,%rax
imul   $0x3c,%eax,%r14d
mov    (%rsp),%rax
mov    (%rax,%r13,1),%edi
call   1040 <AminoAsChar@plt>
mov    %eax,%edi
mov    %r12,%rsi
call   1030 <fputc@plt>
add    %ebp,%r14d
jne    1150 <save_amino_seq+0x30>
mov    $0xa,%edi
mov    %r12,%rsi
call   1030 <fputc@plt>
jmp    1150 <save_amino_seq+0x30>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%c\00"
@.str.1 = [2 x i8] c"\0A\00"
define void @save_amino_seq(i32* %0, i32* %1, i32 %2) {
%4 = alloca i32*
%5 = alloca i32*
%6 = alloca i32
%7 = alloca i32
store i32* %0, i32** %4
store i32* %1, i32** %5
store i32 %2, i32* %6
store i32 0, i32* %7
br label %8
8: ; preds = %28, %3
%9 = load i32, i32* %7
%10 = load i32, i32* %6
%11 = icmp slt i32 %9, %10
br i1 %11, label %12, label %31
12: ; preds = %8
%13 = load i32*, i32** %4
%14 = load i32*, i32** %5
%15 = load i32, i32* %7
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds i32, i32* %14, i64 %16
%18 = load i32, i32* %17
%19 = call i32 @AminoAsChar(i32 %18)
%20 = call i32 (i32*, i8*, ...) @fprintf(i32* %13, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %19)
%21 = load i32, i32* %7
%22 = srem i32 %21, 60
%23 = icmp eq i32 %22, 59
br i1 %23, label %24, label %27
24: ; preds = %12
%25 = load i32*, i32** %4
%26 = call i32 (i32*, i8*, ...) @fprintf(i32* %25, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %27
27: ; preds = %24, %12
br label %28
28: ; preds = %27
%29 = load i32, i32* %7
%30 = add nsw i32 %29, 1
store i32 %30, i32* %7
br label %8
31: ; preds = %8
ret void
}

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