#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_device {
  int dummy;
};

/* Variables and functions */
scalar_t__ fnmatch(char const *, char const *, int /*<<< orphan*/);
char *udev_device_get_sysattr_value(struct udev_device *, char const *);
int match_sysattr_value(struct udev_device *dev, const char *sysattr,
                        const char *match_val) {
  const char *val = NULL;
  bool match = false;
  val = udev_device_get_sysattr_value(dev, sysattr);
  if (val == NULL)
    goto exit;
  if (match_val == NULL) {
    match = true;
    goto exit;
  }
  if (fnmatch(match_val, val, 0) == 0) {
    match = true;
    goto exit;
  }
exit:
  return match;
}


x86 assembly (clang, -O0):
<match_sysattr_value>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1040 <udev_device_get_sysattr_value@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    1164 <match_sysattr_value+0x44>
jmp    11a5 <match_sysattr_value+0x85>
cmpq   $0x0,-0x18(%rbp)
jne    117b <match_sysattr_value+0x5b>
movl   $0x1,-0x24(%rbp)
jmp    11a5 <match_sysattr_value+0x85>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
xor    %edx,%edx
call   1030 <fnmatch@plt>
cmp    $0x0,%rax
jne    11a0 <match_sysattr_value+0x80>
movl   $0x1,-0x24(%rbp)
jmp    11a5 <match_sysattr_value+0x85>
jmp    11a5 <match_sysattr_value+0x85>
mov    -0x24(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<match_sysattr_value>:
push   %rbx
mov    %rdx,%rbx
call   1040 <udev_device_get_sysattr_value@plt>
test   %rax,%rax
je     114d <match_sysattr_value+0x2d>
test   %rbx,%rbx
je     1151 <match_sysattr_value+0x31>
mov    %rbx,%rdi
mov    %rax,%rsi
xor    %edx,%edx
call   1030 <fnmatch@plt>
mov    %rax,%rcx
xor    %eax,%eax
test   %rcx,%rcx
sete   %al
pop    %rbx
ret
xor    %eax,%eax
pop    %rbx
ret
mov    $0x1,%eax
pop    %rbx
ret

LLVM IR (-O0):
%struct.udev_device = type { i32 }
define i32 @match_sysattr_value(%struct.udev_device* %0, i8* %1, i8* %2) {
%4 = alloca %struct.udev_device*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i32
store %struct.udev_device* %0, %struct.udev_device** %4
store i8* %1, i8** %5
store i8* %2, i8** %6
store i8* null, i8** %7
store i32 0, i32* %8
%9 = load %struct.udev_device*, %struct.udev_device** %4
%10 = load i8*, i8** %5
%11 = call i8* @udev_device_get_sysattr_value(%struct.udev_device* %9, i8* %10)
store i8* %11, i8** %7
%12 = load i8*, i8** %7
%13 = icmp eq i8* %12, null
br i1 %13, label %14, label %15
14: ; preds = %3
br label %26
15: ; preds = %3
%16 = load i8*, i8** %6
%17 = icmp eq i8* %16, null
br i1 %17, label %18, label %19
18: ; preds = %15
store i32 1, i32* %8
br label %26
19: ; preds = %15
%20 = load i8*, i8** %6
%21 = load i8*, i8** %7
%22 = call i64 @fnmatch(i8* %20, i8* %21, i32 0)
%23 = icmp eq i64 %22, 0
br i1 %23, label %24, label %25
24: ; preds = %19
store i32 1, i32* %8
br label %26
25: ; preds = %19
br label %26
26: ; preds = %25, %24, %18, %14
%27 = load i32, i32* %8
ret i32 %27
}

LLVM IR (-O2):
%struct.udev_device = type { i32 }
define i32 @match_sysattr_value(%struct.udev_device* %0, i8* %1, i8* %2) {
%4 = tail call i8* @udev_device_get_sysattr_value(%struct.udev_device* %0, i8* %1)
%5 = icmp eq i8* %4, null
br i1 %5, label %12, label %6
6: ; preds = %3
%7 = icmp eq i8* %2, null
br i1 %7, label %12, label %8
8: ; preds = %6
%9 = tail call i64 @fnmatch(i8* %2, i8* %4, i32 0)
%10 = icmp eq i64 %9, 0
%11 = zext i1 %10 to i32
br label %12
12: ; preds = %8, %6, %3
%13 = phi i32 [ 0, %3 ], [ 1, %6 ], [ %11, %8 ]
ret i32 %13
}