#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 scalar_t__ time_t;

/* Variables and functions */
int EXIT_SUCCESS;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, int, char *);
int /*<<< orphan*/ mt_msleep(int);
int /*<<< orphan*/ mt_sleep_until(scalar_t__);
scalar_t__ mt_time();
int /*<<< orphan*/ stderr;
int test_timespec_utils();
int main(void) {
  time_t cur, next, after;
  do {
    int __my_ret__ = test_timespec_utils();
    if (__my_ret__) {
      fprintf(stderr, "failed on line %d: %s\n", 47, "test_timespec_utils()");
      return __my_ret__;
    }
  } while (0);
  ;
  cur = mt_time();
  next = cur + 1;
  mt_sleep_until(next);
  after = mt_time();
  do {
    if ((after) <= (cur)) {
      fprintf(stderr, "failed on line %d: %s\n", 52, "after");
      return 1;
    }
  } while (0);
  ;
  do {
    if ((after) < (next)) {
      fprintf(stderr, "failed on line %d: %s\n", 53, "after");
      return 1;
    }
  } while (0);
  ;
  cur = mt_time();
  mt_msleep(1);
  after = mt_time();
  do {
    if ((after) < (cur)) {
      fprintf(stderr, "failed on line %d: %s\n", 57, "after");
      return 1;
    }
  } while (0);
  ;
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1030 <test_timespec_utils@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
je     119f <main+0x4f>
mov    0x2e66(%rip),%rax
mov    (%rax),%edi
lea    0xe7d(%rip),%rsi
mov    $0x2f,%edx
lea    0xe88(%rip),%rcx
call   1060 <fprintf@plt>
mov    -0x24(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    12c0 <main+0x170>
jmp    11a4 <main+0x54>
mov    $0x0,%al
call   1040 <mt_time@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
call   1070 <mt_sleep_until@plt>
mov    $0x0,%al
call   1040 <mt_time@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
cmp    -0x10(%rbp),%rax
jg     120a <main+0xba>
mov    0x2dfc(%rip),%rax
mov    (%rax),%edi
lea    0xe13(%rip),%rsi
mov    $0x34,%edx
lea    0xe34(%rip),%rcx
call   1060 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    12c0 <main+0x170>
jmp    120f <main+0xbf>
jmp    1214 <main+0xc4>
mov    -0x20(%rbp),%rax
cmp    -0x18(%rbp),%rax
jge    124f <main+0xff>
mov    0x2db7(%rip),%rax
mov    (%rax),%edi
lea    0xdce(%rip),%rsi
mov    $0x35,%edx
lea    0xdef(%rip),%rcx
call   1060 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    12c0 <main+0x170>
jmp    1254 <main+0x104>
mov    $0x0,%al
call   1040 <mt_time@plt>
mov    %rax,-0x10(%rbp)
mov    $0x1,%edi
call   1050 <mt_msleep@plt>
mov    $0x0,%al
call   1040 <mt_time@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
cmp    -0x10(%rbp),%rax
jge    12af <main+0x15f>
mov    0x2d57(%rip),%rax
mov    (%rax),%edi
lea    0xd6e(%rip),%rsi
mov    $0x39,%edx
lea    0xd8f(%rip),%rcx
call   1060 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    12c0 <main+0x170>
jmp    12b4 <main+0x164>
mov    0x2d1d(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
xor    %eax,%eax
call   1030 <test_timespec_utils@plt>
test   %eax,%eax
je     1187 <main+0x37>
mov    %eax,%ebx
mov    0x2e78(%rip),%rax
mov    (%rax),%edi
lea    0xe8f(%rip),%rsi
lea    0xe9f(%rip),%rcx
mov    $0x2f,%edx
call   1060 <fprintf@plt>
jmp    121f <main+0xcf>
xor    %eax,%eax
call   1040 <mt_time@plt>
mov    %rax,%rbx
lea    0x1(%rax),%rdi
call   1070 <mt_sleep_until@plt>
xor    %eax,%eax
call   1040 <mt_time@plt>
cmp    %rbx,%rax
jle    11ee <main+0x9e>
xor    %eax,%eax
call   1040 <mt_time@plt>
mov    %rax,%r14
mov    $0x1,%ebx
mov    $0x1,%edi
call   1050 <mt_msleep@plt>
xor    %eax,%eax
call   1040 <mt_time@plt>
cmp    %r14,%rax
jge    1216 <main+0xc6>
mov    0x2e0e(%rip),%rax
mov    (%rax),%edi
lea    0xe25(%rip),%rsi
lea    0xe4b(%rip),%rcx
mov    $0x39,%edx
call   1060 <fprintf@plt>
jmp    121f <main+0xcf>
mov    0x2deb(%rip),%rax
mov    (%rax),%edi
lea    0xe02(%rip),%rsi
lea    0xe28(%rip),%rcx
mov    $0x34,%edx
call   1060 <fprintf@plt>
mov    $0x1,%ebx
jmp    121f <main+0xcf>
mov    0x2dbb(%rip),%rax
mov    (%rax),%ebx
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [23 x i8] c"failed on line %d: %s\0A\00"
@.str.1 = [22 x i8] c"test_timespec_utils()\00"
@.str.2 = [6 x i8] c"after\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i64
%3 = alloca i64
%4 = alloca i64
%5 = alloca i32
store i32 0, i32* %1
br label %6
6: ; preds = %0
%7 = call i32 (...) @test_timespec_utils()
store i32 %7, i32* %5
%8 = load i32, i32* %5
%9 = icmp ne i32 %8, 0
br i1 %9, label %10, label %14
10: ; preds = %6
%11 = load i32, i32* @stderr
%12 = call i32 @fprintf(i32 %11, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i32 47, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0))
%13 = load i32, i32* %5
store i32 %13, i32* %1
br label %53
14: ; preds = %6
br label %15
15: ; preds = %14
%16 = call i64 (...) @mt_time()
store i64 %16, i64* %2
%17 = load i64, i64* %2
%18 = add nsw i64 %17, 1
store i64 %18, i64* %3
%19 = load i64, i64* %3
%20 = call i32 @mt_sleep_until(i64 %19)
%21 = call i64 (...) @mt_time()
store i64 %21, i64* %4
br label %22
22: ; preds = %15
%23 = load i64, i64* %4
%24 = load i64, i64* %2
%25 = icmp sle i64 %23, %24
br i1 %25, label %26, label %29
26: ; preds = %22
%27 = load i32, i32* @stderr
%28 = call i32 @fprintf(i32 %27, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i32 52, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
store i32 1, i32* %1
br label %53
29: ; preds = %22
br label %30
30: ; preds = %29
br label %31
31: ; preds = %30
%32 = load i64, i64* %4
%33 = load i64, i64* %3
%34 = icmp slt i64 %32, %33
br i1 %34, label %35, label %38
35: ; preds = %31
%36 = load i32, i32* @stderr
%37 = call i32 @fprintf(i32 %36, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i32 53, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
store i32 1, i32* %1
br label %53
38: ; preds = %31
br label %39
39: ; preds = %38
%40 = call i64 (...) @mt_time()
store i64 %40, i64* %2
%41 = call i32 @mt_msleep(i32 1)
%42 = call i64 (...) @mt_time()
store i64 %42, i64* %4
br label %43
43: ; preds = %39
%44 = load i64, i64* %4
%45 = load i64, i64* %2
%46 = icmp slt i64 %44, %45
br i1 %46, label %47, label %50
47: ; preds = %43
%48 = load i32, i32* @stderr
%49 = call i32 @fprintf(i32 %48, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i32 57, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
store i32 1, i32* %1
br label %53
50: ; preds = %43
br label %51
51: ; preds = %50
%52 = load i32, i32* @EXIT_SUCCESS
store i32 %52, i32* %1
br label %53
53: ; preds = %51, %47, %35, %26, %10
%54 = load i32, i32* %1
ret i32 %54
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [23 x i8] c"failed on line %d: %s\0A\00"
@.str.1 = [22 x i8] c"test_timespec_utils()\00"
@.str.2 = [6 x i8] c"after\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = tail call i32 (...) @test_timespec_utils()
%2 = icmp eq i32 %1, 0
br i1 %2, label %6, label %3
3: ; preds = %0
%4 = load i32, i32* @stderr
%5 = tail call i32 @fprintf(i32 %4, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i32 47, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0))
br label %25
6: ; preds = %0
%7 = tail call i64 (...) @mt_time()
%8 = add nsw i64 %7, 1
%9 = tail call i32 @mt_sleep_until(i64 %8)
%10 = tail call i64 (...) @mt_time()
%11 = icmp sgt i64 %10, %7
br i1 %11, label %15, label %12
12: ; preds = %6
%13 = load i32, i32* @stderr
%14 = tail call i32 @fprintf(i32 %13, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i32 52, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
br label %25
15: ; preds = %6
%16 = tail call i64 (...) @mt_time()
%17 = tail call i32 @mt_msleep(i32 1)
%18 = tail call i64 (...) @mt_time()
%19 = icmp slt i64 %18, %16
br i1 %19, label %20, label %23
20: ; preds = %15
%21 = load i32, i32* @stderr
%22 = tail call i32 @fprintf(i32 %21, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i32 57, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
br label %25
23: ; preds = %15
%24 = load i32, i32* @EXIT_SUCCESS
br label %25
25: ; preds = %3, %23, %20, %12
%26 = phi i32 [ 1, %12 ], [ 1, %20 ], [ %24, %23 ], [ %1, %3 ]
ret i32 %26
}