#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 */
struct aminoacid {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ fwrite_unlocked(char *, size_t, int, int /*<<< orphan*/);
char nextc();
int /*<<< orphan*/ stdout;
void random_fasta(struct aminoacid *table, size_t n) {
  size_t i, lines = n / 60;
  const size_t chars_left = n % 60;
  char buf[60 + 1];
  while (lines--) {
    for (i = 0; i < 60; ++i) {
      buf[i] = nextc();
    }
    buf[i] = '\n';
    fwrite_unlocked(buf, i + 1, 1, stdout);
  }
  for (i = 0; i < chars_left; ++i)
    buf[i] = nextc();
  fwrite_unlocked(buf, i, 1, stdout);
}


x86 assembly (clang, -O0):
<random_fasta>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    $0x3c,%ecx
xor    %edx,%edx
div    %rcx
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    $0x3c,%ecx
xor    %edx,%edx
div    %rcx
mov    %rdx,-0x28(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,%rcx
add    $0xffffffffffffffff,%rcx
mov    %rcx,-0x20(%rbp)
cmp    $0x0,%rax
je     11cf <random_fasta+0xaf>
movq   $0x0,-0x18(%rbp)
cmpq   $0x3c,-0x18(%rbp)
jae    11a2 <random_fasta+0x82>
mov    $0x0,%al
call   1030 <nextc@plt>
mov    %al,%cl
mov    -0x18(%rbp),%rax
mov    %cl,-0x70(%rbp,%rax,1)
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    1175 <random_fasta+0x55>
mov    -0x18(%rbp),%rax
movb   $0xa,-0x70(%rbp,%rax,1)
lea    -0x70(%rbp),%rdi
mov    -0x18(%rbp),%rsi
add    $0x1,%rsi
mov    0x2e22(%rip),%rax
mov    (%rax),%ecx
mov    $0x1,%edx
call   1040 <fwrite_unlocked@plt>
jmp    1154 <random_fasta+0x34>
movq   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%rax
cmp    -0x28(%rbp),%rax
jae    1207 <random_fasta+0xe7>
mov    $0x0,%al
call   1030 <nextc@plt>
mov    %al,%cl
mov    -0x18(%rbp),%rax
mov    %cl,-0x70(%rbp,%rax,1)
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    11d7 <random_fasta+0xb7>
lea    -0x70(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    0x2dca(%rip),%rax
mov    (%rax),%ecx
mov    $0x1,%edx
call   1040 <fwrite_unlocked@plt>
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<random_fasta>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x40,%rsp
movabs $0x8888888888888889,%rcx
88 88 88
mov    %rsi,%rax
mul    %rcx
mov    %rdx,%r13
shr    $0x5,%r13
imul   $0x3c,%r13,%rax
mov    %rsi,%r14
sub    %rax,%r14
cmp    $0x3c,%rsi
jb     11a5 <random_fasta+0x85>
mov    0x2e85(%rip),%r12
mov    %rsp,%r15
xchg   %ax,%ax
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
xor    %eax,%eax
call   1030 <nextc@plt>
mov    %al,(%rsp,%rbx,1)
add    $0x1,%rbx
cmp    $0x3c,%rbx
jne    1170 <random_fasta+0x50>
movb   $0xa,0x3c(%rsp)
mov    (%r12),%ecx
mov    $0x3d,%esi
mov    %r15,%rdi
mov    $0x1,%edx
call   1040 <fwrite_unlocked@plt>
add    $0xffffffffffffffff,%r13
jne    1160 <random_fasta+0x40>
test   %r14,%r14
je     11c3 <random_fasta+0xa3>
xor    %ebx,%ebx
nopl   0x0(%rax)
xor    %eax,%eax
call   1030 <nextc@plt>
mov    %al,(%rsp,%rbx,1)
add    $0x1,%rbx
cmp    %rbx,%r14
jne    11b0 <random_fasta+0x90>
mov    0x2e16(%rip),%rax
mov    (%rax),%ecx
mov    %rsp,%rdi
mov    %r14,%rsi
mov    $0x1,%edx
call   1040 <fwrite_unlocked@plt>
add    $0x40,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
%struct.aminoacid = type { i32 }
@stdout = global i32 0
define void @random_fasta(%struct.aminoacid* nocapture readnone %0, i64 %1) {
%3 = alloca [61 x i8]
%4 = urem i64 %1, 60
%5 = udiv i64 %1, 60
%6 = getelementptr inbounds [61 x i8], [61 x i8]* %3, i64 0, i64 0
%7 = icmp ult i64 %1, 60
br i1 %7, label %12, label %8
8: ; preds = %2
%9 = getelementptr inbounds [61 x i8], [61 x i8]* %3, i64 0, i64 60
br label %10
10: ; preds = %8, %20
%11 = phi i64 [ %21, %20 ], [ %5, %8 ]
br label %14
12: ; preds = %20, %2
%13 = icmp eq i64 %4, 0
br i1 %13, label %31, label %25
14: ; preds = %10, %14
%15 = phi i64 [ 0, %10 ], [ %18, %14 ]
%16 = call signext i8 (...) @nextc()
%17 = getelementptr inbounds [61 x i8], [61 x i8]* %3, i64 0, i64 %15
store i8 %16, i8* %17
%18 = add nuw nsw i64 %15, 1
%19 = icmp eq i64 %18, 60
br i1 %19, label %20, label %14
20: ; preds = %14
%21 = add nsw i64 %11, -1
store i8 10, i8* %9
%22 = load i32, i32* @stdout
%23 = call i32 @fwrite_unlocked(i8* %6, i64 61, i32 1, i32 %22)
%24 = icmp eq i64 %21, 0
br i1 %24, label %12, label %10
25: ; preds = %12, %25
%26 = phi i64 [ %29, %25 ], [ 0, %12 ]
%27 = call signext i8 (...) @nextc()
%28 = getelementptr inbounds [61 x i8], [61 x i8]* %3, i64 0, i64 %26
store i8 %27, i8* %28
%29 = add nuw i64 %26, 1
%30 = icmp eq i64 %29, %4
br i1 %30, label %31, label %25
31: ; preds = %25, %12
%32 = load i32, i32* @stdout
%33 = call i32 @fwrite_unlocked(i8* %6, i64 %4, i32 1, i32 %32)
ret void
}