#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 list_simple {
  int dummy;
};
struct list_node {
  int dummy;
};

/* Variables and functions */
int _list_append_node(struct list_simple **, struct list_node *);
int /*<<< orphan*/ _list_node_destroy(struct list_node **,
                                      int /*<<< orphan*/ *);
struct list_node *_list_node_new(void *);
int list_append_data(struct list_simple **list, void *data) {
  int rc;
  struct list_node *node;
  if (!list || !data)
    return -1;
  node = _list_node_new(data);
  if (!node)
    return -1;
  rc = _list_append_node(list, node);
  if (rc < 0)
    _list_node_destroy(&node, NULL);
  return rc;
}


x86 assembly (clang, -O0):
<list_append_data>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     1156 <list_append_data+0x26>
cmpq   $0x0,-0x18(%rbp)
jne    1162 <list_append_data+0x32>
movl   $0xffffffff,-0x4(%rbp)
jmp    11b3 <list_append_data+0x83>
mov    -0x18(%rbp),%rdi
call   1040 <_list_node_new@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    1186 <list_append_data+0x56>
movl   $0xffffffff,-0x4(%rbp)
jmp    11b3 <list_append_data+0x83>
mov    -0x10(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   1050 <_list_append_node@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jge    11ad <list_append_data+0x7d>
lea    -0x28(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1030 <_list_node_destroy@plt>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<list_append_data>:
push   %rbp
push   %rbx
push   %rax
mov    $0xffffffff,%ebp
test   %rdi,%rdi
je     1171 <list_append_data+0x41>
test   %rsi,%rsi
je     1171 <list_append_data+0x41>
mov    %rdi,%rbx
mov    %rsi,%rdi
call   1040 <_list_node_new@plt>
mov    %rax,(%rsp)
test   %rax,%rax
je     1171 <list_append_data+0x41>
mov    %rbx,%rdi
mov    %rax,%rsi
call   1050 <_list_append_node@plt>
mov    %eax,%ebp
test   %eax,%eax
jns    1171 <list_append_data+0x41>
mov    %rsp,%rdi
xor    %esi,%esi
call   1030 <_list_node_destroy@plt>
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
%struct.list_simple = type { i32 }
%struct.list_node = type { i32 }
define i32 @list_append_data(%struct.list_simple** %0, i8* %1) {
%3 = alloca i32
%4 = alloca %struct.list_simple**
%5 = alloca i8*
%6 = alloca i32
%7 = alloca %struct.list_node*
store %struct.list_simple** %0, %struct.list_simple*** %4
store i8* %1, i8** %5
%8 = load %struct.list_simple**, %struct.list_simple*** %4
%9 = icmp ne %struct.list_simple** %8, null
br i1 %9, label %10, label %13
10: ; preds = %2
%11 = load i8*, i8** %5
%12 = icmp ne i8* %11, null
br i1 %12, label %14, label %13
13: ; preds = %10, %2
store i32 -1, i32* %3
br label %30
14: ; preds = %10
%15 = load i8*, i8** %5
%16 = call %struct.list_node* @_list_node_new(i8* %15)
store %struct.list_node* %16, %struct.list_node** %7
%17 = load %struct.list_node*, %struct.list_node** %7
%18 = icmp ne %struct.list_node* %17, null
br i1 %18, label %20, label %19
19: ; preds = %14
store i32 -1, i32* %3
br label %30
20: ; preds = %14
%21 = load %struct.list_simple**, %struct.list_simple*** %4
%22 = load %struct.list_node*, %struct.list_node** %7
%23 = call i32 @_list_append_node(%struct.list_simple** %21, %struct.list_node* %22)
store i32 %23, i32* %6
%24 = load i32, i32* %6
%25 = icmp slt i32 %24, 0
br i1 %25, label %26, label %28
26: ; preds = %20
%27 = call i32 @_list_node_destroy(%struct.list_node** %7, i32* null)
br label %28
28: ; preds = %26, %20
%29 = load i32, i32* %6
store i32 %29, i32* %3
br label %30
30: ; preds = %28, %19, %13
%31 = load i32, i32* %3
ret i32 %31
}

LLVM IR (-O2):
%struct.list_simple = type { i32 }
%struct.list_node = type { i32 }
define i32 @list_append_data(%struct.list_simple** %0, i8* %1) {
%3 = alloca %struct.list_node*
%4 = bitcast %struct.list_node** %3 to i8*
%5 = icmp ne %struct.list_simple** %0, null
%6 = icmp ne i8* %1, null
%7 = and i1 %5, %6
br i1 %7, label %8, label %16
8: ; preds = %2
%9 = tail call %struct.list_node* @_list_node_new(i8* %1)
store %struct.list_node* %9, %struct.list_node** %3
%10 = icmp eq %struct.list_node* %9, null
br i1 %10, label %16, label %11
11: ; preds = %8
%12 = tail call i32 @_list_append_node(%struct.list_simple** %0, %struct.list_node* %9)
%13 = icmp slt i32 %12, 0
br i1 %13, label %14, label %16
14: ; preds = %11
%15 = call i32 @_list_node_destroy(%struct.list_node** %3, i32* null)
br label %16
16: ; preds = %11, %14, %8, %2
%17 = phi i32 [ -1, %2 ], [ -1, %8 ], [ %12, %14 ], [ %12, %11 ]
ret i32 %17
}