#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 net_device {
  int dummy;
};
typedef void neighbour;
struct neigh_table {
  int dummy;
};

/* Variables and functions */
scalar_t__ IS_ERR(void *);
void *neigh_create(struct neigh_table *, void const *, struct net_device *);
void *neigh_lookup(struct neigh_table *, void const *, struct net_device *);
struct neighbour *__neigh_lookup(struct neigh_table *tbl, const void *pkey,
                                 struct net_device *dev, int creat) {
  struct neighbour *n = neigh_lookup(tbl, pkey, dev);
  if (n || !creat)
    return n;
  n = neigh_create(tbl, pkey, dev);
  return IS_ERR(n) ? ((void *)0) : n;
}


x86 assembly (clang, -O0):
<__neigh_lookup>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %ecx,-0x24(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
call   1050 <neigh_lookup@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    1171 <__neigh_lookup+0x41>
cmpl   $0x0,-0x24(%rbp)
jne    117e <__neigh_lookup+0x4e>
mov    -0x30(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    11c1 <__neigh_lookup+0x91>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
call   1030 <neigh_create@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rdi
call   1040 <IS_ERR@plt>
cmp    $0x0,%rax
je     11b1 <__neigh_lookup+0x81>
xor    %eax,%eax
mov    %rax,-0x38(%rbp)
jmp    11b9 <__neigh_lookup+0x89>
mov    -0x30(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<__neigh_lookup>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %ecx,%ebp
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%rbx
call   1050 <neigh_lookup@plt>
test   %ebp,%ebp
je     1175 <__neigh_lookup+0x45>
test   %rax,%rax
jne    1175 <__neigh_lookup+0x45>
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %r14,%rdx
call   1030 <neigh_create@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1040 <IS_ERR@plt>
mov    %rax,%rcx
xor    %eax,%eax
test   %rcx,%rcx
cmove  %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.neighbour = type opaque
%struct.neigh_table = type { i32 }
%struct.net_device = type { i32 }
define %struct.neighbour* @__neigh_lookup(%struct.neigh_table* %0, i8* %1, %struct.net_device* %2, i32 %3) {
%5 = alloca %struct.neighbour*
%6 = alloca %struct.neigh_table*
%7 = alloca i8*
%8 = alloca %struct.net_device*
%9 = alloca i32
%10 = alloca %struct.neighbour*
store %struct.neigh_table* %0, %struct.neigh_table** %6
store i8* %1, i8** %7
store %struct.net_device* %2, %struct.net_device** %8
store i32 %3, i32* %9
%11 = load %struct.neigh_table*, %struct.neigh_table** %6
%12 = load i8*, i8** %7
%13 = load %struct.net_device*, %struct.net_device** %8
%14 = call i8* @neigh_lookup(%struct.neigh_table* %11, i8* %12, %struct.net_device* %13)
%15 = bitcast i8* %14 to %struct.neighbour*
store %struct.neighbour* %15, %struct.neighbour** %10
%16 = load %struct.neighbour*, %struct.neighbour** %10
%17 = icmp ne %struct.neighbour* %16, null
br i1 %17, label %21, label %18
18: ; preds = %4
%19 = load i32, i32* %9
%20 = icmp ne i32 %19, 0
br i1 %20, label %23, label %21
21: ; preds = %18, %4
%22 = load %struct.neighbour*, %struct.neighbour** %10
store %struct.neighbour* %22, %struct.neighbour** %5
br label %38
23: ; preds = %18
%24 = load %struct.neigh_table*, %struct.neigh_table** %6
%25 = load i8*, i8** %7
%26 = load %struct.net_device*, %struct.net_device** %8
%27 = call i8* @neigh_create(%struct.neigh_table* %24, i8* %25, %struct.net_device* %26)
%28 = bitcast i8* %27 to %struct.neighbour*
store %struct.neighbour* %28, %struct.neighbour** %10
%29 = load %struct.neighbour*, %struct.neighbour** %10
%30 = bitcast %struct.neighbour* %29 to i8*
%31 = call i64 @IS_ERR(i8* %30)
%32 = icmp ne i64 %31, 0
br i1 %32, label %33, label %34
33: ; preds = %23
br label %36
34: ; preds = %23
%35 = load %struct.neighbour*, %struct.neighbour** %10
br label %36
36: ; preds = %34, %33
%37 = phi %struct.neighbour* [ null, %33 ], [ %35, %34 ]
store %struct.neighbour* %37, %struct.neighbour** %5
br label %38
38: ; preds = %36, %21
%39 = load %struct.neighbour*, %struct.neighbour** %5
ret %struct.neighbour* %39
}

LLVM IR (-O2):
%struct.neighbour = type opaque
%struct.neigh_table = type { i32 }
%struct.net_device = type { i32 }
define %struct.neighbour* @__neigh_lookup(%struct.neigh_table* %0, i8* %1, %struct.net_device* %2, i32 %3) {
%5 = tail call i8* @neigh_lookup(%struct.neigh_table* %0, i8* %1, %struct.net_device* %2)
%6 = icmp eq i8* %5, null
%7 = icmp ne i32 %3, 0
%8 = and i1 %7, %6
br i1 %8, label %11, label %9
9: ; preds = %4
%10 = bitcast i8* %5 to %struct.neighbour*
br label %17
11: ; preds = %4
%12 = tail call i8* @neigh_create(%struct.neigh_table* %0, i8* %1, %struct.net_device* %2)
%13 = bitcast i8* %12 to %struct.neighbour*
%14 = tail call i64 @IS_ERR(i8* %12)
%15 = icmp eq i64 %14, 0
%16 = select i1 %15, %struct.neighbour* %13, %struct.neighbour* null
br label %17
17: ; preds = %11, %9
%18 = phi %struct.neighbour* [ %16, %11 ], [ %10, %9 ]
ret %struct.neighbour* %18
}