#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_4__ TYPE_2__;
typedef struct TYPE_3__ TYPE_1__;

/* Type definitions */
struct vtimes {
  int vm_utime;
  int vm_stime;
  int /*<<< orphan*/ vm_oublk;
  int /*<<< orphan*/ vm_inblk;
  int /*<<< orphan*/ vm_nswap;
  int /*<<< orphan*/ vm_minflt;
  int /*<<< orphan*/ vm_majflt;
  scalar_t__ vm_idsrss;
};
struct TYPE_4__ {
  int tv_sec;
  int tv_usec;
};
struct TYPE_3__ {
  int tv_sec;
  int tv_usec;
};
struct rusage {
  int /*<<< orphan*/ ru_oublock;
  int /*<<< orphan*/ ru_inblock;
  int /*<<< orphan*/ ru_nswap;
  int /*<<< orphan*/ ru_minflt;
  int /*<<< orphan*/ ru_majflt;
  scalar_t__ ru_isrss;
  scalar_t__ ru_idrss;
  TYPE_2__ ru_stime;
  TYPE_1__ ru_utime;
};
typedef enum __rusage_who { ____Placeholder___rusage_who } __rusage_who;

/* Variables and functions */
int VTIMES_UNITS_PER_SECOND;
scalar_t__ __getrusage(int, struct rusage *);
int vtimes_one(struct vtimes *vt, enum __rusage_who who) {
  if (vt != NULL) {
    struct rusage usage;
    if (__getrusage(who, &usage) < 0)
      return -1;
    vt->vm_utime =
        ((usage.ru_utime.tv_sec * VTIMES_UNITS_PER_SECOND) +
         (usage.ru_utime.tv_usec * VTIMES_UNITS_PER_SECOND / 1000000));
    vt->vm_stime =
        ((usage.ru_stime.tv_sec * VTIMES_UNITS_PER_SECOND) +
         (usage.ru_stime.tv_usec * VTIMES_UNITS_PER_SECOND / 1000000));
    vt->vm_idsrss = usage.ru_idrss + usage.ru_isrss;
    vt->vm_majflt = usage.ru_majflt;
    vt->vm_minflt = usage.ru_minflt;
    vt->vm_nswap = usage.ru_nswap;
    vt->vm_inblk = usage.ru_inblock;
    vt->vm_oublk = usage.ru_oublock;
  }
  return 0;
}


