#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 *malloc(int);
int /*<<< orphan*/ memcpy(char *, char *, int);
int /*<<< orphan*/ printf(char *, int, int);
char *reverseComplement(char *, int);
scalar_t__ strcmp(char *, char *);
int *restrictionEnzymes(char *dnaBuff, int dnaLen) {
  int minSize = 4;
  int maxSize = 12;
  int i = 0;
  int *positionLengthPair = malloc(sizeof(int) * (dnaLen * 2));
  for (i = 0; i < dnaLen; i++) {
    int j = 0;
    for (j = minSize; j <= maxSize; j++) {
      char *subseq = malloc(sizeof(char) * (j + 1));
      memcpy(subseq, &dnaBuff[i], j);
      char *reverseComp = reverseComplement(subseq, j + 1);
      if (strcmp(subseq, reverseComp) == 0)
        printf("%d %d\n", i + 1, j);
    }
  }
  return positionLengthPair;
}


x86 assembly (clang, -O0):
<restrictionEnzymes>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movl   $0x4,-0x10(%rbp)
movl   $0xc,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0xc(%rbp),%eax
shl    $0x1,%eax
cltq
shl    $0x2,%rax
mov    %eax,%edi
call   1060 <malloc@plt>
mov    %rax,-0x20(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    124a <restrictionEnzymes+0xfa>
movl   $0x0,-0x24(%rbp)
mov    -0x10(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x14(%rbp),%eax
jg     1237 <restrictionEnzymes+0xe7>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
cltq
shl    $0x0,%rax
mov    %eax,%edi
call   1060 <malloc@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rdi
mov    -0x8(%rbp),%rsi
movslq -0x18(%rbp),%rax
add    %rax,%rsi
mov    -0x24(%rbp),%edx
call   1050 <memcpy@plt>
mov    -0x30(%rbp),%rdi
mov    -0x24(%rbp),%esi
add    $0x1,%esi
call   1070 <reverseComplement@plt>
mov    %rax,-0x38(%rbp)
mov    -0x30(%rbp),%rdi
mov    -0x38(%rbp),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    1224 <restrictionEnzymes+0xd4>
mov    -0x18(%rbp),%esi
add    $0x1,%esi
mov    -0x24(%rbp),%edx
lea    0xde1(%rip),%rdi
call   1030 <printf@plt>
jmp    1229 <restrictionEnzymes+0xd9>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    11ab <restrictionEnzymes+0x5b>
jmp    123c <restrictionEnzymes+0xec>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1192 <restrictionEnzymes+0x42>
mov    -0x20(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<restrictionEnzymes>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %esi,%ebx
mov    %rdi,0x10(%rsp)
lea    0x0(,%rbx,8),%edi
call   1060 <malloc@plt>
mov    %rax,(%rsp)
test   %ebx,%ebx
jle    11fe <restrictionEnzymes+0xae>
mov    %ebx,%eax
mov    %rax,0x8(%rsp)
xor    %r13d,%r13d
lea    0xe72(%rip),%r12
jmp    1197 <restrictionEnzymes+0x47>
cmp    0x8(%rsp),%r13
je     11fe <restrictionEnzymes+0xae>
mov    0x10(%rsp),%rax
lea    (%rax,%r13,1),%rbx
add    $0x1,%r13
mov    $0x5,%ebp
jmp    11b8 <restrictionEnzymes+0x68>
nopl   0x0(%rax,%rax,1)
add    $0x1,%ebp
cmp    $0xe,%ebp
je     1190 <restrictionEnzymes+0x40>
lea    -0x1(%rbp),%r14d
mov    %ebp,%edi
call   1060 <malloc@plt>
mov    %rax,%r15
mov    %rax,%rdi
mov    %rbx,%rsi
mov    %r14d,%edx
call   1050 <memcpy@plt>
mov    %r15,%rdi
mov    %ebp,%esi
call   1070 <reverseComplement@plt>
mov    %r15,%rdi
mov    %rax,%rsi
call   1040 <strcmp@plt>
test   %rax,%rax
jne    11b0 <restrictionEnzymes+0x60>
mov    %r12,%rdi
mov    %r13d,%esi
mov    %r14d,%edx
call   1030 <printf@plt>
jmp    11b0 <restrictionEnzymes+0x60>
mov    (%rsp),%rax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [7 x i8] c"%d %d\0A\00"
define i32* @restrictionEnzymes(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32*
%9 = alloca i32
%10 = alloca i8*
%11 = alloca i8*
store i8* %0, i8** %3
store i32 %1, i32* %4
store i32 4, i32* %5
store i32 12, i32* %6
store i32 0, i32* %7
%12 = load i32, i32* %4
%13 = mul nsw i32 %12, 2
%14 = sext i32 %13 to i64
%15 = mul i64 4, %14
%16 = trunc i64 %15 to i32
%17 = call i8* @malloc(i32 %16)
%18 = bitcast i8* %17 to i32*
store i32* %18, i32** %8
store i32 0, i32* %7
br label %19
19: ; preds = %61, %2
%20 = load i32, i32* %7
%21 = load i32, i32* %4
%22 = icmp slt i32 %20, %21
br i1 %22, label %23, label %64
23: ; preds = %19
store i32 0, i32* %9
%24 = load i32, i32* %5
store i32 %24, i32* %9
br label %25
25: ; preds = %57, %23
%26 = load i32, i32* %9
%27 = load i32, i32* %6
%28 = icmp sle i32 %26, %27
br i1 %28, label %29, label %60
29: ; preds = %25
%30 = load i32, i32* %9
%31 = add nsw i32 %30, 1
%32 = sext i32 %31 to i64
%33 = mul i64 1, %32
%34 = trunc i64 %33 to i32
%35 = call i8* @malloc(i32 %34)
store i8* %35, i8** %10
%36 = load i8*, i8** %10
%37 = load i8*, i8** %3
%38 = load i32, i32* %7
%39 = sext i32 %38 to i64
%40 = getelementptr inbounds i8, i8* %37, i64 %39
%41 = load i32, i32* %9
%42 = call i32 @memcpy(i8* %36, i8* %40, i32 %41)
%43 = load i8*, i8** %10
%44 = load i32, i32* %9
%45 = add nsw i32 %44, 1
%46 = call i8* @reverseComplement(i8* %43, i32 %45)
store i8* %46, i8** %11
%47 = load i8*, i8** %10
%48 = load i8*, i8** %11
%49 = call i64 @strcmp(i8* %47, i8* %48)
%50 = icmp eq i64 %49, 0
br i1 %50, label %51, label %56
51: ; preds = %29
%52 = load i32, i32* %7
%53 = add nsw i32 %52, 1
%54 = load i32, i32* %9
%55 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 %53, i32 %54)
br label %56
56: ; preds = %51, %29
br label %57
57: ; preds = %56
%58 = load i32, i32* %9
%59 = add nsw i32 %58, 1
store i32 %59, i32* %9
br label %25
60: ; preds = %25
br label %61
61: ; preds = %60
%62 = load i32, i32* %7
%63 = add nsw i32 %62, 1
store i32 %63, i32* %7
br label %19
64: ; preds = %19
%65 = load i32*, i32** %8
ret i32* %65
}

LLVM IR (-O2):
@.str = [7 x i8] c"%d %d\0A\00"
define noalias i32* @restrictionEnzymes(i8* %0, i32 %1) {
%3 = shl i32 %1, 3
%4 = tail call i8* @malloc(i32 %3)
%5 = icmp sgt i32 %1, 0
br i1 %5, label %6, label %27
6: ; preds = %2
%7 = zext i32 %1 to i64
br label %8
8: ; preds = %6, %25
%9 = phi i64 [ 0, %6 ], [ %11, %25 ]
%10 = getelementptr inbounds i8, i8* %0, i64 %9
%11 = add nuw nsw i64 %9, 1
%12 = trunc i64 %11 to i32
br label %13
13: ; preds = %8, %23
%14 = phi i32 [ 4, %8 ], [ %15, %23 ]
%15 = add nuw nsw i32 %14, 1
%16 = tail call i8* @malloc(i32 %15)
%17 = tail call i32 @memcpy(i8* %16, i8* %10, i32 %14)
%18 = tail call i8* @reverseComplement(i8* %16, i32 %15)
%19 = tail call i64 @strcmp(i8* %16, i8* %18)
%20 = icmp eq i64 %19, 0
br i1 %20, label %21, label %23
21: ; preds = %13
%22 = tail call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 %12, i32 %14)
br label %23
23: ; preds = %21, %13
%24 = icmp eq i32 %15, 13
br i1 %24, label %25, label %13
25: ; preds = %23
%26 = icmp eq i64 %11, %7
br i1 %26, label %27, label %8
27: ; preds = %25, %2
%28 = bitcast i8* %4 to i32*
ret i32* %28
}