#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 */
typedef int /*<<< orphan*/ choppyCopy;
typedef int /*<<< orphan*/ alleles;

/* Variables and functions */
int chopByChar(char *, char, char **, int);
scalar_t__ isAllNt(char *, int);
int /*<<< orphan*/ memmove(char *, char *, int);
char *needMem(int);
int /*<<< orphan*/ reverseComplement(char *, int);
int /*<<< orphan*/ safecat(char *, int, char *);
int /*<<< orphan*/ safecpy(char *, int, char *);
scalar_t__ startsWith(char *, char *);
int strlen(char *);
char *reverseComplementSlashSeparated(char *alleleStr) {
  int len = strlen(alleleStr);
  char choppyCopy[len + 1];
  safecpy(choppyCopy, sizeof(choppyCopy), alleleStr);
  char *alleles[len];
  int alCount = chopByChar(choppyCopy, '/', alleles,
                           (sizeof(alleles) / sizeof((alleles)[0])));
  char *outStr = needMem(len + 1);
  int i;
  for (i = alCount - 1; i >= 0; i--) {
    char *allele = alleles[i];
    int alLen = strlen(allele);
    if (isAllNt(allele, alLen))
      reverseComplement(allele, alLen);
    if (i != alCount - 1)
      safecat(outStr, len + 1, "/");
    safecat(outStr, len + 1, allele);
  }
  if (startsWith("-/", alleleStr)) {
    memmove(outStr + 2, outStr, len - 2);
    outStr[0] = '-';
    outStr[1] = '/';
  }
  return outStr;
}