x86 assembly (clang, -O0):
<vtimes_one>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     11e3 <vtimes_one+0xd3>
mov    -0x14(%rbp),%edi
lea    -0x50(%rbp),%rsi
call   1030 <__getrusage@plt>
cmp    $0x0,%rax
jge    114c <vtimes_one+0x3c>
movl   $0xffffffff,-0x4(%rbp)
jmp    11ea <vtimes_one+0xda>
mov    -0x20(%rbp),%ecx
mov    0x2e92(%rip),%rax
imul   (%rax),%ecx
mov    -0x1c(%rbp),%eax
mov    0x2e85(%rip),%rdx
imul   (%rdx),%eax
mov    $0xf4240,%esi
cltd
idiv   %esi
add    %eax,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x28(%rbp),%ecx
mov    0x2e68(%rip),%rax
imul   (%rax),%ecx
mov    -0x24(%rbp),%eax
mov    0x2e5b(%rip),%rdx
imul   (%rdx),%eax
mov    $0xf4240,%esi
cltd
idiv   %esi
add    %eax,%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,0x4(%rax)
mov    -0x30(%rbp),%rcx
add    -0x38(%rbp),%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,0x20(%rax)
mov    -0x40(%rbp),%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,0x18(%rax)
mov    -0x44(%rbp),%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,0x14(%rax)
mov    -0x48(%rbp),%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,0x10(%rax)
mov    -0x4c(%rbp),%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,0xc(%rax)
mov    -0x50(%rbp),%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,0x8(%rax)
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<vtimes_one>:
push   %rbp
push   %rbx
sub    $0x38,%rsp
xor    %ebp,%ebp
test   %rdi,%rdi
je     11b9 <vtimes_one+0xa9>
mov    %rdi,%rbx
mov    %rsp,%rax
mov    %esi,%edi
mov    %rax,%rsi
call   1030 <__getrusage@plt>
test   %rax,%rax
js     11b4 <vtimes_one+0xa4>
mov    0x2eab(%rip),%rax
mov    (%rax),%ecx
mov    0x30(%rsp),%edx
imul   %ecx,%edx
imul   0x34(%rsp),%ecx
movslq %ecx,%rcx
imul   $0x431bde83,%rcx,%rcx
mov    %rcx,%rsi
shr    $0x3f,%rsi
shr    $0x20,%rcx
sar    $0x12,%ecx
add    %esi,%ecx
add    %edx,%ecx
mov    %ecx,(%rbx)
mov    (%rax),%eax
mov    0x28(%rsp),%ecx
imul   %eax,%ecx
imul   0x2c(%rsp),%eax
cltq
imul   $0x431bde83,%rax,%rax
mov    %rax,%rdx
shr    $0x3f,%rdx
shr    $0x20,%rax
sar    $0x12,%eax
add    %edx,%eax
add    %ecx,%eax
mov    %eax,0x4(%rbx)
mov    0x18(%rsp),%rax
add    0x20(%rsp),%rax
mov    %rax,0x20(%rbx)
mov    0x10(%rsp),%eax
mov    %eax,0x18(%rbx)
movaps (%rsp),%xmm0
movups %xmm0,0x8(%rbx)
jmp    11b9 <vtimes_one+0xa9>
mov    $0xffffffff,%ebp
mov    %ebp,%eax
add    $0x38,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
%struct.vtimes = type { i32, i32, i32, i32, i32, i32, i32, i64 }
%struct.rusage = type { i32, i32, i32, i32, i32, i64, i64, %struct.TYPE_4__, %struct.TYPE_3__ }
%struct.TYPE_4__ = type { i32, i32 }
%struct.TYPE_3__ = type { i32, i32 }
@VTIMES_UNITS_PER_SECOND = global i32 0
define i32 @vtimes_one(%struct.vtimes* %0, i32 %1) {
%3 = alloca i32
%4 = alloca %struct.vtimes*
%5 = alloca i32
%6 = alloca %struct.rusage
store %struct.vtimes* %0, %struct.vtimes** %4
store i32 %1, i32* %5
%7 = load %struct.vtimes*, %struct.vtimes** %4
%8 = icmp ne %struct.vtimes* %7, null
br i1 %8, label %9, label %70
9: ; preds = %2
%10 = load i32, i32* %5
%11 = call i64 @__getrusage(i32 %10, %struct.rusage* %6)
%12 = icmp slt i64 %11, 0
br i1 %12, label %13, label %14
13: ; preds = %9
store i32 -1, i32* %3
br label %71
14: ; preds = %9
%15 = getelementptr inbounds %struct.rusage, %struct.rusage* %6, i32 0, i32 8
%16 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %15, i32 0, i32 0
%17 = load i32, i32* %16
%18 = load i32, i32* @VTIMES_UNITS_PER_SECOND
%19 = mul nsw i32 %17, %18
%20 = getelementptr inbounds %struct.rusage, %struct.rusage* %6, i32 0, i32 8
%21 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %20, i32 0, i32 1
%22 = load i32, i32* %21
%23 = load i32, i32* @VTIMES_UNITS_PER_SECOND
%24 = mul nsw i32 %22, %23
%25 = sdiv i32 %24, 1000000
%26 = add nsw i32 %19, %25
%27 = load %struct.vtimes*, %struct.vtimes** %4
%28 = getelementptr inbounds %struct.vtimes, %struct.vtimes* %27, i32 0, i32 0
store i32 %26, i32* %28
%29 = getelementptr inbounds %struct.rusage, %struct.rusage* %6, i32 0, i32 7
%30 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %29, i32 0, i32 0
%31 = load i32, i32* %30
%32 = load i32, i32* @VTIMES_UNITS_PER_SECOND
%33 = mul nsw i32 %31, %32
%34 = getelementptr inbounds %struct.rusage, %struct.rusage* %6, i32 0, i32 7
%35 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %34, i32 0, i32 1
%36 = load i32, i32* %35
%37 = load i32, i32* @VTIMES_UNITS_PER_SECOND
%38 = mul nsw i32 %36, %37
%39 = sdiv i32 %38, 1000000
%40 = add nsw i32 %33, %39
%41 = load %struct.vtimes*, %struct.vtimes** %4
%42 = getelementptr inbounds %struct.vtimes, %struct.vtimes* %41, i32 0, i32 1
store i32 %40, i32* %42
%43 = getelementptr inbounds %struct.rusage, %struct.rusage* %6, i32 0, i32 6
%44 = load i64, i64* %43
%45 = getelementptr inbounds %struct.rusage, %struct.rusage* %6, i32 0, i32 5
%46 = load i64, i64* %45
%47 = add nsw i64 %44, %46
%48 = load %struct.vtimes*, %struct.vtimes** %4
%49 = getelementptr inbounds %struct.vtimes, %struct.vtimes* %48, i32 0, i32 7
store i64 %47, i64* %49
%50 = getelementptr inbounds %struct.rusage, %struct.rusage* %6, i32 0, i32 4
%51 = load i32, i32* %50
%52 = load %struct.vtimes*, %struct.vtimes** %4
%53 = getelementptr inbounds %struct.vtimes, %struct.vtimes* %52, i32 0, i32 6
store i32 %51, i32* %53
%54 = getelementptr inbounds %struct.rusage, %struct.rusage* %6, i32 0, i32 3
%55 = load i32, i32* %54
%56 = load %struct.vtimes*, %struct.vtimes** %4
%57 = getelementptr inbounds %struct.vtimes, %struct.vtimes* %56, i32 0, i32 5
store i32 %55, i32* %57
%58 = getelementptr inbounds %struct.rusage, %struct.rusage* %6, i32 0, i32 2
%59 = load i32, i32* %58
%60 = load %struct.vtimes*, %struct.vtimes** %4
%61 = getelementptr inbounds %struct.vtimes, %struct.vtimes* %60, i32 0, i32 4
store i32 %59, i32* %61
%62 = getelementptr inbounds %struct.rusage, %struct.rusage* %6, i32 0, i32 1
%63 = load i32, i32* %62
%64 = load %struct.vtimes*, %struct.vtimes** %4
%65 = getelementptr inbounds %struct.vtimes, %struct.vtimes* %64, i32 0, i32 3
store i32 %63, i32* %65
%66 = getelementptr inbounds %struct.rusage, %struct.rusage* %6, i32 0, i32 0
%67 = load i32, i32* %66
%68 = load %struct.vtimes*, %struct.vtimes** %4
%69 = getelementptr inbounds %struct.vtimes, %struct.vtimes* %68, i32 0, i32 2
store i32 %67, i32* %69
br label %70
70: ; preds = %14, %2
store i32 0, i32* %3
br label %71
71: ; preds = %70, %13
%72 = load i32, i32* %3
ret i32 %72
}

