#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 */
typedef int /*<<< orphan*/ integer;

/* Variables and functions */
int /*<<< orphan*/ exit(int);
int ntohl(int);
scalar_t__ of1275_finddevice(char const *, int *);
int /*<<< orphan*/ of1275_getprop(int, char const *, int *, int, int *);
int of_find_integer_property(const char *device, const char *property) {
  int phandle;
  int integer;
  int size;
  if (of1275_finddevice(device, &phandle) < 0) {
    exit(1);
  }
  of1275_getprop(phandle, property, &integer, sizeof(integer), &size);
  if (size < sizeof(integer)) {
    exit(1);
  }
  return ntohl(integer);
}


x86 assembly (clang, -O0):
<of_find_integer_property>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0x14(%rbp),%rsi
call   1030 <of1275_finddevice@plt>
cmp    $0x0,%rax
jge    1171 <of_find_integer_property+0x31>
mov    $0x1,%edi
call   1050 <exit@plt>
mov    -0x14(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    -0x18(%rbp),%rdx
mov    $0x4,%ecx
lea    -0x1c(%rbp),%r8
call   1040 <of1275_getprop@plt>
movslq -0x1c(%rbp),%rax
cmp    $0x4,%rax
jae    11a2 <of_find_integer_property+0x62>
mov    $0x1,%edi
call   1050 <exit@plt>
mov    -0x18(%rbp),%edi
call   1060 <ntohl@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<of_find_integer_property>:
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%rbx
lea    0xc(%rsp),%rsi
call   1030 <of1275_finddevice@plt>
test   %rax,%rax
js     1188 <of_find_integer_property+0x48>
mov    0xc(%rsp),%edi
lea    0x8(%rsp),%rdx
lea    0x4(%rsp),%r8
mov    %rbx,%rsi
mov    $0x4,%ecx
call   1040 <of1275_getprop@plt>
cmpl   $0x3,0x4(%rsp)
jbe    1188 <of_find_integer_property+0x48>
mov    0x8(%rsp),%edi
call   1060 <ntohl@plt>
add    $0x10,%rsp
pop    %rbx
ret
mov    $0x1,%edi
call   1050 <exit@plt>

LLVM IR (-O0):
define i32 @of_find_integer_property(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i8* %0, i8** %3
store i8* %1, i8** %4
%8 = load i8*, i8** %3
%9 = call i64 @of1275_finddevice(i8* %8, i32* %5)
%10 = icmp slt i64 %9, 0
br i1 %10, label %11, label %13
11: ; preds = %2
%12 = call i32 @exit(i32 1)
unreachable
13: ; preds = %2
%14 = load i32, i32* %5
%15 = load i8*, i8** %4
%16 = call i32 @of1275_getprop(i32 %14, i8* %15, i32* %6, i32 4, i32* %7)
%17 = load i32, i32* %7
%18 = sext i32 %17 to i64
%19 = icmp ult i64 %18, 4
br i1 %19, label %20, label %22
20: ; preds = %13
%21 = call i32 @exit(i32 1)
unreachable
22: ; preds = %13
%23 = load i32, i32* %6
%24 = call i32 @ntohl(i32 %23)
ret i32 %24
}

LLVM IR (-O2):
define i32 @of_find_integer_property(i8* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = bitcast i32* %3 to i8*
%7 = bitcast i32* %4 to i8*
%8 = bitcast i32* %5 to i8*
%9 = call i64 @of1275_finddevice(i8* %0, i32* %3)
%10 = icmp slt i64 %9, 0
br i1 %10, label %11, label %13
11: ; preds = %2
%12 = call i32 @exit(i32 1)
unreachable
13: ; preds = %2
%14 = load i32, i32* %3
%15 = call i32 @of1275_getprop(i32 %14, i8* %1, i32* %4, i32 4, i32* %5)
%16 = load i32, i32* %5
%17 = icmp ult i32 %16, 4
br i1 %17, label %18, label %20
18: ; preds = %13
%19 = call i32 @exit(i32 1)
unreachable
20: ; preds = %13
%21 = load i32, i32* %4
%22 = call i32 @ntohl(i32 %21)
ret i32 %22
}