#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 getofield(int, int);
int findprop(int obj, int prop) {
  int n, i, p;
  n = getofield(obj, ((int)6));
  for (i = p = 0; i < n; i++, p += 4)
    if ((getofield(obj, ((int)8) + p) & ~(int)0x8000) == prop)
      return (((int)8) + p + 2);
  return (0L);
}


x86 assembly (clang, -O0):
<findprop>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%edi
mov    $0x6,%esi
call   1030 <getofield@plt>
mov    %eax,-0x10(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    1191 <findprop+0x81>
mov    -0x8(%rbp),%edi
mov    -0x18(%rbp),%esi
add    $0x8,%esi
call   1030 <getofield@plt>
and    $0xffff7fff,%eax
cmp    -0xc(%rbp),%eax
jne    1175 <findprop+0x65>
mov    -0x18(%rbp),%eax
add    $0x8,%eax
add    $0x2,%eax
mov    %eax,-0x4(%rbp)
jmp    1198 <findprop+0x88>
jmp    117a <findprop+0x6a>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
mov    -0x18(%rbp),%eax
add    $0x4,%eax
mov    %eax,-0x18(%rbp)
jmp    113c <findprop+0x2c>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<findprop>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %esi,%r15d
mov    %edi,%r12d
mov    $0x6,%esi
call   1030 <getofield@plt>
xor    %r14d,%r14d
test   %eax,%eax
jle    1162 <findprop+0x52>
mov    %eax,%ebx
mov    $0xa,%ebp
cs nopw 0x0(%rax,%rax,1)
lea    -0x2(%rbp),%esi
mov    %r12d,%edi
call   1030 <getofield@plt>
and    $0xffff7fff,%eax
cmp    %r15d,%eax
je     115f <findprop+0x4f>
add    $0x4,%ebp
add    $0xffffffff,%ebx
jne    1140 <findprop+0x30>
jmp    1162 <findprop+0x52>
mov    %ebp,%r14d
mov    %r14d,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

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

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