x86 assembly (clang, -O0):
<reverseComplementSlashSeparated>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%esi
add    $0x1,%esi
mov    %esi,%eax
mov    %rsp,%rcx
mov    %rcx,-0x18(%rbp)
mov    %rax,%rcx
add    $0xf,%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%rdi
sub    %rcx,%rdi
mov    %rdi,-0x60(%rbp)
mov    %rdi,%rsp
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rdx
call   1050 <safecpy@plt>
mov    -0x60(%rbp),%rdi
mov    -0xc(%rbp),%eax
lea    0xf(,%rax,8),%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%rdx
sub    %rcx,%rdx
mov    %rdx,-0x58(%rbp)
mov    %rdx,%rsp
mov    %rax,-0x28(%rbp)
shl    $0x3,%rax
shr    $0x3,%rax
mov    %eax,%ecx
mov    $0x2f,%esi
call   10a0 <chopByChar@plt>
mov    %eax,-0x2c(%rbp)
mov    -0xc(%rbp),%edi
add    $0x1,%edi
call   1060 <needMem@plt>
mov    %rax,-0x38(%rbp)
mov    -0x2c(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x3c(%rbp)
cmpl   $0x0,-0x3c(%rbp)
jl     12bf <reverseComplementSlashSeparated+0x12f>
mov    -0x58(%rbp),%rax
movslq -0x3c(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x48(%rbp)
mov    -0x48(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x4c(%rbp)
mov    -0x48(%rbp),%rdi
mov    -0x4c(%rbp),%esi
call   10b0 <isAllNt@plt>
cmp    $0x0,%rax
je     1277 <reverseComplementSlashSeparated+0xe7>
mov    -0x48(%rbp),%rdi
mov    -0x4c(%rbp),%esi
call   1090 <reverseComplement@plt>
mov    -0x3c(%rbp),%eax
mov    -0x2c(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
je     129e <reverseComplementSlashSeparated+0x10e>
mov    -0x38(%rbp),%rdi
mov    -0xc(%rbp),%esi
add    $0x1,%esi
lea    0xd68(%rip),%rdx
call   1070 <safecat@plt>
mov    -0x38(%rbp),%rdi
mov    -0xc(%rbp),%esi
add    $0x1,%esi
mov    -0x48(%rbp),%rdx
call   1070 <safecat@plt>
mov    -0x3c(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x3c(%rbp)
jmp    122f <reverseComplementSlashSeparated+0x9f>
mov    -0x8(%rbp),%rsi
lea    0xd36(%rip),%rdi
call   1030 <startsWith@plt>
cmp    $0x0,%rax
je     12ff <reverseComplementSlashSeparated+0x16f>
mov    -0x38(%rbp),%rdi
add    $0x2,%rdi
mov    -0x38(%rbp),%rsi
mov    -0xc(%rbp),%edx
sub    $0x2,%edx
call   1080 <memmove@plt>
mov    -0x38(%rbp),%rax
movb   $0x2d,(%rax)
mov    -0x38(%rbp),%rax
movb   $0x2f,0x1(%rax)
mov    -0x38(%rbp),%rax
mov    -0x18(%rbp),%rcx
mov    %rcx,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<reverseComplementSlashSeparated>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rdi,%r15
call   1040 <strlen@plt>
mov    %eax,%r14d
lea    0x1(%r14),%r12d
mov    %rsp,%rbx
lea    0xf(%r12),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rbx
mov    %rbx,%rsp
mov    %rbx,%rdi
mov    %r12d,%esi
mov    %r15,-0x40(%rbp)
mov    %r15,%rdx
call   1050 <safecpy@plt>
mov    %r14d,%eax
mov    %rsp,%rdx
lea    0xf(,%rax,8),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rdx
mov    %rdx,%rsp
mov    %rbx,%rdi
mov    $0x2f,%esi
mov    %rdx,-0x30(%rbp)
mov    %r14,-0x38(%rbp)
mov    %r14d,%ecx
call   10a0 <chopByChar@plt>
mov    %eax,%r14d
mov    %r12d,%edi
call   1060 <needMem@plt>
mov    %rax,%rbx
test   %r14d,%r14d
jle    12ca <reverseComplementSlashSeparated+0x13a>
add    $0xffffffff,%r14d
mov    -0x30(%rbp),%rax
mov    (%rax,%r14,8),%r15
mov    %r15,%rdi
call   1040 <strlen@plt>
mov    %eax,%r13d
mov    %r15,%rdi
mov    %eax,%esi
call   10b0 <isAllNt@plt>
test   %rax,%rax
je     124c <reverseComplementSlashSeparated+0xbc>
mov    %r15,%rdi
mov    %r13d,%esi
call   1090 <reverseComplement@plt>
mov    %rbx,%rdi
mov    %r12d,%esi
mov    %r15,%rdx
call   1070 <safecat@plt>
test   %r14,%r14
je     12ca <reverseComplementSlashSeparated+0x13a>
add    $0x1,%r14
jmp    129a <reverseComplementSlashSeparated+0x10a>
cs nopw 0x0(%rax,%rax,1)
nop
mov    %rbx,%rdi
mov    %r12d,%esi
lea    0xd84(%rip),%rdx
call   1070 <safecat@plt>
mov    %rbx,%rdi
mov    %r12d,%esi
mov    %r15,%rdx
call   1070 <safecat@plt>
add    $0xffffffffffffffff,%r14
cmp    $0x1,%r14
jbe    12ca <reverseComplementSlashSeparated+0x13a>
mov    -0x30(%rbp),%rax
mov    -0x10(%rax,%r14,8),%r15
mov    %r15,%rdi
call   1040 <strlen@plt>
mov    %eax,%r13d
mov    %r15,%rdi
mov    %eax,%esi
call   10b0 <isAllNt@plt>
test   %rax,%rax
je     1270 <reverseComplementSlashSeparated+0xe0>
mov    %r15,%rdi
mov    %r13d,%esi
call   1090 <reverseComplement@plt>
jmp    1270 <reverseComplementSlashSeparated+0xe0>
lea    0xd2f(%rip),%rdi
mov    -0x40(%rbp),%rsi
call   1030 <startsWith@plt>
test   %rax,%rax
je     12fa <reverseComplementSlashSeparated+0x16a>
mov    %rbx,%rdi
add    $0x2,%rdi
mov    -0x38(%rbp),%rdx
add    $0xfffffffe,%edx
mov    %rbx,%rsi
call   1080 <memmove@plt>
movw   $0x2f2d,(%rbx)
mov    %rbx,%rax
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c"/\00"
@.str.1 = [3 x i8] c"-/\00"
define i8* @reverseComplementSlashSeparated(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i64
%6 = alloca i64
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i8*
%11 = alloca i32
store i8* %0, i8** %2
%12 = load i8*, i8** %2
%13 = call i32 @strlen(i8* %12)
store i32 %13, i32* %3
%14 = load i32, i32* %3
%15 = add nsw i32 %14, 1
%16 = zext i32 %15 to i64
%17 = call i8* @llvm.stacksave()
store i8* %17, i8** %4
%18 = alloca i8, i64 %16
store i64 %16, i64* %5
%19 = trunc i64 %16 to i32
%20 = load i8*, i8** %2
%21 = call i32 @safecpy(i8* %18, i32 %19, i8* %20)
%22 = load i32, i32* %3
%23 = zext i32 %22 to i64
%24 = alloca i8*, i64 %23
store i64 %23, i64* %6
%25 = mul nuw i64 8, %23
%26 = udiv i64 %25, 8
%27 = trunc i64 %26 to i32
%28 = call i32 @chopByChar(i8* %18, i8 signext 47, i8** %24, i32 %27)
store i32 %28, i32* %7
%29 = load i32, i32* %3
%30 = add nsw i32 %29, 1
%31 = call i8* @needMem(i32 %30)
store i8* %31, i8** %8
%32 = load i32, i32* %7
%33 = sub nsw i32 %32, 1
store i32 %33, i32* %9
br label %34
34: ; preds = %68, %1
%35 = load i32, i32* %9
%36 = icmp sge i32 %35, 0
br i1 %36, label %37, label %71
37: ; preds = %34
%38 = load i32, i32* %9
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds i8*, i8** %24, i64 %39
%41 = load i8*, i8** %40
store i8* %41, i8** %10
%42 = load i8*, i8** %10
%43 = call i32 @strlen(i8* %42)
store i32 %43, i32* %11
%44 = load i8*, i8** %10
%45 = load i32, i32* %11
%46 = call i64 @isAllNt(i8* %44, i32 %45)
%47 = icmp ne i64 %46, 0
br i1 %47, label %48, label %52
48: ; preds = %37
%49 = load i8*, i8** %10
%50 = load i32, i32* %11
%51 = call i32 @reverseComplement(i8* %49, i32 %50)
br label %52
52: ; preds = %48, %37
%53 = load i32, i32* %9
%54 = load i32, i32* %7
%55 = sub nsw i32 %54, 1
%56 = icmp ne i32 %53, %55
br i1 %56, label %57, label %62
57: ; preds = %52
%58 = load i8*, i8** %8
%59 = load i32, i32* %3
%60 = add nsw i32 %59, 1
%61 = call i32 @safecat(i8* %58, i32 %60, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
br label %62
62: ; preds = %57, %52
%63 = load i8*, i8** %8
%64 = load i32, i32* %3
%65 = add nsw i32 %64, 1
%66 = load i8*, i8** %10
%67 = call i32 @safecat(i8* %63, i32 %65, i8* %66)
br label %68
68: ; preds = %62
%69 = load i32, i32* %9
%70 = add nsw i32 %69, -1
store i32 %70, i32* %9
br label %34
71: ; preds = %34
%72 = load i8*, i8** %2
%73 = call i64 @startsWith(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %72)
%74 = icmp ne i64 %73, 0
br i1 %74, label %75, label %86
75: ; preds = %71
%76 = load i8*, i8** %8
%77 = getelementptr inbounds i8, i8* %76, i64 2
%78 = load i8*, i8** %8
%79 = load i32, i32* %3
%80 = sub nsw i32 %79, 2
%81 = call i32 @memmove(i8* %77, i8* %78, i32 %80)
%82 = load i8*, i8** %8
%83 = getelementptr inbounds i8, i8* %82, i64 0
store i8 45, i8* %83
%84 = load i8*, i8** %8
%85 = getelementptr inbounds i8, i8* %84, i64 1
store i8 47, i8* %85
br label %86
86: ; preds = %75, %71
%87 = load i8*, i8** %8
%88 = load i8*, i8** %4
ret i8* %87
}

LLVM IR (-O2):
@.str = [2 x i8] c"/\00"
@.str.1 = [3 x i8] c"-/\00"
define i8* @reverseComplementSlashSeparated(i8* %0) {
%2 = tail call i32 @strlen(i8* %0)
%3 = add nsw i32 %2, 1
%4 = zext i32 %3 to i64
%5 = alloca i8, i64 %4
%6 = call i32 @safecpy(i8* %5, i32 %3, i8* %0)
%7 = zext i32 %2 to i64
%8 = alloca i8*, i64 %7
%9 = call i32 @chopByChar(i8* %5, i8 signext 47, i8** %8, i32 %2)
%10 = call i8* @needMem(i32 %3)
%11 = icmp sgt i32 %9, 0
br i1 %11, label %12, label %39
12: ; preds = %1
%13 = add nsw i32 %9, -1
%14 = zext i32 %13 to i64
%15 = getelementptr inbounds i8*, i8** %8, i64 %14
%16 = load i8*, i8** %15
%17 = call i32 @strlen(i8* %16)
%18 = call i64 @isAllNt(i8* %16, i32 %17)
%19 = icmp eq i64 %18, 0
br i1 %19, label %22, label %20
20: ; preds = %12
%21 = call i32 @reverseComplement(i8* %16, i32 %17)
br label %22
22: ; preds = %12, %20
%23 = call i32 @safecat(i8* %10, i32 %3, i8* %16)
%24 = icmp eq i32 %13, 0
br i1 %24, label %39, label %25
25: ; preds = %22, %35
%26 = phi i64 [ %27, %35 ], [ %14, %22 ]
%27 = add nsw i64 %26, -1
%28 = getelementptr inbounds i8*, i8** %8, i64 %27
%29 = load i8*, i8** %28
%30 = call i32 @strlen(i8* %29)
%31 = call i64 @isAllNt(i8* %29, i32 %30)
%32 = icmp eq i64 %31, 0
br i1 %32, label %35, label %33
33: ; preds = %25
%34 = call i32 @reverseComplement(i8* %29, i32 %30)
br label %35
35: ; preds = %33, %25
%36 = call i32 @safecat(i8* %10, i32 %3, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%37 = call i32 @safecat(i8* %10, i32 %3, i8* %29)
%38 = icmp ugt i64 %26, 1
br i1 %38, label %25, label %39
39: ; preds = %35, %22, %1
%40 = call i64 @startsWith(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %0)
%41 = icmp eq i64 %40, 0
br i1 %41, label %47, label %42
42: ; preds = %39
%43 = getelementptr inbounds i8, i8* %10, i64 2
%44 = add nsw i32 %2, -2
%45 = call i32 @memmove(i8* %43, i8* %10, i32 %44)
store i8 45, i8* %10
%46 = getelementptr inbounds i8, i8* %10, i64 1
store i8 47, i8* %46
br label %47
47: ; preds = %42, %39
ret i8* %10
}