#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 */
scalar_t__ calloc(long, int);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ stderr;
void compstrand(char **sequence, long int seqlen) {
  char *ptr, *revseq;
  long int pos;
  revseq = (char *)calloc(seqlen + 1, sizeof(char));
  if (revseq == NULL) {
    fprintf(stderr, "tRNAscan1.4: Can't malloc for complement sequence\n");
    exit(-1);
  }
  for (pos = 0, ptr = &((*sequence)[seqlen - 1]); pos < seqlen; pos++, ptr--) {
    switch (*ptr) {
    case 'a':
      revseq[pos] = 't';
      break;
    case 'c':
      revseq[pos] = 'g';
      break;
    case 'g':
      revseq[pos] = 'c';
      break;
    case 't':
      revseq[pos] = 'a';
      break;
    default:
      revseq[pos] = 'n';
      break;
    }
  }
  revseq[seqlen] = '\0';
  free(*sequence);
  *sequence = revseq;
}


x86 assembly (clang, -O0):
<compstrand>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
add    $0x1,%rdi
mov    $0x1,%esi
call   1040 <calloc@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    1190 <compstrand+0x50>
mov    0x2e68(%rip),%rax
mov    (%rax),%edi
lea    0xecf(%rip),%rsi
call   1050 <fprintf@plt>
mov    $0xffffffff,%edi
call   1060 <exit@plt>
movq   $0x0,-0x28(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    -0x10(%rbp),%rcx
sub    $0x1,%rcx
add    %rcx,%rax
mov    %rax,-0x18(%rbp)
mov    -0x28(%rbp),%rax
cmp    -0x10(%rbp),%rax
jge    125b <compstrand+0x11b>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
add    $0xffffff9f,%eax
mov    %eax,%ecx
mov    %rcx,-0x30(%rbp)
sub    $0x13,%eax
ja     122d <compstrand+0xed>
mov    -0x30(%rbp),%rax
lea    0xe20(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x20(%rbp),%rax
mov    -0x28(%rbp),%rcx
movb   $0x74,(%rax,%rcx,1)
jmp    1239 <compstrand+0xf9>
mov    -0x20(%rbp),%rax
mov    -0x28(%rbp),%rcx
movb   $0x67,(%rax,%rcx,1)
jmp    1239 <compstrand+0xf9>
mov    -0x20(%rbp),%rax
mov    -0x28(%rbp),%rcx
movb   $0x63,(%rax,%rcx,1)
jmp    1239 <compstrand+0xf9>
mov    -0x20(%rbp),%rax
mov    -0x28(%rbp),%rcx
movb   $0x61,(%rax,%rcx,1)
jmp    1239 <compstrand+0xf9>
mov    -0x20(%rbp),%rax
mov    -0x28(%rbp),%rcx
movb   $0x6e,(%rax,%rcx,1)
jmp    123e <compstrand+0xfe>
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x18(%rbp)
jmp    11ae <compstrand+0x6e>
mov    -0x20(%rbp),%rax
mov    -0x10(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x8(%rbp),%rax
mov    (%rax),%rdi
call   1030 <free@plt>
mov    -0x20(%rbp),%rcx
mov    -0x8(%rbp),%rax
mov    %rcx,(%rax)
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<compstrand>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r12
mov    %rdi,%r14
lea    0x1(%rsi),%rdi
mov    $0x1,%esi
call   1040 <calloc@plt>
test   %rax,%rax
je     12ae <compstrand+0x16e>
mov    %rax,%r15
test   %r12,%r12
jle    1292 <compstrand+0x152>
mov    (%r14),%rax
lea    (%r12,%rax,1),%rcx
add    $0xffffffffffffffff,%rcx
cmp    $0x1,%r12
jne    1193 <compstrand+0x53>
xor    %eax,%eax
test   $0x1,%r12b
jne    1263 <compstrand+0x123>
jmp    1292 <compstrand+0x152>
mov    %r15,%rdx
add    $0x1,%rdx
mov    %r12,%rsi
and    $0xfffffffffffffffe,%rsi
neg    %rsi
xor    %eax,%eax
lea    0xea3(%rip),%r8
lea    0xe4c(%rip),%r9
jmp    11d5 <compstrand+0x95>
cs nopw 0x0(%rax,%rax,1)
mov    $0x63,%bl
mov    %bl,(%rdx)
add    $0x2,%rdx
add    $0xfffffffffffffffe,%rax
cmp    %rax,%rsi
je     1257 <compstrand+0x117>
movsbl (%rcx,%rax,1),%edi
add    $0xffffff9f,%edi
cmp    $0x13,%edi
ja     1200 <compstrand+0xc0>
mov    $0x74,%bl
movslq (%r9,%rdi,4),%rdi
add    %r9,%rdi
jmp    *%rdi
mov    $0x67,%bl
jmp    1220 <compstrand+0xe0>
mov    $0x63,%bl
jmp    1220 <compstrand+0xe0>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    $0x6e,%bl
jmp    1220 <compstrand+0xe0>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    $0x61,%bl
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %bl,-0x1(%rdx)
movsbl -0x1(%rcx,%rax,1),%edi
add    $0xffffff9f,%edi
cmp    $0x13,%edi
ja     1240 <compstrand+0x100>
mov    $0x74,%bl
movslq (%r8,%rdi,4),%rdi
add    %r8,%rdi
jmp    *%rdi
mov    $0x67,%bl
jmp    11c2 <compstrand+0x82>
nop
mov    $0x6e,%bl
jmp    11c2 <compstrand+0x82>
nopw   0x0(%rax,%rax,1)
mov    $0x61,%bl
jmp    11c2 <compstrand+0x82>
add    %rax,%rcx
neg    %rax
test   $0x1,%r12b
je     1292 <compstrand+0x152>
movsbl (%rcx),%edx
add    $0xffffff9f,%edx
cmp    $0x13,%edx
ja     1284 <compstrand+0x144>
mov    $0x74,%cl
lea    0xe29(%rip),%rsi
movslq (%rsi,%rdx,4),%rdx
add    %rsi,%rdx
jmp    *%rdx
mov    $0x67,%cl
jmp    128e <compstrand+0x14e>
mov    $0x6e,%cl
jmp    128e <compstrand+0x14e>
mov    $0x63,%cl
jmp    128e <compstrand+0x14e>
mov    $0x61,%cl
mov    %cl,(%r15,%rax,1)
movb   $0x0,(%r15,%r12,1)
mov    (%r14),%rdi
call   1030 <free@plt>
mov    %r15,(%r14)
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret
mov    0x2d2b(%rip),%rax
mov    (%rax),%edi
lea    0xe32(%rip),%rsi
call   1050 <fprintf@plt>
mov    $0xffffffff,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [51 x i8] c"tRNAscan1.4: Can't malloc for complement sequence\0A\00"
define void @compstrand(i8** %0, i64 %1) {
%3 = alloca i8**
%4 = alloca i64
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i64
store i8** %0, i8*** %3
store i64 %1, i64* %4
%8 = load i64, i64* %4
%9 = add nsw i64 %8, 1
%10 = call i64 @calloc(i64 %9, i32 1)
%11 = inttoptr i64 %10 to i8*
store i8* %11, i8** %6
%12 = load i8*, i8** %6
%13 = icmp eq i8* %12, null
br i1 %13, label %14, label %18
14: ; preds = %2
%15 = load i32, i32* @stderr
%16 = call i32 @fprintf(i32 %15, i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str, i64 0, i64 0))
%17 = call i32 @exit(i32 -1)
unreachable
18: ; preds = %2
store i64 0, i64* %7
%19 = load i8**, i8*** %3
%20 = load i8*, i8** %19
%21 = load i64, i64* %4
%22 = sub nsw i64 %21, 1
%23 = getelementptr inbounds i8, i8* %20, i64 %22
store i8* %23, i8** %5
br label %24
24: ; preds = %53, %18
%25 = load i64, i64* %7
%26 = load i64, i64* %4
%27 = icmp slt i64 %25, %26
br i1 %27, label %28, label %58
28: ; preds = %24
%29 = load i8*, i8** %5
%30 = load i8, i8* %29
%31 = sext i8 %30 to i32
switch i32 %31, label %48 [
i32 97, label %32
i32 99, label %36
i32 103, label %40
i32 116, label %44
]
32: ; preds = %28
%33 = load i8*, i8** %6
%34 = load i64, i64* %7
%35 = getelementptr inbounds i8, i8* %33, i64 %34
store i8 116, i8* %35
br label %52
36: ; preds = %28
%37 = load i8*, i8** %6
%38 = load i64, i64* %7
%39 = getelementptr inbounds i8, i8* %37, i64 %38
store i8 103, i8* %39
br label %52
40: ; preds = %28
%41 = load i8*, i8** %6
%42 = load i64, i64* %7
%43 = getelementptr inbounds i8, i8* %41, i64 %42
store i8 99, i8* %43
br label %52
44: ; preds = %28
%45 = load i8*, i8** %6
%46 = load i64, i64* %7
%47 = getelementptr inbounds i8, i8* %45, i64 %46
store i8 97, i8* %47
br label %52
48: ; preds = %28
%49 = load i8*, i8** %6
%50 = load i64, i64* %7
%51 = getelementptr inbounds i8, i8* %49, i64 %50
store i8 110, i8* %51
br label %52
52: ; preds = %48, %44, %40, %36, %32
br label %53
53: ; preds = %52
%54 = load i64, i64* %7
%55 = add nsw i64 %54, 1
store i64 %55, i64* %7
%56 = load i8*, i8** %5
%57 = getelementptr inbounds i8, i8* %56, i32 -1
store i8* %57, i8** %5
br label %24
58: ; preds = %24
%59 = load i8*, i8** %6
%60 = load i64, i64* %4
%61 = getelementptr inbounds i8, i8* %59, i64 %60
store i8 0, i8* %61
%62 = load i8**, i8*** %3
%63 = load i8*, i8** %62
%64 = call i32 @free(i8* %63)
%65 = load i8*, i8** %6
%66 = load i8**, i8*** %3
store i8* %65, i8** %66
ret void
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [51 x i8] c"tRNAscan1.4: Can't malloc for complement sequence\0A\00"
define void @compstrand(i8** nocapture %0, i64 %1) {
%3 = add nsw i64 %1, 1
%4 = tail call i64 @calloc(i64 %3, i32 1)
%5 = inttoptr i64 %4 to i8*
%6 = icmp eq i64 %4, 0
br i1 %6, label %7, label %11
7: ; preds = %2
%8 = load i32, i32* @stderr
%9 = tail call i32 @fprintf(i32 %8, i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str, i64 0, i64 0))
%10 = tail call i32 @exit(i32 -1)
unreachable
11: ; preds = %2
%12 = icmp sgt i64 %1, 0
br i1 %12, label %13, label %63
13: ; preds = %11
%14 = load i8*, i8** %0
%15 = add nsw i64 %1, -1
%16 = getelementptr inbounds i8, i8* %14, i64 %15
%17 = and i64 %1, 1
%18 = icmp eq i64 %1, 1
br i1 %18, label %49, label %19
19: ; preds = %13
%20 = and i64 %1, -2
br label %21
21: ; preds = %42, %19
%22 = phi i64 [ 0, %19 ], [ %45, %42 ]
%23 = phi i8* [ %16, %19 ], [ %46, %42 ]
%24 = phi i64 [ 0, %19 ], [ %47, %42 ]
%25 = load i8, i8* %23
%26 = sext i8 %25 to i32
switch i32 %26, label %30 [
i32 97, label %31
i32 99, label %27
i32 103, label %28
i32 116, label %29
]
27: ; preds = %21
br label %31
28: ; preds = %21
br label %31
29: ; preds = %21
br label %31
30: ; preds = %21
br label %31
31: ; preds = %21, %27, %28, %29, %30
%32 = phi i8 [ 103, %27 ], [ 99, %28 ], [ 97, %29 ], [ 110, %30 ], [ 116, %21 ]
%33 = getelementptr inbounds i8, i8* %5, i64 %22
store i8 %32, i8* %33
%34 = or i64 %22, 1
%35 = getelementptr inbounds i8, i8* %23, i64 -1
%36 = load i8, i8* %35
%37 = sext i8 %36 to i32
switch i32 %37, label %41 [
i32 97, label %42
i32 99, label %40
i32 103, label %39
i32 116, label %38
]
38: ; preds = %31
br label %42
39: ; preds = %31
br label %42
40: ; preds = %31
br label %42
41: ; preds = %31
br label %42
42: ; preds = %41, %40, %39, %38, %31
%43 = phi i8 [ 103, %40 ], [ 99, %39 ], [ 97, %38 ], [ 110, %41 ], [ 116, %31 ]
%44 = getelementptr inbounds i8, i8* %5, i64 %34
store i8 %43, i8* %44
%45 = add nuw nsw i64 %22, 2
%46 = getelementptr inbounds i8, i8* %23, i64 -2
%47 = add i64 %24, 2
%48 = icmp eq i64 %47, %20
br i1 %48, label %49, label %21
49: ; preds = %42, %13
%50 = phi i64 [ 0, %13 ], [ %45, %42 ]
%51 = phi i8* [ %16, %13 ], [ %46, %42 ]
%52 = icmp eq i64 %17, 0
br i1 %52, label %63, label %53
53: ; preds = %49
%54 = load i8, i8* %51
%55 = sext i8 %54 to i32
switch i32 %55, label %59 [
i32 97, label %60
i32 99, label %58
i32 103, label %57
i32 116, label %56
]
56: ; preds = %53
br label %60
57: ; preds = %53
br label %60
58: ; preds = %53
br label %60
59: ; preds = %53
br label %60
60: ; preds = %59, %58, %57, %56, %53
%61 = phi i8 [ 103, %58 ], [ 99, %57 ], [ 97, %56 ], [ 110, %59 ], [ 116, %53 ]
%62 = getelementptr inbounds i8, i8* %5, i64 %50
store i8 %61, i8* %62
br label %63
63: ; preds = %60, %49, %11
%64 = getelementptr inbounds i8, i8* %5, i64 %1
store i8 0, i8* %64
%65 = load i8*, i8** %0
%66 = tail call i32 @free(i8* %65)
store i8* %5, i8** %0
ret void
}