#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_2__ TYPE_1__;

/* Type definitions */
struct TYPE_2__ {
  long long tv_sec;
  long long tv_usec;
};
struct rusage {
  TYPE_1__ ru_utime;
};

/* Variables and functions */
int /*<<< orphan*/ RUSAGE_SELF;
int /*<<< orphan*/ assert(int);
int /*<<< orphan*/ getrusage(int /*<<< orphan*/, struct rusage *);
int main() {
  struct rusage ru1;
  getrusage(RUSAGE_SELF, &ru1);
  for (int i = 0; i < 1000; i++) {
  }
  struct rusage ru2;
  getrusage(RUSAGE_SELF, &ru2);
  long long s1 = ru1.ru_utime.tv_sec;
  long long us1 = ru1.ru_utime.tv_usec;
  long long s2 = ru2.ru_utime.tv_sec;
  long long us2 = ru2.ru_utime.tv_usec;
  assert(s1 <= s2);
  if (s1 == s2) {
    assert(us1 < us2);
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2eaa(%rip),%rax
mov    (%rax),%edi
lea    -0x18(%rbp),%rsi
call   1040 <getrusage@plt>
movl   $0x0,-0x1c(%rbp)
cmpl   $0x3e8,-0x1c(%rbp)
jge    1168 <main+0x48>
jmp    115a <main+0x3a>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1148 <main+0x28>
mov    0x2e71(%rip),%rax
mov    (%rax),%edi
lea    -0x30(%rbp),%rsi
call   1040 <getrusage@plt>
mov    -0x18(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x30(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,-0x50(%rbp)
mov    -0x38(%rbp),%rax
cmp    -0x48(%rbp),%rax
setle  %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
mov    -0x38(%rbp),%rax
cmp    -0x48(%rbp),%rax
jne    11d2 <main+0xb2>
mov    -0x40(%rbp),%rax
cmp    -0x50(%rbp),%rax
setl   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    0x2eae(%rip),%rbx
mov    (%rbx),%edi
lea    0x18(%rsp),%rsi
call   1040 <getrusage@plt>
mov    (%rbx),%edi
lea    0x8(%rsp),%rsi
call   1040 <getrusage@plt>
mov    0x18(%rsp),%r12
mov    0x20(%rsp),%r14
mov    0x10(%rsp),%r15
mov    0x8(%rsp),%rbx
xor    %edi,%edi
cmp    %rbx,%r12
setle  %dil
call   1030 <assert@plt>
cmp    %rbx,%r12
jne    117f <main+0x5f>
xor    %edi,%edi
cmp    %r15,%r14
setl   %dil
call   1030 <assert@plt>
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.rusage = type { %struct.TYPE_2__ }
%struct.TYPE_2__ = type { i64, i64 }
@RUSAGE_SELF = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca %struct.rusage
%3 = alloca i32
%4 = alloca %struct.rusage
%5 = alloca i64
%6 = alloca i64
%7 = alloca i64
%8 = alloca i64
store i32 0, i32* %1
%9 = load i32, i32* @RUSAGE_SELF
%10 = call i32 @getrusage(i32 %9, %struct.rusage* %2)
store i32 0, i32* %3
br label %11
11: ; preds = %15, %0
%12 = load i32, i32* %3
%13 = icmp slt i32 %12, 1000
br i1 %13, label %14, label %18
14: ; preds = %11
br label %15
15: ; preds = %14
%16 = load i32, i32* %3
%17 = add nsw i32 %16, 1
store i32 %17, i32* %3
br label %11
18: ; preds = %11
%19 = load i32, i32* @RUSAGE_SELF
%20 = call i32 @getrusage(i32 %19, %struct.rusage* %4)
%21 = getelementptr inbounds %struct.rusage, %struct.rusage* %2, i32 0, i32 0
%22 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %21, i32 0, i32 0
%23 = load i64, i64* %22
store i64 %23, i64* %5
%24 = getelementptr inbounds %struct.rusage, %struct.rusage* %2, i32 0, i32 0
%25 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %24, i32 0, i32 1
%26 = load i64, i64* %25
store i64 %26, i64* %6
%27 = getelementptr inbounds %struct.rusage, %struct.rusage* %4, i32 0, i32 0
%28 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %27, i32 0, i32 0
%29 = load i64, i64* %28
store i64 %29, i64* %7
%30 = getelementptr inbounds %struct.rusage, %struct.rusage* %4, i32 0, i32 0
%31 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %30, i32 0, i32 1
%32 = load i64, i64* %31
store i64 %32, i64* %8
%33 = load i64, i64* %5
%34 = load i64, i64* %7
%35 = icmp sle i64 %33, %34
%36 = zext i1 %35 to i32
%37 = call i32 @assert(i32 %36)
%38 = load i64, i64* %5
%39 = load i64, i64* %7
%40 = icmp eq i64 %38, %39
br i1 %40, label %41, label %47
41: ; preds = %18
%42 = load i64, i64* %6
%43 = load i64, i64* %8
%44 = icmp slt i64 %42, %43
%45 = zext i1 %44 to i32
%46 = call i32 @assert(i32 %45)
br label %47
47: ; preds = %41, %18
%48 = load i32, i32* %1
ret i32 %48
}

LLVM IR (-O2):
%struct.rusage = type { %struct.TYPE_2__ }
%struct.TYPE_2__ = type { i64, i64 }
@RUSAGE_SELF = global i32 0
define i32 @main() {
%1 = alloca %struct.rusage
%2 = alloca %struct.rusage
%3 = bitcast %struct.rusage* %1 to i8*
%4 = load i32, i32* @RUSAGE_SELF
%5 = call i32 @getrusage(i32 %4, %struct.rusage* %1)
%6 = bitcast %struct.rusage* %2 to i8*
%7 = load i32, i32* @RUSAGE_SELF
%8 = call i32 @getrusage(i32 %7, %struct.rusage* %2)
%9 = getelementptr inbounds %struct.rusage, %struct.rusage* %1, i64 0, i32 0, i32 0
%10 = load i64, i64* %9
%11 = getelementptr inbounds %struct.rusage, %struct.rusage* %1, i64 0, i32 0, i32 1
%12 = load i64, i64* %11
%13 = getelementptr inbounds %struct.rusage, %struct.rusage* %2, i64 0, i32 0, i32 0
%14 = load i64, i64* %13
%15 = getelementptr inbounds %struct.rusage, %struct.rusage* %2, i64 0, i32 0, i32 1
%16 = load i64, i64* %15
%17 = icmp sle i64 %10, %14
%18 = zext i1 %17 to i32
%19 = call i32 @assert(i32 %18)
%20 = icmp eq i64 %10, %14
br i1 %20, label %21, label %25
21: ; preds = %0
%22 = icmp slt i64 %12, %16
%23 = zext i1 %22 to i32
%24 = call i32 @assert(i32 %23)
br label %25
25: ; preds = %21, %0
ret i32 0
}