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

/* Variables and functions */
int /*<<< orphan*/ die(int, int, char *);
struct cramfs_inode *malloc(int);
struct cramfs_inode *cramfs_iget(struct cramfs_inode *i) {
  struct cramfs_inode *inode = malloc(sizeof(struct cramfs_inode));
  if (!inode) {
    die(8, 1, "malloc failed");
  }
  *inode = *i;
  return inode;
}


x86 assembly (clang, -O0):
<cramfs_iget>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    $0x4,%edi
call   1030 <malloc@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    115b <cramfs_iget+0x3b>
mov    $0x8,%edi
mov    $0x1,%esi
lea    0xeaa(%rip),%rdx
call   1040 <die@plt>
mov    -0x10(%rbp),%rax
mov    -0x8(%rbp),%rcx
mov    (%rcx),%ecx
mov    %ecx,(%rax)
mov    -0x10(%rbp),%rax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cramfs_iget>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
mov    $0x4,%edi
call   1030 <malloc@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    114f <cramfs_iget+0x2f>
lea    0xec0(%rip),%rdx
mov    $0x8,%edi
mov    $0x1,%esi
call   1040 <die@plt>
mov    (%r14),%eax
mov    %eax,(%rbx)
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.cramfs_inode = type { i32 }
@.str = [14 x i8] c"malloc failed\00"
define %struct.cramfs_inode* @cramfs_iget(%struct.cramfs_inode* %0) {
%2 = alloca %struct.cramfs_inode*
%3 = alloca %struct.cramfs_inode*
store %struct.cramfs_inode* %0, %struct.cramfs_inode** %2
%4 = call %struct.cramfs_inode* @malloc(i32 4)
store %struct.cramfs_inode* %4, %struct.cramfs_inode** %3
%5 = load %struct.cramfs_inode*, %struct.cramfs_inode** %3
%6 = icmp ne %struct.cramfs_inode* %5, null
br i1 %6, label %9, label %7
7: ; preds = %1
%8 = call i32 @die(i32 8, i32 1, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
br label %9
9: ; preds = %7, %1
%10 = load %struct.cramfs_inode*, %struct.cramfs_inode** %3
%11 = load %struct.cramfs_inode*, %struct.cramfs_inode** %2
%12 = bitcast %struct.cramfs_inode* %10 to i8*
%13 = bitcast %struct.cramfs_inode* %11 to i8*
%14 = load %struct.cramfs_inode*, %struct.cramfs_inode** %3
ret %struct.cramfs_inode* %14
}

LLVM IR (-O2):
%struct.cramfs_inode = type { i32 }
@.str = [14 x i8] c"malloc failed\00"
define noalias %struct.cramfs_inode* @cramfs_iget(%struct.cramfs_inode* nocapture %0) {
%2 = tail call %struct.cramfs_inode* @malloc(i32 4)
%3 = icmp eq %struct.cramfs_inode* %2, null
br i1 %3, label %4, label %6
4: ; preds = %1
%5 = tail call i32 @die(i32 8, i32 1, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
br label %6
6: ; preds = %4, %1
%7 = getelementptr %struct.cramfs_inode, %struct.cramfs_inode* %0, i64 0, i32 0
%8 = getelementptr %struct.cramfs_inode, %struct.cramfs_inode* %2, i64 0, i32 0
%9 = load i32, i32* %7
store i32 %9, i32* %8
ret %struct.cramfs_inode* %2
}