#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 /*<<< orphan*/ printf(char *, char *);
int strlen(char *);
void fasta_print_cons(char *cons, char *id) {
  int len, i, line_pos;
  char curr_line[(60) + 1];
  len = strlen(cons);
  printf(">%s\n", id);
  line_pos = 0;
  for (i = 0; i < len; i++) {
    if (!(cons[i] == '-')) {
      if (cons[i] == ' ') {
        curr_line[line_pos++] = 'X';
      } else {
        curr_line[line_pos++] = cons[i];
      }
      if (line_pos == (60)) {
        curr_line[line_pos] = '\0';
        printf("%s\n", curr_line);
        line_pos = 0;
      }
    }
  }
  curr_line[line_pos] = '\0';
  printf("%s\n", curr_line);
}


x86 assembly (clang, -O0):
<fasta_print_cons>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rsi
lea    0xeb9(%rip),%rdi
call   1040 <printf@plt>
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1205 <fasta_print_cons+0xe5>
mov    -0x8(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x2d,%eax
je     11f2 <fasta_print_cons+0xd2>
mov    -0x8(%rbp),%rax
movslq -0x18(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x20,%eax
jne    11a7 <fasta_print_cons+0x87>
mov    -0x1c(%rbp),%eax
mov    %eax,%ecx
add    $0x1,%ecx
mov    %ecx,-0x1c(%rbp)
cltq
movb   $0x58,-0x60(%rbp,%rax,1)
jmp    11c3 <fasta_print_cons+0xa3>
mov    -0x8(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,1),%cl
mov    -0x1c(%rbp),%eax
mov    %eax,%edx
add    $0x1,%edx
mov    %edx,-0x1c(%rbp)
cltq
mov    %cl,-0x60(%rbp,%rax,1)
cmpl   $0x3c,-0x1c(%rbp)
jne    11ed <fasta_print_cons+0xcd>
movslq -0x1c(%rbp),%rax
movb   $0x0,-0x60(%rbp,%rax,1)
lea    -0x60(%rbp),%rsi
lea    0xe20(%rip),%rdi
call   1040 <printf@plt>
movl   $0x0,-0x1c(%rbp)
jmp    11f2 <fasta_print_cons+0xd2>
jmp    11f7 <fasta_print_cons+0xd7>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    115a <fasta_print_cons+0x3a>
movslq -0x1c(%rbp),%rax
movb   $0x0,-0x60(%rbp,%rax,1)
lea    -0x60(%rbp),%rsi
lea    0xde8(%rip),%rdi
call   1040 <printf@plt>
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fasta_print_cons>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x40,%rsp
mov    %rsi,%r14
mov    %rdi,%r12
call   1030 <strlen@plt>
mov    %eax,%ebp
lea    0xec0(%rip),%rdi
mov    %r14,%rsi
call   1040 <printf@plt>
test   %ebp,%ebp
jle    11a3 <fasta_print_cons+0x83>
mov    %ebp,%ebp
xor    %ebx,%ebx
lea    0xeaa(%rip),%r14
mov    %rsp,%r15
xor    %eax,%eax
jmp    1169 <fasta_print_cons+0x49>
xchg   %ax,%ax
add    $0x1,%rbx
cmp    %rbx,%rbp
je     11a5 <fasta_print_cons+0x85>
movzbl (%r12,%rbx,1),%ecx
cmp    $0x20,%cl
je     1180 <fasta_print_cons+0x60>
cmp    $0x2d,%cl
je     1160 <fasta_print_cons+0x40>
jmp    1182 <fasta_print_cons+0x62>
nopw   0x0(%rax,%rax,1)
mov    $0x58,%cl
cltq
mov    %cl,(%rsp,%rax,1)
add    $0x1,%eax
cmp    $0x3c,%eax
jne    1160 <fasta_print_cons+0x40>
movb   $0x0,0x3c(%rsp)
mov    %r14,%rdi
mov    %r15,%rsi
call   1040 <printf@plt>
xor    %eax,%eax
jmp    1160 <fasta_print_cons+0x40>
xor    %eax,%eax
cltq
movb   $0x0,(%rsp,%rax,1)
lea    0xe4f(%rip),%rdi
mov    %rsp,%rsi
call   1040 <printf@plt>
add    $0x40,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [5 x i8] c">%s\0A\00"
@.str.1 = [4 x i8] c"%s\0A\00"
define void @fasta_print_cons(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca [61 x i8]
store i8* %0, i8** %3
store i8* %1, i8** %4
%9 = load i8*, i8** %3
%10 = call i32 @strlen(i8* %9)
store i32 %10, i32* %5
%11 = load i8*, i8** %4
%12 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %11)
store i32 0, i32* %7
store i32 0, i32* %6
br label %13
13: ; preds = %59, %2
%14 = load i32, i32* %6
%15 = load i32, i32* %5
%16 = icmp slt i32 %14, %15
br i1 %16, label %17, label %62
17: ; preds = %13
%18 = load i8*, i8** %3
%19 = load i32, i32* %6
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds i8, i8* %18, i64 %20
%22 = load i8, i8* %21
%23 = sext i8 %22 to i32
%24 = icmp eq i32 %23, 45
br i1 %24, label %58, label %25
25: ; preds = %17
%26 = load i8*, i8** %3
%27 = load i32, i32* %6
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds i8, i8* %26, i64 %28
%30 = load i8, i8* %29
%31 = sext i8 %30 to i32
%32 = icmp eq i32 %31, 32
br i1 %32, label %33, label %38
33: ; preds = %25
%34 = load i32, i32* %7
%35 = add nsw i32 %34, 1
store i32 %35, i32* %7
%36 = sext i32 %34 to i64
%37 = getelementptr inbounds [61 x i8], [61 x i8]* %8, i64 0, i64 %36
store i8 88, i8* %37
br label %48
38: ; preds = %25
%39 = load i8*, i8** %3
%40 = load i32, i32* %6
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds i8, i8* %39, i64 %41
%43 = load i8, i8* %42
%44 = load i32, i32* %7
%45 = add nsw i32 %44, 1
store i32 %45, i32* %7
%46 = sext i32 %44 to i64
%47 = getelementptr inbounds [61 x i8], [61 x i8]* %8, i64 0, i64 %46
store i8 %43, i8* %47
br label %48
48: ; preds = %38, %33
%49 = load i32, i32* %7
%50 = icmp eq i32 %49, 60
br i1 %50, label %51, label %57
51: ; preds = %48
%52 = load i32, i32* %7
%53 = sext i32 %52 to i64
%54 = getelementptr inbounds [61 x i8], [61 x i8]* %8, i64 0, i64 %53
store i8 0, i8* %54
%55 = getelementptr inbounds [61 x i8], [61 x i8]* %8, i64 0, i64 0
%56 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %55)
store i32 0, i32* %7
br label %57
57: ; preds = %51, %48
br label %58
58: ; preds = %57, %17
br label %59
59: ; preds = %58
%60 = load i32, i32* %6
%61 = add nsw i32 %60, 1
store i32 %61, i32* %6
br label %13
62: ; preds = %13
%63 = load i32, i32* %7
%64 = sext i32 %63 to i64
%65 = getelementptr inbounds [61 x i8], [61 x i8]* %8, i64 0, i64 %64
store i8 0, i8* %65
%66 = getelementptr inbounds [61 x i8], [61 x i8]* %8, i64 0, i64 0
%67 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %66)
ret void
}

