#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 abs(int);
int /*<<< orphan*/ printf(char *, ...);
void check_pentagonal_sums(int *pentagonals, int size) {
  for (int i = 0; i < size; i++) {
    for (int j = 0; j < size; j++) {
      if (i == j)
        continue;
      int sum = pentagonals[i] + pentagonals[j];
      for (int index = (i < j) ? (j) : (i); index < 10000; index++) {
        if (sum == pentagonals[index]) {
          printf("p[%d] + p[%d] = p[%d]\n", i + 1, j + 1, index + 1);
          printf("\n---------------------------\n");
          int delta = abs(pentagonals[i] - pentagonals[j]);
          int ulimit = (i > j) ? i : j;
          for (int k = 0; k < ulimit; k++) {
            if (delta == pentagonals[k]) {
              printf("\n---------------------------\n");
              printf("Found DELTA: %d \n", delta);
              printf("\n---------------------------\n");
            }
          }
        }
        if (sum < pentagonals[index])
          break;
      }
    }
  }
}


x86 assembly (clang, -O0):
<check_pentagonal_sums>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    12f0 <check_pentagonal_sums+0x1d0>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    12dd <check_pentagonal_sums+0x1bd>
mov    -0x10(%rbp),%eax
cmp    -0x14(%rbp),%eax
jne    1166 <check_pentagonal_sums+0x46>
jmp    12cf <check_pentagonal_sums+0x1af>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
mov    -0x8(%rbp),%rcx
movslq -0x14(%rbp),%rdx
add    (%rcx,%rdx,4),%eax
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    1196 <check_pentagonal_sums+0x76>
mov    -0x14(%rbp),%eax
mov    %eax,-0x2c(%rbp)
jmp    119c <check_pentagonal_sums+0x7c>
mov    -0x10(%rbp),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
mov    %eax,-0x1c(%rbp)
cmpl   $0x2710,-0x1c(%rbp)
jge    12ca <check_pentagonal_sums+0x1aa>
mov    -0x18(%rbp),%eax
mov    -0x8(%rbp),%rcx
movslq -0x1c(%rbp),%rdx
cmp    (%rcx,%rdx,4),%eax
jne    129e <check_pentagonal_sums+0x17e>
mov    -0x10(%rbp),%esi
add    $0x1,%esi
mov    -0x14(%rbp),%edx
add    $0x1,%edx
mov    -0x1c(%rbp),%ecx
add    $0x1,%ecx
lea    0xe24(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe2d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
mov    (%rax,%rcx,4),%edi
mov    -0x8(%rbp),%rax
movslq -0x14(%rbp),%rcx
sub    (%rax,%rcx,4),%edi
call   1030 <abs@plt>
mov    %eax,-0x20(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0x14(%rbp),%eax
jle    1226 <check_pentagonal_sums+0x106>
mov    -0x10(%rbp),%eax
mov    %eax,-0x30(%rbp)
jmp    122c <check_pentagonal_sums+0x10c>
mov    -0x14(%rbp),%eax
mov    %eax,-0x30(%rbp)
mov    -0x30(%rbp),%eax
mov    %eax,-0x24(%rbp)
movl   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%eax
cmp    -0x24(%rbp),%eax
jge    1299 <check_pentagonal_sums+0x179>
mov    -0x20(%rbp),%eax
mov    -0x8(%rbp),%rcx
movslq -0x28(%rbp),%rdx
cmp    (%rcx,%rdx,4),%eax
jne    1286 <check_pentagonal_sums+0x166>
lea    0xdb7(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x20(%rbp),%esi
lea    0xdc4(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xd98(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    128b <check_pentagonal_sums+0x16b>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    1239 <check_pentagonal_sums+0x119>
jmp    129e <check_pentagonal_sums+0x17e>
mov    -0x18(%rbp),%eax
mov    -0x8(%rbp),%rcx
movslq -0x1c(%rbp),%rdx
cmp    (%rcx,%rdx,4),%eax
jge    12b7 <check_pentagonal_sums+0x197>
jmp    12ca <check_pentagonal_sums+0x1aa>
jmp    12bc <check_pentagonal_sums+0x19c>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    11a2 <check_pentagonal_sums+0x82>
jmp    12cf <check_pentagonal_sums+0x1af>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1149 <check_pentagonal_sums+0x29>
jmp    12e2 <check_pentagonal_sums+0x1c2>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1136 <check_pentagonal_sums+0x16>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<check_pentagonal_sums>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
test   %esi,%esi
jle    12a5 <check_pentagonal_sums+0x185>
mov    %rdi,%rbx
mov    %esi,%eax
mov    %rax,0x20(%rsp)
lea    0xee2(%rip),%r15
xor    %eax,%eax
jmp    1163 <check_pentagonal_sums+0x43>
nopl   0x0(%rax,%rax,1)
mov    0x28(%rsp),%rcx
mov    %rcx,%rax
cmp    0x20(%rsp),%rcx
je     12a5 <check_pentagonal_sums+0x185>
lea    0x1(%rax),%rcx
mov    %rcx,0x28(%rsp)
xor    %edx,%edx
mov    %rax,(%rsp)
jmp    1194 <check_pentagonal_sums+0x74>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    0x8(%rsp),%rdx
add    $0x1,%rdx
cmp    0x20(%rsp),%rdx
mov    (%rsp),%rax
je     1150 <check_pentagonal_sums+0x30>
cmp    %edx,%eax
mov    %edx,%ebp
cmova  %eax,%ebp
mov    %rdx,%rcx
mov    %rdx,0x8(%rsp)
cmp    %rdx,%rax
je     1180 <check_pentagonal_sums+0x60>
mov    0x8(%rsp),%rax
cmova  (%rsp),%eax
mov    %eax,0x18(%rsp)
cmp    $0x270f,%eax
ja     1180 <check_pentagonal_sums+0x60>
mov    0x8(%rsp),%rcx
mov    (%rbx,%rcx,4),%edx
mov    (%rsp),%rax
add    (%rbx,%rax,4),%edx
lea    0x1(%rcx),%eax
mov    %eax,0x14(%rsp)
mov    %rbp,%r14
mov    %edx,0x1c(%rsp)
nopl   0x0(%rax)
lea    0x1(%r14),%rax
mov    %rax,0x30(%rsp)
cmp    (%rbx,%r14,4),%edx
jne    1280 <check_pentagonal_sums+0x160>
lea    0xe06(%rip),%rdi
mov    0x28(%rsp),%rsi
mov    0x14(%rsp),%edx
mov    0x30(%rsp),%rcx
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r15,%rdi
call   1030 <puts@plt>
mov    (%rsp),%rax
mov    (%rbx,%rax,4),%eax
mov    0x8(%rsp),%rcx
sub    (%rbx,%rcx,4),%eax
mov    %eax,%r13d
neg    %r13d
cmovs  %eax,%r13d
cmpl   $0x0,0x18(%rsp)
je     1280 <check_pentagonal_sums+0x160>
xor    %r12d,%r12d
jmp    1249 <check_pentagonal_sums+0x129>
nopl   0x0(%rax)
add    $0x1,%r12
cmp    %r12,%rbp
je     1280 <check_pentagonal_sums+0x160>
cmp    (%rbx,%r12,4),%r13d
jne    1240 <check_pentagonal_sums+0x120>
mov    %r15,%rdi
call   1030 <puts@plt>
lea    0xdb9(%rip),%rdi
mov    %r13d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r15,%rdi
call   1030 <puts@plt>
jmp    1240 <check_pentagonal_sums+0x120>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    0x1c(%rsp),%edx
cmp    (%rbx,%r14,4),%edx
jl     1180 <check_pentagonal_sums+0x60>
cmp    $0x270f,%r14
mov    0x30(%rsp),%r14
jb     11e0 <check_pentagonal_sums+0xc0>
jmp    1180 <check_pentagonal_sums+0x60>
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [23 x i8] c"p[%d] + p[%d] = p[%d]\0A\00"
@.str.1 = [30 x i8] c"\0A---------------------------\0A\00"
@.str.2 = [18 x i8] c"Found DELTA: %d \0A\00"
define void @check_pentagonal_sums(i32* %0, i32 %1) {
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
store i32* %0, i32** %3
store i32 %1, i32* %4
store i32 0, i32* %5
br label %12
12: ; preds = %128, %2
%13 = load i32, i32* %5
%14 = load i32, i32* %4
%15 = icmp slt i32 %13, %14
br i1 %15, label %16, label %131
16: ; preds = %12
store i32 0, i32* %6
br label %17
17: ; preds = %124, %16
%18 = load i32, i32* %6
%19 = load i32, i32* %4
%20 = icmp slt i32 %18, %19
br i1 %20, label %21, label %127
21: ; preds = %17
%22 = load i32, i32* %5
%23 = load i32, i32* %6
%24 = icmp eq i32 %22, %23
br i1 %24, label %25, label %26
25: ; preds = %21
br label %124
26: ; preds = %21
%27 = load i32*, i32** %3
%28 = load i32, i32* %5
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds i32, i32* %27, i64 %29
%31 = load i32, i32* %30
%32 = load i32*, i32** %3
%33 = load i32, i32* %6
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds i32, i32* %32, i64 %34
%36 = load i32, i32* %35
%37 = add nsw i32 %31, %36
store i32 %37, i32* %7
%38 = load i32, i32* %5
%39 = load i32, i32* %6
%40 = icmp slt i32 %38, %39
br i1 %40, label %41, label %43
41: ; preds = %26
%42 = load i32, i32* %6
br label %45
43: ; preds = %26
%44 = load i32, i32* %5
br label %45
45: ; preds = %43, %41
%46 = phi i32 [ %42, %41 ], [ %44, %43 ]
store i32 %46, i32* %8
br label %47
47: ; preds = %120, %45
%48 = load i32, i32* %8
%49 = icmp slt i32 %48, 10000
br i1 %49, label %50, label %123
50: ; preds = %47
%51 = load i32, i32* %7
%52 = load i32*, i32** %3
%53 = load i32, i32* %8
%54 = sext i32 %53 to i64
%55 = getelementptr inbounds i32, i32* %52, i64 %54
%56 = load i32, i32* %55
%57 = icmp eq i32 %51, %56
br i1 %57, label %58, label %110
58: ; preds = %50
%59 = load i32, i32* %5
%60 = add nsw i32 %59, 1
%61 = load i32, i32* %6
%62 = add nsw i32 %61, 1
%63 = load i32, i32* %8
%64 = add nsw i32 %63, 1
%65 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i32 %60, i32 %62, i32 %64)
%66 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0))
%67 = load i32*, i32** %3
%68 = load i32, i32* %5
%69 = sext i32 %68 to i64
%70 = getelementptr inbounds i32, i32* %67, i64 %69
%71 = load i32, i32* %70
%72 = load i32*, i32** %3
%73 = load i32, i32* %6
%74 = sext i32 %73 to i64
%75 = getelementptr inbounds i32, i32* %72, i64 %74
%76 = load i32, i32* %75
%77 = sub nsw i32 %71, %76
%78 = call i32 @abs(i32 %77)
store i32 %78, i32* %9
%79 = load i32, i32* %5
%80 = load i32, i32* %6
%81 = icmp sgt i32 %79, %80
br i1 %81, label %82, label %84
82: ; preds = %58
%83 = load i32, i32* %5
br label %86
84: ; preds = %58
%85 = load i32, i32* %6
br label %86
86: ; preds = %84, %82
%87 = phi i32 [ %83, %82 ], [ %85, %84 ]
store i32 %87, i32* %10
store i32 0, i32* %11
br label %88
88: ; preds = %106, %86
%89 = load i32, i32* %11
%90 = load i32, i32* %10
%91 = icmp slt i32 %89, %90
br i1 %91, label %92, label %109
92: ; preds = %88
%93 = load i32, i32* %9
%94 = load i32*, i32** %3
%95 = load i32, i32* %11
%96 = sext i32 %95 to i64
%97 = getelementptr inbounds i32, i32* %94, i64 %96
%98 = load i32, i32* %97
%99 = icmp eq i32 %93, %98
br i1 %99, label %100, label %105
100: ; preds = %92
%101 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0))
%102 = load i32, i32* %9
%103 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i32 %102)
%104 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0))
br label %105
105: ; preds = %100, %92
br label %106
106: ; preds = %105
%107 = load i32, i32* %11
%108 = add nsw i32 %107, 1
store i32 %108, i32* %11
br label %88
109: ; preds = %88
br label %110
110: ; preds = %109, %50
%111 = load i32, i32* %7
%112 = load i32*, i32** %3
%113 = load i32, i32* %8
%114 = sext i32 %113 to i64
%115 = getelementptr inbounds i32, i32* %112, i64 %114
%116 = load i32, i32* %115
%117 = icmp slt i32 %111, %116
br i1 %117, label %118, label %119
118: ; preds = %110
br label %123
119: ; preds = %110
br label %120
120: ; preds = %119
%121 = load i32, i32* %8
%122 = add nsw i32 %121, 1
store i32 %122, i32* %8
br label %47
123: ; preds = %118, %47
br label %124
124: ; preds = %123, %25
%125 = load i32, i32* %6
%126 = add nsw i32 %125, 1
store i32 %126, i32* %6
br label %17
127: ; preds = %17
br label %128
128: ; preds = %127
%129 = load i32, i32* %5
%130 = add nsw i32 %129, 1
store i32 %130, i32* %5
br label %12
131: ; preds = %12
ret void
}

