#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 bondList {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ areBonded(int, int);
int /*<<< orphan*/ getBondList(struct bondList **);
int numBonds(int);
int recursiveShortestRingCheck(struct bondList *, int *, int, int, int, int);
int getRing(int *path, int ar, int ac, int al, int length) {
  struct bondList *blist;
  int realDepth = 0;
  if (!areBonded(ar, ac) || !areBonded(ac, al))
    return -2;
  getBondList(&blist);
  path[0] = ar;
  path[1] = ac;
  if (numBonds(ar) > 2)
    realDepth++;
  if (numBonds(ac) > 2)
    realDepth++;
  return recursiveShortestRingCheck(blist, path, al, 2, realDepth, length);
}


x86 assembly (clang, -O0):
<getRing>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %edx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    %r8d,-0x20(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x14(%rbp),%edi
mov    -0x18(%rbp),%esi
call   1060 <areBonded@plt>
cmp    $0x0,%eax
je     1188 <getRing+0x48>
mov    -0x18(%rbp),%edi
mov    -0x1c(%rbp),%esi
call   1060 <areBonded@plt>
cmp    $0x0,%eax
jne    1194 <getRing+0x54>
movl   $0xfffffffe,-0x4(%rbp)
jmp    1204 <getRing+0xc4>
lea    -0x28(%rbp),%rdi
call   1040 <getBondList@plt>
mov    -0x14(%rbp),%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x18(%rbp),%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,0x4(%rax)
mov    -0x14(%rbp),%edi
call   1030 <numBonds@plt>
cmp    $0x2,%eax
jle    11ca <getRing+0x8a>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
mov    -0x18(%rbp),%edi
call   1030 <numBonds@plt>
cmp    $0x2,%eax
jle    11e4 <getRing+0xa4>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x1c(%rbp),%edx
mov    -0x2c(%rbp),%r8d
mov    -0x20(%rbp),%r9d
mov    $0x2,%ecx
call   1050 <recursiveShortestRingCheck@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getRing>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r8d,%r14d
mov    %ecx,%r15d
mov    %edx,%ebp
mov    %esi,%r13d
mov    %rdi,%r12
mov    %esi,%edi
mov    %edx,%esi
call   1060 <areBonded@plt>
mov    $0xfffffffe,%ebx
test   %eax,%eax
je     11c5 <getRing+0x85>
mov    %ebp,%edi
mov    %r15d,%esi
call   1060 <areBonded@plt>
test   %eax,%eax
je     11c5 <getRing+0x85>
mov    %rsp,%rdi
call   1040 <getBondList@plt>
mov    %r13d,(%r12)
mov    %ebp,0x4(%r12)
mov    %r13d,%edi
call   1030 <numBonds@plt>
xor    %ebx,%ebx
cmp    $0x3,%eax
setge  %bl
mov    %ebp,%edi
call   1030 <numBonds@plt>
lea    0x1(%rbx),%r8d
cmp    $0x3,%eax
cmovl  %ebx,%r8d
mov    (%rsp),%rdi
mov    %r12,%rsi
mov    %r15d,%edx
mov    $0x2,%ecx
mov    %r14d,%r9d
call   1050 <recursiveShortestRingCheck@plt>
mov    %eax,%ebx
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.bondList = type { i32 }
define i32 @getRing(i32* %0, i32 %1, i32 %2, i32 %3, i32 %4) {
%6 = alloca i32
%7 = alloca i32*
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca %struct.bondList*
%13 = alloca i32
store i32* %0, i32** %7
store i32 %1, i32* %8
store i32 %2, i32* %9
store i32 %3, i32* %10
store i32 %4, i32* %11
store i32 0, i32* %13
%14 = load i32, i32* %8
%15 = load i32, i32* %9
%16 = call i32 @areBonded(i32 %14, i32 %15)
%17 = icmp ne i32 %16, 0
br i1 %17, label %18, label %23
18: ; preds = %5
%19 = load i32, i32* %9
%20 = load i32, i32* %10
%21 = call i32 @areBonded(i32 %19, i32 %20)
%22 = icmp ne i32 %21, 0
br i1 %22, label %24, label %23
23: ; preds = %18, %5
store i32 -2, i32* %6
br label %52
24: ; preds = %18
%25 = call i32 @getBondList(%struct.bondList** %12)
%26 = load i32, i32* %8
%27 = load i32*, i32** %7
%28 = getelementptr inbounds i32, i32* %27, i64 0
store i32 %26, i32* %28
%29 = load i32, i32* %9
%30 = load i32*, i32** %7
%31 = getelementptr inbounds i32, i32* %30, i64 1
store i32 %29, i32* %31
%32 = load i32, i32* %8
%33 = call i32 @numBonds(i32 %32)
%34 = icmp sgt i32 %33, 2
br i1 %34, label %35, label %38
35: ; preds = %24
%36 = load i32, i32* %13
%37 = add nsw i32 %36, 1
store i32 %37, i32* %13
br label %38
38: ; preds = %35, %24
%39 = load i32, i32* %9
%40 = call i32 @numBonds(i32 %39)
%41 = icmp sgt i32 %40, 2
br i1 %41, label %42, label %45
42: ; preds = %38
%43 = load i32, i32* %13
%44 = add nsw i32 %43, 1
store i32 %44, i32* %13
br label %45
45: ; preds = %42, %38
%46 = load %struct.bondList*, %struct.bondList** %12
%47 = load i32*, i32** %7
%48 = load i32, i32* %10
%49 = load i32, i32* %13
%50 = load i32, i32* %11
%51 = call i32 @recursiveShortestRingCheck(%struct.bondList* %46, i32* %47, i32 %48, i32 2, i32 %49, i32 %50)
store i32 %51, i32* %6
br label %52
52: ; preds = %45, %23
%53 = load i32, i32* %6
ret i32 %53
}

LLVM IR (-O2):
%struct.bondList = type { i32 }
define i32 @getRing(i32* %0, i32 %1, i32 %2, i32 %3, i32 %4) {
%6 = alloca %struct.bondList*
%7 = bitcast %struct.bondList** %6 to i8*
%8 = tail call i32 @areBonded(i32 %1, i32 %2)
%9 = icmp eq i32 %8, 0
br i1 %9, label %25, label %10
10: ; preds = %5
%11 = tail call i32 @areBonded(i32 %2, i32 %3)
%12 = icmp eq i32 %11, 0
br i1 %12, label %25, label %13
13: ; preds = %10
%14 = call i32 @getBondList(%struct.bondList** %6)
store i32 %1, i32* %0
%15 = getelementptr inbounds i32, i32* %0, i64 1
store i32 %2, i32* %15
%16 = call i32 @numBonds(i32 %1)
%17 = icmp sgt i32 %16, 2
%18 = zext i1 %17 to i32
%19 = call i32 @numBonds(i32 %2)
%20 = icmp sgt i32 %19, 2
%21 = select i1 %17, i32 2, i32 1
%22 = select i1 %20, i32 %21, i32 %18
%23 = load %struct.bondList*, %struct.bondList** %6
%24 = call i32 @recursiveShortestRingCheck(%struct.bondList* %23, i32* %0, i32 %3, i32 2, i32 %22, i32 %4)
br label %25
25: ; preds = %5, %10, %13
%26 = phi i32 [ %24, %13 ], [ -2, %10 ], [ -2, %5 ]
ret i32 %26
}