#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 */
char biosal_dna_helper_complement_nucleotide(char);
int strlen(char *);
void biosal_dna_helper_reverse_complement(char *sequence1, char *sequence2) {
  int length;
  int position1;
  int position2;
  char nucleotide1;
  char nucleotide2;
  length = strlen(sequence1);
  position1 = length - 1;
  position2 = 0;
  while (position2 < length) {
    nucleotide1 = sequence1[position1];
    nucleotide2 = biosal_dna_helper_complement_nucleotide(nucleotide1);
    sequence2[position2] = nucleotide2;
    position2++;
    position1--;
  }
  sequence2[position2] = '\0';
}


x86 assembly (clang, -O0):
<biosal_dna_helper_reverse_complement>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1197 <biosal_dna_helper_reverse_complement+0x77>
mov    -0x8(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,1),%al
mov    %al,-0x1d(%rbp)
movsbl -0x1d(%rbp),%edi
call   1040 <biosal_dna_helper_complement_nucleotide@plt>
mov    %al,-0x1e(%rbp)
mov    -0x1e(%rbp),%dl
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x18(%rbp)
jmp    114c <biosal_dna_helper_reverse_complement+0x2c>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
movb   $0x0,(%rax,%rcx,1)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<biosal_dna_helper_reverse_complement>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %rsi,%r14
mov    %rdi,%r12
call   1030 <strlen@plt>
test   %eax,%eax
jle    116b <biosal_dna_helper_reverse_complement+0x4b>
mov    %eax,%r15d
mov    %r14,%r13
mov    %r15,%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movsbl -0x1(%r12,%rbx,1),%edi
call   1040 <biosal_dna_helper_complement_nucleotide@plt>
mov    %al,0x0(%r13)
add    $0x1,%r13
add    $0xffffffffffffffff,%rbx
jne    1150 <biosal_dna_helper_reverse_complement+0x30>
jmp    116e <biosal_dna_helper_reverse_complement+0x4e>
xor    %r15d,%r15d
movb   $0x0,(%r14,%r15,1)
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @biosal_dna_helper_reverse_complement(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i8
%9 = alloca i8
store i8* %0, i8** %3
store i8* %1, i8** %4
%10 = load i8*, i8** %3
%11 = call i32 @strlen(i8* %10)
store i32 %11, i32* %5
%12 = load i32, i32* %5
%13 = sub nsw i32 %12, 1
store i32 %13, i32* %6
store i32 0, i32* %7
br label %14
14: ; preds = %18, %2
%15 = load i32, i32* %7
%16 = load i32, i32* %5
%17 = icmp slt i32 %15, %16
br i1 %17, label %18, label %35
18: ; preds = %14
%19 = load i8*, i8** %3
%20 = load i32, i32* %6
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds i8, i8* %19, i64 %21
%23 = load i8, i8* %22
store i8 %23, i8* %8
%24 = load i8, i8* %8
%25 = call signext i8 @biosal_dna_helper_complement_nucleotide(i8 signext %24)
store i8 %25, i8* %9
%26 = load i8, i8* %9
%27 = load i8*, i8** %4
%28 = load i32, i32* %7
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds i8, i8* %27, i64 %29
store i8 %26, i8* %30
%31 = load i32, i32* %7
%32 = add nsw i32 %31, 1
store i32 %32, i32* %7
%33 = load i32, i32* %6
%34 = add nsw i32 %33, -1
store i32 %34, i32* %6
br label %14
35: ; preds = %14
%36 = load i8*, i8** %4
%37 = load i32, i32* %7
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds i8, i8* %36, i64 %38
store i8 0, i8* %39
ret void
}

LLVM IR (-O2):
define void @biosal_dna_helper_reverse_complement(i8* %0, i8* nocapture writeonly %1) {
%3 = tail call i32 @strlen(i8* %0)
%4 = icmp sgt i32 %3, 0
br i1 %4, label %5, label %20
5: ; preds = %2
%6 = zext i32 %3 to i64
%7 = zext i32 %3 to i64
br label %8
8: ; preds = %5, %8
%9 = phi i64 [ 0, %5 ], [ %16, %8 ]
%10 = phi i64 [ %6, %5 ], [ %11, %8 ]
%11 = add nsw i64 %10, -1
%12 = getelementptr inbounds i8, i8* %0, i64 %11
%13 = load i8, i8* %12
%14 = tail call signext i8 @biosal_dna_helper_complement_nucleotide(i8 signext %13)
%15 = getelementptr inbounds i8, i8* %1, i64 %9
store i8 %14, i8* %15
%16 = add nuw nsw i64 %9, 1
%17 = icmp eq i64 %16, %7
br i1 %17, label %18, label %8
18: ; preds = %8
%19 = zext i32 %3 to i64
br label %20
20: ; preds = %2, %18
%21 = phi i64 [ %19, %18 ], [ 0, %2 ]
%22 = getelementptr inbounds i8, i8* %1, i64 %21
store i8 0, i8* %22
ret void
}