#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 */
void *get_char_comp(char);
int strlen(char *);
char *revcomp(char *str) {
  char *left = str;
  char *right = left + strlen(str) - 1;
  char tmp;
  while (left < right) {
    tmp = get_char_comp(*left);
    *(left++) = get_char_comp(*right);
    *(right--) = tmp;
  }
  return str;
}


x86 assembly (clang, -O0):
<revcomp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x28(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
add    $0xffffffffffffffff,%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
cmp    -0x18(%rbp),%rax
jae    11ae <revcomp+0x8e>
mov    -0x10(%rbp),%rax
movsbl (%rax),%edi
call   1040 <get_char_comp@plt>
mov    %al,-0x19(%rbp)
mov    -0x18(%rbp),%rax
movsbl (%rax),%edi
call   1040 <get_char_comp@plt>
mov    %al,%cl
mov    -0x10(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x10(%rbp)
mov    %cl,(%rax)
mov    -0x19(%rbp),%cl
mov    -0x18(%rbp),%rax
mov    %rax,%rdx
add    $0xffffffffffffffff,%rdx
mov    %rdx,-0x18(%rbp)
mov    %cl,(%rax)
jmp    1159 <revcomp+0x39>
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<revcomp>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdi,%r14
call   1030 <strlen@plt>
cltq
lea    (%r14,%rax,1),%rbx
add    $0xffffffffffffffff,%rbx
cmp    %r14,%rbx
jbe    117f <revcomp+0x5f>
lea    0x1(%r14),%r12
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movsbl -0x1(%r12),%edi
call   1040 <get_char_comp@plt>
mov    %rax,%r15
movsbl (%rbx),%edi
call   1040 <get_char_comp@plt>
mov    %al,-0x1(%r12)
mov    %r15b,(%rbx)
add    $0xffffffffffffffff,%rbx
lea    0x1(%r12),%rax
cmp    %rbx,%r12
mov    %rax,%r12
jb     1150 <revcomp+0x30>
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
define i8* @revcomp(i8* returned %0) {
%2 = tail call i32 @strlen(i8* %0)
%3 = sext i32 %2 to i64
%4 = getelementptr inbounds i8, i8* %0, i64 %3
%5 = getelementptr inbounds i8, i8* %4, i64 -1
%6 = icmp ugt i8* %5, %0
br i1 %6, label %7, label %21
7: ; preds = %1, %7
%8 = phi i8* [ %19, %7 ], [ %5, %1 ]
%9 = phi i8* [ %18, %7 ], [ %0, %1 ]
%10 = load i8, i8* %9
%11 = tail call i8* @get_char_comp(i8 signext %10)
%12 = ptrtoint i8* %11 to i64
%13 = trunc i64 %12 to i8
%14 = load i8, i8* %8
%15 = tail call i8* @get_char_comp(i8 signext %14)
%16 = ptrtoint i8* %15 to i64
%17 = trunc i64 %16 to i8
%18 = getelementptr inbounds i8, i8* %9, i64 1
store i8 %17, i8* %9
store i8 %13, i8* %8
%19 = getelementptr inbounds i8, i8* %8, i64 -1
%20 = icmp ult i8* %18, %19
br i1 %20, label %7, label %21
21: ; preds = %7, %1
ret i8* %0
}