#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*/ free(char *);
scalar_t__ malloc(int);
int /*<<< orphan*/ memcpy(char *, char const *, int);
int /*<<< orphan*/ printf(char *, char const *, ...);
int /*<<< orphan*/ puts(char *);
int strlen(char const *);
void makeRepeatFasta(const char *id, const char *desc, const char *s, int n) {
  char *ss;
  int todo = n, k = 0, kn = strlen(s);
  int m;
  ss = (char *)malloc(kn + 1);
  memcpy(ss, s, kn + 1);
  printf(">%s %s\n", id, desc);
  for (; todo > 0; todo -= (60)) {
    if (todo < (60))
      m = todo;
    else
      m = (60);
    while (m >= kn - k) {
      printf("%s", s + k);
      m -= kn - k;
      k = 0;
    }
    ss[k + m] = '\0';
    puts(ss + k);
    ss[k + m] = s[m + k];
    k += m;
  }
  free(ss);
}


x86 assembly (clang, -O0):
<makeRepeatFasta>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,-0x2c(%rbp)
movl   $0x0,-0x30(%rbp)
mov    -0x18(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,-0x34(%rbp)
mov    -0x34(%rbp),%edi
add    $0x1,%edi
call   1080 <malloc@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x34(%rbp),%edx
add    $0x1,%edx
call   1070 <memcpy@plt>
mov    -0x8(%rbp),%rsi
mov    -0x10(%rbp),%rdx
lea    0xe3f(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
cmpl   $0x0,-0x2c(%rbp)
jle    128f <makeRepeatFasta+0x12f>
cmpl   $0x3c,-0x2c(%rbp)
jge    11e7 <makeRepeatFasta+0x87>
mov    -0x2c(%rbp),%eax
mov    %eax,-0x38(%rbp)
jmp    11ee <makeRepeatFasta+0x8e>
movl   $0x3c,-0x38(%rbp)
jmp    11f3 <makeRepeatFasta+0x93>
mov    -0x38(%rbp),%eax
mov    -0x34(%rbp),%ecx
sub    -0x30(%rbp),%ecx
cmp    %ecx,%eax
jl     1237 <makeRepeatFasta+0xd7>
mov    -0x18(%rbp),%rsi
movslq -0x30(%rbp),%rax
add    %rax,%rsi
lea    0xdf2(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x34(%rbp),%ecx
sub    -0x30(%rbp),%ecx
mov    -0x38(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0x38(%rbp)
movl   $0x0,-0x30(%rbp)
jmp    11f3 <makeRepeatFasta+0x93>
mov    -0x28(%rbp),%rax
mov    -0x30(%rbp),%ecx
add    -0x38(%rbp),%ecx
movslq %ecx,%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x28(%rbp),%rdi
movslq -0x30(%rbp),%rax
add    %rax,%rdi
call   1040 <puts@plt>
mov    -0x18(%rbp),%rax
mov    -0x38(%rbp),%ecx
add    -0x30(%rbp),%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,1),%dl
mov    -0x28(%rbp),%rax
mov    -0x30(%rbp),%ecx
add    -0x38(%rbp),%ecx
movslq %ecx,%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x38(%rbp),%eax
add    -0x30(%rbp),%eax
mov    %eax,-0x30(%rbp)
mov    -0x2c(%rbp),%eax
sub    $0x3c,%eax
mov    %eax,-0x2c(%rbp)
jmp    11c8 <makeRepeatFasta+0x68>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<makeRepeatFasta>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %ecx,%r12d
mov    %rdx,%rbp
mov    %rsi,%r13
mov    %rdi,%rbx
mov    %rdx,%rdi
call   1050 <strlen@plt>
mov    %eax,%r14d
lea    0x1(%r14),%r15d
mov    %r15d,%edi
call   1080 <malloc@plt>
mov    %rax,0x8(%rsp)
mov    %rax,%rdi
mov    %rbp,0x10(%rsp)
mov    %rbp,%rsi
mov    %r15d,%edx
call   1070 <memcpy@plt>
lea    0xe50(%rip),%rdi
xor    %r15d,%r15d
mov    %rbx,%rsi
mov    %r13,%rdx
xor    %eax,%eax
call   1060 <printf@plt>
test   %r12d,%r12d
jle    127d <makeRepeatFasta+0x11d>
lea    0xe38(%rip),%rbx
jmp    1218 <makeRepeatFasta+0xb8>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %eax,%r13d
add    %r15d,%r13d
movslq %r13d,%rbp
mov    0x8(%rsp),%r12
movb   $0x0,(%r12,%rbp,1)
movslq %r15d,%rdi
add    %r12,%rdi
call   1040 <puts@plt>
mov    0x10(%rsp),%rax
mov    (%rax,%rbp,1),%al
mov    %al,(%r12,%rbp,1)
mov    %r13d,%r15d
cmpl   $0x3c,(%rsp)
mov    0x4(%rsp),%r12d
jle    127d <makeRepeatFasta+0x11d>
mov    %r12d,%edx
sub    $0x3c,%r12d
mov    $0x3c,%eax
cmovb  %edx,%eax
mov    %r14d,%ecx
sub    %r15d,%ecx
mov    %eax,%r13d
sub    %ecx,%r13d
mov    %r12d,0x4(%rsp)
mov    %edx,(%rsp)
jl     11e0 <makeRepeatFasta+0x80>
movslq %r15d,%rsi
mov    0x10(%rsp),%rbp
add    %rbp,%rsi
xor    %r15d,%r15d
mov    %rbx,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
cmp    %r14d,%r13d
jl     11e3 <makeRepeatFasta+0x83>
nopw   0x0(%rax,%rax,1)
xor    %r15d,%r15d
mov    %rbx,%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
sub    %r14d,%r13d
cmp    %r14d,%r13d
jge    1260 <makeRepeatFasta+0x100>
jmp    11e3 <makeRepeatFasta+0x83>
mov    0x8(%rsp),%rdi
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <free@plt>

LLVM IR (-O0):
@.str = [8 x i8] c">%s %s\0A\00"
@.str.1 = [3 x i8] c"%s\00"
define void @makeRepeatFasta(i8* %0, i8* %1, i8* %2, i32 %3) {
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i8*
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
store i8* %0, i8** %5
store i8* %1, i8** %6
store i8* %2, i8** %7
store i32 %3, i32* %8
%14 = load i32, i32* %8
store i32 %14, i32* %10
store i32 0, i32* %11
%15 = load i8*, i8** %7
%16 = call i32 @strlen(i8* %15)
store i32 %16, i32* %12
%17 = load i32, i32* %12
%18 = add nsw i32 %17, 1
%19 = call i64 @malloc(i32 %18)
%20 = inttoptr i64 %19 to i8*
store i8* %20, i8** %9
%21 = load i8*, i8** %9
%22 = load i8*, i8** %7
%23 = load i32, i32* %12
%24 = add nsw i32 %23, 1
%25 = call i32 @memcpy(i8* %21, i8* %22, i32 %24)
%26 = load i8*, i8** %5
%27 = load i8*, i8** %6
%28 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* %26, i8* %27)
br label %29
29: ; preds = %84, %4
%30 = load i32, i32* %10
%31 = icmp sgt i32 %30, 0
br i1 %31, label %32, label %87
32: ; preds = %29
%33 = load i32, i32* %10
%34 = icmp slt i32 %33, 60
br i1 %34, label %35, label %37
35: ; preds = %32
%36 = load i32, i32* %10
store i32 %36, i32* %13
br label %38
37: ; preds = %32
store i32 60, i32* %13
br label %38
38: ; preds = %37, %35
br label %39
39: ; preds = %45, %38
%40 = load i32, i32* %13
%41 = load i32, i32* %12
%42 = load i32, i32* %11
%43 = sub nsw i32 %41, %42
%44 = icmp sge i32 %40, %43
br i1 %44, label %45, label %56
45: ; preds = %39
%46 = load i8*, i8** %7
%47 = load i32, i32* %11
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds i8, i8* %46, i64 %48
%50 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %49)
%51 = load i32, i32* %12
%52 = load i32, i32* %11
%53 = sub nsw i32 %51, %52
%54 = load i32, i32* %13
%55 = sub nsw i32 %54, %53
store i32 %55, i32* %13
store i32 0, i32* %11
br label %39
56: ; preds = %39
%57 = load i8*, i8** %9
%58 = load i32, i32* %11
%59 = load i32, i32* %13
%60 = add nsw i32 %58, %59
%61 = sext i32 %60 to i64
%62 = getelementptr inbounds i8, i8* %57, i64 %61
store i8 0, i8* %62
%63 = load i8*, i8** %9
%64 = load i32, i32* %11
%65 = sext i32 %64 to i64
%66 = getelementptr inbounds i8, i8* %63, i64 %65
%67 = call i32 @puts(i8* %66)
%68 = load i8*, i8** %7
%69 = load i32, i32* %13
%70 = load i32, i32* %11
%71 = add nsw i32 %69, %70
%72 = sext i32 %71 to i64
%73 = getelementptr inbounds i8, i8* %68, i64 %72
%74 = load i8, i8* %73
%75 = load i8*, i8** %9
%76 = load i32, i32* %11
%77 = load i32, i32* %13
%78 = add nsw i32 %76, %77
%79 = sext i32 %78 to i64
%80 = getelementptr inbounds i8, i8* %75, i64 %79
store i8 %74, i8* %80
%81 = load i32, i32* %13
%82 = load i32, i32* %11
%83 = add nsw i32 %82, %81
store i32 %83, i32* %11
br label %84
84: ; preds = %56
%85 = load i32, i32* %10
%86 = sub nsw i32 %85, 60
store i32 %86, i32* %10
br label %29
87: ; preds = %29
%88 = load i8*, i8** %9
%89 = call i32 @free(i8* %88)
ret void
}

LLVM IR (-O2):
@.str = [8 x i8] c">%s %s\0A\00"
@.str.1 = [3 x i8] c"%s\00"
define void @makeRepeatFasta(i8* %0, i8* %1, i8* %2, i32 %3) {
%5 = tail call i32 @strlen(i8* %2)
%6 = add nsw i32 %5, 1
%7 = tail call i64 @malloc(i32 %6)
%8 = inttoptr i64 %7 to i8*
%9 = tail call i32 @memcpy(i8* %8, i8* %2, i32 %6)
%10 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* %0, i8* %1)
%11 = icmp sgt i32 %3, 0
br i1 %11, label %12, label %43
12: ; preds = %4, %30
%13 = phi i32 [ %41, %30 ], [ %3, %4 ]
%14 = phi i32 [ %33, %30 ], [ 0, %4 ]
%15 = icmp ult i32 %13, 60
%16 = select i1 %15, i32 %13, i32 60
%17 = sub nsw i32 %5, %14
%18 = icmp slt i32 %16, %17
br i1 %18, label %30, label %19
19: ; preds = %12
%20 = sext i32 %14 to i64
%21 = getelementptr inbounds i8, i8* %2, i64 %20
%22 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %21)
%23 = sub nsw i32 %16, %17
%24 = icmp slt i32 %23, %5
br i1 %24, label %30, label %25
25: ; preds = %19, %25
%26 = phi i32 [ %28, %25 ], [ %23, %19 ]
%27 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %2)
%28 = sub nsw i32 %26, %5
%29 = icmp slt i32 %28, %5
br i1 %29, label %30, label %25
30: ; preds = %25, %19, %12
%31 = phi i32 [ %14, %12 ], [ 0, %19 ], [ 0, %25 ]
%32 = phi i32 [ %16, %12 ], [ %23, %19 ], [ %28, %25 ]
%33 = add nsw i32 %32, %31
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds i8, i8* %8, i64 %34
store i8 0, i8* %35
%36 = sext i32 %31 to i64
%37 = getelementptr inbounds i8, i8* %8, i64 %36
%38 = tail call i32 @puts(i8* dereferenceable(1) %37)
%39 = getelementptr inbounds i8, i8* %2, i64 %34
%40 = load i8, i8* %39
store i8 %40, i8* %35
%41 = add nsw i32 %13, -60
%42 = icmp sgt i32 %13, 60
br i1 %42, label %12, label %43
43: ; preds = %30, %4
%44 = tail call i32 @free(i8* %8)
ret void
}