#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 max(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ robWithoutCircle(int *, int);
int rob(int *nums, int n) {
  if (nums == NULL || n <= 0)
    return 0;
  if (n == 1)
    return nums[0];
  return max(robWithoutCircle(nums, n - 1), robWithoutCircle(nums + 1, n - 1));
}


x86 assembly (clang, -O0):
<rob>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     1144 <rob+0x24>
cmpl   $0x0,-0x14(%rbp)
jg     1150 <rob+0x30>
movl   $0x0,-0x4(%rbp)
jmp    119a <rob+0x7a>
cmpl   $0x1,-0x14(%rbp)
jne    1168 <rob+0x48>
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    119a <rob+0x7a>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
sub    $0x1,%esi
call   1040 <robWithoutCircle@plt>
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
add    $0x4,%rdi
mov    -0x14(%rbp),%esi
sub    $0x1,%esi
call   1040 <robWithoutCircle@plt>
mov    -0x18(%rbp),%edi
mov    %eax,%esi
call   1030 <max@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<rob>:
push   %rbp
push   %r14
push   %rbx
xor    %eax,%eax
test   %rdi,%rdi
je     113b <rob+0x1b>
mov    %esi,%ebp
test   %esi,%esi
jle    113b <rob+0x1b>
mov    %rdi,%rbx
cmp    $0x1,%ebp
jne    1140 <rob+0x20>
mov    (%rbx),%eax
pop    %rbx
pop    %r14
pop    %rbp
ret
add    $0xffffffff,%ebp
mov    %rbx,%rdi
mov    %ebp,%esi
call   1040 <robWithoutCircle@plt>
mov    %eax,%r14d
add    $0x4,%rbx
mov    %rbx,%rdi
mov    %ebp,%esi
call   1040 <robWithoutCircle@plt>
mov    %r14d,%edi
mov    %eax,%esi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1030 <max@plt>

LLVM IR (-O0):
define i32 @rob(i32* %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32*
%5 = alloca i32
store i32* %0, i32** %4
store i32 %1, i32* %5
%6 = load i32*, i32** %4
%7 = icmp eq i32* %6, null
br i1 %7, label %11, label %8
8: ; preds = %2
%9 = load i32, i32* %5
%10 = icmp sle i32 %9, 0
br i1 %10, label %11, label %12
11: ; preds = %8, %2
store i32 0, i32* %3
br label %30
12: ; preds = %8
%13 = load i32, i32* %5
%14 = icmp eq i32 %13, 1
br i1 %14, label %15, label %19
15: ; preds = %12
%16 = load i32*, i32** %4
%17 = getelementptr inbounds i32, i32* %16, i64 0
%18 = load i32, i32* %17
store i32 %18, i32* %3
br label %30
19: ; preds = %12
%20 = load i32*, i32** %4
%21 = load i32, i32* %5
%22 = sub nsw i32 %21, 1
%23 = call i32 @robWithoutCircle(i32* %20, i32 %22)
%24 = load i32*, i32** %4
%25 = getelementptr inbounds i32, i32* %24, i64 1
%26 = load i32, i32* %5
%27 = sub nsw i32 %26, 1
%28 = call i32 @robWithoutCircle(i32* %25, i32 %27)
%29 = call i32 @max(i32 %23, i32 %28)
store i32 %29, i32* %3
br label %30
30: ; preds = %19, %15, %11
%31 = load i32, i32* %3
ret i32 %31
}

LLVM IR (-O2):
define i32 @rob(i32* %0, i32 %1) {
%3 = icmp eq i32* %0, null
%4 = icmp slt i32 %1, 1
%5 = or i1 %3, %4
br i1 %5, label %16, label %6
6: ; preds = %2
%7 = icmp eq i32 %1, 1
br i1 %7, label %8, label %10
8: ; preds = %6
%9 = load i32, i32* %0
br label %16
10: ; preds = %6
%11 = add nsw i32 %1, -1
%12 = tail call i32 @robWithoutCircle(i32* %0, i32 %11)
%13 = getelementptr inbounds i32, i32* %0, i64 1
%14 = tail call i32 @robWithoutCircle(i32* %13, i32 %11)
%15 = tail call i32 @max(i32 %12, i32 %14)
br label %16
16: ; preds = %2, %10, %8
%17 = phi i32 [ %9, %8 ], [ %15, %10 ], [ 0, %2 ]
ret i32 %17
}