#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;
};
typedef int clock_t;

/* Variables and functions */
int times(struct tms *);
void grt_get_times(int *wall, int *user, int *sys) {
  clock_t res;
  struct tms buf;
  res = times(&buf);
  if (res == (clock_t)-1) {
    *wall = 0;
    *user = 0;
    *sys = 0;
  } else {
    *wall = res;
    *user = buf.tms_utime;
    *sys = buf.tms_stime;
  }
}


x86 assembly (clang, -O0):
<grt_get_times>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
lea    -0x28(%rbp),%rdi
call   1030 <times@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0xffffffff,-0x1c(%rbp)
jne    115d <grt_get_times+0x4d>
mov    -0x8(%rbp),%rax
movl   $0x0,(%rax)
mov    -0x10(%rbp),%rax
movl   $0x0,(%rax)
mov    -0x18(%rbp),%rax
movl   $0x0,(%rax)
jmp    1178 <grt_get_times+0x68>
mov    -0x1c(%rbp),%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x28(%rbp),%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x24(%rbp),%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<grt_get_times>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%rbx
lea    0x8(%rsp),%rdi
call   1030 <times@plt>
cmp    $0xffffffff,%eax
je     1140 <grt_get_times+0x30>
mov    %eax,(%rbx)
mov    0x8(%rsp),%eax
mov    %eax,(%r15)
mov    0xc(%rsp),%eax
jmp    114f <grt_get_times+0x3f>
movl   $0x0,(%rbx)
movl   $0x0,(%r15)
xor    %eax,%eax
mov    %eax,(%r14)
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.tms = type { i32, i32 }
define void @grt_get_times(i32* %0, i32* %1, i32* %2) {
%4 = alloca i32*
%5 = alloca i32*
%6 = alloca i32*
%7 = alloca i32
%8 = alloca %struct.tms
store i32* %0, i32** %4
store i32* %1, i32** %5
store i32* %2, i32** %6
%9 = call i32 @times(%struct.tms* %8)
store i32 %9, i32* %7
%10 = load i32, i32* %7
%11 = icmp eq i32 %10, -1
br i1 %11, label %12, label %16
12: ; preds = %3
%13 = load i32*, i32** %4
store i32 0, i32* %13
%14 = load i32*, i32** %5
store i32 0, i32* %14
%15 = load i32*, i32** %6
store i32 0, i32* %15
br label %25
16: ; preds = %3
%17 = load i32, i32* %7
%18 = load i32*, i32** %4
store i32 %17, i32* %18
%19 = getelementptr inbounds %struct.tms, %struct.tms* %8, i32 0, i32 0
%20 = load i32, i32* %19
%21 = load i32*, i32** %5
store i32 %20, i32* %21
%22 = getelementptr inbounds %struct.tms, %struct.tms* %8, i32 0, i32 1
%23 = load i32, i32* %22
%24 = load i32*, i32** %6
store i32 %23, i32* %24
br label %25
25: ; preds = %16, %12
ret void
}

LLVM IR (-O2):
%struct.tms = type { i32, i32 }
define void @grt_get_times(i32* nocapture writeonly %0, i32* nocapture writeonly %1, i32* nocapture writeonly %2) {
%4 = alloca %struct.tms
%5 = bitcast %struct.tms* %4 to i8*
%6 = call i32 @times(%struct.tms* %4)
%7 = icmp eq i32 %6, -1
br i1 %7, label %8, label %9
8: ; preds = %3
store i32 0, i32* %0
store i32 0, i32* %1
br label %14
9: ; preds = %3
store i32 %6, i32* %0
%10 = getelementptr inbounds %struct.tms, %struct.tms* %4, i64 0, i32 0
%11 = load i32, i32* %10
store i32 %11, i32* %1
%12 = getelementptr inbounds %struct.tms, %struct.tms* %4, i64 0, i32 1
%13 = load i32, i32* %12
br label %14
14: ; preds = %9, %8
%15 = phi i32 [ %13, %9 ], [ 0, %8 ]
store i32 %15, i32* %2
ret void
}