#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 obs_output {
  int dummy;
};
struct encoder_packet {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ os_gettime_ns();
scalar_t__ pop_packet(struct obs_output *, int /*<<< orphan*/);
int /*<<< orphan*/ push_packet(struct obs_output *, struct encoder_packet *,
                               int /*<<< orphan*/);
void process_delay(void *data, struct encoder_packet *packet) {
  struct obs_output *output = data;
  uint64_t t = os_gettime_ns();
  push_packet(output, packet, t);
  while (pop_packet(output, t))
    ;
}


x86 assembly (clang, -O0):
<process_delay>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    $0x0,%al
call   1030 <os_gettime_ns@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x1c(%rbp),%edx
call   1040 <push_packet@plt>
mov    -0x18(%rbp),%rdi
mov    -0x1c(%rbp),%esi
call   1050 <pop_packet@plt>
cmp    $0x0,%rax
je     117d <process_delay+0x4d>
jmp    1162 <process_delay+0x32>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<process_delay>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %rdi,%rbx
xor    %eax,%eax
call   1030 <os_gettime_ns@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %eax,%edx
call   1040 <push_packet@plt>
mov    %rbx,%rdi
mov    %ebp,%esi
call   1050 <pop_packet@plt>
test   %rax,%rax
jne    1150 <process_delay+0x20>
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
%struct.encoder_packet = type { i32 }
%struct.obs_output = type { i32 }
define void @process_delay(i8* %0, %struct.encoder_packet* %1) {
%3 = alloca i8*
%4 = alloca %struct.encoder_packet*
%5 = alloca %struct.obs_output*
%6 = alloca i32
store i8* %0, i8** %3
store %struct.encoder_packet* %1, %struct.encoder_packet** %4
%7 = load i8*, i8** %3
%8 = bitcast i8* %7 to %struct.obs_output*
store %struct.obs_output* %8, %struct.obs_output** %5
%9 = call i32 (...) @os_gettime_ns()
store i32 %9, i32* %6
%10 = load %struct.obs_output*, %struct.obs_output** %5
%11 = load %struct.encoder_packet*, %struct.encoder_packet** %4
%12 = load i32, i32* %6
%13 = call i32 @push_packet(%struct.obs_output* %10, %struct.encoder_packet* %11, i32 %12)
br label %14
14: ; preds = %19, %2
%15 = load %struct.obs_output*, %struct.obs_output** %5
%16 = load i32, i32* %6
%17 = call i64 @pop_packet(%struct.obs_output* %15, i32 %16)
%18 = icmp ne i64 %17, 0
br i1 %18, label %19, label %20
19: ; preds = %14
br label %14
20: ; preds = %14
ret void
}

LLVM IR (-O2):
%struct.encoder_packet = type { i32 }
%struct.obs_output = type { i32 }
define void @process_delay(i8* %0, %struct.encoder_packet* %1) {
%3 = bitcast i8* %0 to %struct.obs_output*
%4 = tail call i32 (...) @os_gettime_ns()
%5 = tail call i32 @push_packet(%struct.obs_output* %3, %struct.encoder_packet* %1, i32 %4)
br label %6
6: ; preds = %6, %2
%7 = tail call i64 @pop_packet(%struct.obs_output* %3, i32 %4)
%8 = icmp eq i64 %7, 0
br i1 %8, label %9, label %6
9: ; preds = %6
ret void
}