#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 */
unsigned char *calloc(int, int);
char *init_complement_ascii();
int strlen(char *);
unsigned char *GetReverseComplement(unsigned char *original) {
  static char *Complementascii = NULL;
  unsigned char *sourceptr, *destinptr;
  int length;
  unsigned char *buffer;
  if (Complementascii == NULL) {
    Complementascii = init_complement_ascii();
    if (NULL == Complementascii)
      return NULL;
  }
  length = strlen((char *)original);
  buffer = calloc((length + 1), sizeof(*buffer));
  if (buffer == NULL) {
    return NULL;
  }
  sourceptr = original;
  destinptr = buffer + length;
  *destinptr = '\0';
  destinptr--;
  while (*sourceptr != '\0') {
    (*destinptr) = Complementascii[(*sourceptr)];
    destinptr--;
    sourceptr++;
  }
  return buffer;
}


x86 assembly (clang, -O0):
<GetReverseComplement>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
cmpq   $0x0,0x2efc(%rip)
jne    1179 <GetReverseComplement+0x49>
mov    $0x0,%al
call   1050 <init_complement_ascii@plt>
mov    %rax,0x2ee8(%rip)
xor    %eax,%eax
cmp    0x2edf(%rip),%rax
jne    1174 <GetReverseComplement+0x44>
movq   $0x0,-0x8(%rbp)
jmp    1227 <GetReverseComplement+0xf7>
jmp    1179 <GetReverseComplement+0x49>
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%edi
add    $0x1,%edi
mov    $0x1,%esi
call   1040 <calloc@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    11b1 <GetReverseComplement+0x81>
movq   $0x0,-0x8(%rbp)
jmp    1227 <GetReverseComplement+0xf7>
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x30(%rbp),%rax
movslq -0x24(%rbp),%rcx
add    %rcx,%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x20(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rax
movzbl (%rax),%eax
cmp    $0x0,%eax
je     121f <GetReverseComplement+0xef>
mov    0x2e4e(%rip),%rax
mov    -0x18(%rbp),%rcx
movzbl (%rcx),%ecx
mov    (%rax,%rcx,1),%cl
mov    -0x20(%rbp),%rax
mov    %cl,(%rax)
mov    -0x20(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    11db <GetReverseComplement+0xab>
mov    -0x30(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<GetReverseComplement>:
push   %r15
push   %r14
push   %rbx
mov    %rdi,%rbx
cmpq   $0x0,0x2f00(%rip)
jne    1158 <GetReverseComplement+0x28>
xor    %r14d,%r14d
xor    %eax,%eax
call   1050 <init_complement_ascii@plt>
mov    %rax,0x2eed(%rip)
test   %rax,%rax
je     11bd <GetReverseComplement+0x8d>
mov    %rbx,%rdi
call   1030 <strlen@plt>
mov    %eax,%r15d
lea    0x1(%r15),%edi
mov    $0x1,%esi
call   1040 <calloc@plt>
test   %rax,%rax
je     11ba <GetReverseComplement+0x8a>
mov    %rax,%r14
mov    (%rbx),%al
test   %al,%al
je     11bd <GetReverseComplement+0x8d>
movslq %r15d,%rdx
mov    0x2eb7(%rip),%rcx
add    %r14,%rdx
add    $0xffffffffffffffff,%rdx
add    $0x1,%rbx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movzbl %al,%eax
movzbl (%rcx,%rax,1),%eax
mov    %al,(%rdx)
movzbl (%rbx),%eax
add    $0xffffffffffffffff,%rdx
add    $0x1,%rbx
test   %al,%al
jne    11a0 <GetReverseComplement+0x70>
jmp    11bd <GetReverseComplement+0x8d>
xor    %r14d,%r14d
mov    %r14,%rax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@GetReverseComplement.Complementascii = internal global i8* null
define i8* @GetReverseComplement(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i8*
store i8* %0, i8** %3
%8 = load i8*, i8** @GetReverseComplement.Complementascii
%9 = icmp eq i8* %8, null
br i1 %9, label %10, label %16
10: ; preds = %1
%11 = call i8* (...) @init_complement_ascii()
store i8* %11, i8** @GetReverseComplement.Complementascii
%12 = load i8*, i8** @GetReverseComplement.Complementascii
%13 = icmp eq i8* null, %12
br i1 %13, label %14, label %15
14: ; preds = %10
store i8* null, i8** %2
br label %53
15: ; preds = %10
br label %16
16: ; preds = %15, %1
%17 = load i8*, i8** %3
%18 = call i32 @strlen(i8* %17)
store i32 %18, i32* %6
%19 = load i32, i32* %6
%20 = add nsw i32 %19, 1
%21 = call i8* @calloc(i32 %20, i32 1)
store i8* %21, i8** %7
%22 = load i8*, i8** %7
%23 = icmp eq i8* %22, null
br i1 %23, label %24, label %25
24: ; preds = %16
store i8* null, i8** %2
br label %53
25: ; preds = %16
%26 = load i8*, i8** %3
store i8* %26, i8** %4
%27 = load i8*, i8** %7
%28 = load i32, i32* %6
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds i8, i8* %27, i64 %29
store i8* %30, i8** %5
%31 = load i8*, i8** %5
store i8 0, i8* %31
%32 = load i8*, i8** %5
%33 = getelementptr inbounds i8, i8* %32, i32 -1
store i8* %33, i8** %5
br label %34
34: ; preds = %39, %25
%35 = load i8*, i8** %4
%36 = load i8, i8* %35
%37 = zext i8 %36 to i32
%38 = icmp ne i32 %37, 0
br i1 %38, label %39, label %51
39: ; preds = %34
%40 = load i8*, i8** @GetReverseComplement.Complementascii
%41 = load i8*, i8** %4
%42 = load i8, i8* %41
%43 = zext i8 %42 to i64
%44 = getelementptr inbounds i8, i8* %40, i64 %43
%45 = load i8, i8* %44
%46 = load i8*, i8** %5
store i8 %45, i8* %46
%47 = load i8*, i8** %5
%48 = getelementptr inbounds i8, i8* %47, i32 -1
store i8* %48, i8** %5
%49 = load i8*, i8** %4
%50 = getelementptr inbounds i8, i8* %49, i32 1
store i8* %50, i8** %4
br label %34
51: ; preds = %34
%52 = load i8*, i8** %7
store i8* %52, i8** %2
br label %53
53: ; preds = %51, %24, %14
%54 = load i8*, i8** %2
ret i8* %54
}

LLVM IR (-O2):
@GetReverseComplement.Complementascii = internal unnamed_addr global i8* null
define noalias i8* @GetReverseComplement(i8* %0) {
%2 = load i8*, i8** @GetReverseComplement.Complementascii
%3 = icmp eq i8* %2, null
br i1 %3, label %4, label %7
4: ; preds = %1
%5 = tail call i8* (...) @init_complement_ascii()
store i8* %5, i8** @GetReverseComplement.Complementascii
%6 = icmp eq i8* %5, null
br i1 %6, label %30, label %7
7: ; preds = %4, %1
%8 = tail call i32 @strlen(i8* %0)
%9 = add nsw i32 %8, 1
%10 = tail call i8* @calloc(i32 %9, i32 1)
%11 = icmp eq i8* %10, null
br i1 %11, label %30, label %12
12: ; preds = %7
%13 = load i8, i8* %0
%14 = icmp eq i8 %13, 0
br i1 %14, label %30, label %15
15: ; preds = %12
%16 = sext i32 %8 to i64
%17 = getelementptr inbounds i8, i8* %10, i64 %16
%18 = load i8*, i8** @GetReverseComplement.Complementascii
br label %19
19: ; preds = %15, %19
%20 = phi i8 [ %13, %15 ], [ %28, %19 ]
%21 = phi i8* [ %17, %15 ], [ %23, %19 ]
%22 = phi i8* [ %0, %15 ], [ %27, %19 ]
%23 = getelementptr inbounds i8, i8* %21, i64 -1
%24 = zext i8 %20 to i64
%25 = getelementptr inbounds i8, i8* %18, i64 %24
%26 = load i8, i8* %25
store i8 %26, i8* %23
%27 = getelementptr inbounds i8, i8* %22, i64 1
%28 = load i8, i8* %27
%29 = icmp eq i8 %28, 0
br i1 %29, label %30, label %19
30: ; preds = %19, %12, %7, %4
%31 = phi i8* [ null, %4 ], [ null, %7 ], [ %10, %12 ], [ %10, %19 ]
ret i8* %31
}