LLVM IR (-O2):
%struct.vtimes = type { i32, i32, i32, i32, i32, i32, i32, i64 }
%struct.rusage = type { i32, i32, i32, i32, i32, i64, i64, %struct.TYPE_4__, %struct.TYPE_3__ }
%struct.TYPE_4__ = type { i32, i32 }
%struct.TYPE_3__ = type { i32, i32 }
@VTIMES_UNITS_PER_SECOND = global i32 0
define i32 @vtimes_one(%struct.vtimes* writeonly %0, i32 %1) {
%3 = alloca %struct.rusage
%4 = icmp eq %struct.vtimes* %0, null
br i1 %4, label %44, label %5
5: ; preds = %2
%6 = bitcast %struct.rusage* %3 to i8*
%7 = call i64 @__getrusage(i32 %1, %struct.rusage* %3)
%8 = icmp slt i64 %7, 0
br i1 %8, label %43, label %9
9: ; preds = %5
%10 = getelementptr inbounds %struct.rusage, %struct.rusage* %3, i64 0, i32 8, i32 0
%11 = load i32, i32* %10
%12 = load i32, i32* @VTIMES_UNITS_PER_SECOND
%13 = mul nsw i32 %12, %11
%14 = getelementptr inbounds %struct.rusage, %struct.rusage* %3, i64 0, i32 8, i32 1
%15 = load i32, i32* %14
%16 = mul nsw i32 %15, %12
%17 = sdiv i32 %16, 1000000
%18 = add nsw i32 %17, %13
%19 = getelementptr inbounds %struct.vtimes, %struct.vtimes* %0, i64 0, i32 0
store i32 %18, i32* %19
%20 = getelementptr inbounds %struct.rusage, %struct.rusage* %3, i64 0, i32 7, i32 0
%21 = load i32, i32* %20
%22 = load i32, i32* @VTIMES_UNITS_PER_SECOND
%23 = mul nsw i32 %22, %21
%24 = getelementptr inbounds %struct.rusage, %struct.rusage* %3, i64 0, i32 7, i32 1
%25 = load i32, i32* %24
%26 = mul nsw i32 %25, %22
%27 = sdiv i32 %26, 1000000
%28 = add nsw i32 %27, %23
%29 = getelementptr inbounds %struct.vtimes, %struct.vtimes* %0, i64 0, i32 1
store i32 %28, i32* %29
%30 = getelementptr inbounds %struct.rusage, %struct.rusage* %3, i64 0, i32 6
%31 = load i64, i64* %30
%32 = getelementptr inbounds %struct.rusage, %struct.rusage* %3, i64 0, i32 5
%33 = load i64, i64* %32
%34 = add nsw i64 %33, %31
%35 = getelementptr inbounds %struct.vtimes, %struct.vtimes* %0, i64 0, i32 7
store i64 %34, i64* %35
%36 = getelementptr inbounds %struct.rusage, %struct.rusage* %3, i64 0, i32 4
%37 = load i32, i32* %36
%38 = getelementptr inbounds %struct.vtimes, %struct.vtimes* %0, i64 0, i32 6
store i32 %37, i32* %38
%39 = bitcast %struct.rusage* %3 to <4 x i32>*
%40 = load <4 x i32>, <4 x i32>* %39
%41 = getelementptr inbounds %struct.vtimes, %struct.vtimes* %0, i64 0, i32 2
%42 = bitcast i32* %41 to <4 x i32>*
store <4 x i32> %40, <4 x i32>* %42
br label %44
43: ; preds = %5
br label %44
44: ; preds = %2, %9, %43
%45 = phi i32 [ -1, %43 ], [ 0, %9 ], [ 0, %2 ]
ret i32 %45
}