#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 */
typedef int uint64_t;

/* Variables and functions */
char *bfc_kmer_2str(int k, const uint64_t y[2], char *buf) {
  int l;
  for (l = 0; l < k; ++l)
    buf[k - 1 - l] = "ACGT"[(y[1] >> l & 1) << 1 | (y[0] >> l & 1)];
  buf[k] = 0;
  return buf;
}


x86 assembly (clang, -O0):
<bfc_kmer_2str>:
push   %rbp
mov    %rsp,%rbp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    1174 <bfc_kmer_2str+0x74>
mov    -0x10(%rbp),%rax
mov    0x4(%rax),%eax
mov    -0x1c(%rbp),%ecx
sar    %cl,%eax
and    $0x1,%eax
shl    $0x1,%eax
mov    -0x10(%rbp),%rcx
mov    (%rcx),%edx
mov    -0x1c(%rbp),%ecx
sar    %cl,%edx
mov    %edx,%ecx
and    $0x1,%ecx
or     %ecx,%eax
movslq %eax,%rcx
lea    0xeb0(%rip),%rax
mov    (%rax,%rcx,1),%dl
mov    -0x18(%rbp),%rax
mov    -0x4(%rbp),%ecx
sub    $0x1,%ecx
sub    -0x1c(%rbp),%ecx
movslq %ecx,%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1116 <bfc_kmer_2str+0x16>
mov    -0x18(%rbp),%rax
movslq -0x4(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x18(%rbp),%rax
pop    %rbp
ret

x86 assembly (clang, -O2):
<bfc_kmer_2str>:
push   %rbx
mov    %rdx,%rax
test   %edi,%edi
jle    1150 <bfc_kmer_2str+0x50>
mov    %edi,%r8d
lea    -0x1(%rdi),%ebx
xor    %ecx,%ecx
lea    0xee9(%rip),%r9
nopw   0x0(%rax,%rax,1)
mov    (%rsi),%r10d
mov    0x4(%rsi),%r11d
shr    %cl,%r11
and    $0x1,%r11d
shr    %cl,%r10
and    $0x1,%r10d
lea    (%r10,%r11,2),%rdx
movzbl (%r9,%rdx,1),%edx
movslq %ebx,%rbx
mov    %dl,(%rax,%rbx,1)
add    $0x1,%rcx
add    $0xffffffff,%ebx
cmp    %rcx,%r8
jne    1120 <bfc_kmer_2str+0x20>
movslq %edi,%rcx
movb   $0x0,(%rax,%rcx,1)
pop    %rbx
ret

LLVM IR (-O0):
@.str = [5 x i8] c"ACGT\00"
define i8* @bfc_kmer_2str(i32 %0, i32* %1, i8* %2) {
%4 = alloca i32
%5 = alloca i32*
%6 = alloca i8*
%7 = alloca i32
store i32 %0, i32* %4
store i32* %1, i32** %5
store i8* %2, i8** %6
store i32 0, i32* %7
br label %8
8: ; preds = %37, %3
%9 = load i32, i32* %7
%10 = load i32, i32* %4
%11 = icmp slt i32 %9, %10
br i1 %11, label %12, label %40
12: ; preds = %8
%13 = load i32*, i32** %5
%14 = getelementptr inbounds i32, i32* %13, i64 1
%15 = load i32, i32* %14
%16 = load i32, i32* %7
%17 = ashr i32 %15, %16
%18 = and i32 %17, 1
%19 = shl i32 %18, 1
%20 = load i32*, i32** %5
%21 = getelementptr inbounds i32, i32* %20, i64 0
%22 = load i32, i32* %21
%23 = load i32, i32* %7
%24 = ashr i32 %22, %23
%25 = and i32 %24, 1
%26 = or i32 %19, %25
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds [5 x i8], [5 x i8]* @.str, i64 0, i64 %27
%29 = load i8, i8* %28
%30 = load i8*, i8** %6
%31 = load i32, i32* %4
%32 = sub nsw i32 %31, 1
%33 = load i32, i32* %7
%34 = sub nsw i32 %32, %33
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds i8, i8* %30, i64 %35
store i8 %29, i8* %36
br label %37
37: ; preds = %12
%38 = load i32, i32* %7
%39 = add nsw i32 %38, 1
store i32 %39, i32* %7
br label %8
40: ; preds = %8
%41 = load i8*, i8** %6
%42 = load i32, i32* %4
%43 = sext i32 %42 to i64
%44 = getelementptr inbounds i8, i8* %41, i64 %43
store i8 0, i8* %44
%45 = load i8*, i8** %6
ret i8* %45
}

LLVM IR (-O2):
@.str = [5 x i8] c"ACGT\00"
define i8* @bfc_kmer_2str(i32 %0, i32* nocapture %1, i8* returned writeonly %2) {
%4 = icmp sgt i32 %0, 0
br i1 %4, label %5, label %29
5: ; preds = %3
%6 = getelementptr inbounds i32, i32* %1, i64 1
%7 = zext i32 %0 to i64
br label %8
8: ; preds = %5, %8
%9 = phi i64 [ 0, %5 ], [ %27, %8 ]
%10 = load i32, i32* %6
%11 = trunc i64 %9 to i32
%12 = lshr i32 %10, %11
%13 = shl i32 %12, 1
%14 = and i32 %13, 2
%15 = load i32, i32* %1
%16 = lshr i32 %15, %11
%17 = and i32 %16, 1
%18 = or i32 %14, %17
%19 = zext i32 %18 to i64
%20 = getelementptr inbounds [5 x i8], [5 x i8]* @.str, i64 0, i64 %19
%21 = load i8, i8* %20
%22 = trunc i64 %9 to i32
%23 = xor i32 %22, -1
%24 = add i32 %23, %0
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds i8, i8* %2, i64 %25
store i8 %21, i8* %26
%27 = add nuw nsw i64 %9, 1
%28 = icmp eq i64 %27, %7
br i1 %28, label %29, label %8
29: ; preds = %8, %3
%30 = sext i32 %0 to i64
%31 = getelementptr inbounds i8, i8* %2, i64 %30
store i8 0, i8* %31
ret i8* %2
}