#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_in_place(char *sequence) {
  int position;
  int length;
  int middle;
  char saved;
  int position2;
  length = strlen(sequence);
  middle = length / 2;
  position = 0;
  while (position < length) {
    sequence[position] =
        biosal_dna_helper_complement_nucleotide(sequence[position]);
    position++;
  }
  position = 0;
  while (position < middle) {
    position2 = length - 1 - position;
    saved = sequence[position2];
    sequence[position2] = sequence[position];
    sequence[position] = saved;
    position++;
  }
}


x86 assembly (clang, -O0):
<biosal_dna_helper_reverse_complement_in_place>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x14(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    1185 <biosal_dna_helper_reverse_complement_in_place+0x65>
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1040 <biosal_dna_helper_complement_nucleotide@plt>
mov    %al,%dl
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    114d <biosal_dna_helper_reverse_complement_in_place+0x2d>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    11e4 <biosal_dna_helper_reverse_complement_in_place+0xc4>
mov    -0x10(%rbp),%eax
sub    $0x1,%eax
sub    -0xc(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,1),%al
mov    %al,-0x15(%rbp)
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    (%rax,%rcx,1),%dl
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x15(%rbp),%dl
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    118c <biosal_dna_helper_reverse_complement_in_place+0x6c>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<biosal_dna_helper_reverse_complement_in_place>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rdi,%rbx
call   1030 <strlen@plt>
test   %eax,%eax
jle    11e1 <biosal_dna_helper_reverse_complement_in_place+0xc1>
mov    %eax,%r14d
mov    %eax,%r15d
shr    $0x1f,%r15d
add    %eax,%r15d
sar    %r15d
mov    %eax,%r12d
xor    %ebp,%ebp
nopl   (%rax)
movsbl (%rbx,%rbp,1),%edi
call   1040 <biosal_dna_helper_complement_nucleotide@plt>
mov    %al,(%rbx,%rbp,1)
add    $0x1,%rbp
cmp    %rbp,%r12
jne    1150 <biosal_dna_helper_reverse_complement_in_place+0x30>
cmp    $0x2,%r14d
jl     11e1 <biosal_dna_helper_reverse_complement_in_place+0xc1>
mov    %r15d,%r8d
mov    %r14d,%ecx
and    $0xfffffffe,%ecx
cmp    $0x2,%ecx
jne    117d <biosal_dna_helper_reverse_complement_in_place+0x5d>
xor    %ecx,%ecx
jmp    11c3 <biosal_dna_helper_reverse_complement_in_place+0xa3>
mov    %r8d,%ebp
and    $0xfffffffe,%ebp
lea    -0x2(%r14),%esi
xor    %ecx,%ecx
nopl   0x0(%rax)
lea    0x1(%rsi),%edi
movslq %edi,%rdi
movzbl (%rbx,%rdi,1),%eax
movzbl (%rbx,%rcx,1),%edx
mov    %dl,(%rbx,%rdi,1)
mov    %al,(%rbx,%rcx,1)
movslq %esi,%rsi
movzbl (%rbx,%rsi,1),%eax
movzbl 0x1(%rbx,%rcx,1),%edx
mov    %dl,(%rbx,%rsi,1)
mov    %al,0x1(%rbx,%rcx,1)
add    $0x2,%rcx
add    $0xfffffffe,%esi
cmp    %rcx,%rbp
jne    1190 <biosal_dna_helper_reverse_complement_in_place+0x70>
test   $0x1,%r8b
je     11e1 <biosal_dna_helper_reverse_complement_in_place+0xc1>
mov    %ecx,%eax
not    %eax
add    %eax,%r14d
movslq %r14d,%rax
mov    (%rbx,%rax,1),%sil
mov    (%rbx,%rcx,1),%dl
mov    %dl,(%rbx,%rax,1)
mov    %sil,(%rbx,%rcx,1)
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @biosal_dna_helper_reverse_complement_in_place(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8
%7 = alloca i32
store i8* %0, i8** %2
%8 = load i8*, i8** %2
%9 = call i32 @strlen(i8* %8)
store i32 %9, i32* %4
%10 = load i32, i32* %4
%11 = sdiv i32 %10, 2
store i32 %11, i32* %5
store i32 0, i32* %3
br label %12
12: ; preds = %16, %1
%13 = load i32, i32* %3
%14 = load i32, i32* %4
%15 = icmp slt i32 %13, %14
br i1 %15, label %16, label %29
16: ; preds = %12
%17 = load i8*, i8** %2
%18 = load i32, i32* %3
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds i8, i8* %17, i64 %19
%21 = load i8, i8* %20
%22 = call signext i8 @biosal_dna_helper_complement_nucleotide(i8 signext %21)
%23 = load i8*, i8** %2
%24 = load i32, i32* %3
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds i8, i8* %23, i64 %25
store i8 %22, i8* %26
%27 = load i32, i32* %3
%28 = add nsw i32 %27, 1
store i32 %28, i32* %3
br label %12
29: ; preds = %12
store i32 0, i32* %3
br label %30
30: ; preds = %34, %29
%31 = load i32, i32* %3
%32 = load i32, i32* %5
%33 = icmp slt i32 %31, %32
br i1 %33, label %34, label %60
34: ; preds = %30
%35 = load i32, i32* %4
%36 = sub nsw i32 %35, 1
%37 = load i32, i32* %3
%38 = sub nsw i32 %36, %37
store i32 %38, i32* %7
%39 = load i8*, i8** %2
%40 = load i32, i32* %7
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds i8, i8* %39, i64 %41
%43 = load i8, i8* %42
store i8 %43, i8* %6
%44 = load i8*, i8** %2
%45 = load i32, i32* %3
%46 = sext i32 %45 to i64
%47 = getelementptr inbounds i8, i8* %44, i64 %46
%48 = load i8, i8* %47
%49 = load i8*, i8** %2
%50 = load i32, i32* %7
%51 = sext i32 %50 to i64
%52 = getelementptr inbounds i8, i8* %49, i64 %51
store i8 %48, i8* %52
%53 = load i8, i8* %6
%54 = load i8*, i8** %2
%55 = load i32, i32* %3
%56 = sext i32 %55 to i64
%57 = getelementptr inbounds i8, i8* %54, i64 %56
store i8 %53, i8* %57
%58 = load i32, i32* %3
%59 = add nsw i32 %58, 1
store i32 %59, i32* %3
br label %30
60: ; preds = %30
ret void
}

LLVM IR (-O2):
define void @biosal_dna_helper_reverse_complement_in_place(i8* %0) {
%2 = tail call i32 @strlen(i8* %0)
%3 = sdiv i32 %2, 2
%4 = icmp sgt i32 %2, 0
br i1 %4, label %5, label %58
5: ; preds = %1
%6 = zext i32 %2 to i64
br label %16
7: ; preds = %16
%8 = icmp sgt i32 %2, 1
br i1 %8, label %9, label %58
9: ; preds = %7
%10 = zext i32 %3 to i64
%11 = and i64 %10, 1
%12 = and i32 %2, -2
%13 = icmp eq i32 %12, 2
br i1 %13, label %46, label %14
14: ; preds = %9
%15 = and i64 %10, 4294967294
br label %23
16: ; preds = %5, %16
%17 = phi i64 [ 0, %5 ], [ %21, %16 ]
%18 = getelementptr inbounds i8, i8* %0, i64 %17
%19 = load i8, i8* %18
%20 = tail call signext i8 @biosal_dna_helper_complement_nucleotide(i8 signext %19)
store i8 %20, i8* %18
%21 = add nuw nsw i64 %17, 1
%22 = icmp eq i64 %21, %6
br i1 %22, label %7, label %16
23: ; preds = %23, %14
%24 = phi i64 [ 0, %14 ], [ %43, %23 ]
%25 = phi i64 [ 0, %14 ], [ %44, %23 ]
%26 = trunc i64 %24 to i32
%27 = xor i32 %26, -1
%28 = add i32 %2, %27
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds i8, i8* %0, i64 %29
%31 = load i8, i8* %30
%32 = getelementptr inbounds i8, i8* %0, i64 %24
%33 = load i8, i8* %32
store i8 %33, i8* %30
store i8 %31, i8* %32
%34 = or i64 %24, 1
%35 = trunc i64 %34 to i32
%36 = xor i32 %35, -1
%37 = add i32 %2, %36
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds i8, i8* %0, i64 %38
%40 = load i8, i8* %39
%41 = getelementptr inbounds i8, i8* %0, i64 %34
%42 = load i8, i8* %41
store i8 %42, i8* %39
store i8 %40, i8* %41
%43 = add nuw nsw i64 %24, 2
%44 = add i64 %25, 2
%45 = icmp eq i64 %44, %15
br i1 %45, label %46, label %23
46: ; preds = %23, %9
%47 = phi i64 [ 0, %9 ], [ %43, %23 ]
%48 = icmp eq i64 %11, 0
br i1 %48, label %58, label %49
49: ; preds = %46
%50 = trunc i64 %47 to i32
%51 = xor i32 %50, -1
%52 = add i32 %2, %51
%53 = sext i32 %52 to i64
%54 = getelementptr inbounds i8, i8* %0, i64 %53
%55 = load i8, i8* %54
%56 = getelementptr inbounds i8, i8* %0, i64 %47
%57 = load i8, i8* %56
store i8 %57, i8* %54
store i8 %55, i8* %56
br label %58
58: ; preds = %49, %46, %1, %7
ret void
}