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

/* Variables and functions */
int /*<<< orphan*/ CLOCK_MONOTONIC;
int /*<<< orphan*/ clock_gettime(int /*<<< orphan*/, struct timespec *);
int /*<<< orphan*/ sleep(int);
int main(int argc, char **argv, char **env) {
  uint64_t dt;
  struct timespec t0, t1;
  clock_gettime(CLOCK_MONOTONIC, &t0);
  sleep(1);
  clock_gettime(CLOCK_MONOTONIC, &t1);
  dt = ((t1.tv_sec * 1000000000) + t1.tv_nsec) -
       ((t0.tv_sec * 1000000000) + t0.tv_nsec);
  return ((int)(dt / 1000000) > 950) ? 0 : 1;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    0x2ea7(%rip),%rax
mov    (%rax),%edi
lea    -0x28(%rbp),%rsi
call   1030 <clock_gettime@plt>
mov    $0x1,%edi
call   1040 <sleep@plt>
mov    0x2e8b(%rip),%rax
mov    (%rax),%edi
lea    -0x30(%rbp),%rsi
call   1030 <clock_gettime@plt>
imul   $0x3b9aca00,-0x30(%rbp),%eax
add    -0x2c(%rbp),%eax
imul   $0x3b9aca00,-0x28(%rbp),%ecx
add    -0x24(%rbp),%ecx
sub    %ecx,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    $0xf4240,%ecx
cltd
idiv   %ecx
mov    %eax,%edx
mov    $0x1,%eax
xor    %ecx,%ecx
cmp    $0x3b6,%edx
cmovg  %ecx,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
mov    0x2ebc(%rip),%rbx
mov    (%rbx),%edi
lea    0x8(%rsp),%rsi
call   1030 <clock_gettime@plt>
mov    $0x1,%edi
call   1040 <sleep@plt>
mov    (%rbx),%edi
mov    %rsp,%rsi
call   1030 <clock_gettime@plt>
mov    (%rsp),%eax
sub    0x8(%rsp),%eax
mov    0x4(%rsp),%ecx
imul   $0x3b9aca00,%eax,%eax
sub    0xc(%rsp),%ecx
add    %eax,%ecx
xor    %eax,%eax
cmp    $0x38af1bc0,%ecx
setl   %al
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.timespec = type { i32, i32 }
@CLOCK_MONOTONIC = global i32 0
define i32 @main(i32 %0, i8** %1, i8** %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8**
%7 = alloca i8**
%8 = alloca i32
%9 = alloca %struct.timespec
%10 = alloca %struct.timespec
store i32 0, i32* %4
store i32 %0, i32* %5
store i8** %1, i8*** %6
store i8** %2, i8*** %7
%11 = load i32, i32* @CLOCK_MONOTONIC
%12 = call i32 @clock_gettime(i32 %11, %struct.timespec* %9)
%13 = call i32 @sleep(i32 1)
%14 = load i32, i32* @CLOCK_MONOTONIC
%15 = call i32 @clock_gettime(i32 %14, %struct.timespec* %10)
%16 = getelementptr inbounds %struct.timespec, %struct.timespec* %10, i32 0, i32 0
%17 = load i32, i32* %16
%18 = mul nsw i32 %17, 1000000000
%19 = getelementptr inbounds %struct.timespec, %struct.timespec* %10, i32 0, i32 1
%20 = load i32, i32* %19
%21 = add nsw i32 %18, %20
%22 = getelementptr inbounds %struct.timespec, %struct.timespec* %9, i32 0, i32 0
%23 = load i32, i32* %22
%24 = mul nsw i32 %23, 1000000000
%25 = getelementptr inbounds %struct.timespec, %struct.timespec* %9, i32 0, i32 1
%26 = load i32, i32* %25
%27 = add nsw i32 %24, %26
%28 = sub nsw i32 %21, %27
store i32 %28, i32* %8
%29 = load i32, i32* %8
%30 = sdiv i32 %29, 1000000
%31 = icmp sgt i32 %30, 950
%32 = zext i1 %31 to i64
%33 = select i1 %31, i32 0, i32 1
ret i32 %33
}

LLVM IR (-O2):
%struct.timespec = type { i32, i32 }
@CLOCK_MONOTONIC = global i32 0
define i32 @main(i32 %0, i8** nocapture readnone %1, i8** nocapture readnone %2) {
%4 = alloca %struct.timespec
%5 = alloca %struct.timespec
%6 = bitcast %struct.timespec* %4 to i8*
%7 = bitcast %struct.timespec* %5 to i8*
%8 = load i32, i32* @CLOCK_MONOTONIC
%9 = call i32 @clock_gettime(i32 %8, %struct.timespec* %4)
%10 = call i32 @sleep(i32 1)
%11 = load i32, i32* @CLOCK_MONOTONIC
%12 = call i32 @clock_gettime(i32 %11, %struct.timespec* %5)
%13 = getelementptr inbounds %struct.timespec, %struct.timespec* %5, i64 0, i32 0
%14 = load i32, i32* %13
%15 = getelementptr inbounds %struct.timespec, %struct.timespec* %5, i64 0, i32 1
%16 = load i32, i32* %15
%17 = getelementptr inbounds %struct.timespec, %struct.timespec* %4, i64 0, i32 0
%18 = load i32, i32* %17
%19 = getelementptr inbounds %struct.timespec, %struct.timespec* %4, i64 0, i32 1
%20 = load i32, i32* %19
%21 = sub i32 %14, %18
%22 = mul i32 %21, 1000000000
%23 = sub i32 %16, %20
%24 = add i32 %23, %22
%25 = icmp slt i32 %24, 951000000
%26 = zext i1 %25 to i32
ret i32 %26
}