#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 inode {
  int dummy;
};
struct dentry {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ d_instantiate(struct dentry *, struct inode *);
int /*<<< orphan*/ iput(struct inode *);
int sfs_add_link(struct dentry *, struct inode *);
int add_nondir(struct dentry *dentry, struct inode *inode) {
  int err = sfs_add_link(dentry, inode);
  if (!err) {
    d_instantiate(dentry, inode);
    return 0;
  }
  iput(inode);
  return err;
}


x86 assembly (clang, -O0):
<add_nondir>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1050 <sfs_add_link@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jne    1173 <add_nondir+0x43>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <d_instantiate@plt>
movl   $0x0,-0x4(%rbp)
jmp    1182 <add_nondir+0x52>
mov    -0x18(%rbp),%rdi
call   1040 <iput@plt>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<add_nondir>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%rbx
mov    %rdi,%r14
call   1050 <sfs_add_link@plt>
mov    %eax,%ebp
test   %eax,%eax
je     114f <add_nondir+0x1f>
mov    %rbx,%rdi
call   1040 <iput@plt>
jmp    115a <add_nondir+0x2a>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1030 <d_instantiate@plt>
mov    %ebp,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
%struct.dentry = type { i32 }
%struct.inode = type { i32 }
define i32 @add_nondir(%struct.dentry* %0, %struct.inode* %1) {
%3 = alloca i32
%4 = alloca %struct.dentry*
%5 = alloca %struct.inode*
%6 = alloca i32
store %struct.dentry* %0, %struct.dentry** %4
store %struct.inode* %1, %struct.inode** %5
%7 = load %struct.dentry*, %struct.dentry** %4
%8 = load %struct.inode*, %struct.inode** %5
%9 = call i32 @sfs_add_link(%struct.dentry* %7, %struct.inode* %8)
store i32 %9, i32* %6
%10 = load i32, i32* %6
%11 = icmp ne i32 %10, 0
br i1 %11, label %16, label %12
12: ; preds = %2
%13 = load %struct.dentry*, %struct.dentry** %4
%14 = load %struct.inode*, %struct.inode** %5
%15 = call i32 @d_instantiate(%struct.dentry* %13, %struct.inode* %14)
store i32 0, i32* %3
br label %20
16: ; preds = %2
%17 = load %struct.inode*, %struct.inode** %5
%18 = call i32 @iput(%struct.inode* %17)
%19 = load i32, i32* %6
store i32 %19, i32* %3
br label %20
20: ; preds = %16, %12
%21 = load i32, i32* %3
ret i32 %21
}

LLVM IR (-O2):
%struct.dentry = type { i32 }
%struct.inode = type { i32 }
define i32 @add_nondir(%struct.dentry* %0, %struct.inode* %1) {
%3 = tail call i32 @sfs_add_link(%struct.dentry* %0, %struct.inode* %1)
%4 = icmp eq i32 %3, 0
br i1 %4, label %5, label %7
5: ; preds = %2
%6 = tail call i32 @d_instantiate(%struct.dentry* %0, %struct.inode* %1)
br label %9
7: ; preds = %2
%8 = tail call i32 @iput(%struct.inode* %1)
br label %9
9: ; preds = %7, %5
ret i32 %3
}