#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__ {
  int tv_usec;
  scalar_t__ tv_sec;
};
struct rusage {
  TYPE_1__ ru_utime;
};

/* Variables and functions */
int /*<<< orphan*/ RUSAGE_SELF;
int /*<<< orphan*/ getrusage(int /*<<< orphan*/, struct rusage *);
int /*<<< orphan*/ printf(char *, scalar_t__, int);
void userprint(struct rusage *start, struct rusage *end) {
  getrusage(RUSAGE_SELF, end);
  end->ru_utime.tv_sec -= start->ru_utime.tv_sec;
  end->ru_utime.tv_usec -= start->ru_utime.tv_usec;
  if (end->ru_utime.tv_usec < 0)
    end->ru_utime.tv_sec--, end->ru_utime.tv_usec += 1000000;
  printf("-> %ld.%02ld sec.\n", end->ru_utime.tv_sec,
         end->ru_utime.tv_usec / 10000);
}


x86 assembly (clang, -O0):
<userprint>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2ea9(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rsi
call   1040 <getrusage@plt>
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%rdx
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rcx
sub    %rdx,%rcx
mov    %rcx,0x8(%rax)
mov    -0x8(%rbp),%rax
mov    (%rax),%edx
mov    -0x10(%rbp),%rax
mov    (%rax),%ecx
sub    %edx,%ecx
mov    %ecx,(%rax)
mov    -0x10(%rbp),%rax
cmpl   $0x0,(%rax)
jge    1194 <userprint+0x74>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rcx
add    $0xffffffffffffffff,%rcx
mov    %rcx,0x8(%rax)
mov    -0x10(%rbp),%rax
mov    (%rax),%ecx
add    $0xf4240,%ecx
mov    %ecx,(%rax)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
mov    $0x2710,%ecx
cltd
idiv   %ecx
mov    %eax,%edx
lea    0xe4d(%rip),%rdi
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<userprint>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %rdi,%r14
mov    0x2eaf(%rip),%rax
mov    (%rax),%edi
call   1040 <getrusage@plt>
mov    0x8(%rbx),%rsi
sub    0x8(%r14),%rsi
mov    %rsi,0x8(%rbx)
mov    (%rbx),%eax
sub    (%r14),%eax
mov    %eax,(%rbx)
jns    115c <userprint+0x3c>
add    $0xffffffffffffffff,%rsi
mov    %rsi,0x8(%rbx)
add    $0xf4240,%eax
mov    %eax,(%rbx)
cltq
imul   $0x68db8bad,%rax,%rdx
mov    %rdx,%rax
shr    $0x3f,%rax
sar    $0x2c,%rdx
add    %eax,%edx
lea    0xe87(%rip),%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <printf@plt>

LLVM IR (-O0):
%struct.rusage = type { %struct.TYPE_2__ }
%struct.TYPE_2__ = type { i32, i64 }
@RUSAGE_SELF = global i32 0
@.str = [19 x i8] c"-> %ld.%02ld sec.\0A\00"
define void @userprint(%struct.rusage* %0, %struct.rusage* %1) {
%3 = alloca %struct.rusage*
%4 = alloca %struct.rusage*
store %struct.rusage* %0, %struct.rusage** %3
store %struct.rusage* %1, %struct.rusage** %4
%5 = load i32, i32* @RUSAGE_SELF
%6 = load %struct.rusage*, %struct.rusage** %4
%7 = call i32 @getrusage(i32 %5, %struct.rusage* %6)
%8 = load %struct.rusage*, %struct.rusage** %3
%9 = getelementptr inbounds %struct.rusage, %struct.rusage* %8, i32 0, i32 0
%10 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %9, i32 0, i32 1
%11 = load i64, i64* %10
%12 = load %struct.rusage*, %struct.rusage** %4
%13 = getelementptr inbounds %struct.rusage, %struct.rusage* %12, i32 0, i32 0
%14 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %13, i32 0, i32 1
%15 = load i64, i64* %14
%16 = sub nsw i64 %15, %11
store i64 %16, i64* %14
%17 = load %struct.rusage*, %struct.rusage** %3
%18 = getelementptr inbounds %struct.rusage, %struct.rusage* %17, i32 0, i32 0
%19 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %18, i32 0, i32 0
%20 = load i32, i32* %19
%21 = load %struct.rusage*, %struct.rusage** %4
%22 = getelementptr inbounds %struct.rusage, %struct.rusage* %21, i32 0, i32 0
%23 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %22, i32 0, i32 0
%24 = load i32, i32* %23
%25 = sub nsw i32 %24, %20
store i32 %25, i32* %23
%26 = load %struct.rusage*, %struct.rusage** %4
%27 = getelementptr inbounds %struct.rusage, %struct.rusage* %26, i32 0, i32 0
%28 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %27, i32 0, i32 0
%29 = load i32, i32* %28
%30 = icmp slt i32 %29, 0
br i1 %30, label %31, label %42
31: ; preds = %2
%32 = load %struct.rusage*, %struct.rusage** %4
%33 = getelementptr inbounds %struct.rusage, %struct.rusage* %32, i32 0, i32 0
%34 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %33, i32 0, i32 1
%35 = load i64, i64* %34
%36 = add nsw i64 %35, -1
store i64 %36, i64* %34
%37 = load %struct.rusage*, %struct.rusage** %4
%38 = getelementptr inbounds %struct.rusage, %struct.rusage* %37, i32 0, i32 0
%39 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %38, i32 0, i32 0
%40 = load i32, i32* %39
%41 = add nsw i32 %40, 1000000
store i32 %41, i32* %39
br label %42
42: ; preds = %31, %2
%43 = load %struct.rusage*, %struct.rusage** %4
%44 = getelementptr inbounds %struct.rusage, %struct.rusage* %43, i32 0, i32 0
%45 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %44, i32 0, i32 1
%46 = load i64, i64* %45
%47 = load %struct.rusage*, %struct.rusage** %4
%48 = getelementptr inbounds %struct.rusage, %struct.rusage* %47, i32 0, i32 0
%49 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %48, i32 0, i32 0
%50 = load i32, i32* %49
%51 = sdiv i32 %50, 10000
%52 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i64 %46, i32 %51)
ret void
}

