#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__ safe_malloc(int);
int strlen(char *);
char *reverse_complement(char *seq) {
  int i;
  char *res = (char *)safe_malloc(sizeof(char) * (strlen(seq) + 1));
  int last_pos = strlen(seq) - 1;
  for (i = 0; i < strlen(seq); i++) {
    switch (seq[i]) {
    case 'C':
    case 'c':
      res[last_pos - i] = 'G';
      break;
    case 'G':
    case 'g':
      res[last_pos - i] = 'C';
      break;
    case 'A':
    case 'a':
      res[last_pos - i] = 'T';
      break;
    case 'T':
    case 't':
    case 'U':
    case 'u':
      res[last_pos - i] = 'A';
      break;
    default:
      break;
    }
  }
  res[i] = '\0';
  return res;
}


x86 assembly (clang, -O0):
<reverse_complement>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
add    $0x1,%eax
cltq
shl    $0x0,%rax
mov    %eax,%edi
call   1030 <safe_malloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
sub    $0x1,%eax
mov    %eax,-0x1c(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%eax
cmp    %ecx,%eax
jge    121d <reverse_complement+0xfd>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
add    $0xffffffbf,%eax
mov    %eax,%ecx
mov    %rcx,-0x28(%rbp)
sub    $0x34,%eax
ja     1205 <reverse_complement+0xe5>
mov    -0x28(%rbp),%rax
lea    0xe5c(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x18(%rbp),%rax
mov    -0x1c(%rbp),%ecx
sub    -0xc(%rbp),%ecx
movslq %ecx,%rcx
movb   $0x47,(%rax,%rcx,1)
jmp    120a <reverse_complement+0xea>
mov    -0x18(%rbp),%rax
mov    -0x1c(%rbp),%ecx
sub    -0xc(%rbp),%ecx
movslq %ecx,%rcx
movb   $0x43,(%rax,%rcx,1)
jmp    120a <reverse_complement+0xea>
mov    -0x18(%rbp),%rax
mov    -0x1c(%rbp),%ecx
sub    -0xc(%rbp),%ecx
movslq %ecx,%rcx
movb   $0x54,(%rax,%rcx,1)
jmp    120a <reverse_complement+0xea>
mov    -0x18(%rbp),%rax
mov    -0x1c(%rbp),%ecx
sub    -0xc(%rbp),%ecx
movslq %ecx,%rcx
movb   $0x41,(%rax,%rcx,1)
jmp    120a <reverse_complement+0xea>
jmp    120a <reverse_complement+0xea>
jmp    120f <reverse_complement+0xef>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    115f <reverse_complement+0x3f>
mov    -0x18(%rbp),%rax
movslq -0xc(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x18(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<reverse_complement>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rdi,%r15
call   1040 <strlen@plt>
lea    0x1(%rax),%edi
call   1030 <safe_malloc@plt>
mov    %rax,%r14
mov    %r15,%rdi
call   1040 <strlen@plt>
mov    %eax,%ebp
mov    %r15,%rdi
call   1040 <strlen@plt>
test   %eax,%eax
jle    11bb <reverse_complement+0x9b>
movslq %ebp,%rax
lea    (%rax,%r14,1),%rbx
add    $0xffffffffffffffff,%rbx
xor    %ebp,%ebp
lea    0xe9b(%rip),%r12
cs nopw 0x0(%rax,%rax,1)
nop
movsbl (%r15,%rbp,1),%ecx
add    $0xffffffbf,%ecx
cmp    $0x34,%ecx
ja     11a2 <reverse_complement+0x82>
mov    $0x47,%al
movslq (%r12,%rcx,4),%rcx
add    %r12,%rcx
jmp    *%rcx
mov    $0x41,%al
jmp    11a0 <reverse_complement+0x80>
mov    $0x54,%al
jmp    11a0 <reverse_complement+0x80>
mov    $0x43,%al
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %al,(%rbx)
add    $0x1,%rbp
mov    %r15,%rdi
call   1040 <strlen@plt>
cltq
add    $0xffffffffffffffff,%rbx
cmp    %rax,%rbp
jl     1170 <reverse_complement+0x50>
jmp    11bd <reverse_complement+0x9d>
xor    %ebp,%ebp
movb   $0x0,(%r14,%rbp,1)
mov    %r14,%rax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i8* @reverse_complement(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i32
store i8* %0, i8** %2
%6 = load i8*, i8** %2
%7 = call i32 @strlen(i8* %6)
%8 = add nsw i32 %7, 1
%9 = sext i32 %8 to i64
%10 = mul i64 1, %9
%11 = trunc i64 %10 to i32
%12 = call i64 @safe_malloc(i32 %11)
%13 = inttoptr i64 %12 to i8*
store i8* %13, i8** %4
%14 = load i8*, i8** %2
%15 = call i32 @strlen(i8* %14)
%16 = sub nsw i32 %15, 1
store i32 %16, i32* %5
store i32 0, i32* %3
br label %17
17: ; preds = %59, %1
%18 = load i32, i32* %3
%19 = load i8*, i8** %2
%20 = call i32 @strlen(i8* %19)
%21 = icmp slt i32 %18, %20
br i1 %21, label %22, label %62
22: ; preds = %17
%23 = load i8*, i8** %2
%24 = load i32, i32* %3
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds i8, i8* %23, i64 %25
%27 = load i8, i8* %26
%28 = sext i8 %27 to i32
switch i32 %28, label %57 [
i32 67, label %29
i32 99, label %29
i32 71, label %36
i32 103, label %36
i32 65, label %43
i32 97, label %43
i32 84, label %50
i32 116, label %50
i32 85, label %50
i32 117, label %50
]
29: ; preds = %22, %22
%30 = load i8*, i8** %4
%31 = load i32, i32* %5
%32 = load i32, i32* %3
%33 = sub nsw i32 %31, %32
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds i8, i8* %30, i64 %34
store i8 71, i8* %35
br label %58
36: ; preds = %22, %22
%37 = load i8*, i8** %4
%38 = load i32, i32* %5
%39 = load i32, i32* %3
%40 = sub nsw i32 %38, %39
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds i8, i8* %37, i64 %41
store i8 67, i8* %42
br label %58
43: ; preds = %22, %22
%44 = load i8*, i8** %4
%45 = load i32, i32* %5
%46 = load i32, i32* %3
%47 = sub nsw i32 %45, %46
%48 = sext i32 %47 to i64
%49 = getelementptr inbounds i8, i8* %44, i64 %48
store i8 84, i8* %49
br label %58
50: ; preds = %22, %22, %22, %22
%51 = load i8*, i8** %4
%52 = load i32, i32* %5
%53 = load i32, i32* %3
%54 = sub nsw i32 %52, %53
%55 = sext i32 %54 to i64
%56 = getelementptr inbounds i8, i8* %51, i64 %55
store i8 65, i8* %56
br label %58
57: ; preds = %22
br label %58
58: ; preds = %57, %50, %43, %36, %29
br label %59
59: ; preds = %58
%60 = load i32, i32* %3
%61 = add nsw i32 %60, 1
store i32 %61, i32* %3
br label %17
62: ; preds = %17
%63 = load i8*, i8** %4
%64 = load i32, i32* %3
%65 = sext i32 %64 to i64
%66 = getelementptr inbounds i8, i8* %63, i64 %65
store i8 0, i8* %66
%67 = load i8*, i8** %4
ret i8* %67
}

LLVM IR (-O2):
define i8* @reverse_complement(i8* %0) {
%2 = tail call i32 @strlen(i8* %0)
%3 = add nsw i32 %2, 1
%4 = tail call i64 @safe_malloc(i32 %3)
%5 = inttoptr i64 %4 to i8*
%6 = tail call i32 @strlen(i8* %0)
%7 = tail call i32 @strlen(i8* %0)
%8 = icmp sgt i32 %7, 0
br i1 %8, label %9, label %31
9: ; preds = %1
%10 = add nsw i32 %6, -1
%11 = sext i32 %10 to i64
br label %12
12: ; preds = %9, %24
%13 = phi i64 [ 0, %9 ], [ %25, %24 ]
%14 = getelementptr inbounds i8, i8* %0, i64 %13
%15 = load i8, i8* %14
%16 = sext i8 %15 to i32
switch i32 %16, label %24 [
i32 67, label %20
i32 99, label %20
i32 71, label %17
i32 103, label %17
i32 65, label %18
i32 97, label %18
i32 84, label %19
i32 116, label %19
i32 85, label %19
i32 117, label %19
]
17: ; preds = %12, %12
br label %20
18: ; preds = %12, %12
br label %20
19: ; preds = %12, %12, %12, %12
br label %20
20: ; preds = %12, %12, %19, %18, %17
%21 = phi i8 [ 67, %17 ], [ 84, %18 ], [ 65, %19 ], [ 71, %12 ], [ 71, %12 ]
%22 = sub nsw i64 %11, %13
%23 = getelementptr inbounds i8, i8* %5, i64 %22
store i8 %21, i8* %23
br label %24
24: ; preds = %20, %12
%25 = add nuw nsw i64 %13, 1
%26 = tail call i32 @strlen(i8* %0)
%27 = sext i32 %26 to i64
%28 = icmp slt i64 %25, %27
br i1 %28, label %12, label %29
29: ; preds = %24
%30 = and i64 %25, 4294967295
br label %31
31: ; preds = %29, %1
%32 = phi i64 [ 0, %1 ], [ %30, %29 ]
%33 = getelementptr inbounds i8, i8* %5, i64 %32
store i8 0, i8* %33
ret i8* %5
}