#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 strlen(char *);
void rev_comp(char *data, char *cdata) {
  int n = strlen(data);
  char *p = data + (n - 1);
  char *pc = cdata;
  while (n--) {
    *(pc++) = compl(*(p--));
  }
  *pc = 0;
}


x86 assembly (clang, -O0):
<rev_comp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%rax
mov    -0x14(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x14(%rbp)
cmp    $0x0,%eax
je     119d <rev_comp+0x7d>
mov    -0x20(%rbp),%rax
mov    %rax,%rcx
add    $0xffffffffffffffff,%rcx
mov    %rcx,-0x20(%rbp)
movsbl (%rax),%edi
mov    $0x0,%al
call   1040 <compl@plt>
mov    %al,%cl
mov    -0x28(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x28(%rbp)
mov    %cl,(%rax)
jmp    1158 <rev_comp+0x38>
mov    -0x28(%rbp),%rax
movb   $0x0,(%rax)
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rev_comp>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r12
mov    %rdi,%r15
call   1030 <strlen@plt>
test   %eax,%eax
je     116d <rev_comp+0x4d>
mov    %eax,%r14d
cltq
add    %rax,%r15
add    $0xffffffffffffffff,%r15
neg    %r14d
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
movsbl (%r15,%rbx,1),%edi
xor    %eax,%eax
call   1040 <compl@plt>
mov    %al,(%r12)
add    $0x1,%r12
add    $0xffffffffffffffff,%rbx
cmp    %ebx,%r14d
jne    1150 <rev_comp+0x30>
movb   $0x0,(%r12)
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define void @rev_comp(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i8*
store i8* %0, i8** %3
store i8* %1, i8** %4
%8 = load i8*, i8** %3
%9 = call i32 @strlen(i8* %8)
store i32 %9, i32* %5
%10 = load i8*, i8** %3
%11 = load i32, i32* %5
%12 = sub nsw i32 %11, 1
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds i8, i8* %10, i64 %13
store i8* %14, i8** %6
%15 = load i8*, i8** %4
store i8* %15, i8** %7
br label %16
16: ; preds = %20, %2
%17 = load i32, i32* %5
%18 = add nsw i32 %17, -1
store i32 %18, i32* %5
%19 = icmp ne i32 %17, 0
br i1 %19, label %20, label %29
20: ; preds = %16
%21 = load i8*, i8** %6
%22 = getelementptr inbounds i8, i8* %21, i32 -1
store i8* %22, i8** %6
%23 = load i8, i8* %21
%24 = sext i8 %23 to i32
%25 = call i32 (i32, ...) bitcast (i32 (...)* @compl to i32 (i32, ...)*)(i32 %24)
%26 = trunc i32 %25 to i8
%27 = load i8*, i8** %7
%28 = getelementptr inbounds i8, i8* %27, i32 1
store i8* %28, i8** %7
store i8 %26, i8* %27
br label %16
29: ; preds = %16
%30 = load i8*, i8** %7
store i8 0, i8* %30
ret void
}

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