#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 waiter_ticket {
  int dummy;
};
struct waiter {
  int dummy;
};

/* Variables and functions */
struct waiter_ticket *waiter_add_null(struct waiter *);
int /*<<< orphan*/ waiter_ticket_set_timeout(struct waiter_ticket *,
                                             unsigned int);
struct waiter_ticket *waiter_add_timeout(struct waiter *w, unsigned int ms) {
  struct waiter_ticket *ticket;
  ticket = waiter_add_null(w);
  if (ticket == NULL)
    return NULL;
  waiter_ticket_set_timeout(ticket, ms);
  return ticket;
}


x86 assembly (clang, -O0):
<waiter_add_timeout>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <waiter_add_null@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    1154 <waiter_add_timeout+0x34>
movq   $0x0,-0x8(%rbp)
jmp    1168 <waiter_add_timeout+0x48>
mov    -0x20(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1040 <waiter_ticket_set_timeout@plt>
mov    -0x20(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<waiter_add_timeout>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebp
call   1030 <waiter_add_null@plt>
mov    %rax,%rbx
test   %rax,%rax
je     113c <waiter_add_timeout+0x1c>
mov    %rbx,%rdi
mov    %ebp,%esi
call   1040 <waiter_ticket_set_timeout@plt>
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
%struct.waiter_ticket = type { i32 }
%struct.waiter = type { i32 }
define %struct.waiter_ticket* @waiter_add_timeout(%struct.waiter* %0, i32 %1) {
%3 = alloca %struct.waiter_ticket*
%4 = alloca %struct.waiter*
%5 = alloca i32
%6 = alloca %struct.waiter_ticket*
store %struct.waiter* %0, %struct.waiter** %4
store i32 %1, i32* %5
%7 = load %struct.waiter*, %struct.waiter** %4
%8 = call %struct.waiter_ticket* @waiter_add_null(%struct.waiter* %7)
store %struct.waiter_ticket* %8, %struct.waiter_ticket** %6
%9 = load %struct.waiter_ticket*, %struct.waiter_ticket** %6
%10 = icmp eq %struct.waiter_ticket* %9, null
br i1 %10, label %11, label %12
11: ; preds = %2
store %struct.waiter_ticket* null, %struct.waiter_ticket** %3
br label %17
12: ; preds = %2
%13 = load %struct.waiter_ticket*, %struct.waiter_ticket** %6
%14 = load i32, i32* %5
%15 = call i32 @waiter_ticket_set_timeout(%struct.waiter_ticket* %13, i32 %14)
%16 = load %struct.waiter_ticket*, %struct.waiter_ticket** %6
store %struct.waiter_ticket* %16, %struct.waiter_ticket** %3
br label %17
17: ; preds = %12, %11
%18 = load %struct.waiter_ticket*, %struct.waiter_ticket** %3
ret %struct.waiter_ticket* %18
}

LLVM IR (-O2):
%struct.waiter_ticket = type { i32 }
%struct.waiter = type { i32 }
define %struct.waiter_ticket* @waiter_add_timeout(%struct.waiter* %0, i32 %1) {
%3 = tail call %struct.waiter_ticket* @waiter_add_null(%struct.waiter* %0)
%4 = icmp eq %struct.waiter_ticket* %3, null
br i1 %4, label %7, label %5
5: ; preds = %2
%6 = tail call i32 @waiter_ticket_set_timeout(%struct.waiter_ticket* %3, i32 %1)
br label %7
7: ; preds = %2, %5
ret %struct.waiter_ticket* %3
}