#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 complement(char);
void reverse_complement(char *p, size_t len) {
  char *pp = p + len - 1;
  while (p <= pp) {
    char tmp = *p;
    *p = complement(*pp);
    *pp = complement(tmp);
    p++;
    pp--;
  }
}


x86 assembly (clang, -O0):
<reverse_complement>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
add    -0x10(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%rax
cmp    -0x18(%rbp),%rax
ja     1189 <reverse_complement+0x79>
mov    -0x8(%rbp),%rax
mov    (%rax),%al
mov    %al,-0x19(%rbp)
mov    -0x18(%rbp),%rax
movsbl (%rax),%edi
call   1030 <complement@plt>
mov    %al,%cl
mov    -0x8(%rbp),%rax
mov    %cl,(%rax)
movsbl -0x19(%rbp),%edi
call   1030 <complement@plt>
mov    %al,%cl
mov    -0x18(%rbp),%rax
mov    %cl,(%rax)
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
mov    -0x18(%rbp),%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x18(%rbp)
jmp    1130 <reverse_complement+0x20>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<reverse_complement>:
push   %rbp
push   %r14
push   %rbx
lea    (%rdi,%rsi,1),%rbp
add    $0xffffffffffffffff,%rbp
cmp    %rdi,%rbp
jb     115c <reverse_complement+0x4c>
mov    %rdi,%rbx
add    $0x1,%rbx
nopl   0x0(%rax,%rax,1)
movsbl -0x1(%rbx),%r14d
movsbl 0x0(%rbp),%edi
call   1030 <complement@plt>
mov    %al,-0x1(%rbx)
mov    %r14d,%edi
call   1030 <complement@plt>
mov    %al,0x0(%rbp)
add    $0xffffffffffffffff,%rbp
lea    0x1(%rbx),%rax
cmp    %rbp,%rbx
mov    %rax,%rbx
jbe    1130 <reverse_complement+0x20>
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define void @reverse_complement(i8* %0, i64 %1) {
%3 = alloca i8*
%4 = alloca i64
%5 = alloca i8*
%6 = alloca i8
store i8* %0, i8** %3
store i64 %1, i64* %4
%7 = load i8*, i8** %3
%8 = load i64, i64* %4
%9 = getelementptr inbounds i8, i8* %7, i64 %8
%10 = getelementptr inbounds i8, i8* %9, i64 -1
store i8* %10, i8** %5
br label %11
11: ; preds = %15, %2
%12 = load i8*, i8** %3
%13 = load i8*, i8** %5
%14 = icmp ule i8* %12, %13
br i1 %14, label %15, label %29
15: ; preds = %11
%16 = load i8*, i8** %3
%17 = load i8, i8* %16
store i8 %17, i8* %6
%18 = load i8*, i8** %5
%19 = load i8, i8* %18
%20 = call signext i8 @complement(i8 signext %19)
%21 = load i8*, i8** %3
store i8 %20, i8* %21
%22 = load i8, i8* %6
%23 = call signext i8 @complement(i8 signext %22)
%24 = load i8*, i8** %5
store i8 %23, i8* %24
%25 = load i8*, i8** %3
%26 = getelementptr inbounds i8, i8* %25, i32 1
store i8* %26, i8** %3
%27 = load i8*, i8** %5
%28 = getelementptr inbounds i8, i8* %27, i32 -1
store i8* %28, i8** %5
br label %11
29: ; preds = %11
ret void
}

LLVM IR (-O2):
define void @reverse_complement(i8* %0, i64 %1) {
%3 = getelementptr inbounds i8, i8* %0, i64 %1
%4 = getelementptr inbounds i8, i8* %3, i64 -1
%5 = icmp ult i8* %4, %0
br i1 %5, label %16, label %6
6: ; preds = %2, %6
%7 = phi i8* [ %14, %6 ], [ %4, %2 ]
%8 = phi i8* [ %13, %6 ], [ %0, %2 ]
%9 = load i8, i8* %8
%10 = load i8, i8* %7
%11 = tail call signext i8 @complement(i8 signext %10)
store i8 %11, i8* %8
%12 = tail call signext i8 @complement(i8 signext %9)
store i8 %12, i8* %7
%13 = getelementptr inbounds i8, i8* %8, i64 1
%14 = getelementptr inbounds i8, i8* %7, i64 -1
%15 = icmp ugt i8* %13, %14
br i1 %15, label %16, label %6
16: ; preds = %6, %2
ret void
}