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

/* Variables and functions */
struct list_t *insert_between(struct list_t *, struct list_t *,
                              char const *const);
int update_list(struct list_t **list, struct list_t *prev, struct list_t *next,
                char const *const name) {
  struct list_t *e;
  e = insert_between(prev, next, name);
  if (e == NULL)
    return -1;
  *list = e;
  return 0;
}


x86 assembly (clang, -O0):
<update_list>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x28(%rbp),%rdx
call   1030 <insert_between@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    1154 <update_list+0x44>
movl   $0xffffffff,-0x4(%rbp)
jmp    1166 <update_list+0x56>
mov    -0x30(%rbp),%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<update_list>:
push   %rbx
mov    %rdi,%rbx
mov    %rsi,%rdi
mov    %rdx,%rsi
mov    %rcx,%rdx
call   1030 <insert_between@plt>
test   %rax,%rax
je     112e <update_list+0x1e>
mov    %rax,(%rbx)
xor    %eax,%eax
pop    %rbx
ret
mov    $0xffffffff,%eax
pop    %rbx
ret

LLVM IR (-O0):
%struct.list_t = type { i32 }
define i32 @update_list(%struct.list_t** %0, %struct.list_t* %1, %struct.list_t* %2, i8* %3) {
%5 = alloca i32
%6 = alloca %struct.list_t**
%7 = alloca %struct.list_t*
%8 = alloca %struct.list_t*
%9 = alloca i8*
%10 = alloca %struct.list_t*
store %struct.list_t** %0, %struct.list_t*** %6
store %struct.list_t* %1, %struct.list_t** %7
store %struct.list_t* %2, %struct.list_t** %8
store i8* %3, i8** %9
%11 = load %struct.list_t*, %struct.list_t** %7
%12 = load %struct.list_t*, %struct.list_t** %8
%13 = load i8*, i8** %9
%14 = call %struct.list_t* @insert_between(%struct.list_t* %11, %struct.list_t* %12, i8* %13)
store %struct.list_t* %14, %struct.list_t** %10
%15 = load %struct.list_t*, %struct.list_t** %10
%16 = icmp eq %struct.list_t* %15, null
br i1 %16, label %17, label %18
17: ; preds = %4
store i32 -1, i32* %5
br label %21
18: ; preds = %4
%19 = load %struct.list_t*, %struct.list_t** %10
%20 = load %struct.list_t**, %struct.list_t*** %6
store %struct.list_t* %19, %struct.list_t** %20
store i32 0, i32* %5
br label %21
21: ; preds = %18, %17
%22 = load i32, i32* %5
ret i32 %22
}

LLVM IR (-O2):
%struct.list_t = type { i32 }
define i32 @update_list(%struct.list_t** nocapture writeonly %0, %struct.list_t* %1, %struct.list_t* %2, i8* %3) {
%5 = tail call %struct.list_t* @insert_between(%struct.list_t* %1, %struct.list_t* %2, i8* %3)
%6 = icmp eq %struct.list_t* %5, null
br i1 %6, label %8, label %7
7: ; preds = %4
store %struct.list_t* %5, %struct.list_t** %0
br label %8
8: ; preds = %4, %7
%9 = phi i32 [ 0, %7 ], [ -1, %4 ]
ret i32 %9
}