#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 tms {
  int tms_utime;
  int tms_stime;
  int tms_cutime;
  int tms_cstime;
};
struct timezone {
  int dummy;
};
struct timeval {
  int tv_sec;
  int tv_usec;
};

/* Variables and functions */
int /*<<< orphan*/ gettimeofday(struct timeval *, struct timezone *);
int /*<<< orphan*/ times(struct tms *);
unsigned int ReadClock(int *elapsed, int *cpu) {
  struct tms t;
  struct timeval timeval;
  struct timezone timezone;
  (void)times(&t);
  *cpu = t.tms_utime + t.tms_stime + t.tms_cutime + t.tms_cstime;
  gettimeofday(&timeval, &timezone);
  *elapsed = (timeval.tv_sec * 100 + (timeval.tv_usec / 10000));
}


x86 assembly (clang, -O0):
<ReadClock>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
lea    -0x28(%rbp),%rdi
call   1040 <times@plt>
mov    -0x28(%rbp),%ecx
add    -0x24(%rbp),%ecx
add    -0x20(%rbp),%ecx
add    -0x1c(%rbp),%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
lea    -0x30(%rbp),%rdi
lea    -0x38(%rbp),%rsi
call   1030 <gettimeofday@plt>
imul   $0x64,-0x30(%rbp),%ecx
mov    -0x2c(%rbp),%eax
mov    $0x2710,%esi
cltd
idiv   %esi
add    %eax,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ReadClock>:
push   %r14
push   %rbx
sub    $0x28,%rsp
mov    %rsi,%rbx
mov    %rdi,%r14
lea    0x10(%rsp),%rdi
call   1040 <times@plt>
mov    0x14(%rsp),%eax
add    0x10(%rsp),%eax
add    0x18(%rsp),%eax
add    0x1c(%rsp),%eax
mov    %eax,(%rbx)
lea    0x8(%rsp),%rdi
lea    0x20(%rsp),%rsi
call   1030 <gettimeofday@plt>
imul   $0x64,0x8(%rsp),%eax
movslq 0xc(%rsp),%rcx
imul   $0x68db8bad,%rcx,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
sar    $0x2c,%rcx
add    %edx,%ecx
add    %eax,%ecx
mov    %ecx,(%r14)
add    $0x28,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.tms = type { i32, i32, i32, i32 }
%struct.timeval = type { i32, i32 }
%struct.timezone = type { i32 }
define i32 @ReadClock(i32* %0, i32* %1) {
%3 = alloca i32
%4 = alloca i32*
%5 = alloca i32*
%6 = alloca %struct.tms
%7 = alloca %struct.timeval
%8 = alloca %struct.timezone
store i32* %0, i32** %4
store i32* %1, i32** %5
%9 = call i32 @times(%struct.tms* %6)
%10 = getelementptr inbounds %struct.tms, %struct.tms* %6, i32 0, i32 0
%11 = load i32, i32* %10
%12 = getelementptr inbounds %struct.tms, %struct.tms* %6, i32 0, i32 1
%13 = load i32, i32* %12
%14 = add nsw i32 %11, %13
%15 = getelementptr inbounds %struct.tms, %struct.tms* %6, i32 0, i32 2
%16 = load i32, i32* %15
%17 = add nsw i32 %14, %16
%18 = getelementptr inbounds %struct.tms, %struct.tms* %6, i32 0, i32 3
%19 = load i32, i32* %18
%20 = add nsw i32 %17, %19
%21 = load i32*, i32** %5
store i32 %20, i32* %21
%22 = call i32 @gettimeofday(%struct.timeval* %7, %struct.timezone* %8)
%23 = getelementptr inbounds %struct.timeval, %struct.timeval* %7, i32 0, i32 0
%24 = load i32, i32* %23
%25 = mul nsw i32 %24, 100
%26 = getelementptr inbounds %struct.timeval, %struct.timeval* %7, i32 0, i32 1
%27 = load i32, i32* %26
%28 = sdiv i32 %27, 10000
%29 = add nsw i32 %25, %28
%30 = load i32*, i32** %4
store i32 %29, i32* %30
%31 = load i32, i32* %3
ret i32 %31
}

LLVM IR (-O2):
%struct.tms = type { i32, i32, i32, i32 }
%struct.timeval = type { i32, i32 }
%struct.timezone = type { i32 }
define i32 @ReadClock(i32* nocapture writeonly %0, i32* nocapture writeonly %1) {
%3 = alloca %struct.tms
%4 = alloca %struct.timeval
%5 = alloca %struct.timezone
%6 = bitcast %struct.tms* %3 to i8*
%7 = bitcast %struct.timeval* %4 to i8*
%8 = bitcast %struct.timezone* %5 to i8*
%9 = call i32 @times(%struct.tms* %3)
%10 = getelementptr inbounds %struct.tms, %struct.tms* %3, i64 0, i32 0
%11 = load i32, i32* %10
%12 = getelementptr inbounds %struct.tms, %struct.tms* %3, i64 0, i32 1
%13 = load i32, i32* %12
%14 = add nsw i32 %13, %11
%15 = getelementptr inbounds %struct.tms, %struct.tms* %3, i64 0, i32 2
%16 = load i32, i32* %15
%17 = add nsw i32 %14, %16
%18 = getelementptr inbounds %struct.tms, %struct.tms* %3, i64 0, i32 3
%19 = load i32, i32* %18
%20 = add nsw i32 %17, %19
store i32 %20, i32* %1
%21 = call i32 @gettimeofday(%struct.timeval* %4, %struct.timezone* %5)
%22 = getelementptr inbounds %struct.timeval, %struct.timeval* %4, i64 0, i32 0
%23 = load i32, i32* %22
%24 = mul nsw i32 %23, 100
%25 = getelementptr inbounds %struct.timeval, %struct.timeval* %4, i64 0, i32 1
%26 = load i32, i32* %25
%27 = sdiv i32 %26, 10000
%28 = add nsw i32 %27, %24
store i32 %28, i32* %0
ret i32 undef
}