LLVM IR (-O2):
@.str = [5 x i8] c">%s\0A\00"
@.str.1 = [4 x i8] c"%s\0A\00"
define void @fasta_print_cons(i8* %0, i8* %1) {
%3 = alloca [61 x i8]
%4 = getelementptr inbounds [61 x i8], [61 x i8]* %3, i64 0, i64 0
%5 = tail call i32 @strlen(i8* %0)
%6 = tail call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %1)
%7 = icmp sgt i32 %5, 0
br i1 %7, label %8, label %29
8: ; preds = %2
%9 = getelementptr inbounds [61 x i8], [61 x i8]* %3, i64 0, i64 60
%10 = zext i32 %5 to i64
br label %11
11: ; preds = %8, %25
%12 = phi i64 [ 0, %8 ], [ %27, %25 ]
%13 = phi i32 [ 0, %8 ], [ %26, %25 ]
%14 = getelementptr inbounds i8, i8* %0, i64 %12
%15 = load i8, i8* %14
switch i8 %15, label %16 [
i8 45, label %25
i8 32, label %17
]
16: ; preds = %11
br label %17
17: ; preds = %11, %16
%18 = phi i8 [ %15, %16 ], [ 88, %11 ]
%19 = sext i32 %13 to i64
%20 = getelementptr inbounds [61 x i8], [61 x i8]* %3, i64 0, i64 %19
store i8 %18, i8* %20
%21 = add nsw i32 %13, 1
%22 = icmp eq i32 %21, 60
br i1 %22, label %23, label %25
23: ; preds = %17
store i8 0, i8* %9
%24 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %4)
br label %25
25: ; preds = %11, %23, %17
%26 = phi i32 [ %13, %11 ], [ 0, %23 ], [ %21, %17 ]
%27 = add nuw nsw i64 %12, 1
%28 = icmp eq i64 %27, %10
br i1 %28, label %29, label %11
29: ; preds = %25, %2
%30 = phi i32 [ 0, %2 ], [ %26, %25 ]
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds [61 x i8], [61 x i8]* %3, i64 0, i64 %31
store i8 0, i8* %32
%33 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %4)
ret void
}