#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 /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, char *, ...);
int strlen(char *);
int /*<<< orphan*/ strncpy(char *, char *, int);
void WriteSimpleFASTA(FILE *fp, char *seq, char *name, char *desc) {
  char buf[61];
  int len;
  int pos;
  len = strlen(seq);
  buf[60] = '\0';
  fprintf(fp, ">%s %s\n", name, desc != NULL ? desc : "");
  for (pos = 0; pos < len; pos += 60) {
    strncpy(buf, seq + pos, 60);
    fprintf(fp, "%s\n", buf);
  }
}


x86 assembly (clang, -O0):
<WriteSimpleFASTA>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x64(%rbp)
movb   $0x0,-0x24(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x78(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x70(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     1183 <WriteSimpleFASTA+0x53>
mov    -0x20(%rbp),%rax
mov    %rax,-0x80(%rbp)
jmp    1193 <WriteSimpleFASTA+0x63>
lea    0xe7d(%rip),%rax
mov    %rax,-0x80(%rbp)
jmp    1193 <WriteSimpleFASTA+0x63>
mov    -0x70(%rbp),%rdx
mov    -0x78(%rbp),%rdi
mov    -0x80(%rbp),%rcx
lea    0xe5a(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
movl   $0x0,-0x68(%rbp)
mov    -0x68(%rbp),%eax
cmp    -0x64(%rbp),%eax
jge    11fd <WriteSimpleFASTA+0xcd>
lea    -0x60(%rbp),%rdi
mov    -0x10(%rbp),%rsi
movslq -0x68(%rbp),%rax
add    %rax,%rsi
mov    $0x3c,%edx
call   1030 <strncpy@plt>
mov    -0x8(%rbp),%rdi
lea    -0x60(%rbp),%rdx
lea    0xe1c(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    -0x68(%rbp),%eax
add    $0x3c,%eax
mov    %eax,-0x68(%rbp)
jmp    11b4 <WriteSimpleFASTA+0x84>
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<WriteSimpleFASTA>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x48,%rsp
mov    %rcx,%rbx
mov    %rdx,%r12
mov    %rsi,%r14
mov    %rdi,%r15
mov    %rsi,%rdi
call   1040 <strlen@plt>
mov    %eax,%r13d
movb   $0x0,0x3c(%rsp)
test   %rbx,%rbx
lea    0xea3(%rip),%rcx
cmovne %rbx,%rcx
lea    0xe91(%rip),%rsi
mov    %r15,%rdi
mov    %r12,%rdx
xor    %eax,%eax
call   1050 <fprintf@plt>
test   %r13d,%r13d
jle    11ba <WriteSimpleFASTA+0x8a>
mov    %rsp,%rbx
lea    0xe79(%rip),%r12
xor    %ebp,%ebp
nopl   (%rax)
lea    (%r14,%rbp,1),%rsi
mov    %rbx,%rdi
mov    $0x3c,%edx
call   1030 <strncpy@plt>
mov    %r15,%rdi
mov    %r12,%rsi
mov    %rbx,%rdx
xor    %eax,%eax
call   1050 <fprintf@plt>
add    $0x3c,%rbp
cmp    %ebp,%r13d
jg     1190 <WriteSimpleFASTA+0x60>
add    $0x48,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [8 x i8] c">%s %s\0A\00"
@.str.1 = [1 x i8] zeroinitializer
@.str.2 = [4 x i8] c"%s\0A\00"
define void @WriteSimpleFASTA(i32* %0, i8* %1, i8* %2, i8* %3) {
%5 = alloca i32*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca [61 x i8]
%10 = alloca i32
%11 = alloca i32
store i32* %0, i32** %5
store i8* %1, i8** %6
store i8* %2, i8** %7
store i8* %3, i8** %8
%12 = load i8*, i8** %6
%13 = call i32 @strlen(i8* %12)
store i32 %13, i32* %10
%14 = getelementptr inbounds [61 x i8], [61 x i8]* %9, i64 0, i64 60
store i8 0, i8* %14
%15 = load i32*, i32** %5
%16 = load i8*, i8** %7
%17 = load i8*, i8** %8
%18 = icmp ne i8* %17, null
br i1 %18, label %19, label %21
19: ; preds = %4
%20 = load i8*, i8** %8
br label %22
21: ; preds = %4
br label %22
22: ; preds = %21, %19
%23 = phi i8* [ %20, %19 ], [ getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0), %21 ]
%24 = call i32 (i32*, i8*, i8*, ...) @fprintf(i32* %15, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* %16, i8* %23)
store i32 0, i32* %11
br label %25
25: ; preds = %39, %22
%26 = load i32, i32* %11
%27 = load i32, i32* %10
%28 = icmp slt i32 %26, %27
br i1 %28, label %29, label %42
29: ; preds = %25
%30 = getelementptr inbounds [61 x i8], [61 x i8]* %9, i64 0, i64 0
%31 = load i8*, i8** %6
%32 = load i32, i32* %11
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds i8, i8* %31, i64 %33
%35 = call i32 @strncpy(i8* %30, i8* %34, i32 60)
%36 = load i32*, i32** %5
%37 = getelementptr inbounds [61 x i8], [61 x i8]* %9, i64 0, i64 0
%38 = call i32 (i32*, i8*, i8*, ...) @fprintf(i32* %36, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %37)
br label %39
39: ; preds = %29
%40 = load i32, i32* %11
%41 = add nsw i32 %40, 60
store i32 %41, i32* %11
br label %25
42: ; preds = %25
ret void
}

LLVM IR (-O2):
@.str = [8 x i8] c">%s %s\0A\00"
@.str.1 = [1 x i8] zeroinitializer
@.str.2 = [4 x i8] c"%s\0A\00"
define void @WriteSimpleFASTA(i32* nocapture %0, i8* %1, i8* %2, i8* %3) {
%5 = alloca [61 x i8]
%6 = getelementptr inbounds [61 x i8], [61 x i8]* %5, i64 0, i64 0
%7 = tail call i32 @strlen(i8* %1)
%8 = getelementptr inbounds [61 x i8], [61 x i8]* %5, i64 0, i64 60
store i8 0, i8* %8
%9 = icmp eq i8* %3, null
%10 = select i1 %9, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.1, i64 0, i64 0), i8* %3
%11 = tail call i32 (i32*, i8*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* %2, i8* %10)
%12 = icmp sgt i32 %7, 0
br i1 %12, label %13, label %21
13: ; preds = %4, %13
%14 = phi i64 [ %18, %13 ], [ 0, %4 ]
%15 = getelementptr inbounds i8, i8* %1, i64 %14
%16 = call i32 @strncpy(i8* %6, i8* %15, i32 60)
%17 = call i32 (i32*, i8*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %6)
%18 = add nuw i64 %14, 60
%19 = trunc i64 %18 to i32
%20 = icmp sgt i32 %7, %19
br i1 %20, label %13, label %21
21: ; preds = %13, %4
ret void
}