#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 */
char *alloca(size_t);
int /*<<< orphan*/ memcpy(char *, char const *, int);
size_t strlen(char const *);
void repeat_fasta(char const *s, size_t count) {
  size_t pos = 0;
  size_t len = strlen(s);
  char *s2 = alloca(len + 60);
  memcpy(s2, s, len);
  memcpy(s2 + len, s, 60);
  do {
    size_t line = ((60) <= (count) ? (60) : (count));
    pos += line;
    if (pos >= len)
      pos -= len;
    count -= line;
  } while (count);
}


x86 assembly (clang, -O0):
<repeat_fasta>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
add    $0x3c,%rdi
call   1040 <alloca@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    -0x20(%rbp),%rax
mov    %eax,%edx
call   1050 <memcpy@plt>
mov    -0x28(%rbp),%rdi
add    -0x20(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    $0x3c,%edx
call   1050 <memcpy@plt>
mov    $0x3c,%eax
cmp    -0x10(%rbp),%rax
ja     11ac <repeat_fasta+0x7c>
mov    $0x3c,%eax
mov    %rax,-0x38(%rbp)
jmp    11b4 <repeat_fasta+0x84>
mov    -0x10(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
add    -0x18(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
cmp    -0x20(%rbp),%rax
jb     11e5 <repeat_fasta+0xb5>
mov    -0x20(%rbp),%rcx
mov    -0x18(%rbp),%rax
sub    %rcx,%rax
mov    %rax,-0x18(%rbp)
mov    -0x30(%rbp),%rcx
mov    -0x10(%rbp),%rax
sub    %rcx,%rax
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    118f <repeat_fasta+0x5f>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<repeat_fasta>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%r14
call   1030 <strlen@plt>
mov    %rax,%r15
lea    0x3c(%rax),%rdi
call   1040 <alloca@plt>
mov    %rax,%rbx
mov    %rax,%rdi
mov    %r14,%rsi
mov    %r15d,%edx
call   1050 <memcpy@plt>
add    %r15,%rbx
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x3c,%edx
pop    %rbx
pop    %r14
pop    %r15
jmp    1050 <memcpy@plt>

LLVM IR (-O0):
define void @repeat_fasta(i8* %0, i64 %1) {
%3 = alloca i8*
%4 = alloca i64
%5 = alloca i64
%6 = alloca i64
%7 = alloca i8*
%8 = alloca i64
store i8* %0, i8** %3
store i64 %1, i64* %4
store i64 0, i64* %5
%9 = load i8*, i8** %3
%10 = call i64 @strlen(i8* %9)
store i64 %10, i64* %6
%11 = load i64, i64* %6
%12 = add i64 %11, 60
%13 = call i8* @alloca(i64 %12)
store i8* %13, i8** %7
%14 = load i8*, i8** %7
%15 = load i8*, i8** %3
%16 = load i64, i64* %6
%17 = trunc i64 %16 to i32
%18 = call i32 @memcpy(i8* %14, i8* %15, i32 %17)
%19 = load i8*, i8** %7
%20 = load i64, i64* %6
%21 = getelementptr inbounds i8, i8* %19, i64 %20
%22 = load i8*, i8** %3
%23 = call i32 @memcpy(i8* %21, i8* %22, i32 60)
br label %24
24: ; preds = %46, %2
%25 = load i64, i64* %4
%26 = icmp ule i64 60, %25
br i1 %26, label %27, label %28
27: ; preds = %24
br label %30
28: ; preds = %24
%29 = load i64, i64* %4
br label %30
30: ; preds = %28, %27
%31 = phi i64 [ 60, %27 ], [ %29, %28 ]
store i64 %31, i64* %8
%32 = load i64, i64* %8
%33 = load i64, i64* %5
%34 = add i64 %33, %32
store i64 %34, i64* %5
%35 = load i64, i64* %5
%36 = load i64, i64* %6
%37 = icmp uge i64 %35, %36
br i1 %37, label %38, label %42
38: ; preds = %30
%39 = load i64, i64* %6
%40 = load i64, i64* %5
%41 = sub i64 %40, %39
store i64 %41, i64* %5
br label %42
42: ; preds = %38, %30
%43 = load i64, i64* %8
%44 = load i64, i64* %4
%45 = sub i64 %44, %43
store i64 %45, i64* %4
br label %46
46: ; preds = %42
%47 = load i64, i64* %4
%48 = icmp ne i64 %47, 0
br i1 %48, label %24, label %49
49: ; preds = %46
ret void
}

LLVM IR (-O2):
define void @repeat_fasta(i8* %0, i64 %1) {
%3 = tail call i64 @strlen(i8* dereferenceable(1) %0)
%4 = add i64 %3, 60
%5 = tail call i8* @alloca(i64 %4)
%6 = trunc i64 %3 to i32
%7 = tail call i32 @memcpy(i8* %5, i8* %0, i32 %6)
%8 = getelementptr inbounds i8, i8* %5, i64 %3
%9 = tail call i32 @memcpy(i8* %8, i8* %0, i32 60)
ret void
}