#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*/ fwrite_unlocked(char *, size_t, int, int /*<<< orphan*/);
int /*<<< orphan*/ memcpy(char *, char const *, size_t const);
int /*<<< orphan*/ putchar_unlocked(char);
int /*<<< orphan*/ stdout;
size_t strlen(char const *);
void repeat_fasta(const char *alu, size_t n) {
  const size_t alulen = strlen(alu);
  char buf[alulen + 60];
  size_t pos = 0, bytes;
  memcpy(buf, alu, alulen);
  memcpy(buf + alulen, alu, 60);
  while (n) {
    bytes = ((60 < n) ? 60 : n);
    fwrite_unlocked(buf + pos, bytes, 1, stdout);
    putchar_unlocked('\n');
    pos += bytes;
    if (pos > alulen)
      pos -= alulen;
    n -= bytes;
  }
}


x86 assembly (clang, -O0):
<repeat_fasta>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rcx
mov    %rcx,%rax
add    $0x3c,%rax
mov    %rsp,%rdx
mov    %rdx,-0x20(%rbp)
add    $0x4b,%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%rdi
sub    %rcx,%rdi
mov    %rdi,-0x40(%rbp)
mov    %rdi,%rsp
mov    %rax,-0x28(%rbp)
movq   $0x0,-0x30(%rbp)
mov    -0x8(%rbp),%rsi
mov    -0x18(%rbp),%rdx
call   1040 <memcpy@plt>
mov    -0x40(%rbp),%rdi
add    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    $0x3c,%edx
call   1040 <memcpy@plt>
cmpq   $0x0,-0x10(%rbp)
je     1251 <repeat_fasta+0x111>
mov    $0x3c,%eax
cmp    -0x10(%rbp),%rax
jae    11db <repeat_fasta+0x9b>
mov    $0x3c,%eax
mov    %rax,-0x48(%rbp)
jmp    11e3 <repeat_fasta+0xa3>
mov    -0x10(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    -0x40(%rbp),%rdi
mov    -0x48(%rbp),%rax
mov    %rax,-0x38(%rbp)
add    -0x30(%rbp),%rdi
mov    -0x38(%rbp),%rsi
mov    0x2de2(%rip),%rax
mov    (%rax),%ecx
mov    $0x1,%edx
call   1060 <fwrite_unlocked@plt>
mov    $0xa,%edi
call   1050 <putchar_unlocked@plt>
mov    -0x38(%rbp),%rax
add    -0x30(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rax
cmp    -0x18(%rbp),%rax
jbe    123d <repeat_fasta+0xfd>
mov    -0x18(%rbp),%rcx
mov    -0x30(%rbp),%rax
sub    %rcx,%rax
mov    %rax,-0x30(%rbp)
mov    -0x38(%rbp),%rcx
mov    -0x10(%rbp),%rax
sub    %rcx,%rax
mov    %rax,-0x10(%rbp)
jmp    11b3 <repeat_fasta+0x73>
mov    -0x20(%rbp),%rax
mov    %rax,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<repeat_fasta>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r13
mov    %rdi,%r12
call   1030 <strlen@plt>
mov    %rax,%r14
mov    %rsp,%r15
add    $0x4b,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r15
mov    %r15,%rsp
mov    %r15,%rdi
mov    %r12,%rsi
mov    %r14,%rdx
call   1040 <memcpy@plt>
lea    (%r15,%r14,1),%rdi
mov    $0x3c,%edx
mov    %r12,%rsi
call   1040 <memcpy@plt>
test   %r13,%r13
je     11e9 <repeat_fasta+0xa9>
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
cmp    $0x3c,%r13
mov    $0x3c,%r12d
cmovb  %r13,%r12
lea    (%r15,%rbx,1),%rdi
mov    0x2e27(%rip),%rax
mov    (%rax),%ecx
mov    %r12,%rsi
mov    $0x1,%edx
call   1060 <fwrite_unlocked@plt>
mov    $0xa,%edi
call   1050 <putchar_unlocked@plt>
add    %r12,%rbx
cmp    %r14,%rbx
mov    $0x0,%eax
cmova  %r14,%rax
sub    %rax,%rbx
sub    %r12,%r13
jne    11a0 <repeat_fasta+0x60>
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@stdout = global i32 0
define void @repeat_fasta(i8* %0, i64 %1) {
%3 = tail call i64 @strlen(i8* dereferenceable(1) %0)
%4 = add i64 %3, 60
%5 = alloca i8, i64 %4
%6 = call i32 @memcpy(i8* %5, i8* %0, i64 %3)
%7 = getelementptr inbounds i8, i8* %5, i64 %3
%8 = call i32 @memcpy(i8* %7, i8* %0, i64 60)
%9 = icmp eq i64 %1, 0
br i1 %9, label %25, label %10
10: ; preds = %2, %10
%11 = phi i64 [ %23, %10 ], [ %1, %2 ]
%12 = phi i64 [ %22, %10 ], [ 0, %2 ]
%13 = icmp ult i64 %11, 60
%14 = select i1 %13, i64 %11, i64 60
%15 = getelementptr inbounds i8, i8* %5, i64 %12
%16 = load i32, i32* @stdout
%17 = call i32 @fwrite_unlocked(i8* %15, i64 %14, i32 1, i32 %16)
%18 = call i32 @putchar_unlocked(i8 signext 10)
%19 = add i64 %14, %12
%20 = icmp ugt i64 %19, %3
%21 = select i1 %20, i64 %3, i64 0
%22 = sub i64 %19, %21
%23 = sub i64 %11, %14
%24 = icmp eq i64 %23, 0
br i1 %24, label %25, label %10
25: ; preds = %10, %2
ret void
}