#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 */
scalar_t__ strcmp(char const *, char const *);
char *talloc_get_name(void const *);
void *talloc_check_name(const void *ptr, const char *name) {
  const char *pname;
  if (ptr == NULL)
    return NULL;
  pname = talloc_get_name(ptr);
  if (pname == name || strcmp(pname, name) == 0) {
    return ((void *)(ptr));
  }
  return NULL;
}


x86 assembly (clang, -O0):
<talloc_check_name>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1148 <talloc_check_name+0x28>
movq   $0x0,-0x8(%rbp)
jmp    118f <talloc_check_name+0x6f>
mov    -0x10(%rbp),%rdi
call   1030 <talloc_get_name@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
cmp    -0x18(%rbp),%rax
je     117a <talloc_check_name+0x5a>
mov    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    1187 <talloc_check_name+0x67>
mov    -0x10(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    118f <talloc_check_name+0x6f>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<talloc_check_name>:
push   %r14
push   %rbx
push   %rax
test   %rdi,%rdi
je     114f <talloc_check_name+0x2f>
mov    %rsi,%r14
mov    %rdi,%rbx
call   1030 <talloc_get_name@plt>
cmp    %r14,%rax
je     1151 <talloc_check_name+0x31>
mov    %rax,%rdi
mov    %r14,%rsi
call   1040 <strcmp@plt>
xor    %ecx,%ecx
test   %rax,%rax
cmovne %rcx,%rbx
jmp    1151 <talloc_check_name+0x31>
xor    %ebx,%ebx
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
define i8* @talloc_check_name(i8* %0, i8* %1) {
%3 = icmp eq i8* %0, null
br i1 %3, label %11, label %4
4: ; preds = %2
%5 = tail call i8* @talloc_get_name(i8* %0)
%6 = icmp eq i8* %5, %1
br i1 %6, label %11, label %7
7: ; preds = %4
%8 = tail call i64 @strcmp(i8* %5, i8* %1)
%9 = icmp eq i64 %8, 0
%10 = select i1 %9, i8* %0, i8* null
br label %11
11: ; preds = %7, %4, %2
%12 = phi i8* [ null, %2 ], [ %0, %4 ], [ %10, %7 ]
ret i8* %12
}