#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 getrusage(int /*<<< orphan*/, struct rusage *);
int main() {
  struct rusage ru1;
  struct rusage ru2;
  long long s1;
  long long us1;
  long long s2;
  long long us2;
  int r;
  int success = 0;
  r = getrusage(RUSAGE_SELF, &ru1);
  assert(r == 0);
  s1 = ru1.ru_utime.tv_sec;
  us1 = ru1.ru_utime.tv_usec;
  for (int i = 0; i < 10000; i++) {
    r = getrusage(RUSAGE_SELF, &ru2);
    assert(r == 0);
    s2 = ru2.ru_utime.tv_sec;
    us2 = ru2.ru_utime.tv_usec;
    assert(s1 <= s2);
    if (s2 > s1 || (s2 == s1 && us2 > us1)) {
      success = 1;
      break;
    }
  }
  assert(success == 1);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x50(%rbp)
mov    0x2ea3(%rip),%rax
mov    (%rax),%edi
lea    -0x18(%rbp),%rsi
call   1040 <getrusage@plt>
mov    %eax,-0x4c(%rbp)
cmpl   $0x0,-0x4c(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
mov    -0x18(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x38(%rbp)
movl   $0x0,-0x54(%rbp)
cmpl   $0x2710,-0x54(%rbp)
jge    1214 <main+0xf4>
mov    0x2e59(%rip),%rax
mov    (%rax),%edi
lea    -0x28(%rbp),%rsi
call   1040 <getrusage@plt>
mov    %eax,-0x4c(%rbp)
cmpl   $0x0,-0x4c(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
mov    -0x28(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    -0x30(%rbp),%rax
cmp    -0x40(%rbp),%rax
setle  %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
mov    -0x40(%rbp),%rax
cmp    -0x30(%rbp),%rax
jg     11f5 <main+0xd5>
mov    -0x40(%rbp),%rax
cmp    -0x30(%rbp),%rax
jne    1201 <main+0xe1>
mov    -0x48(%rbp),%rax
cmp    -0x38(%rbp),%rax
jle    1201 <main+0xe1>
movl   $0x1,-0x50(%rbp)
jmp    1214 <main+0xf4>
jmp    1206 <main+0xe6>
mov    -0x54(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x54(%rbp)
jmp    1173 <main+0x53>
cmpl   $0x1,-0x50(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
mov    -0x4(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    0x2eab(%rip),%rbx
mov    (%rbx),%edi
lea    0x18(%rsp),%rsi
call   1040 <getrusage@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
call   1030 <assert@plt>
mov    0x18(%rsp),%r13
mov    0x20(%rsp),%rax
mov    %rax,0x10(%rsp)
mov    (%rbx),%edi
mov    %rsp,%rsi
call   1040 <getrusage@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
call   1030 <assert@plt>
mov    (%rsp),%r12
mov    0x8(%rsp),%r14
xor    %edi,%edi
cmp    %r12,%r13
setle  %dil
call   1030 <assert@plt>
mov    $0x1,%bl
cmp    %r13,%r12
jg     11f4 <main+0xd4>
mov    $0x1,%bl
xor    %ebp,%ebp
mov    %rsp,%r15
nopl   0x0(%rax)
cmp    %r13,%r12
jne    11ac <main+0x8c>
cmp    0x10(%rsp),%r14
jg     11f4 <main+0xd4>
cmp    $0x270f,%ebp
setb   %bl
je     11f4 <main+0xd4>
mov    0x2e22(%rip),%rax
mov    (%rax),%edi
mov    %r15,%rsi
call   1040 <getrusage@plt>
xor    %edi,%edi
test   %eax,%eax
sete   %dil
call   1030 <assert@plt>
mov    (%rsp),%r12
mov    0x8(%rsp),%r14
xor    %edi,%edi
cmp    %r12,%r13
setle  %dil
call   1030 <assert@plt>
add    $0x1,%ebp
cmp    %r13,%r12
jle    11a0 <main+0x80>
movzbl %bl,%edi
and    $0x1,%edi
call   1030 <assert@plt>
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
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 %struct.rusage
%4 = alloca i64
%5 = alloca i64
%6 = alloca i64
%7 = alloca i64
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %9
%11 = load i32, i32* @RUSAGE_SELF
%12 = call i32 @getrusage(i32 %11, %struct.rusage* %2)
store i32 %12, i32* %8
%13 = load i32, i32* %8
%14 = icmp eq i32 %13, 0
%15 = zext i1 %14 to i32
%16 = call i32 @assert(i32 %15)
%17 = getelementptr inbounds %struct.rusage, %struct.rusage* %2, i32 0, i32 0
%18 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %17, i32 0, i32 0
%19 = load i64, i64* %18
store i64 %19, i64* %4
%20 = getelementptr inbounds %struct.rusage, %struct.rusage* %2, i32 0, i32 0
%21 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %20, i32 0, i32 1
%22 = load i64, i64* %21
store i64 %22, i64* %5
store i32 0, i32* %10
br label %23
23: ; preds = %57, %0
%24 = load i32, i32* %10
%25 = icmp slt i32 %24, 10000
br i1 %25, label %26, label %60
26: ; preds = %23
%27 = load i32, i32* @RUSAGE_SELF
%28 = call i32 @getrusage(i32 %27, %struct.rusage* %3)
store i32 %28, i32* %8
%29 = load i32, i32* %8
%30 = icmp eq i32 %29, 0
%31 = zext i1 %30 to i32
%32 = call i32 @assert(i32 %31)
%33 = getelementptr inbounds %struct.rusage, %struct.rusage* %3, i32 0, i32 0
%34 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %33, i32 0, i32 0
%35 = load i64, i64* %34
store i64 %35, i64* %6
%36 = getelementptr inbounds %struct.rusage, %struct.rusage* %3, i32 0, i32 0
%37 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %36, i32 0, i32 1
%38 = load i64, i64* %37
store i64 %38, i64* %7
%39 = load i64, i64* %4
%40 = load i64, i64* %6
%41 = icmp sle i64 %39, %40
%42 = zext i1 %41 to i32
%43 = call i32 @assert(i32 %42)
%44 = load i64, i64* %6
%45 = load i64, i64* %4
%46 = icmp sgt i64 %44, %45
br i1 %46, label %55, label %47
47: ; preds = %26
%48 = load i64, i64* %6
%49 = load i64, i64* %4
%50 = icmp eq i64 %48, %49
br i1 %50, label %51, label %56
51: ; preds = %47
%52 = load i64, i64* %7
%53 = load i64, i64* %5
%54 = icmp sgt i64 %52, %53
br i1 %54, label %55, label %56
55: ; preds = %51, %26
store i32 1, i32* %9
br label %60
56: ; preds = %51, %47
br label %57
57: ; preds = %56
%58 = load i32, i32* %10
%59 = add nsw i32 %58, 1
store i32 %59, i32* %10
br label %23
60: ; preds = %55, %23
%61 = load i32, i32* %9
%62 = icmp eq i32 %61, 1
%63 = zext i1 %62 to i32
%64 = call i32 @assert(i32 %63)
%65 = load i32, i32* %1
ret i32 %65
}

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 = bitcast %struct.rusage* %2 to i8*
%5 = load i32, i32* @RUSAGE_SELF
%6 = call i32 @getrusage(i32 %5, %struct.rusage* %1)
%7 = icmp eq i32 %6, 0
%8 = zext i1 %7 to i32
%9 = call i32 @assert(i32 %8)
%10 = getelementptr inbounds %struct.rusage, %struct.rusage* %1, i64 0, i32 0, i32 0
%11 = load i64, i64* %10
%12 = getelementptr inbounds %struct.rusage, %struct.rusage* %1, i64 0, i32 0, i32 1
%13 = load i64, i64* %12
%14 = getelementptr inbounds %struct.rusage, %struct.rusage* %2, i64 0, i32 0, i32 0
%15 = getelementptr inbounds %struct.rusage, %struct.rusage* %2, i64 0, i32 0, i32 1
%16 = load i32, i32* @RUSAGE_SELF
%17 = call i32 @getrusage(i32 %16, %struct.rusage* %2)
%18 = icmp eq i32 %17, 0
%19 = zext i1 %18 to i32
%20 = call i32 @assert(i32 %19)
%21 = load i64, i64* %14
%22 = load i64, i64* %15
%23 = icmp sle i64 %11, %21
%24 = zext i1 %23 to i32
%25 = call i32 @assert(i32 %24)
%26 = icmp sgt i64 %21, %11
br i1 %26, label %51, label %43
27: ; preds = %43
%28 = add nuw nsw i32 %46, 1
%29 = icmp ult i32 %46, 9999
%30 = icmp eq i32 %28, 10000
br i1 %30, label %51, label %31
31: ; preds = %27
%32 = load i32, i32* @RUSAGE_SELF
%33 = call i32 @getrusage(i32 %32, %struct.rusage* %2)
%34 = icmp eq i32 %33, 0
%35 = zext i1 %34 to i32
%36 = call i32 @assert(i32 %35)
%37 = load i64, i64* %14
%38 = load i64, i64* %15
%39 = icmp sle i64 %11, %37
%40 = zext i1 %39 to i32
%41 = call i32 @assert(i32 %40)
%42 = icmp sgt i64 %37, %11
br i1 %42, label %51, label %43
43: ; preds = %0, %31
%44 = phi i64 [ %38, %31 ], [ %22, %0 ]
%45 = phi i64 [ %37, %31 ], [ %21, %0 ]
%46 = phi i32 [ %28, %31 ], [ 0, %0 ]
%47 = phi i1 [ %29, %31 ], [ true, %0 ]
%48 = icmp eq i64 %45, %11
%49 = icmp sgt i64 %44, %13
%50 = select i1 %48, i1 %49, i1 false
br i1 %50, label %51, label %27
51: ; preds = %27, %43, %31, %0
%52 = phi i1 [ true, %0 ], [ %29, %27 ], [ %47, %43 ], [ %29, %31 ]
%53 = zext i1 %52 to i32
%54 = call i32 @assert(i32 %53)
ret i32 0
}