#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 */
typedef int /*<<< orphan*/ uint64_t;
struct Node {
  int dummy;
};

/* Variables and functions */
int node_link(struct Node *, struct Node *);
struct Node *node_new(int /*<<< orphan*/ const);
int /*<<< orphan*/ printf(char *);
struct Node *node_new_leaf(const uint64_t ope, void *val) {
  struct Node *a = node_new(ope);
  if (a == NULL) {
    printf("err: node_new_leaf(), node_new(), a\n");
    return NULL;
  }
  int err = node_link(a, (struct Node *)val);
  if (err) {
    printf("err: node_new_leaf(), node_link()\n");
    return NULL;
  }
  return a;
}


x86 assembly (clang, -O0):
<node_new_leaf>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0xc(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0xc(%rbp),%edi
call   1050 <node_new@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    116f <node_new_leaf+0x3f>
lea    0xea3(%rip),%rdi
call   1040 <printf@plt>
movq   $0x0,-0x8(%rbp)
jmp    11aa <node_new_leaf+0x7a>
mov    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <node_link@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
je     11a2 <node_new_leaf+0x72>
lea    0xe95(%rip),%rdi
call   1040 <printf@plt>
movq   $0x0,-0x8(%rbp)
jmp    11aa <node_new_leaf+0x7a>
mov    -0x20(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<node_new_leaf>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
call   1050 <node_new@plt>
test   %rax,%rax
je     115c <node_new_leaf+0x2c>
mov    %rax,%rbx
mov    %rax,%rdi
mov    %r14,%rsi
call   1040 <node_link@plt>
test   %eax,%eax
je     116a <node_new_leaf+0x3a>
lea    0xea6(%rip),%rdi
jmp    1163 <node_new_leaf+0x33>
lea    0xebf(%rip),%rdi
call   1030 <puts@plt>
xor    %ebx,%ebx
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.Node = type { i32 }
@.str = [37 x i8] c"err: node_new_leaf(), node_new(), a\0A\00"
@.str.1 = [35 x i8] c"err: node_new_leaf(), node_link()\0A\00"
define %struct.Node* @node_new_leaf(i32 %0, i8* %1) {
%3 = alloca %struct.Node*
%4 = alloca i32
%5 = alloca i8*
%6 = alloca %struct.Node*
%7 = alloca i32
store i32 %0, i32* %4
store i8* %1, i8** %5
%8 = load i32, i32* %4
%9 = call %struct.Node* @node_new(i32 %8)
store %struct.Node* %9, %struct.Node** %6
%10 = load %struct.Node*, %struct.Node** %6
%11 = icmp eq %struct.Node* %10, null
br i1 %11, label %12, label %14
12: ; preds = %2
%13 = call i32 @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str, i64 0, i64 0))
store %struct.Node* null, %struct.Node** %3
br label %25
14: ; preds = %2
%15 = load %struct.Node*, %struct.Node** %6
%16 = load i8*, i8** %5
%17 = bitcast i8* %16 to %struct.Node*
%18 = call i32 @node_link(%struct.Node* %15, %struct.Node* %17)
store i32 %18, i32* %7
%19 = load i32, i32* %7
%20 = icmp ne i32 %19, 0
br i1 %20, label %21, label %23
21: ; preds = %14
%22 = call i32 @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.1, i64 0, i64 0))
store %struct.Node* null, %struct.Node** %3
br label %25
23: ; preds = %14
%24 = load %struct.Node*, %struct.Node** %6
store %struct.Node* %24, %struct.Node** %3
br label %25
25: ; preds = %23, %21, %12
%26 = load %struct.Node*, %struct.Node** %3
ret %struct.Node* %26
}

LLVM IR (-O2):
%struct.Node = type { i32 }
@str = [34 x i8] c"err: node_new_leaf(), node_link()\00"
@str.2 = [36 x i8] c"err: node_new_leaf(), node_new(), a\00"
define %struct.Node* @node_new_leaf(i32 %0, i8* %1) {
%3 = tail call %struct.Node* @node_new(i32 %0)
%4 = icmp eq %struct.Node* %3, null
br i1 %4, label %9, label %5
5: ; preds = %2
%6 = bitcast i8* %1 to %struct.Node*
%7 = tail call i32 @node_link(%struct.Node* %3, %struct.Node* %6)
%8 = icmp eq i32 %7, 0
br i1 %8, label %12, label %9
9: ; preds = %5, %2
%10 = phi i8* [ getelementptr inbounds ([36 x i8], [36 x i8]* @str.2, i64 0, i64 0), %2 ], [ getelementptr inbounds ([34 x i8], [34 x i8]* @str, i64 0, i64 0), %5 ]
%11 = tail call i32 @puts(i8* dereferenceable(1) %10)
br label %12
12: ; preds = %9, %5
%13 = phi %struct.Node* [ %3, %5 ], [ null, %9 ]
ret %struct.Node* %13
}