#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 */
scalar_t__ check_hairpin_min(char *, char *, int, int);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ reverse_string(char *, char *, int);
int check_hairpin(char *ss, int n) {
  int min;
  char flip[1024];
  if (n > 1000) {
    printf("\n Dude what's with a %d base primer .... PPPPLEEASE \n", n);
    exit(1);
  }
  reverse_string(ss, flip, n);
  for (min = 3; min <= n / 2 - 4; min++)
    if (check_hairpin_min(ss, flip, n, min))
      return 1;
  return 0;
}


x86 assembly (clang, -O0):
<check_hairpin>:
push   %rbp
mov    %rsp,%rbp
sub    $0x430,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
cmpl   $0x3e8,-0x14(%rbp)
jle    1178 <check_hairpin+0x38>
mov    -0x14(%rbp),%esi
lea    0xe97(%rip),%rdi
call   1040 <printf@plt>
mov    $0x1,%edi
call   1060 <exit@plt>
mov    -0x10(%rbp),%rdi
lea    -0x420(%rbp),%rsi
mov    -0x14(%rbp),%edx
call   1030 <reverse_string@plt>
movl   $0x3,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    %eax,-0x424(%rbp)
mov    -0x14(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x424(%rbp),%eax
sub    $0x4,%ecx
cmp    %ecx,%eax
jg     11f8 <check_hairpin+0xb8>
mov    -0x10(%rbp),%rdi
lea    -0x420(%rbp),%rsi
mov    -0x14(%rbp),%edx
mov    -0x18(%rbp),%ecx
call   1050 <check_hairpin_min@plt>
cmp    $0x0,%rax
je     11e5 <check_hairpin+0xa5>
movl   $0x1,-0x4(%rbp)
jmp    11ff <check_hairpin+0xbf>
jmp    11ea <check_hairpin+0xaa>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1192 <check_hairpin+0x52>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x430,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<check_hairpin>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x408,%rsp
mov    %esi,%r13d
cmp    $0x3e9,%esi
jge    11d4 <check_hairpin+0x94>
mov    %rdi,%r14
mov    %rsp,%rsi
mov    %r13d,%edx
call   1030 <reverse_string@plt>
xor    %r15d,%r15d
cmp    $0xe,%r13d
jl     11bf <check_hairpin+0x7f>
mov    %r13d,%ebx
shr    %ebx
and    $0x7fff,%ebx
neg    %ebx
mov    $0x3,%ebp
mov    %rsp,%r12
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    %r12,%rsi
mov    %r13d,%edx
mov    %ebp,%ecx
call   1050 <check_hairpin_min@plt>
test   %rax,%rax
jne    11b9 <check_hairpin+0x79>
lea    (%rbx,%rbp,1),%eax
add    $0x1,%eax
mov    %ebp,%ecx
add    $0x1,%ecx
mov    %ecx,%ebp
cmp    $0xfffffffd,%eax
jne    1190 <check_hairpin+0x50>
jmp    11bf <check_hairpin+0x7f>
mov    $0x1,%r15d
mov    %r15d,%eax
add    $0x408,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xe25(%rip),%rdi
mov    %r13d,%esi
call   1040 <printf@plt>
mov    $0x1,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@.str = [54 x i8] c"\0A Dude what's with a %d base primer .... PPPPLEEASE \0A\00"
define i32 @check_hairpin(i8* %0, i32 %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
%7 = alloca [1024 x i8]
store i8* %0, i8** %4
store i32 %1, i32* %5
%8 = load i32, i32* %5
%9 = icmp sgt i32 %8, 1000
br i1 %9, label %10, label %14
10: ; preds = %2
%11 = load i32, i32* %5
%12 = call i32 @printf(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str, i64 0, i64 0), i32 %11)
%13 = call i32 @exit(i32 1)
unreachable
14: ; preds = %2
%15 = load i8*, i8** %4
%16 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%17 = load i32, i32* %5
%18 = call i32 @reverse_string(i8* %15, i8* %16, i32 %17)
store i32 3, i32* %6
br label %19
19: ; preds = %34, %14
%20 = load i32, i32* %6
%21 = load i32, i32* %5
%22 = sdiv i32 %21, 2
%23 = sub nsw i32 %22, 4
%24 = icmp sle i32 %20, %23
br i1 %24, label %25, label %37
25: ; preds = %19
%26 = load i8*, i8** %4
%27 = getelementptr inbounds [1024 x i8], [1024 x i8]* %7, i64 0, i64 0
%28 = load i32, i32* %5
%29 = load i32, i32* %6
%30 = call i64 @check_hairpin_min(i8* %26, i8* %27, i32 %28, i32 %29)
%31 = icmp ne i64 %30, 0
br i1 %31, label %32, label %33
32: ; preds = %25
store i32 1, i32* %3
br label %38
33: ; preds = %25
br label %34
34: ; preds = %33
%35 = load i32, i32* %6
%36 = add nsw i32 %35, 1
store i32 %36, i32* %6
br label %19
37: ; preds = %19
store i32 0, i32* %3
br label %38
38: ; preds = %37, %32
%39 = load i32, i32* %3
ret i32 %39
}

LLVM IR (-O2):
@.str = [54 x i8] c"\0A Dude what's with a %d base primer .... PPPPLEEASE \0A\00"
define i32 @check_hairpin(i8* %0, i32 %1) {
%3 = alloca [1024 x i8]
%4 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%5 = icmp sgt i32 %1, 1000
br i1 %5, label %6, label %9
6: ; preds = %2
%7 = tail call i32 @printf(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str, i64 0, i64 0), i32 %1)
%8 = tail call i32 @exit(i32 1)
unreachable
9: ; preds = %2
%10 = call i32 @reverse_string(i8* %0, i8* %4, i32 %1)
%11 = icmp slt i32 %1, 14
br i1 %11, label %23, label %12
12: ; preds = %9
%13 = lshr i32 %1, 1
%14 = and i32 %13, 32767
%15 = add nsw i32 %14, -3
br label %19
16: ; preds = %19
%17 = add nuw nsw i32 %20, 1
%18 = icmp eq i32 %17, %15
br i1 %18, label %23, label %19
19: ; preds = %12, %16
%20 = phi i32 [ %17, %16 ], [ 3, %12 ]
%21 = call i64 @check_hairpin_min(i8* %0, i8* %4, i32 %1, i32 %20)
%22 = icmp eq i64 %21, 0
br i1 %22, label %16, label %23
23: ; preds = %19, %16, %9
%24 = phi i32 [ 0, %9 ], [ 0, %16 ], [ 1, %19 ]
ret i32 %24
}