#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 */
char *fdt_get_name(void const *, int, int *);
int /*<<< orphan*/ memchr(char const *, char, int);
scalar_t__ memcmp(char const *, char const *, int);
int fdt_nodename_eq_(const void *fdt, int offset, const char *s, int len) {
  int olen;
  const char *p = fdt_get_name(fdt, offset, &olen);
  if (!p || olen < len)
    return 0;
  if (memcmp(p, s, len) != 0)
    return 0;
  if (p[len] == '\0')
    return 1;
  else if (!memchr(s, '@', len) && (p[len] == '@'))
    return 1;
  else
    return 0;
}


x86 assembly (clang, -O0):
<fdt_nodename_eq_>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %ecx,-0x24(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
lea    -0x28(%rbp),%rdx
call   1030 <fdt_get_name@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
je     1171 <fdt_nodename_eq_+0x41>
mov    -0x28(%rbp),%eax
cmp    -0x24(%rbp),%eax
jge    117d <fdt_nodename_eq_+0x4d>
movl   $0x0,-0x4(%rbp)
jmp    1206 <fdt_nodename_eq_+0xd6>
mov    -0x30(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x24(%rbp),%edx
call   1050 <memcmp@plt>
cmp    $0x0,%rax
je     11a3 <fdt_nodename_eq_+0x73>
movl   $0x0,-0x4(%rbp)
jmp    1206 <fdt_nodename_eq_+0xd6>
mov    -0x30(%rbp),%rax
movslq -0x24(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x0,%eax
jne    11c4 <fdt_nodename_eq_+0x94>
movl   $0x1,-0x4(%rbp)
jmp    1206 <fdt_nodename_eq_+0xd6>
mov    -0x20(%rbp),%rdi
mov    -0x24(%rbp),%edx
mov    $0x40,%esi
call   1040 <memchr@plt>
cmp    $0x0,%eax
jne    11ff <fdt_nodename_eq_+0xcf>
mov    -0x30(%rbp),%rax
movslq -0x24(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x40,%eax
jne    11ff <fdt_nodename_eq_+0xcf>
movl   $0x1,-0x4(%rbp)
jmp    1206 <fdt_nodename_eq_+0xd6>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fdt_nodename_eq_>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %ecx,%ebp
mov    %rdx,%r15
lea    0xc(%rsp),%rdx
call   1030 <fdt_get_name@plt>
xor    %r14d,%r14d
test   %rax,%rax
je     119b <fdt_nodename_eq_+0x6b>
cmp    %ebp,0xc(%rsp)
jl     119b <fdt_nodename_eq_+0x6b>
mov    %rax,%rbx
mov    %rax,%rdi
mov    %r15,%rsi
mov    %ebp,%edx
call   1050 <memcmp@plt>
test   %rax,%rax
jne    119b <fdt_nodename_eq_+0x6b>
movslq %ebp,%r12
mov    $0x1,%r14d
cmpb   $0x0,(%rbx,%r12,1)
je     119b <fdt_nodename_eq_+0x6b>
mov    %r15,%rdi
mov    $0x40,%esi
mov    %ebp,%edx
call   1040 <memchr@plt>
test   %eax,%eax
jne    1198 <fdt_nodename_eq_+0x68>
cmpb   $0x40,(%rbx,%r12,1)
je     119b <fdt_nodename_eq_+0x6b>
xor    %r14d,%r14d
mov    %r14d,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @fdt_nodename_eq_(i8* %0, i32 %1, i8* %2, i32 %3) {
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i32
%10 = alloca i32
%11 = alloca i8*
store i8* %0, i8** %6
store i32 %1, i32* %7
store i8* %2, i8** %8
store i32 %3, i32* %9
%12 = load i8*, i8** %6
%13 = load i32, i32* %7
%14 = call i8* @fdt_get_name(i8* %12, i32 %13, i32* %10)
store i8* %14, i8** %11
%15 = load i8*, i8** %11
%16 = icmp ne i8* %15, null
br i1 %16, label %17, label %21
17: ; preds = %4
%18 = load i32, i32* %10
%19 = load i32, i32* %9
%20 = icmp slt i32 %18, %19
br i1 %20, label %21, label %22
21: ; preds = %17, %4
store i32 0, i32* %5
br label %53
22: ; preds = %17
%23 = load i8*, i8** %11
%24 = load i8*, i8** %8
%25 = load i32, i32* %9
%26 = call i64 @memcmp(i8* %23, i8* %24, i32 %25)
%27 = icmp ne i64 %26, 0
br i1 %27, label %28, label %29
28: ; preds = %22
store i32 0, i32* %5
br label %53
29: ; preds = %22
%30 = load i8*, i8** %11
%31 = load i32, i32* %9
%32 = sext i32 %31 to i64
%33 = getelementptr inbounds i8, i8* %30, i64 %32
%34 = load i8, i8* %33
%35 = sext i8 %34 to i32
%36 = icmp eq i32 %35, 0
br i1 %36, label %37, label %38
37: ; preds = %29
store i32 1, i32* %5
br label %53
38: ; preds = %29
%39 = load i8*, i8** %8
%40 = load i32, i32* %9
%41 = call i32 @memchr(i8* %39, i8 signext 64, i32 %40)
%42 = icmp ne i32 %41, 0
br i1 %42, label %52, label %43
43: ; preds = %38
%44 = load i8*, i8** %11
%45 = load i32, i32* %9
%46 = sext i32 %45 to i64
%47 = getelementptr inbounds i8, i8* %44, i64 %46
%48 = load i8, i8* %47
%49 = sext i8 %48 to i32
%50 = icmp eq i32 %49, 64
br i1 %50, label %51, label %52
51: ; preds = %43
store i32 1, i32* %5
br label %53
52: ; preds = %43, %38
store i32 0, i32* %5
br label %53
53: ; preds = %52, %51, %37, %28, %21
%54 = load i32, i32* %5
ret i32 %54
}

LLVM IR (-O2):
define i32 @fdt_nodename_eq_(i8* %0, i32 %1, i8* %2, i32 %3) {
%5 = alloca i32
%6 = bitcast i32* %5 to i8*
%7 = call i8* @fdt_get_name(i8* %0, i32 %1, i32* %5)
%8 = icmp eq i8* %7, null
%9 = load i32, i32* %5
%10 = icmp slt i32 %9, %3
%11 = select i1 %8, i1 true, i1 %10
br i1 %11, label %27, label %12
12: ; preds = %4
%13 = call i64 @memcmp(i8* %7, i8* %2, i32 %3)
%14 = icmp eq i64 %13, 0
br i1 %14, label %15, label %27
15: ; preds = %12
%16 = sext i32 %3 to i64
%17 = getelementptr inbounds i8, i8* %7, i64 %16
%18 = load i8, i8* %17
%19 = icmp eq i8 %18, 0
br i1 %19, label %27, label %20
20: ; preds = %15
%21 = call i32 @memchr(i8* %2, i8 signext 64, i32 %3)
%22 = icmp eq i32 %21, 0
br i1 %22, label %23, label %26
23: ; preds = %20
%24 = load i8, i8* %17
%25 = icmp eq i8 %24, 64
br i1 %25, label %27, label %26
26: ; preds = %23, %20
br label %27
27: ; preds = %23, %15, %12, %4, %26
%28 = phi i32 [ 0, %26 ], [ 0, %4 ], [ 0, %12 ], [ 1, %15 ], [ 1, %23 ]
ret i32 %28
}