LLVM IR (-O2):
%struct.rusage = type { %struct.TYPE_2__ }
%struct.TYPE_2__ = type { i32, i64 }
@RUSAGE_SELF = global i32 0
@.str = [19 x i8] c"-> %ld.%02ld sec.\0A\00"
define void @userprint(%struct.rusage* nocapture %0, %struct.rusage* %1) {
%3 = load i32, i32* @RUSAGE_SELF
%4 = tail call i32 @getrusage(i32 %3, %struct.rusage* %1)
%5 = getelementptr inbounds %struct.rusage, %struct.rusage* %0, i64 0, i32 0, i32 1
%6 = load i64, i64* %5
%7 = getelementptr inbounds %struct.rusage, %struct.rusage* %1, i64 0, i32 0, i32 1
%8 = load i64, i64* %7
%9 = sub nsw i64 %8, %6
store i64 %9, i64* %7
%10 = getelementptr inbounds %struct.rusage, %struct.rusage* %0, i64 0, i32 0, i32 0
%11 = load i32, i32* %10
%12 = getelementptr inbounds %struct.rusage, %struct.rusage* %1, i64 0, i32 0, i32 0
%13 = load i32, i32* %12
%14 = sub nsw i32 %13, %11
store i32 %14, i32* %12
%15 = icmp slt i32 %14, 0
br i1 %15, label %16, label %19
16: ; preds = %2
%17 = add nsw i64 %9, -1
store i64 %17, i64* %7
%18 = add nsw i32 %14, 1000000
store i32 %18, i32* %12
br label %19
19: ; preds = %16, %2
%20 = phi i32 [ %18, %16 ], [ %14, %2 ]
%21 = phi i64 [ %17, %16 ], [ %9, %2 ]
%22 = sdiv i32 %20, 10000
%23 = tail call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i64 %21, i32 %22)
ret void
}