#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 /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *);
void writeAsNucleotides(FILE *file, unsigned long long int sequence) {
  const unsigned long long int MASK = 0x3;
  for (int i = 0; i < 31; i++) {
    unsigned int position = (i * 2) % 64;
    unsigned long long int nucleotide = (sequence >> (62 - position)) & MASK;
    if (nucleotide == 0x0) {
      fprintf(file, "A");
    } else if (nucleotide == 0x1) {
      fprintf(file, "G");
    } else if (nucleotide == 0x2) {
      fprintf(file, "C");
    } else if (nucleotide == 0x3) {
      fprintf(file, "T");
    } else {
      fprintf(file, "E");
    }
  }
}


x86 assembly (clang, -O0):
<writeAsNucleotides>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x3,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
cmpl   $0x1f,-0x1c(%rbp)
jge    1215 <writeAsNucleotides+0x105>
mov    -0x1c(%rbp),%eax
shl    $0x1,%eax
mov    $0x40,%ecx
cltd
idiv   %ecx
mov    %edx,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    $0x3e,%ecx
sub    -0x20(%rbp),%ecx
mov    %ecx,%ecx
shr    %cl,%rax
and    $0x3,%rax
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    1183 <writeAsNucleotides+0x73>
mov    -0x8(%rbp),%rdi
lea    0xe87(%rip),%rsi
call   1030 <fprintf@plt>
jmp    1202 <writeAsNucleotides+0xf2>
cmpq   $0x1,-0x28(%rbp)
jne    11a3 <writeAsNucleotides+0x93>
mov    -0x8(%rbp),%rdi
lea    0xe69(%rip),%rsi
call   1030 <fprintf@plt>
jmp    11fd <writeAsNucleotides+0xed>
cmpq   $0x2,-0x28(%rbp)
jne    11c3 <writeAsNucleotides+0xb3>
mov    -0x8(%rbp),%rdi
lea    0xe4b(%rip),%rsi
call   1030 <fprintf@plt>
jmp    11f8 <writeAsNucleotides+0xe8>
cmpq   $0x3,-0x28(%rbp)
jne    11e3 <writeAsNucleotides+0xd3>
mov    -0x8(%rbp),%rdi
lea    0xe2d(%rip),%rsi
call   1030 <fprintf@plt>
jmp    11f3 <writeAsNucleotides+0xe3>
mov    -0x8(%rbp),%rdi
lea    0xe1a(%rip),%rsi
call   1030 <fprintf@plt>
jmp    11f8 <writeAsNucleotides+0xe8>
jmp    11fd <writeAsNucleotides+0xed>
jmp    1202 <writeAsNucleotides+0xf2>
jmp    1207 <writeAsNucleotides+0xf7>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    112f <writeAsNucleotides+0x1f>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<writeAsNucleotides>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
xor    %ebp,%ebp
lea    0xeda(%rip),%r15
jmp    1140 <writeAsNucleotides+0x30>
nopl   0x0(%rax,%rax,1)
mov    %rbx,%rsi
call   1030 <fputc@plt>
add    $0x2,%ebp
cmp    $0x3e,%ebp
je     115f <writeAsNucleotides+0x4f>
mov    %ebp,%ecx
xor    $0x3e,%cl
mov    %r14,%rax
shr    %cl,%rax
and    $0x3,%eax
mov    $0x54,%edi
cmp    $0x3,%rax
je     1130 <writeAsNucleotides+0x20>
mov    (%r15,%rax,4),%edi
jmp    1130 <writeAsNucleotides+0x20>
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c"A\00"
@.str.1 = [2 x i8] c"G\00"
@.str.2 = [2 x i8] c"C\00"
@.str.3 = [2 x i8] c"T\00"
@.str.4 = [2 x i8] c"E\00"
define void @writeAsNucleotides(i32* %0, i64 %1) {
%3 = alloca i32*
%4 = alloca i64
%5 = alloca i64
%6 = alloca i32
%7 = alloca i32
%8 = alloca i64
store i32* %0, i32** %3
store i64 %1, i64* %4
store i64 3, i64* %5
store i32 0, i32* %6
br label %9
9: ; preds = %52, %2
%10 = load i32, i32* %6
%11 = icmp slt i32 %10, 31
br i1 %11, label %12, label %55
12: ; preds = %9
%13 = load i32, i32* %6
%14 = mul nsw i32 %13, 2
%15 = srem i32 %14, 64
store i32 %15, i32* %7
%16 = load i64, i64* %4
%17 = load i32, i32* %7
%18 = sub i32 62, %17
%19 = zext i32 %18 to i64
%20 = lshr i64 %16, %19
%21 = and i64 %20, 3
store i64 %21, i64* %8
%22 = load i64, i64* %8
%23 = icmp eq i64 %22, 0
br i1 %23, label %24, label %27
24: ; preds = %12
%25 = load i32*, i32** %3
%26 = call i32 @fprintf(i32* %25, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
br label %51
27: ; preds = %12
%28 = load i64, i64* %8
%29 = icmp eq i64 %28, 1
br i1 %29, label %30, label %33
30: ; preds = %27
%31 = load i32*, i32** %3
%32 = call i32 @fprintf(i32* %31, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %50
33: ; preds = %27
%34 = load i64, i64* %8
%35 = icmp eq i64 %34, 2
br i1 %35, label %36, label %39
36: ; preds = %33
%37 = load i32*, i32** %3
%38 = call i32 @fprintf(i32* %37, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %49
39: ; preds = %33
%40 = load i64, i64* %8
%41 = icmp eq i64 %40, 3
br i1 %41, label %42, label %45
42: ; preds = %39
%43 = load i32*, i32** %3
%44 = call i32 @fprintf(i32* %43, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
br label %48
45: ; preds = %39
%46 = load i32*, i32** %3
%47 = call i32 @fprintf(i32* %46, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
br label %48
48: ; preds = %45, %42
br label %49
49: ; preds = %48, %36
br label %50
50: ; preds = %49, %30
br label %51
51: ; preds = %50, %24
br label %52
52: ; preds = %51
%53 = load i32, i32* %6
%54 = add nsw i32 %53, 1
store i32 %54, i32* %6
br label %9
55: ; preds = %9
ret void
}

LLVM IR (-O2):
@switch.table.writeAsNucleotides = [3 x i32] [i32 65, i32 71, i32 67]
define void @writeAsNucleotides(i32* nocapture %0, i64 %1) {
br label %4
3: ; preds = %15
ret void
4: ; preds = %2, %15
%5 = phi i32 [ 0, %2 ], [ %18, %15 ]
%6 = shl nuw nsw i32 %5, 1
%7 = xor i32 %6, 62
%8 = zext i32 %7 to i64
%9 = lshr i64 %1, %8
%10 = and i64 %9, 3
%11 = icmp eq i64 %10, 3
br i1 %11, label %15, label %12
12: ; preds = %4
%13 = getelementptr inbounds [3 x i32], [3 x i32]* @switch.table.writeAsNucleotides, i64 0, i64 %10
%14 = load i32, i32* %13
br label %15
15: ; preds = %4, %12
%16 = phi i32 [ %14, %12 ], [ 84, %4 ]
%17 = tail call i32 @fputc(i32 %16, i32* %0)
%18 = add nuw nsw i32 %5, 1
%19 = icmp eq i32 %18, 31
br i1 %19, label %3, label %4
}