#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*/ time_t;
struct timespec {
  scalar_t__ tv_nsec;
  int /*<<< orphan*/ tv_sec;
};

/* Variables and functions */
int /*<<< orphan*/ CLOCK_REALTIME;
int /*<<< orphan*/ TIMER_ABSTIME;
scalar_t__ clock_nanosleep(int /*<<< orphan*/, int /*<<< orphan*/,
                           struct timespec *, int /*<<< orphan*/ *);
void sleep_until(time_t dst_sec) {
  struct timespec dst;
  dst.tv_sec = dst_sec;
  dst.tv_nsec = 0;
  while (clock_nanosleep(CLOCK_REALTIME, TIMER_ABSTIME, &dst, NULL))
    ;
}


x86 assembly (clang, -O0):
<sleep_until>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
mov    0x2ea8(%rip),%rax
mov    (%rax),%edi
mov    0x2eaf(%rip),%rax
mov    (%rax),%esi
lea    -0x18(%rbp),%rdx
xor    %eax,%eax
mov    %eax,%ecx
call   1030 <clock_nanosleep@plt>
cmp    $0x0,%rax
je     1157 <sleep_until+0x47>
jmp    1129 <sleep_until+0x19>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sleep_until>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %edi,0x8(%rsp)
movq   $0x0,(%rsp)
mov    0x2eac(%rip),%r14
mov    0x2eb5(%rip),%r15
mov    %rsp,%rbx
cs nopw 0x0(%rax,%rax,1)
mov    (%r14),%edi
mov    (%r15),%esi
mov    %rbx,%rdx
xor    %ecx,%ecx
call   1030 <clock_nanosleep@plt>
test   %rax,%rax
jne    1140 <sleep_until+0x30>
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.timespec = type { i64, i32 }
@CLOCK_REALTIME = global i32 0
@TIMER_ABSTIME = global i32 0
define void @sleep_until(i32 %0) {
%2 = alloca i32
%3 = alloca %struct.timespec
store i32 %0, i32* %2
%4 = load i32, i32* %2
%5 = getelementptr inbounds %struct.timespec, %struct.timespec* %3, i32 0, i32 1
store i32 %4, i32* %5
%6 = getelementptr inbounds %struct.timespec, %struct.timespec* %3, i32 0, i32 0
store i64 0, i64* %6
br label %7
7: ; preds = %12, %1
%8 = load i32, i32* @CLOCK_REALTIME
%9 = load i32, i32* @TIMER_ABSTIME
%10 = call i64 @clock_nanosleep(i32 %8, i32 %9, %struct.timespec* %3, i32* null)
%11 = icmp ne i64 %10, 0
br i1 %11, label %12, label %13
12: ; preds = %7
br label %7
13: ; preds = %7
ret void
}

LLVM IR (-O2):
%struct.timespec = type { i64, i32 }
@CLOCK_REALTIME = global i32 0
@TIMER_ABSTIME = global i32 0
define void @sleep_until(i32 %0) {
%2 = alloca %struct.timespec
%3 = bitcast %struct.timespec* %2 to i8*
%4 = getelementptr inbounds %struct.timespec, %struct.timespec* %2, i64 0, i32 1
store i32 %0, i32* %4
%5 = getelementptr inbounds %struct.timespec, %struct.timespec* %2, i64 0, i32 0
store i64 0, i64* %5
br label %6
6: ; preds = %6, %1
%7 = load i32, i32* @CLOCK_REALTIME
%8 = load i32, i32* @TIMER_ABSTIME
%9 = call i64 @clock_nanosleep(i32 %7, i32 %8, %struct.timespec* %2, i32* null)
%10 = icmp eq i64 %9, 0
br i1 %10, label %11, label %6
11: ; preds = %6
ret void
}