#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 userprintoff(struct rusage *start, struct rusage *end,
                  struct rusage *off) {
  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;
  end->ru_utime.tv_sec -= off->ru_utime.tv_sec;
  end->ru_utime.tv_usec -= off->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. (rel)\n", end->ru_utime.tv_sec,
         end->ru_utime.tv_usec / 10000);
}


x86 assembly (clang, -O0):
<userprintoff>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    0x2ea5(%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    1198 <userprintoff+0x78>
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    -0x18(%rbp),%rax
mov    0x8(%rax),%rdx
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rcx
sub    %rdx,%rcx
mov    %rcx,0x8(%rax)
mov    -0x18(%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    11ea <userprintoff+0xca>
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    0xdf7(%rip),%rdi
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<userprintoff>:
push   %r15
push   %r14
push   %rbx
mov    %rdx,%r14
mov    %rsi,%rbx
mov    %rdi,%r15
mov    0x2eab(%rip),%rax
mov    (%rax),%edi
call   1040 <getrusage@plt>
mov    0x8(%rbx),%rsi
sub    0x8(%r15),%rsi
mov    %rsi,0x8(%rbx)
mov    (%rbx),%eax
sub    (%r15),%eax
mov    %eax,(%rbx)
jns    1160 <userprintoff+0x40>
add    $0xffffffffffffffff,%rsi
mov    %rsi,0x8(%rbx)
add    $0xf4240,%eax
mov    %eax,(%rbx)
sub    0x8(%r14),%rsi
mov    %rsi,0x8(%rbx)
sub    (%r14),%eax
mov    %eax,(%rbx)
jns    117e <userprintoff+0x5e>
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    0xe65(%rip),%rdi
pop    %rbx
pop    %r14
pop    %r15
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 = [25 x i8] c"-> %ld.%02ld sec. (rel)\0A\00"
define void @userprintoff(%struct.rusage* %0, %struct.rusage* %1, %struct.rusage* %2) {
%4 = alloca %struct.rusage*
%5 = alloca %struct.rusage*
%6 = alloca %struct.rusage*
store %struct.rusage* %0, %struct.rusage** %4
store %struct.rusage* %1, %struct.rusage** %5
store %struct.rusage* %2, %struct.rusage** %6
%7 = load i32, i32* @RUSAGE_SELF
%8 = load %struct.rusage*, %struct.rusage** %5
%9 = call i32 @getrusage(i32 %7, %struct.rusage* %8)
%10 = load %struct.rusage*, %struct.rusage** %4
%11 = getelementptr inbounds %struct.rusage, %struct.rusage* %10, i32 0, i32 0
%12 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %11, i32 0, i32 1
%13 = load i64, i64* %12
%14 = load %struct.rusage*, %struct.rusage** %5
%15 = getelementptr inbounds %struct.rusage, %struct.rusage* %14, i32 0, i32 0
%16 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %15, i32 0, i32 1
%17 = load i64, i64* %16
%18 = sub nsw i64 %17, %13
store i64 %18, i64* %16
%19 = load %struct.rusage*, %struct.rusage** %4
%20 = getelementptr inbounds %struct.rusage, %struct.rusage* %19, i32 0, i32 0
%21 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %20, i32 0, i32 0
%22 = load i32, i32* %21
%23 = load %struct.rusage*, %struct.rusage** %5
%24 = getelementptr inbounds %struct.rusage, %struct.rusage* %23, i32 0, i32 0
%25 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %24, i32 0, i32 0
%26 = load i32, i32* %25
%27 = sub nsw i32 %26, %22
store i32 %27, i32* %25
%28 = load %struct.rusage*, %struct.rusage** %5
%29 = getelementptr inbounds %struct.rusage, %struct.rusage* %28, i32 0, i32 0
%30 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %29, i32 0, i32 0
%31 = load i32, i32* %30
%32 = icmp slt i32 %31, 0
br i1 %32, label %33, label %44
33: ; preds = %3
%34 = load %struct.rusage*, %struct.rusage** %5
%35 = getelementptr inbounds %struct.rusage, %struct.rusage* %34, i32 0, i32 0
%36 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %35, i32 0, i32 1
%37 = load i64, i64* %36
%38 = add nsw i64 %37, -1
store i64 %38, i64* %36
%39 = load %struct.rusage*, %struct.rusage** %5
%40 = getelementptr inbounds %struct.rusage, %struct.rusage* %39, i32 0, i32 0
%41 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %40, i32 0, i32 0
%42 = load i32, i32* %41
%43 = add nsw i32 %42, 1000000
store i32 %43, i32* %41
br label %44
44: ; preds = %33, %3
%45 = load %struct.rusage*, %struct.rusage** %6
%46 = getelementptr inbounds %struct.rusage, %struct.rusage* %45, i32 0, i32 0
%47 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %46, i32 0, i32 1
%48 = load i64, i64* %47
%49 = load %struct.rusage*, %struct.rusage** %5
%50 = getelementptr inbounds %struct.rusage, %struct.rusage* %49, i32 0, i32 0
%51 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %50, i32 0, i32 1
%52 = load i64, i64* %51
%53 = sub nsw i64 %52, %48
store i64 %53, i64* %51
%54 = load %struct.rusage*, %struct.rusage** %6
%55 = getelementptr inbounds %struct.rusage, %struct.rusage* %54, i32 0, i32 0
%56 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %55, i32 0, i32 0
%57 = load i32, i32* %56
%58 = load %struct.rusage*, %struct.rusage** %5
%59 = getelementptr inbounds %struct.rusage, %struct.rusage* %58, i32 0, i32 0
%60 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %59, i32 0, i32 0
%61 = load i32, i32* %60
%62 = sub nsw i32 %61, %57
store i32 %62, i32* %60
%63 = load %struct.rusage*, %struct.rusage** %5
%64 = getelementptr inbounds %struct.rusage, %struct.rusage* %63, i32 0, i32 0
%65 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %64, i32 0, i32 0
%66 = load i32, i32* %65
%67 = icmp slt i32 %66, 0
br i1 %67, label %68, label %79
68: ; preds = %44
%69 = load %struct.rusage*, %struct.rusage** %5
%70 = getelementptr inbounds %struct.rusage, %struct.rusage* %69, i32 0, i32 0
%71 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %70, i32 0, i32 1
%72 = load i64, i64* %71
%73 = add nsw i64 %72, -1
store i64 %73, i64* %71
%74 = load %struct.rusage*, %struct.rusage** %5
%75 = getelementptr inbounds %struct.rusage, %struct.rusage* %74, i32 0, i32 0
%76 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %75, i32 0, i32 0
%77 = load i32, i32* %76
%78 = add nsw i32 %77, 1000000
store i32 %78, i32* %76
br label %79
79: ; preds = %68, %44
%80 = load %struct.rusage*, %struct.rusage** %5
%81 = getelementptr inbounds %struct.rusage, %struct.rusage* %80, i32 0, i32 0
%82 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %81, i32 0, i32 1
%83 = load i64, i64* %82
%84 = load %struct.rusage*, %struct.rusage** %5
%85 = getelementptr inbounds %struct.rusage, %struct.rusage* %84, i32 0, i32 0
%86 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %85, i32 0, i32 0
%87 = load i32, i32* %86
%88 = sdiv i32 %87, 10000
%89 = call i32 @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str, i64 0, i64 0), i64 %83, i32 %88)
ret void
}

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