#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 */
struct timeval {
  unsigned long long tv_usec;
  scalar_t__ tv_sec;
};
struct rusage {
  struct timeval ru_stime;
  struct timeval ru_utime;
};

/* Variables and functions */
int /*<<< orphan*/ RUSAGE_SELF;
int /*<<< orphan*/ getrusage(int /*<<< orphan*/, struct rusage *);
unsigned long long myclock() {
  struct timeval tm, tm2;
  struct rusage ru;
  getrusage(RUSAGE_SELF, &ru);
  tm = ru.ru_utime;
  tm2 = ru.ru_stime;
  return (((unsigned long long)tm.tv_sec) * 1000000) + tm.tv_usec +
         (((unsigned long long)tm2.tv_sec) * 1000000) + tm2.tv_usec;
}


x86 assembly (clang, -O0):
<myclock>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    0x2ec1(%rip),%rax
mov    (%rax),%edi
lea    -0x40(%rbp),%rsi
call   1030 <getrusage@plt>
mov    -0x30(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x40(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x38(%rbp),%rax
mov    %rax,-0x18(%rbp)
imul   $0xf4240,-0x8(%rbp),%rax
add    -0x10(%rbp),%rax
imul   $0xf4240,-0x18(%rbp),%rcx
add    %rcx,%rax
add    -0x20(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<myclock>:
sub    $0x28,%rsp
mov    0x2ec5(%rip),%rax
mov    (%rax),%edi
lea    0x8(%rsp),%rsi
call   1030 <getrusage@plt>
mov    0x8(%rsp),%rax
mov    0x10(%rsp),%rcx
add    0x20(%rsp),%rcx
imul   $0xf4240,%rcx,%rcx
add    0x18(%rsp),%rax
add    %rcx,%rax
add    $0x28,%rsp
ret

LLVM IR (-O0):
%struct.timeval = type { i64, i64 }
%struct.rusage = type { %struct.timeval, %struct.timeval }
@RUSAGE_SELF = global i32 0
define i64 @myclock() {
%1 = alloca %struct.timeval
%2 = alloca %struct.timeval
%3 = alloca %struct.rusage
%4 = load i32, i32* @RUSAGE_SELF
%5 = call i32 @getrusage(i32 %4, %struct.rusage* %3)
%6 = getelementptr inbounds %struct.rusage, %struct.rusage* %3, i32 0, i32 1
%7 = bitcast %struct.timeval* %1 to i8*
%8 = bitcast %struct.timeval* %6 to i8*
%9 = getelementptr inbounds %struct.rusage, %struct.rusage* %3, i32 0, i32 0
%10 = bitcast %struct.timeval* %2 to i8*
%11 = bitcast %struct.timeval* %9 to i8*
%12 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i32 0, i32 1
%13 = load i64, i64* %12
%14 = mul i64 %13, 1000000
%15 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i32 0, i32 0
%16 = load i64, i64* %15
%17 = add i64 %14, %16
%18 = getelementptr inbounds %struct.timeval, %struct.timeval* %2, i32 0, i32 1
%19 = load i64, i64* %18
%20 = mul i64 %19, 1000000
%21 = add i64 %17, %20
%22 = getelementptr inbounds %struct.timeval, %struct.timeval* %2, i32 0, i32 0
%23 = load i64, i64* %22
%24 = add i64 %21, %23
ret i64 %24
}

LLVM IR (-O2):
%struct.rusage = type { %struct.timeval, %struct.timeval }
%struct.timeval = type { i64, i64 }
@RUSAGE_SELF = global i32 0
define i64 @myclock() {
%1 = alloca %struct.rusage
%2 = bitcast %struct.rusage* %1 to i8*
%3 = load i32, i32* @RUSAGE_SELF
%4 = call i32 @getrusage(i32 %3, %struct.rusage* %1)
%5 = getelementptr inbounds %struct.rusage, %struct.rusage* %1, i64 0, i32 1, i32 0
%6 = load i64, i64* %5
%7 = getelementptr inbounds %struct.rusage, %struct.rusage* %1, i64 0, i32 1, i32 1
%8 = load i64, i64* %7
%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 = add i64 %12, %8
%14 = mul i64 %13, 1000000
%15 = add i64 %10, %6
%16 = add i64 %15, %14
ret i64 %16
}