#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 */
typedef struct TYPE_4__ TYPE_2__;
typedef struct TYPE_3__ TYPE_1__;

/* Type definitions */
struct timeval {
  int tv_sec;
};
struct timespec {
  int tv_sec;
  int tv_nsec;
};
struct TYPE_4__ {
  scalar_t__ tv_sec;
};
struct TYPE_3__ {
  scalar_t__ tv_sec;
};
struct rusage {
  TYPE_2__ ru_stime;
  TYPE_1__ ru_utime;
};

/* Variables and functions */
int /*<<< orphan*/ RUSAGE_SELF;
int /*<<< orphan*/ __chk_error(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ error1(char *, int, char *);
int /*<<< orphan*/ getrusage(int /*<<< orphan*/, struct rusage *);
int /*<<< orphan*/ gettimeofday(struct timeval *, int /*<<< orphan*/ *);
int /*<<< orphan*/ nanosleep(struct timespec *, struct timespec *);
void test_time(void) {
  struct timeval tv, tv2;
  struct timespec ts, rem;
  struct rusage rusg1, rusg2;
  int ti, i;
  __chk_error("/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
              "2022-01-22/02-19-57/repos/Cisco-Talos/pyrebox/refs/heads/master/"
              "qemu/tests/tcg/multiarch/linux-test.c",
              231, (gettimeofday(&tv, NULL)));
  rem.tv_sec = 1;
  ts.tv_sec = 0;
  ts.tv_nsec = 20 * 1000000;
  __chk_error("/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
              "2022-01-22/02-19-57/repos/Cisco-Talos/pyrebox/refs/heads/master/"
              "qemu/tests/tcg/multiarch/linux-test.c",
              235, (nanosleep(&ts, &rem)));
  if (rem.tv_sec != 1)
    error1("/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
           "2022-01-22/02-19-57/repos/Cisco-Talos/pyrebox/refs/heads/master/"
           "qemu/tests/tcg/multiarch/linux-test.c",
           237, "nanosleep");
  __chk_error("/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
              "2022-01-22/02-19-57/repos/Cisco-Talos/pyrebox/refs/heads/master/"
              "qemu/tests/tcg/multiarch/linux-test.c",
              238, (gettimeofday(&tv2, NULL)));
  ti = tv2.tv_sec - tv.tv_sec;
  if (ti >= 2)
    error1("/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
           "2022-01-22/02-19-57/repos/Cisco-Talos/pyrebox/refs/heads/master/"
           "qemu/tests/tcg/multiarch/linux-test.c",
           241, "gettimeofday");
  __chk_error("/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
              "2022-01-22/02-19-57/repos/Cisco-Talos/pyrebox/refs/heads/master/"
              "qemu/tests/tcg/multiarch/linux-test.c",
              243, (getrusage(RUSAGE_SELF, &rusg1)));
  for (i = 0; i < 10000; i++)
    ;
  __chk_error("/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
              "2022-01-22/02-19-57/repos/Cisco-Talos/pyrebox/refs/heads/master/"
              "qemu/tests/tcg/multiarch/linux-test.c",
              245, (getrusage(RUSAGE_SELF, &rusg2)));
  if ((rusg2.ru_utime.tv_sec - rusg1.ru_utime.tv_sec) < 0 ||
      (rusg2.ru_stime.tv_sec - rusg1.ru_stime.tv_sec) < 0)
    error1("/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
           "2022-01-22/02-19-57/repos/Cisco-Talos/pyrebox/refs/heads/master/"
           "qemu/tests/tcg/multiarch/linux-test.c",
           248, "getrusage");
}


x86 assembly (clang, -O0):
<test_time>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
lea    -0x8(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1050 <gettimeofday@plt>
mov    %eax,%edx
lea    0xe92(%rip),%rdi
mov    $0xe7,%esi
call   1030 <__chk_error@plt>
movl   $0x1,-0x20(%rbp)
movl   $0x0,-0x18(%rbp)
movl   $0x1312d00,-0x14(%rbp)
lea    -0x18(%rbp),%rdi
lea    -0x20(%rbp),%rsi
call   1040 <nanosleep@plt>
mov    %eax,%edx
lea    0xe5d(%rip),%rdi
mov    $0xeb,%esi
call   1030 <__chk_error@plt>
cmpl   $0x1,-0x20(%rbp)
je     11cf <test_time+0x7f>
lea    0xe42(%rip),%rdi
mov    $0xed,%esi
lea    0xedc(%rip),%rdx
call   1070 <error1@plt>
lea    -0x10(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1050 <gettimeofday@plt>
mov    %eax,%edx
lea    0xe1b(%rip),%rdi
mov    $0xee,%esi
call   1030 <__chk_error@plt>
mov    -0x10(%rbp),%eax
sub    -0x8(%rbp),%eax
mov    %eax,-0x44(%rbp)
cmpl   $0x2,-0x44(%rbp)
jl     121a <test_time+0xca>
lea    0xdf7(%rip),%rdi
mov    $0xf1,%esi
lea    0xe9b(%rip),%rdx
call   1070 <error1@plt>
mov    0x2dbf(%rip),%rax
mov    (%rax),%edi
lea    -0x30(%rbp),%rsi
call   1060 <getrusage@plt>
mov    %eax,%edx
lea    0xdcb(%rip),%rdi
mov    $0xf3,%esi
call   1030 <__chk_error@plt>
movl   $0x0,-0x48(%rbp)
cmpl   $0x2710,-0x48(%rbp)
jge    1266 <test_time+0x116>
jmp    1258 <test_time+0x108>
mov    -0x48(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x48(%rbp)
jmp    1246 <test_time+0xf6>
mov    0x2d73(%rip),%rax
mov    (%rax),%edi
lea    -0x40(%rbp),%rsi
call   1060 <getrusage@plt>
mov    %eax,%edx
lea    0xd7f(%rip),%rdi
mov    $0xf5,%esi
call   1030 <__chk_error@plt>
mov    -0x38(%rbp),%rax
sub    -0x28(%rbp),%rax
cmp    $0x0,%rax
jl     12af <test_time+0x15f>
mov    -0x40(%rbp),%rax
sub    -0x30(%rbp),%rax
cmp    $0x0,%rax
jge    12c7 <test_time+0x177>
lea    0xd4a(%rip),%rdi
mov    $0xf8,%esi
lea    0xdfb(%rip),%rdx
call   1070 <error1@plt>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_time>:
push   %r14
push   %rbx
sub    $0x48,%rsp
lea    0x10(%rsp),%rdi
xor    %esi,%esi
call   1050 <gettimeofday@plt>
lea    0xe96(%rip),%rbx
mov    %rbx,%rdi
mov    $0xe7,%esi
mov    %eax,%edx
call   1030 <__chk_error@plt>
movl   $0x1,0x18(%rsp)
movabs $0x1312d0000000000,%rax
2d 31 01
mov    %rax,0x20(%rsp)
lea    0x20(%rsp),%rdi
lea    0x18(%rsp),%rsi
call   1040 <nanosleep@plt>
mov    %rbx,%rdi
mov    $0xeb,%esi
mov    %eax,%edx
call   1030 <__chk_error@plt>
cmpl   $0x1,0x18(%rsp)
je     11cd <test_time+0x7d>
lea    0xe44(%rip),%rdi
lea    0xee3(%rip),%rdx
mov    $0xed,%esi
call   1070 <error1@plt>
lea    0x8(%rsp),%rdi
xor    %esi,%esi
call   1050 <gettimeofday@plt>
lea    0xe20(%rip),%rdi
mov    $0xee,%esi
mov    %eax,%edx
call   1030 <__chk_error@plt>
mov    0x8(%rsp),%eax
sub    0x10(%rsp),%eax
cmp    $0x2,%eax
jl     1211 <test_time+0xc1>
lea    0xe00(%rip),%rdi
lea    0xea9(%rip),%rdx
mov    $0xf1,%esi
call   1070 <error1@plt>
mov    0x2dc8(%rip),%r14
mov    (%r14),%edi
lea    0x38(%rsp),%rsi
call   1060 <getrusage@plt>
lea    0xdd4(%rip),%rbx
mov    %rbx,%rdi
mov    $0xf3,%esi
mov    %eax,%edx
call   1030 <__chk_error@plt>
mov    (%r14),%edi
lea    0x28(%rsp),%rsi
call   1060 <getrusage@plt>
mov    %rbx,%rdi
mov    $0xf5,%esi
mov    %eax,%edx
call   1030 <__chk_error@plt>
mov    0x30(%rsp),%rax
cmp    0x40(%rsp),%rax
jl     126f <test_time+0x11f>
mov    0x28(%rsp),%rax
cmp    0x38(%rsp),%rax
jge    1287 <test_time+0x137>
lea    0xd8a(%rip),%rdi
lea    0xe40(%rip),%rdx
mov    $0xf8,%esi
call   1070 <error1@plt>
add    $0x48,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.timeval = type { i32 }
%struct.timespec = type { i32, i32 }
%struct.rusage = type { %struct.TYPE_4__, %struct.TYPE_3__ }
%struct.TYPE_4__ = type { i64 }
%struct.TYPE_3__ = type { i64 }
@.str = [166 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/Cisco-Talos/pyrebox/refs/heads/master/qemu/tests/tcg/multiarch/linux-test.c\00"
@.str.1 = [10 x i8] c"nanosleep\00"
@.str.2 = [13 x i8] c"gettimeofday\00"
@RUSAGE_SELF = global i32 0
@.str.3 = [10 x i8] c"getrusage\00"
define void @test_time() {
%1 = alloca %struct.timeval
%2 = alloca %struct.timeval
%3 = alloca %struct.timespec
%4 = alloca %struct.timespec
%5 = alloca %struct.rusage
%6 = alloca %struct.rusage
%7 = alloca i32
%8 = alloca i32
%9 = call i32 @gettimeofday(%struct.timeval* %1, i32* null)
%10 = call i32 @__chk_error(i8* getelementptr inbounds ([166 x i8], [166 x i8]* @.str, i64 0, i64 0), i32 231, i32 %9)
%11 = getelementptr inbounds %struct.timespec, %struct.timespec* %4, i32 0, i32 0
store i32 1, i32* %11
%12 = getelementptr inbounds %struct.timespec, %struct.timespec* %3, i32 0, i32 0
store i32 0, i32* %12
%13 = getelementptr inbounds %struct.timespec, %struct.timespec* %3, i32 0, i32 1
store i32 20000000, i32* %13
%14 = call i32 @nanosleep(%struct.timespec* %3, %struct.timespec* %4)
%15 = call i32 @__chk_error(i8* getelementptr inbounds ([166 x i8], [166 x i8]* @.str, i64 0, i64 0), i32 235, i32 %14)
%16 = getelementptr inbounds %struct.timespec, %struct.timespec* %4, i32 0, i32 0
%17 = load i32, i32* %16
%18 = icmp ne i32 %17, 1
br i1 %18, label %19, label %21
19: ; preds = %0
%20 = call i32 @error1(i8* getelementptr inbounds ([166 x i8], [166 x i8]* @.str, i64 0, i64 0), i32 237, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
br label %21
21: ; preds = %19, %0
%22 = call i32 @gettimeofday(%struct.timeval* %2, i32* null)
%23 = call i32 @__chk_error(i8* getelementptr inbounds ([166 x i8], [166 x i8]* @.str, i64 0, i64 0), i32 238, i32 %22)
%24 = getelementptr inbounds %struct.timeval, %struct.timeval* %2, i32 0, i32 0
%25 = load i32, i32* %24
%26 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i32 0, i32 0
%27 = load i32, i32* %26
%28 = sub nsw i32 %25, %27
store i32 %28, i32* %7
%29 = load i32, i32* %7
%30 = icmp sge i32 %29, 2
br i1 %30, label %31, label %33
31: ; preds = %21
%32 = call i32 @error1(i8* getelementptr inbounds ([166 x i8], [166 x i8]* @.str, i64 0, i64 0), i32 241, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0))
br label %33
33: ; preds = %31, %21
%34 = load i32, i32* @RUSAGE_SELF
%35 = call i32 @getrusage(i32 %34, %struct.rusage* %5)
%36 = call i32 @__chk_error(i8* getelementptr inbounds ([166 x i8], [166 x i8]* @.str, i64 0, i64 0), i32 243, i32 %35)
store i32 0, i32* %8
br label %37
37: ; preds = %41, %33
%38 = load i32, i32* %8
%39 = icmp slt i32 %38, 10000
br i1 %39, label %40, label %44
40: ; preds = %37
br label %41
41: ; preds = %40
%42 = load i32, i32* %8
%43 = add nsw i32 %42, 1
store i32 %43, i32* %8
br label %37
44: ; preds = %37
%45 = load i32, i32* @RUSAGE_SELF
%46 = call i32 @getrusage(i32 %45, %struct.rusage* %6)
%47 = call i32 @__chk_error(i8* getelementptr inbounds ([166 x i8], [166 x i8]* @.str, i64 0, i64 0), i32 245, i32 %46)
%48 = getelementptr inbounds %struct.rusage, %struct.rusage* %6, i32 0, i32 1
%49 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %48, i32 0, i32 0
%50 = load i64, i64* %49
%51 = getelementptr inbounds %struct.rusage, %struct.rusage* %5, i32 0, i32 1
%52 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %51, i32 0, i32 0
%53 = load i64, i64* %52
%54 = sub nsw i64 %50, %53
%55 = icmp slt i64 %54, 0
br i1 %55, label %65, label %56
56: ; preds = %44
%57 = getelementptr inbounds %struct.rusage, %struct.rusage* %6, i32 0, i32 0
%58 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %57, i32 0, i32 0
%59 = load i64, i64* %58
%60 = getelementptr inbounds %struct.rusage, %struct.rusage* %5, i32 0, i32 0
%61 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %60, i32 0, i32 0
%62 = load i64, i64* %61
%63 = sub nsw i64 %59, %62
%64 = icmp slt i64 %63, 0
br i1 %64, label %65, label %67
65: ; preds = %56, %44
%66 = call i32 @error1(i8* getelementptr inbounds ([166 x i8], [166 x i8]* @.str, i64 0, i64 0), i32 248, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0))
br label %67
67: ; preds = %65, %56
ret void
}

LLVM IR (-O2):
%struct.timeval = type { i32 }
%struct.timespec = type { i32, i32 }
%struct.rusage = type { %struct.TYPE_4__, %struct.TYPE_3__ }
%struct.TYPE_4__ = type { i64 }
%struct.TYPE_3__ = type { i64 }
@.str = [166 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/Cisco-Talos/pyrebox/refs/heads/master/qemu/tests/tcg/multiarch/linux-test.c\00"
@.str.1 = [10 x i8] c"nanosleep\00"
@.str.2 = [13 x i8] c"gettimeofday\00"
@RUSAGE_SELF = global i32 0
@.str.3 = [10 x i8] c"getrusage\00"
define void @test_time() {
%1 = alloca %struct.timeval
%2 = alloca %struct.timeval
%3 = alloca %struct.timespec
%4 = alloca %struct.timespec
%5 = alloca %struct.rusage
%6 = alloca %struct.rusage
%7 = bitcast %struct.timeval* %1 to i8*
%8 = bitcast %struct.timeval* %2 to i8*
%9 = bitcast %struct.timespec* %3 to i8*
%10 = bitcast %struct.timespec* %4 to i8*
%11 = bitcast %struct.rusage* %5 to i8*
%12 = bitcast %struct.rusage* %6 to i8*
%13 = call i32 @gettimeofday(%struct.timeval* %1, i32* null)
%14 = tail call i32 @__chk_error(i8* getelementptr inbounds ([166 x i8], [166 x i8]* @.str, i64 0, i64 0), i32 231, i32 %13)
%15 = getelementptr inbounds %struct.timespec, %struct.timespec* %4, i64 0, i32 0
store i32 1, i32* %15
%16 = getelementptr inbounds %struct.timespec, %struct.timespec* %3, i64 0, i32 0
store i32 0, i32* %16
%17 = getelementptr inbounds %struct.timespec, %struct.timespec* %3, i64 0, i32 1
store i32 20000000, i32* %17
%18 = call i32 @nanosleep(%struct.timespec* %3, %struct.timespec* %4)
%19 = call i32 @__chk_error(i8* getelementptr inbounds ([166 x i8], [166 x i8]* @.str, i64 0, i64 0), i32 235, i32 %18)
%20 = load i32, i32* %15
%21 = icmp eq i32 %20, 1
br i1 %21, label %24, label %22
22: ; preds = %0
%23 = call i32 @error1(i8* getelementptr inbounds ([166 x i8], [166 x i8]* @.str, i64 0, i64 0), i32 237, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
br label %24
24: ; preds = %22, %0
%25 = call i32 @gettimeofday(%struct.timeval* %2, i32* null)
%26 = call i32 @__chk_error(i8* getelementptr inbounds ([166 x i8], [166 x i8]* @.str, i64 0, i64 0), i32 238, i32 %25)
%27 = getelementptr inbounds %struct.timeval, %struct.timeval* %2, i64 0, i32 0
%28 = load i32, i32* %27
%29 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i64 0, i32 0
%30 = load i32, i32* %29
%31 = sub nsw i32 %28, %30
%32 = icmp sgt i32 %31, 1
br i1 %32, label %33, label %35
33: ; preds = %24
%34 = call i32 @error1(i8* getelementptr inbounds ([166 x i8], [166 x i8]* @.str, i64 0, i64 0), i32 241, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0))
br label %35
35: ; preds = %33, %24
%36 = load i32, i32* @RUSAGE_SELF
%37 = call i32 @getrusage(i32 %36, %struct.rusage* %5)
%38 = call i32 @__chk_error(i8* getelementptr inbounds ([166 x i8], [166 x i8]* @.str, i64 0, i64 0), i32 243, i32 %37)
%39 = load i32, i32* @RUSAGE_SELF
%40 = call i32 @getrusage(i32 %39, %struct.rusage* %6)
%41 = call i32 @__chk_error(i8* getelementptr inbounds ([166 x i8], [166 x i8]* @.str, i64 0, i64 0), i32 245, i32 %40)
%42 = getelementptr inbounds %struct.rusage, %struct.rusage* %6, i64 0, i32 1, i32 0
%43 = load i64, i64* %42
%44 = getelementptr inbounds %struct.rusage, %struct.rusage* %5, i64 0, i32 1, i32 0
%45 = load i64, i64* %44
%46 = icmp slt i64 %43, %45
br i1 %46, label %53, label %47
47: ; preds = %35
%48 = getelementptr inbounds %struct.rusage, %struct.rusage* %6, i64 0, i32 0, i32 0
%49 = load i64, i64* %48
%50 = getelementptr inbounds %struct.rusage, %struct.rusage* %5, i64 0, i32 0, i32 0
%51 = load i64, i64* %50
%52 = icmp slt i64 %49, %51
br i1 %52, label %53, label %55
53: ; preds = %47, %35
%54 = call i32 @error1(i8* getelementptr inbounds ([166 x i8], [166 x i8]* @.str, i64 0, i64 0), i32 248, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0))
br label %55
55: ; preds = %53, %47
ret void
}