#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 {
  int dummy;
};

/* Variables and functions */
int timeval_delta(struct timeval const *, struct timeval const *,
                  struct timeval *);
int timeval_delta2(const struct timeval *t1, const struct timeval *t2,
                   struct timeval *delta) {
  int rc = timeval_delta(t1, t2, delta);
  if (rc)
    rc = timeval_delta(t2, t1, delta);
  return rc;
}


x86 assembly (clang, -O0):
<timeval_delta2>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
call   1030 <timeval_delta@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
je     1156 <timeval_delta2+0x46>
mov    -0x10(%rbp),%rdi
mov    -0x8(%rbp),%rsi
mov    -0x18(%rbp),%rdx
call   1030 <timeval_delta@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<timeval_delta2>:
push   %r15
push   %r14
push   %rbx
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%rbx
call   1030 <timeval_delta@plt>
test   %eax,%eax
je     113a <timeval_delta2+0x2a>
mov    %r15,%rdi
mov    %rbx,%rsi
mov    %r14,%rdx
pop    %rbx
pop    %r14
pop    %r15
jmp    1030 <timeval_delta@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.timeval = type { i32 }
define i32 @timeval_delta2(%struct.timeval* %0, %struct.timeval* %1, %struct.timeval* %2) {
%4 = alloca %struct.timeval*
%5 = alloca %struct.timeval*
%6 = alloca %struct.timeval*
%7 = alloca i32
store %struct.timeval* %0, %struct.timeval** %4
store %struct.timeval* %1, %struct.timeval** %5
store %struct.timeval* %2, %struct.timeval** %6
%8 = load %struct.timeval*, %struct.timeval** %4
%9 = load %struct.timeval*, %struct.timeval** %5
%10 = load %struct.timeval*, %struct.timeval** %6
%11 = call i32 @timeval_delta(%struct.timeval* %8, %struct.timeval* %9, %struct.timeval* %10)
store i32 %11, i32* %7
%12 = load i32, i32* %7
%13 = icmp ne i32 %12, 0
br i1 %13, label %14, label %19
14: ; preds = %3
%15 = load %struct.timeval*, %struct.timeval** %5
%16 = load %struct.timeval*, %struct.timeval** %4
%17 = load %struct.timeval*, %struct.timeval** %6
%18 = call i32 @timeval_delta(%struct.timeval* %15, %struct.timeval* %16, %struct.timeval* %17)
store i32 %18, i32* %7
br label %19
19: ; preds = %14, %3
%20 = load i32, i32* %7
ret i32 %20
}

LLVM IR (-O2):
%struct.timeval = type { i32 }
define i32 @timeval_delta2(%struct.timeval* %0, %struct.timeval* %1, %struct.timeval* %2) {
%4 = tail call i32 @timeval_delta(%struct.timeval* %0, %struct.timeval* %1, %struct.timeval* %2)
%5 = icmp eq i32 %4, 0
br i1 %5, label %8, label %6
6: ; preds = %3
%7 = tail call i32 @timeval_delta(%struct.timeval* %1, %struct.timeval* %0, %struct.timeval* %2)
br label %8
8: ; preds = %6, %3
%9 = phi i32 [ %7, %6 ], [ 0, %3 ]
ret i32 %9
}