#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 array_value_count(int, int *);
int get_rudolph_number(int barn[]) {
  int counter = 0;
  while (barn[counter] > 0) {
    int count = array_value_count(barn[counter], barn);
    if (count == 1) {
      return barn[counter];
    }
    counter++;
  }
  return -1;
}


x86 assembly (clang, -O0):
<get_rudolph_number>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
cmpl   $0x0,(%rax,%rcx,4)
jle    1177 <get_rudolph_number+0x67>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,4),%edi
mov    -0x10(%rbp),%rsi
call   1030 <array_value_count@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x1,-0x18(%rbp)
jne    1169 <get_rudolph_number+0x59>
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
mov    %eax,-0x4(%rbp)
jmp    117e <get_rudolph_number+0x6e>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1123 <get_rudolph_number+0x13>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_rudolph_number>:
push   %rbp
push   %r14
push   %rbx
mov    %rdi,%rbx
mov    (%rdi),%edi
mov    $0xffffffff,%r14d
test   %edi,%edi
jle    1151 <get_rudolph_number+0x41>
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nop
mov    %rbx,%rsi
call   1030 <array_value_count@plt>
cmp    $0x1,%eax
je     114b <get_rudolph_number+0x3b>
mov    0x4(%rbx,%rbp,4),%edi
add    $0x1,%rbp
test   %edi,%edi
jg     1130 <get_rudolph_number+0x20>
jmp    1151 <get_rudolph_number+0x41>
mov    %ebp,%eax
mov    (%rbx,%rax,4),%r14d
mov    %r14d,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

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

LLVM IR (-O2):
define i32 @get_rudolph_number(i32* %0) {
%2 = load i32, i32* %0
%3 = icmp sgt i32 %2, 0
br i1 %3, label %4, label %18
4: ; preds = %1, %13
%5 = phi i64 [ %14, %13 ], [ 0, %1 ]
%6 = phi i32 [ %16, %13 ], [ %2, %1 ]
%7 = tail call i32 @array_value_count(i32 %6, i32* %0)
%8 = icmp eq i32 %7, 1
br i1 %8, label %9, label %13
9: ; preds = %4
%10 = and i64 %5, 4294967295
%11 = getelementptr inbounds i32, i32* %0, i64 %10
%12 = load i32, i32* %11
br label %18
13: ; preds = %4
%14 = add nuw i64 %5, 1
%15 = getelementptr inbounds i32, i32* %0, i64 %14
%16 = load i32, i32* %15
%17 = icmp sgt i32 %16, 0
br i1 %17, label %4, label %18
18: ; preds = %13, %1, %9
%19 = phi i32 [ %12, %9 ], [ -1, %1 ], [ -1, %13 ]
ret i32 %19
}