#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 */
struct graph {
  int dummy;
};

/* Variables and functions */
int heuristic(struct graph *, int);
int core_heuristic(struct graph *g, int iterlimit, int replimit) {
  int ret = 0;
  for (int i = 0; i < iterlimit; i++) {
    ret = heuristic(g, replimit);
    if (ret) {
      ret = i + 1;
      break;
    }
  }
  return ret;
}


x86 assembly (clang, -O0):
<core_heuristic>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1176 <core_heuristic+0x66>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%esi
call   1030 <heuristic@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
je     1163 <core_heuristic+0x53>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1176 <core_heuristic+0x66>
jmp    1168 <core_heuristic+0x58>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1130 <core_heuristic+0x20>
mov    -0x14(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<core_heuristic>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
xor    %r14d,%r14d
test   %esi,%esi
jle    1156 <core_heuristic+0x46>
mov    %edx,%r15d
mov    %esi,%ebx
mov    %rdi,%r12
neg    %ebx
mov    $0x1,%ebp
xchg   %ax,%ax
mov    %r12,%rdi
mov    %r15d,%esi
call   1030 <heuristic@plt>
test   %eax,%eax
jne    1153 <core_heuristic+0x43>
lea    (%rbx,%rbp,1),%eax
add    $0x1,%eax
mov    %ebp,%ecx
add    $0x1,%ecx
mov    %ecx,%ebp
cmp    $0x1,%eax
jne    1130 <core_heuristic+0x20>
jmp    1156 <core_heuristic+0x46>
mov    %ebp,%r14d
mov    %r14d,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.graph = type { i32 }
define i32 @core_heuristic(%struct.graph* %0, i32 %1, i32 %2) {
%4 = alloca %struct.graph*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store %struct.graph* %0, %struct.graph** %4
store i32 %1, i32* %5
store i32 %2, i32* %6
store i32 0, i32* %7
store i32 0, i32* %8
br label %9
9: ; preds = %23, %3
%10 = load i32, i32* %8
%11 = load i32, i32* %5
%12 = icmp slt i32 %10, %11
br i1 %12, label %13, label %26
13: ; preds = %9
%14 = load %struct.graph*, %struct.graph** %4
%15 = load i32, i32* %6
%16 = call i32 @heuristic(%struct.graph* %14, i32 %15)
store i32 %16, i32* %7
%17 = load i32, i32* %7
%18 = icmp ne i32 %17, 0
br i1 %18, label %19, label %22
19: ; preds = %13
%20 = load i32, i32* %8
%21 = add nsw i32 %20, 1
store i32 %21, i32* %7
br label %26
22: ; preds = %13
br label %23
23: ; preds = %22
%24 = load i32, i32* %8
%25 = add nsw i32 %24, 1
store i32 %25, i32* %8
br label %9
26: ; preds = %19, %9
%27 = load i32, i32* %7
ret i32 %27
}

LLVM IR (-O2):
%struct.graph = type { i32 }
define i32 @core_heuristic(%struct.graph* %0, i32 %1, i32 %2) {
%4 = icmp sgt i32 %1, 0
br i1 %4, label %5, label %12
5: ; preds = %3, %10
%6 = phi i32 [ %9, %10 ], [ 0, %3 ]
%7 = tail call i32 @heuristic(%struct.graph* %0, i32 %2)
%8 = icmp eq i32 %7, 0
%9 = add nuw nsw i32 %6, 1
br i1 %8, label %10, label %12
10: ; preds = %5
%11 = icmp eq i32 %9, %1
br i1 %11, label %12, label %5
12: ; preds = %10, %5, %3
%13 = phi i32 [ 0, %3 ], [ 0, %10 ], [ %9, %5 ]
ret i32 %13
}