#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 comp(char);
int strlen(char *);
void revComplement(char *a) {
  int length = strlen(a);
  char lft;
  int i;
  for (i = 0; i < length / 2; i++) {
    lft = a[i];
    a[i] = comp(a[length - i - 1]);
    a[length - i - 1] = comp(lft);
  }
  if (length % 2)
    a[length / 2] = comp(a[length / 2]);
}


x86 assembly (clang, -O0):
<revComplement>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0xc(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0xc(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x18(%rbp),%eax
cmp    %ecx,%eax
jge    11bd <revComplement+0x9d>
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,1),%al
mov    %al,-0xd(%rbp)
mov    -0x8(%rbp),%rax
mov    -0xc(%rbp),%ecx
sub    -0x14(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%edi
call   1030 <comp@plt>
mov    %al,%dl
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
movsbl -0xd(%rbp),%edi
call   1030 <comp@plt>
mov    %al,%dl
mov    -0x8(%rbp),%rax
mov    -0xc(%rbp),%ecx
sub    -0x14(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    113f <revComplement+0x1f>
mov    -0xc(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
je     121b <revComplement+0xfb>
mov    -0x8(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0xc(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x30(%rbp),%rax
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%edi
call   1030 <comp@plt>
mov    %al,-0x21(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0xc(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    -0x21(%rbp),%dl
mov    %eax,%ecx
mov    -0x20(%rbp),%rax
movslq %ecx,%rcx
mov    %dl,(%rax,%rcx,1)
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<revComplement>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdi,%r13
call   1040 <strlen@plt>
mov    %eax,%r15d
shr    $0x1f,%r15d
add    %eax,%r15d
sar    %r15d
mov    %eax,0x4(%rsp)
cmp    $0x2,%eax
jl     1191 <revComplement+0x71>
mov    %r15d,%r12d
mov    0x4(%rsp),%eax
mov    %eax,%ebx
add    $0xffffffff,%ebx
xor    %r14d,%r14d
nopl   0x0(%rax,%rax,1)
movsbl 0x0(%r13,%r14,1),%ebp
movslq %ebx,%rbx
movsbl 0x0(%r13,%rbx,1),%edi
call   1030 <comp@plt>
mov    %al,0x0(%r13,%r14,1)
mov    %ebp,%edi
call   1030 <comp@plt>
mov    %al,0x0(%r13,%rbx,1)
add    $0x1,%r14
add    $0xffffffff,%ebx
cmp    %r14,%r12
jne    1160 <revComplement+0x40>
testb  $0x1,0x4(%rsp)
je     11ab <revComplement+0x8b>
movslq %r15d,%rbx
movsbl 0x0(%r13,%rbx,1),%edi
call   1030 <comp@plt>
mov    %al,0x0(%r13,%rbx,1)
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define void @revComplement(i8* %0) {
%2 = tail call i32 @strlen(i8* %0)
%3 = sdiv i32 %2, 2
%4 = icmp sgt i32 %2, 1
br i1 %4, label %5, label %21
5: ; preds = %1
%6 = zext i32 %3 to i64
br label %7
7: ; preds = %5, %7
%8 = phi i64 [ 0, %5 ], [ %19, %7 ]
%9 = getelementptr inbounds i8, i8* %0, i64 %8
%10 = load i8, i8* %9
%11 = trunc i64 %8 to i32
%12 = xor i32 %11, -1
%13 = add i32 %2, %12
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds i8, i8* %0, i64 %14
%16 = load i8, i8* %15
%17 = tail call signext i8 @comp(i8 signext %16)
store i8 %17, i8* %9
%18 = tail call signext i8 @comp(i8 signext %10)
store i8 %18, i8* %15
%19 = add nuw nsw i64 %8, 1
%20 = icmp eq i64 %19, %6
br i1 %20, label %21, label %7
21: ; preds = %7, %1
%22 = and i32 %2, 1
%23 = icmp eq i32 %22, 0
br i1 %23, label %29, label %24
24: ; preds = %21
%25 = sext i32 %3 to i64
%26 = getelementptr inbounds i8, i8* %0, i64 %25
%27 = load i8, i8* %26
%28 = tail call signext i8 @comp(i8 signext %27)
store i8 %28, i8* %26
br label %29
29: ; preds = %24, %21
ret void
}