#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 /*<<< orphan*/ exit(int);
scalar_t__ of1275_finddevice(char const *, int *);
int /*<<< orphan*/ of1275_getprop(int, char const *, char *, int, int *);
void of_find_string_property(const char *device, const char *property,
                             char *string, int sizeof_string) {
  int phandle;
  int size;
  if (of1275_finddevice(device, &phandle) < 0) {
    exit(1);
  }
  of1275_getprop(phandle, property, string, sizeof_string, &size);
  if (size == 0 || size >= sizeof_string) {
    exit(1);
  }
}


x86 assembly (clang, -O0):
<of_find_string_property>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0x20(%rbp),%rsi
call   1030 <of1275_finddevice@plt>
cmp    $0x0,%rax
jge    1168 <of_find_string_property+0x38>
mov    $0x1,%edi
call   1050 <exit@plt>
mov    -0x20(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x1c(%rbp),%ecx
lea    -0x24(%rbp),%r8
call   1040 <of1275_getprop@plt>
cmpl   $0x0,-0x24(%rbp)
je     1195 <of_find_string_property+0x65>
mov    -0x24(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jl     119f <of_find_string_property+0x6f>
mov    $0x1,%edi
call   1050 <exit@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<of_find_string_property>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %ecx,%ebx
mov    %rdx,%r14
mov    %rsi,%r15
lea    0xc(%rsp),%rsi
call   1030 <of1275_finddevice@plt>
test   %rax,%rax
js     117c <of_find_string_property+0x4c>
mov    0xc(%rsp),%edi
lea    0x8(%rsp),%r8
mov    %r15,%rsi
mov    %r14,%rdx
mov    %ebx,%ecx
call   1040 <of1275_getprop@plt>
mov    0x8(%rsp),%eax
test   %eax,%eax
je     117c <of_find_string_property+0x4c>
cmp    %ebx,%eax
jge    117c <of_find_string_property+0x4c>
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret
mov    $0x1,%edi
call   1050 <exit@plt>

LLVM IR (-O0):
define void @of_find_string_property(i8* %0, i8* %1, i8* %2, i32 %3) {
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
store i8* %0, i8** %5
store i8* %1, i8** %6
store i8* %2, i8** %7
store i32 %3, i32* %8
%11 = load i8*, i8** %5
%12 = call i64 @of1275_finddevice(i8* %11, i32* %9)
%13 = icmp slt i64 %12, 0
br i1 %13, label %14, label %16
14: ; preds = %4
%15 = call i32 @exit(i32 1)
unreachable
16: ; preds = %4
%17 = load i32, i32* %9
%18 = load i8*, i8** %6
%19 = load i8*, i8** %7
%20 = load i32, i32* %8
%21 = call i32 @of1275_getprop(i32 %17, i8* %18, i8* %19, i32 %20, i32* %10)
%22 = load i32, i32* %10
%23 = icmp eq i32 %22, 0
br i1 %23, label %28, label %24
24: ; preds = %16
%25 = load i32, i32* %10
%26 = load i32, i32* %8
%27 = icmp sge i32 %25, %26
br i1 %27, label %28, label %30
28: ; preds = %24, %16
%29 = call i32 @exit(i32 1)
unreachable
30: ; preds = %24
ret void
}

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