LLVM IR (-O2):
@.str = [23 x i8] c"p[%d] + p[%d] = p[%d]\0A\00"
@.str.2 = [18 x i8] c"Found DELTA: %d \0A\00"
@str.4 = [29 x i8] c"\0A---------------------------\00"
define void @check_pentagonal_sums(i32* nocapture %0, i32 %1) {
%3 = icmp sgt i32 %1, 0
br i1 %3, label %4, label %12
4: ; preds = %2
%5 = zext i32 %1 to i64
br label %6
6: ; preds = %13, %4
%7 = phi i64 [ 0, %4 ], [ %9, %13 ]
%8 = getelementptr inbounds i32, i32* %0, i64 %7
%9 = add nuw nsw i64 %7, 1
%10 = trunc i64 %7 to i32
%11 = trunc i64 %9 to i32
br label %15
12: ; preds = %13, %2
ret void
13: ; preds = %65
%14 = icmp eq i64 %9, %5
br i1 %14, label %12, label %6
15: ; preds = %6, %65
%16 = phi i64 [ 0, %6 ], [ %66, %65 ]
%17 = trunc i64 %16 to i32
%18 = call i32 @llvm.umax.i32(i32 %10, i32 %17)
%19 = zext i32 %18 to i64
%20 = icmp eq i64 %7, %16
br i1 %20, label %65, label %21
21: ; preds = %15
%22 = load i32, i32* %8
%23 = getelementptr inbounds i32, i32* %0, i64 %16
%24 = load i32, i32* %23
%25 = add nsw i32 %24, %22
%26 = icmp ugt i64 %7, %16
%27 = select i1 %26, i64 %7, i64 %16
%28 = trunc i64 %27 to i32
%29 = icmp ult i32 %28, 10000
br i1 %29, label %30, label %65
30: ; preds = %21
%31 = icmp eq i32 %28, 0
%32 = trunc i64 %16 to i32
%33 = add i32 %32, 1
br label %34
34: ; preds = %60, %30
%35 = phi i64 [ %39, %60 ], [ %19, %30 ]
%36 = getelementptr inbounds i32, i32* %0, i64 %35
%37 = load i32, i32* %36
%38 = icmp eq i32 %25, %37
%39 = add nuw nsw i64 %35, 1
br i1 %38, label %40, label %60
40: ; preds = %34
%41 = trunc i64 %39 to i32
%42 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i32 %11, i32 %33, i32 %41)
%43 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @str.4, i64 0, i64 0))
%44 = load i32, i32* %8
%45 = load i32, i32* %23
%46 = sub nsw i32 %44, %45
%47 = tail call i32 @llvm.abs.i32(i32 %46, i1 true)
br i1 %31, label %60, label %48
48: ; preds = %40, %57
%49 = phi i64 [ %58, %57 ], [ 0, %40 ]
%50 = getelementptr inbounds i32, i32* %0, i64 %49
%51 = load i32, i32* %50
%52 = icmp eq i32 %47, %51
br i1 %52, label %53, label %57
53: ; preds = %48
%54 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @str.4, i64 0, i64 0))
%55 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i32 %47)
%56 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @str.4, i64 0, i64 0))
br label %57
57: ; preds = %48, %53
%58 = add nuw nsw i64 %49, 1
%59 = icmp eq i64 %58, %19
br i1 %59, label %60, label %48
60: ; preds = %57, %34, %40
%61 = load i32, i32* %36
%62 = icmp sge i32 %25, %61
%63 = icmp ult i64 %35, 9999
%64 = select i1 %62, i1 %63, i1 false
br i1 %64, label %34, label %65
65: ; preds = %60, %21, %15
%66 = add nuw nsw i64 %16, 1
%67 = icmp eq i64 %66, %5
br i1 %67, label %13, label %15
}