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

/* Variables and functions */
int /*<<< orphan*/ O_RDONLY;
int /*<<< orphan*/ assert(int);
int open(char *, int /*<<< orphan*/);
int /*<<< orphan*/ proc_uptime(int, int *, int *);
int main(void) {
  uint64_t start, u0, u1, i0, i1;
  int fd;
  fd = open("/proc/uptime", O_RDONLY);
  assert(fd >= 0);
  proc_uptime(fd, &u0, &i0);
  start = u0;
  do {
    proc_uptime(fd, &u1, &i1);
    assert(u1 >= u0);
    assert(i1 >= i0);
    u0 = u1;
    i0 = i1;
  } while (u1 - start < 100);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2ea2(%rip),%rax
mov    (%rax),%esi
lea    0xeb1(%rip),%rdi
call   1050 <open@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
setge  %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
mov    -0x1c(%rbp),%edi
lea    -0xc(%rbp),%rsi
lea    -0x14(%rbp),%rdx
call   1030 <proc_uptime@plt>
mov    -0xc(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x1c(%rbp),%edi
lea    -0x10(%rbp),%rsi
lea    -0x18(%rbp),%rdx
call   1030 <proc_uptime@plt>
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
setge  %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
setge  %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
mov    -0x10(%rbp),%eax
mov    %eax,-0xc(%rbp)
mov    -0x18(%rbp),%eax
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%eax
sub    -0x8(%rbp),%eax
cmp    $0x64,%eax
jl     117e <main+0x4e>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    0x2ea7(%rip),%rax
mov    (%rax),%esi
lea    0xeb6(%rip),%rdi
call   1050 <open@plt>
mov    %eax,%ebx
mov    %eax,%edi
not    %edi
shr    $0x1f,%edi
call   1040 <assert@plt>
lea    0x8(%rsp),%rsi
lea    0x10(%rsp),%rdx
mov    %ebx,%edi
call   1030 <proc_uptime@plt>
mov    0x8(%rsp),%ebp
lea    0x14(%rsp),%r14
lea    0xc(%rsp),%r15
nopl   0x0(%rax)
mov    %ebx,%edi
mov    %r14,%rsi
mov    %r15,%rdx
call   1030 <proc_uptime@plt>
mov    0x14(%rsp),%eax
xor    %edi,%edi
cmp    0x8(%rsp),%eax
setge  %dil
call   1040 <assert@plt>
mov    0xc(%rsp),%eax
xor    %edi,%edi
cmp    0x10(%rsp),%eax
setge  %dil
call   1040 <assert@plt>
mov    0x14(%rsp),%eax
mov    %eax,0x8(%rsp)
mov    0xc(%rsp),%ecx
mov    %ecx,0x10(%rsp)
sub    %ebp,%eax
cmp    $0x64,%eax
jl     1180 <main+0x50>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [13 x i8] c"/proc/uptime\00"
@O_RDONLY = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32 0, i32* %1
%8 = load i32, i32* @O_RDONLY
%9 = call i32 @open(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 %8)
store i32 %9, i32* %7
%10 = load i32, i32* %7
%11 = icmp sge i32 %10, 0
%12 = zext i1 %11 to i32
%13 = call i32 @assert(i32 %12)
%14 = load i32, i32* %7
%15 = call i32 @proc_uptime(i32 %14, i32* %3, i32* %5)
%16 = load i32, i32* %3
store i32 %16, i32* %2
br label %17
17: ; preds = %32, %0
%18 = load i32, i32* %7
%19 = call i32 @proc_uptime(i32 %18, i32* %4, i32* %6)
%20 = load i32, i32* %4
%21 = load i32, i32* %3
%22 = icmp sge i32 %20, %21
%23 = zext i1 %22 to i32
%24 = call i32 @assert(i32 %23)
%25 = load i32, i32* %6
%26 = load i32, i32* %5
%27 = icmp sge i32 %25, %26
%28 = zext i1 %27 to i32
%29 = call i32 @assert(i32 %28)
%30 = load i32, i32* %4
store i32 %30, i32* %3
%31 = load i32, i32* %6
store i32 %31, i32* %5
br label %32
32: ; preds = %17
%33 = load i32, i32* %4
%34 = load i32, i32* %2
%35 = sub nsw i32 %33, %34
%36 = icmp slt i32 %35, 100
br i1 %36, label %17, label %37
37: ; preds = %32
ret i32 0
}

LLVM IR (-O2):
@.str = [13 x i8] c"/proc/uptime\00"
@O_RDONLY = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = bitcast i32* %1 to i8*
%6 = bitcast i32* %2 to i8*
%7 = bitcast i32* %3 to i8*
%8 = bitcast i32* %4 to i8*
%9 = load i32, i32* @O_RDONLY
%10 = tail call i32 @open(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 %9)
%11 = xor i32 %10, -1
%12 = lshr i32 %11, 31
%13 = tail call i32 @assert(i32 %12)
%14 = call i32 @proc_uptime(i32 %10, i32* %1, i32* %3)
%15 = load i32, i32* %1
br label %16
16: ; preds = %16, %0
%17 = call i32 @proc_uptime(i32 %10, i32* %2, i32* %4)
%18 = load i32, i32* %2
%19 = load i32, i32* %1
%20 = icmp sge i32 %18, %19
%21 = zext i1 %20 to i32
%22 = call i32 @assert(i32 %21)
%23 = load i32, i32* %4
%24 = load i32, i32* %3
%25 = icmp sge i32 %23, %24
%26 = zext i1 %25 to i32
%27 = call i32 @assert(i32 %26)
%28 = load i32, i32* %2
store i32 %28, i32* %1
%29 = load i32, i32* %4
store i32 %29, i32* %3
%30 = sub nsw i32 %28, %15
%31 = icmp slt i32 %30, 100
br i1 %31, label %16, label %32
32: ; preds = %16
ret i32 0
}