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

/* Variables and functions */
struct node *init_list();
scalar_t__ list_insert(struct node *, int);
int /*<<< orphan*/ list_show(struct node *);
int /*<<< orphan*/ release_list(struct node *);
int main() {
  struct node *p_head = init_list();
  int array[10] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
  int i = 0;
  for (i = 0; i < 10; i++) {
    if (list_insert(p_head, array[i]) < 0) {
      goto failed;
    }
  }
  list_show(p_head);
failed:
  release_list(p_head);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1070 <init_list@plt>
mov    %rax,-0x10(%rbp)
lea    -0x40(%rbp),%rdi
lea    0xe8b(%rip),%rsi
mov    $0x28,%edx
call   1030 <memcpy@plt>
movl   $0x0,-0x44(%rbp)
movl   $0x0,-0x44(%rbp)
cmpl   $0xa,-0x44(%rbp)
jge    11ca <main+0x7a>
mov    -0x10(%rbp),%rdi
movslq -0x44(%rbp),%rax
mov    -0x40(%rbp,%rax,4),%esi
call   1040 <list_insert@plt>
cmp    $0x0,%rax
jge    11b7 <main+0x67>
jmp    11d3 <main+0x83>
jmp    11bc <main+0x6c>
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
jmp    118d <main+0x3d>
mov    -0x10(%rbp),%rdi
call   1060 <list_show@plt>
mov    -0x10(%rbp),%rdi
call   1050 <release_list@plt>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
xor    %eax,%eax
call   1060 <init_list@plt>
mov    %rax,%rbx
mov    %rax,%rdi
mov    $0x1,%esi
call   1030 <list_insert@plt>
test   %rax,%rax
js     1213 <main+0xd3>
mov    %rbx,%rdi
mov    $0x2,%esi
call   1030 <list_insert@plt>
test   %rax,%rax
js     1213 <main+0xd3>
mov    %rbx,%rdi
mov    $0x3,%esi
call   1030 <list_insert@plt>
test   %rax,%rax
js     1213 <main+0xd3>
mov    %rbx,%rdi
mov    $0x4,%esi
call   1030 <list_insert@plt>
test   %rax,%rax
js     1213 <main+0xd3>
mov    %rbx,%rdi
mov    $0x5,%esi
call   1030 <list_insert@plt>
test   %rax,%rax
js     1213 <main+0xd3>
mov    %rbx,%rdi
mov    $0x6,%esi
call   1030 <list_insert@plt>
test   %rax,%rax
js     1213 <main+0xd3>
mov    %rbx,%rdi
mov    $0x7,%esi
call   1030 <list_insert@plt>
test   %rax,%rax
js     1213 <main+0xd3>
mov    %rbx,%rdi
mov    $0x8,%esi
call   1030 <list_insert@plt>
test   %rax,%rax
js     1213 <main+0xd3>
mov    %rbx,%rdi
mov    $0x9,%esi
call   1030 <list_insert@plt>
test   %rax,%rax
js     1213 <main+0xd3>
mov    %rbx,%rdi
mov    $0xa,%esi
call   1030 <list_insert@plt>
test   %rax,%rax
js     1213 <main+0xd3>
mov    %rbx,%rdi
call   1050 <list_show@plt>
mov    %rbx,%rdi
call   1040 <release_list@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
%struct.node = type { i32 }
@__const.main.array = [10 x i32] [i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10]
define i32 @main() {
%1 = alloca i32
%2 = alloca %struct.node*
%3 = alloca [10 x i32]
%4 = alloca i32
store i32 0, i32* %1
%5 = call %struct.node* (...) @init_list()
store %struct.node* %5, %struct.node** %2
%6 = bitcast [10 x i32]* %3 to i8*
store i32 0, i32* %4
store i32 0, i32* %4
br label %7
7: ; preds = %20, %0
%8 = load i32, i32* %4
%9 = icmp slt i32 %8, 10
br i1 %9, label %10, label %23
10: ; preds = %7
%11 = load %struct.node*, %struct.node** %2
%12 = load i32, i32* %4
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds [10 x i32], [10 x i32]* %3, i64 0, i64 %13
%15 = load i32, i32* %14
%16 = call i64 @list_insert(%struct.node* %11, i32 %15)
%17 = icmp slt i64 %16, 0
br i1 %17, label %18, label %19
18: ; preds = %10
br label %26
19: ; preds = %10
br label %20
20: ; preds = %19
%21 = load i32, i32* %4
%22 = add nsw i32 %21, 1
store i32 %22, i32* %4
br label %7
23: ; preds = %7
%24 = load %struct.node*, %struct.node** %2
%25 = call i32 @list_show(%struct.node* %24)
br label %26
26: ; preds = %23, %18
%27 = load %struct.node*, %struct.node** %2
%28 = call i32 @release_list(%struct.node* %27)
ret i32 0
}

LLVM IR (-O2):
%struct.node = type { i32 }
define i32 @main() {
%1 = tail call %struct.node* (...) @init_list()
%2 = tail call i64 @list_insert(%struct.node* %1, i32 1)
%3 = icmp slt i64 %2, 0
br i1 %3, label %33, label %4
4: ; preds = %0
%5 = tail call i64 @list_insert(%struct.node* %1, i32 2)
%6 = icmp slt i64 %5, 0
br i1 %6, label %33, label %7
7: ; preds = %4
%8 = tail call i64 @list_insert(%struct.node* %1, i32 3)
%9 = icmp slt i64 %8, 0
br i1 %9, label %33, label %10
10: ; preds = %7
%11 = tail call i64 @list_insert(%struct.node* %1, i32 4)
%12 = icmp slt i64 %11, 0
br i1 %12, label %33, label %13
13: ; preds = %10
%14 = tail call i64 @list_insert(%struct.node* %1, i32 5)
%15 = icmp slt i64 %14, 0
br i1 %15, label %33, label %16
16: ; preds = %13
%17 = tail call i64 @list_insert(%struct.node* %1, i32 6)
%18 = icmp slt i64 %17, 0
br i1 %18, label %33, label %19
19: ; preds = %16
%20 = tail call i64 @list_insert(%struct.node* %1, i32 7)
%21 = icmp slt i64 %20, 0
br i1 %21, label %33, label %22
22: ; preds = %19
%23 = tail call i64 @list_insert(%struct.node* %1, i32 8)
%24 = icmp slt i64 %23, 0
br i1 %24, label %33, label %25
25: ; preds = %22
%26 = tail call i64 @list_insert(%struct.node* %1, i32 9)
%27 = icmp slt i64 %26, 0
br i1 %27, label %33, label %28
28: ; preds = %25
%29 = tail call i64 @list_insert(%struct.node* %1, i32 10)
%30 = icmp slt i64 %29, 0
br i1 %30, label %33, label %31
31: ; preds = %28
%32 = tail call i32 @list_show(%struct.node* %1)
br label %33
33: ; preds = %0, %4, %7, %10, %13, %16, %19, %22, %25, %28, %31
%34 = tail call i32 @release_list(%struct.node* %1)
ret i32 0
}