#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 */
struct udev_list_entry {
  int dummy;
};
struct udev_device {
  int dummy;
};
typedef int /*<<< orphan*/ name;

/* Variables and functions */
char *strchr(char *, char);
struct udev_list_entry *udev_device_add_property(struct udev_device *, char *,
                                                 char *);
int /*<<< orphan*/ util_strlcpy(char *, char const *, int);
struct udev_list_entry *
udev_device_add_property_from_string(struct udev_device *udev_device,
                                     const char *property) {
  char name[1024];
  char *val;
  util_strlcpy(name, property, sizeof(name));
  val = strchr(name, '=');
  if (val == NULL)
    return NULL;
  val[0] = '\0';
  val = &val[1];
  if (val[0] == '\0')
    val = NULL;
  return udev_device_add_property(udev_device, name, val);
}


x86 assembly (clang, -O0):
<udev_device_add_property_from_string>:
push   %rbp
mov    %rsp,%rbp
sub    $0x430,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
lea    -0x420(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    $0x400,%edx
call   1040 <util_strlcpy@plt>
lea    -0x420(%rbp),%rdi
mov    $0x3d,%esi
call   1030 <strchr@plt>
mov    %rax,-0x428(%rbp)
cmpq   $0x0,-0x428(%rbp)
jne    118b <udev_device_add_property_from_string+0x5b>
movq   $0x0,-0x8(%rbp)
jmp    11e0 <udev_device_add_property_from_string+0xb0>
mov    -0x428(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x428(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x428(%rbp)
mov    -0x428(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
jne    11c5 <udev_device_add_property_from_string+0x95>
movq   $0x0,-0x428(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x420(%rbp),%rsi
mov    -0x428(%rbp),%rdx
call   1050 <udev_device_add_property@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x430,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<udev_device_add_property_from_string>:
push   %r14
push   %rbx
sub    $0x408,%rsp
mov    %rdi,%r14
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0x400,%edx
call   1040 <util_strlcpy@plt>
mov    %rbx,%rdi
mov    $0x3d,%esi
call   1030 <strchr@plt>
test   %rax,%rax
je     1180 <udev_device_add_property_from_string+0x50>
movb   $0x0,(%rax)
mov    %rax,%rcx
add    $0x1,%rcx
xor    %edx,%edx
cmpb   $0x0,0x1(%rax)
cmovne %rcx,%rdx
mov    %rsp,%rsi
mov    %r14,%rdi
call   1050 <udev_device_add_property@plt>
jmp    1182 <udev_device_add_property_from_string+0x52>
xor    %eax,%eax
add    $0x408,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.udev_list_entry = type { i32 }
%struct.udev_device = type { i32 }
define %struct.udev_list_entry* @udev_device_add_property_from_string(%struct.udev_device* %0, i8* %1) {
%3 = alloca %struct.udev_list_entry*
%4 = alloca %struct.udev_device*
%5 = alloca i8*
%6 = alloca [1024 x i8]
%7 = alloca i8*
store %struct.udev_device* %0, %struct.udev_device** %4
store i8* %1, i8** %5
%8 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%9 = load i8*, i8** %5
%10 = call i32 @util_strlcpy(i8* %8, i8* %9, i32 1024)
%11 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%12 = call i8* @strchr(i8* %11, i8 signext 61)
store i8* %12, i8** %7
%13 = load i8*, i8** %7
%14 = icmp eq i8* %13, null
br i1 %14, label %15, label %16
15: ; preds = %2
store %struct.udev_list_entry* null, %struct.udev_list_entry** %3
br label %32
16: ; preds = %2
%17 = load i8*, i8** %7
%18 = getelementptr inbounds i8, i8* %17, i64 0
store i8 0, i8* %18
%19 = load i8*, i8** %7
%20 = getelementptr inbounds i8, i8* %19, i64 1
store i8* %20, i8** %7
%21 = load i8*, i8** %7
%22 = getelementptr inbounds i8, i8* %21, i64 0
%23 = load i8, i8* %22
%24 = sext i8 %23 to i32
%25 = icmp eq i32 %24, 0
br i1 %25, label %26, label %27
26: ; preds = %16
store i8* null, i8** %7
br label %27
27: ; preds = %26, %16
%28 = load %struct.udev_device*, %struct.udev_device** %4
%29 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%30 = load i8*, i8** %7
%31 = call %struct.udev_list_entry* @udev_device_add_property(%struct.udev_device* %28, i8* %29, i8* %30)
store %struct.udev_list_entry* %31, %struct.udev_list_entry** %3
br label %32
32: ; preds = %27, %15
%33 = load %struct.udev_list_entry*, %struct.udev_list_entry** %3
ret %struct.udev_list_entry* %33
}

LLVM IR (-O2):
%struct.udev_list_entry = type { i32 }
%struct.udev_device = type { i32 }
define %struct.udev_list_entry* @udev_device_add_property_from_string(%struct.udev_device* %0, i8* %1) {
%3 = alloca [1024 x i8]
%4 = getelementptr inbounds [1024 x i8], [1024 x i8]* %3, i64 0, i64 0
%5 = call i32 @util_strlcpy(i8* %4, i8* %1, i32 1024)
%6 = call i8* @strchr(i8* %4, i8 signext 61)
%7 = icmp eq i8* %6, null
br i1 %7, label %14, label %8
8: ; preds = %2
store i8 0, i8* %6
%9 = getelementptr inbounds i8, i8* %6, i64 1
%10 = load i8, i8* %9
%11 = icmp eq i8 %10, 0
%12 = select i1 %11, i8* null, i8* %9
%13 = call %struct.udev_list_entry* @udev_device_add_property(%struct.udev_device* %0, i8* %4, i8* %12)
br label %14
14: ; preds = %2, %8
%15 = phi %struct.udev_list_entry* [ %13, %8 ], [ null, %2 ]
ret %struct.udev_list_entry* %15
}