#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 */
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ printf(char *, int, char);
void revComp(int length, char *seq, char *rcSeq) {
  int i, j;
  char c;
  for (i = 0; i <= length; i++) {
    rcSeq[i] = '\0';
  }
  for (i = 0; i < length; i++) {
    switch (seq[i]) {
    case 'A':
      c = 'U';
      break;
    case 'U':
      c = 'A';
      break;
    case 'T':
      c = 'A';
      break;
    case 'G':
      c = 'C';
      break;
    case 'C':
      c = 'G';
      break;
    case 'a':
      c = 'U';
      break;
    case 'u':
      c = 'A';
      break;
    case 't':
      c = 'A';
      break;
    case 'g':
      c = 'C';
      break;
    case 'c':
      c = 'G';
      break;
    default:
      printf("Wrong RNA letters: seq[%d] = %c\n", i, seq[i]);
      exit(1);
    }
    rcSeq[length - 1 - i] = c;
  }
}


x86 assembly (clang, -O0):
<revComp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x4(%rbp),%eax
jg     1160 <revComp+0x40>
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    113a <revComp+0x1a>
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    1248 <revComp+0x128>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
add    $0xffffffbf,%eax
mov    %eax,%ecx
mov    %rcx,-0x30(%rbp)
sub    $0x34,%eax
ja     11ff <revComp+0xdf>
mov    -0x30(%rbp),%rax
lea    0xe64(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movb   $0x55,-0x21(%rbp)
jmp    1224 <revComp+0x104>
movb   $0x41,-0x21(%rbp)
jmp    1224 <revComp+0x104>
movb   $0x41,-0x21(%rbp)
jmp    1224 <revComp+0x104>
movb   $0x43,-0x21(%rbp)
jmp    1224 <revComp+0x104>
movb   $0x47,-0x21(%rbp)
jmp    1224 <revComp+0x104>
movb   $0x55,-0x21(%rbp)
jmp    1224 <revComp+0x104>
movb   $0x41,-0x21(%rbp)
jmp    1224 <revComp+0x104>
movb   $0x41,-0x21(%rbp)
jmp    1224 <revComp+0x104>
movb   $0x43,-0x21(%rbp)
jmp    1224 <revComp+0x104>
movb   $0x47,-0x21(%rbp)
jmp    1224 <revComp+0x104>
mov    -0x1c(%rbp),%esi
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
lea    0xec3(%rip),%rdi
movsbl (%rax,%rcx,1),%edx
call   1030 <printf@plt>
mov    $0x1,%edi
call   1040 <exit@plt>
mov    -0x21(%rbp),%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    1167 <revComp+0x47>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<revComp>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
test   %edi,%edi
js     11a5 <revComp+0x75>
mov    %rdx,%r15
mov    %rsi,%r14
mov    %edi,%ebx
mov    %edi,%r12d
lea    0x1(%r12),%rdx
mov    %r15,%rdi
xor    %esi,%esi
call   1040 <memset@plt>
test   %ebx,%ebx
je     11a5 <revComp+0x75>
add    $0xffffffff,%ebx
xor    %esi,%esi
lea    0xe9a(%rip),%rax
jmp    1185 <revComp+0x55>
nopl   0x0(%rax,%rax,1)
mov    $0x41,%cl
movslq %ebx,%rbx
mov    %cl,(%r15,%rbx,1)
add    $0x1,%rsi
add    $0xffffffff,%ebx
cmp    %rsi,%r12
je     11a5 <revComp+0x75>
movsbl (%r14,%rsi,1),%edx
lea    -0x41(%rdx),%edi
cmp    $0x34,%edi
ja     11b1 <revComp+0x81>
mov    $0x55,%cl
movslq (%rax,%rdi,4),%rdi
add    %rax,%rdi
jmp    *%rdi
mov    $0x47,%cl
jmp    1172 <revComp+0x42>
mov    $0x43,%cl
jmp    1172 <revComp+0x42>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret
movsbl %dl,%edx
lea    0xf19(%rip),%rdi
call   1030 <printf@plt>
mov    $0x1,%edi
call   1050 <exit@plt>

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

LLVM IR (-O2):
@.str = [33 x i8] c"Wrong RNA letters: seq[%d] = %c\0A\00"
define void @revComp(i32 %0, i8* nocapture %1, i8* nocapture writeonly %2) {
%4 = icmp slt i32 %0, 0
br i1 %4, label %37, label %5
5: ; preds = %3
%6 = zext i32 %0 to i64
%7 = add nuw nsw i64 %6, 1
%8 = icmp eq i32 %0, 0
br i1 %8, label %37, label %9
9: ; preds = %5
%10 = zext i32 %0 to i64
br label %11
11: ; preds = %9, %28
%12 = phi i64 [ 0, %9 ], [ %35, %28 ]
%13 = getelementptr inbounds i8, i8* %1, i64 %12
%14 = load i8, i8* %13
%15 = sext i8 %14 to i32
switch i32 %15, label %24 [
i32 65, label %28
i32 85, label %16
i32 84, label %17
i32 71, label %18
i32 67, label %19
i32 97, label %28
i32 117, label %20
i32 116, label %21
i32 103, label %22
i32 99, label %23
]
16: ; preds = %11
br label %28
17: ; preds = %11
br label %28
18: ; preds = %11
br label %28
19: ; preds = %11
br label %28
20: ; preds = %11
br label %28
21: ; preds = %11
br label %28
22: ; preds = %11
br label %28
23: ; preds = %11
br label %28
24: ; preds = %11
%25 = trunc i64 %12 to i32
%26 = tail call i32 @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0), i32 %25, i8 signext %14)
%27 = tail call i32 @exit(i32 1)
unreachable
28: ; preds = %11, %11, %23, %22, %21, %20, %19, %18, %17, %16
%29 = phi i8 [ 71, %23 ], [ 67, %22 ], [ 65, %21 ], [ 65, %20 ], [ 71, %19 ], [ 67, %18 ], [ 65, %17 ], [ 65, %16 ], [ 85, %11 ], [ 85, %11 ]
%30 = trunc i64 %12 to i32
%31 = xor i32 %30, -1
%32 = add i32 %31, %0
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds i8, i8* %2, i64 %33
store i8 %29, i8* %34
%35 = add nuw nsw i64 %12, 1
%36 = icmp eq i64 %35, %10
br i1 %36, label %37, label %11
37: ; preds = %28, %3, %5
ret void
}