#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 GetMismatchShift(int, int);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ stderr;
long double HelixEnergy(int i, int j, int h, int m) {
  int shift_ij;
  int shift_hm;
  extern long double Stack[];
  shift_ij = GetMismatchShift(i, j);
  shift_hm = GetMismatchShift(h, m);
  if (shift_ij < 4 && shift_hm < 4) {
    return Stack[(i - 1) * 6 + (h - 1)];
  }
  if (shift_ij < 4 && shift_hm >= 4) {
    return Stack[(i - 1) * 6 + (h + 1)];
  }
  if (shift_ij >= 4 && shift_hm < 4) {
    return Stack[(i + 1) * 6 + (h - 1)];
  }
  if (shift_ij >= 4 && shift_hm >= 4) {
    return Stack[(i + 1) * 6 + (h + 1)];
  } else {
    fprintf(stderr, "Error in HelixEnergy!");
    exit(1);
    return 100000;
  }
}


x86 assembly (clang, -O0):
<HelixEnergy>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x14(%rbp)
mov    %esi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    %ecx,-0x20(%rbp)
mov    -0x14(%rbp),%edi
mov    -0x18(%rbp),%esi
call   1030 <GetMismatchShift@plt>
mov    %eax,-0x24(%rbp)
mov    -0x1c(%rbp),%edi
mov    -0x20(%rbp),%esi
call   1030 <GetMismatchShift@plt>
mov    %eax,-0x28(%rbp)
cmpl   $0x4,-0x24(%rbp)
jge    11a0 <HelixEnergy+0x70>
cmpl   $0x4,-0x28(%rbp)
jge    11a0 <HelixEnergy+0x70>
mov    -0x14(%rbp),%ecx
mov    %ecx,%eax
lea    (%rax,%rax,2),%edx
mov    -0x1c(%rbp),%ecx
mov    %ecx,%eax
mov    %edx,%ecx
lea    -0x7(%rax,%rcx,2),%eax
movslq %eax,%rcx
shl    $0x4,%rcx
mov    0x2e43(%rip),%rax
fldt   (%rax,%rcx,1)
fstpt  -0x10(%rbp)
jmp    127f <HelixEnergy+0x14f>
cmpl   $0x4,-0x24(%rbp)
jge    11e0 <HelixEnergy+0xb0>
cmpl   $0x4,-0x28(%rbp)
jl     11e0 <HelixEnergy+0xb0>
mov    -0x14(%rbp),%ecx
mov    %ecx,%eax
lea    (%rax,%rax,2),%edx
mov    -0x1c(%rbp),%ecx
mov    %ecx,%eax
mov    %edx,%ecx
lea    -0x5(%rax,%rcx,2),%eax
movslq %eax,%rcx
shl    $0x4,%rcx
mov    0x2e03(%rip),%rax
fldt   (%rax,%rcx,1)
fstpt  -0x10(%rbp)
jmp    127f <HelixEnergy+0x14f>
cmpl   $0x4,-0x24(%rbp)
jl     1220 <HelixEnergy+0xf0>
cmpl   $0x4,-0x28(%rbp)
jge    1220 <HelixEnergy+0xf0>
mov    -0x14(%rbp),%ecx
mov    %ecx,%eax
lea    (%rax,%rax,2),%edx
mov    -0x1c(%rbp),%ecx
mov    %ecx,%eax
mov    %edx,%ecx
lea    0x5(%rax,%rcx,2),%eax
movslq %eax,%rcx
shl    $0x4,%rcx
mov    0x2dc3(%rip),%rax
fldt   (%rax,%rcx,1)
fstpt  -0x10(%rbp)
jmp    127f <HelixEnergy+0x14f>
cmpl   $0x4,-0x24(%rbp)
jl     1260 <HelixEnergy+0x130>
cmpl   $0x4,-0x28(%rbp)
jl     1260 <HelixEnergy+0x130>
mov    -0x14(%rbp),%ecx
mov    %ecx,%eax
lea    (%rax,%rax,2),%edx
mov    -0x1c(%rbp),%ecx
mov    %ecx,%eax
mov    %edx,%ecx
lea    0x7(%rax,%rcx,2),%eax
movslq %eax,%rcx
shl    $0x4,%rcx
mov    0x2d83(%rip),%rax
fldt   (%rax,%rcx,1)
fstpt  -0x10(%rbp)
jmp    127f <HelixEnergy+0x14f>
mov    0x2d79(%rip),%rax
mov    (%rax),%edi
lea    0xd90(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0x1,%edi
call   1050 <exit@plt>
fldt   -0x10(%rbp)
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<HelixEnergy>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %ecx,%ebx
mov    %edx,%r14d
mov    %edi,%r15d
call   1030 <GetMismatchShift@plt>
mov    %eax,%ebp
mov    %r14d,%edi
mov    %ebx,%esi
call   1030 <GetMismatchShift@plt>
cmp    $0x3,%ebp
jg     115f <HelixEnergy+0x2f>
mov    $0xfffffff9,%ecx
cmp    $0x4,%eax
jl     118c <HelixEnergy+0x5c>
cmp    $0x3,%ebp
jg     116e <HelixEnergy+0x3e>
mov    $0xfffffffb,%ecx
cmp    $0x3,%eax
jg     118c <HelixEnergy+0x5c>
cmp    $0x4,%ebp
jl     117d <HelixEnergy+0x4d>
mov    $0x5,%ecx
cmp    $0x4,%eax
jl     118c <HelixEnergy+0x5c>
cmp    $0x4,%ebp
jl     11b1 <HelixEnergy+0x81>
mov    $0x7,%ecx
cmp    $0x3,%eax
jle    11b1 <HelixEnergy+0x81>
lea    (%r15,%r15,2),%eax
lea    (%rcx,%rax,2),%eax
add    %r14d,%eax
cltq
shl    $0x4,%rax
mov    0x2e35(%rip),%rcx
fldt   (%rcx,%rax,1)
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2e28(%rip),%rax
mov    (%rax),%edi
lea    0xe3f(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0x1,%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@Stack = external global [0 x x86_fp80]
@stderr = global i32 0
@.str = [22 x i8] c"Error in HelixEnergy!\00"
define x86_fp80 @HelixEnergy(i32 %0, i32 %1, i32 %2, i32 %3) {
%5 = alloca x86_fp80
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
store i32 %0, i32* %6
store i32 %1, i32* %7
store i32 %2, i32* %8
store i32 %3, i32* %9
%12 = load i32, i32* %6
%13 = load i32, i32* %7
%14 = call i32 @GetMismatchShift(i32 %12, i32 %13)
store i32 %14, i32* %10
%15 = load i32, i32* %8
%16 = load i32, i32* %9
%17 = call i32 @GetMismatchShift(i32 %15, i32 %16)
store i32 %17, i32* %11
%18 = load i32, i32* %10
%19 = icmp slt i32 %18, 4
br i1 %19, label %20, label %33
20: ; preds = %4
%21 = load i32, i32* %11
%22 = icmp slt i32 %21, 4
br i1 %22, label %23, label %33
23: ; preds = %20
%24 = load i32, i32* %6
%25 = sub nsw i32 %24, 1
%26 = mul nsw i32 %25, 6
%27 = load i32, i32* %8
%28 = sub nsw i32 %27, 1
%29 = add nsw i32 %26, %28
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds [0 x x86_fp80], [0 x x86_fp80]* @Stack, i64 0, i64 %30
%32 = load x86_fp80, x86_fp80* %31
store x86_fp80 %32, x86_fp80* %5
br label %85
33: ; preds = %20, %4
%34 = load i32, i32* %10
%35 = icmp slt i32 %34, 4
br i1 %35, label %36, label %49
36: ; preds = %33
%37 = load i32, i32* %11
%38 = icmp sge i32 %37, 4
br i1 %38, label %39, label %49
39: ; preds = %36
%40 = load i32, i32* %6
%41 = sub nsw i32 %40, 1
%42 = mul nsw i32 %41, 6
%43 = load i32, i32* %8
%44 = add nsw i32 %43, 1
%45 = add nsw i32 %42, %44
%46 = sext i32 %45 to i64
%47 = getelementptr inbounds [0 x x86_fp80], [0 x x86_fp80]* @Stack, i64 0, i64 %46
%48 = load x86_fp80, x86_fp80* %47
store x86_fp80 %48, x86_fp80* %5
br label %85
49: ; preds = %36, %33
%50 = load i32, i32* %10
%51 = icmp sge i32 %50, 4
br i1 %51, label %52, label %65
52: ; preds = %49
%53 = load i32, i32* %11
%54 = icmp slt i32 %53, 4
br i1 %54, label %55, label %65
55: ; preds = %52
%56 = load i32, i32* %6
%57 = add nsw i32 %56, 1
%58 = mul nsw i32 %57, 6
%59 = load i32, i32* %8
%60 = sub nsw i32 %59, 1
%61 = add nsw i32 %58, %60
%62 = sext i32 %61 to i64
%63 = getelementptr inbounds [0 x x86_fp80], [0 x x86_fp80]* @Stack, i64 0, i64 %62
%64 = load x86_fp80, x86_fp80* %63
store x86_fp80 %64, x86_fp80* %5
br label %85
65: ; preds = %52, %49
%66 = load i32, i32* %10
%67 = icmp sge i32 %66, 4
br i1 %67, label %68, label %81
68: ; preds = %65
%69 = load i32, i32* %11
%70 = icmp sge i32 %69, 4
br i1 %70, label %71, label %81
71: ; preds = %68
%72 = load i32, i32* %6
%73 = add nsw i32 %72, 1
%74 = mul nsw i32 %73, 6
%75 = load i32, i32* %8
%76 = add nsw i32 %75, 1
%77 = add nsw i32 %74, %76
%78 = sext i32 %77 to i64
%79 = getelementptr inbounds [0 x x86_fp80], [0 x x86_fp80]* @Stack, i64 0, i64 %78
%80 = load x86_fp80, x86_fp80* %79
store x86_fp80 %80, x86_fp80* %5
br label %85
81: ; preds = %68, %65
%82 = load i32, i32* @stderr
%83 = call i32 @fprintf(i32 %82, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
%84 = call i32 @exit(i32 1)
unreachable
85: ; preds = %71, %55, %39, %23
%86 = load x86_fp80, x86_fp80* %5
ret x86_fp80 %86
}

LLVM IR (-O2):
@Stack = external global [0 x x86_fp80]
@stderr = global i32 0
@.str = [22 x i8] c"Error in HelixEnergy!\00"
define x86_fp80 @HelixEnergy(i32 %0, i32 %1, i32 %2, i32 %3) {
%5 = tail call i32 @GetMismatchShift(i32 %0, i32 %1)
%6 = tail call i32 @GetMismatchShift(i32 %2, i32 %3)
%7 = icmp slt i32 %5, 4
%8 = icmp slt i32 %6, 4
%9 = select i1 %7, i1 %8, i1 false
br i1 %9, label %22, label %10
10: ; preds = %4
%11 = icmp sgt i32 %6, 3
%12 = select i1 %7, i1 %11, i1 false
br i1 %12, label %22, label %13
13: ; preds = %10
%14 = icmp sgt i32 %5, 3
%15 = select i1 %14, i1 %8, i1 false
br i1 %15, label %22, label %16
16: ; preds = %13
%17 = select i1 %14, i1 %11, i1 false
br i1 %17, label %22, label %18
18: ; preds = %16
%19 = load i32, i32* @stderr
%20 = tail call i32 @fprintf(i32 %19, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
%21 = tail call i32 @exit(i32 1)
unreachable
22: ; preds = %16, %13, %10, %4
%23 = phi i32 [ -7, %4 ], [ -5, %10 ], [ 5, %13 ], [ 7, %16 ]
%24 = mul i32 %0, 6
%25 = add i32 %24, %23
%26 = add i32 %25, %2
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds [0 x x86_fp80], [0 x x86_fp80]* @Stack, i64 0, i64 %27
%29 = load x86_fp80, x86_fp80* %28
ret x86_fp80 %29
}