#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 timespec {
  int tv_sec;
  scalar_t__ tv_nsec;
};

/* Variables and functions */
int /*<<< orphan*/ CLOCK_REALTIME;
int EXIT_SUCCESS;
int /*<<< orphan*/ clock_gettime(int /*<<< orphan*/, struct timespec *);
int /*<<< orphan*/ nanosleep(struct timespec *, int /*<<< orphan*/ *);
int main() {
  struct timespec t;
  clock_gettime(CLOCK_REALTIME, &t);
  t.tv_sec = 58 - t.tv_sec % 60;
  t.tv_nsec = 999999999L - t.tv_nsec;
  nanosleep(&t, NULL);
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2eaa(%rip),%rax
mov    (%rax),%edi
lea    -0x18(%rbp),%rsi
call   1030 <clock_gettime@plt>
mov    -0x18(%rbp),%eax
mov    $0x3c,%ecx
cltd
idiv   %ecx
mov    $0x3a,%eax
sub    %edx,%eax
mov    %eax,-0x18(%rbp)
mov    $0x3b9ac9ff,%eax
sub    -0x10(%rbp),%rax
mov    %rax,-0x10(%rbp)
lea    -0x18(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1040 <nanosleep@plt>
mov    0x2e61(%rip),%rax
mov    (%rax),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
mov    0x2eb4(%rip),%rax
mov    (%rax),%edi
mov    %rsp,%rbx
mov    %rbx,%rsi
call   1030 <clock_gettime@plt>
movslq (%rsp),%rax
imul   $0xffffffff88888889,%rax,%rcx
shr    $0x20,%rcx
add    %eax,%ecx
mov    %ecx,%edx
shr    $0x1f,%edx
sar    $0x5,%ecx
add    %edx,%ecx
imul   $0x3c,%ecx,%ecx
sub    %eax,%ecx
add    $0x3a,%ecx
mov    %ecx,(%rsp)
mov    $0x3b9ac9ff,%eax
sub    0x8(%rsp),%rax
mov    %rax,0x8(%rsp)
mov    %rbx,%rdi
xor    %esi,%esi
call   1040 <nanosleep@plt>
mov    0x2e59(%rip),%rax
mov    (%rax),%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.timespec = type { i32, i64 }
@CLOCK_REALTIME = global i32 0
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca %struct.timespec
store i32 0, i32* %1
%3 = load i32, i32* @CLOCK_REALTIME
%4 = call i32 @clock_gettime(i32 %3, %struct.timespec* %2)
%5 = getelementptr inbounds %struct.timespec, %struct.timespec* %2, i32 0, i32 0
%6 = load i32, i32* %5
%7 = srem i32 %6, 60
%8 = sub nsw i32 58, %7
%9 = getelementptr inbounds %struct.timespec, %struct.timespec* %2, i32 0, i32 0
store i32 %8, i32* %9
%10 = getelementptr inbounds %struct.timespec, %struct.timespec* %2, i32 0, i32 1
%11 = load i64, i64* %10
%12 = sub nsw i64 999999999, %11
%13 = getelementptr inbounds %struct.timespec, %struct.timespec* %2, i32 0, i32 1
store i64 %12, i64* %13
%14 = call i32 @nanosleep(%struct.timespec* %2, i32* null)
%15 = load i32, i32* @EXIT_SUCCESS
ret i32 %15
}

LLVM IR (-O2):
%struct.timespec = type { i32, i64 }
@CLOCK_REALTIME = global i32 0
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca %struct.timespec
%2 = bitcast %struct.timespec* %1 to i8*
%3 = load i32, i32* @CLOCK_REALTIME
%4 = call i32 @clock_gettime(i32 %3, %struct.timespec* %1)
%5 = getelementptr inbounds %struct.timespec, %struct.timespec* %1, i64 0, i32 0
%6 = load i32, i32* %5
%7 = srem i32 %6, 60
%8 = sub nsw i32 58, %7
store i32 %8, i32* %5
%9 = getelementptr inbounds %struct.timespec, %struct.timespec* %1, i64 0, i32 1
%10 = load i64, i64* %9
%11 = sub nsw i64 999999999, %10
store i64 %11, i64* %9
%12 = call i32 @nanosleep(%struct.timespec* %1, i32* null)
%13 = load i32, i32* @EXIT_SUCCESS
ret i32 %13
}