#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 {
  scalar_t__ tv_sec;
};

/* Variables and functions */
scalar_t__ timeval_compare(struct timeval *, struct timeval const *);
void timeval_min(struct timeval *d, const struct timeval *s) {
  if (s->tv_sec == 0)
    return;
  if (d->tv_sec == 0 || timeval_compare(d, s) > 0) {
    *d = *s;
  }
}


x86 assembly (clang, -O0):
<timeval_min>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
cmpq   $0x0,(%rax)
jne    1133 <timeval_min+0x23>
jmp    1166 <timeval_min+0x56>
mov    -0x8(%rbp),%rax
cmpq   $0x0,(%rax)
je     1158 <timeval_min+0x48>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <timeval_compare@plt>
cmp    $0x0,%rax
jle    1166 <timeval_min+0x56>
mov    -0x8(%rbp),%rax
mov    -0x10(%rbp),%rcx
mov    (%rcx),%rcx
mov    %rcx,(%rax)
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<timeval_min>:
push   %r14
push   %rbx
push   %rax
mov    (%rsi),%rax
test   %rax,%rax
je     113b <timeval_min+0x2b>
mov    %rdi,%r14
cmpq   $0x0,(%rdi)
je     1138 <timeval_min+0x28>
mov    %rsi,%rbx
mov    %r14,%rdi
call   1030 <timeval_compare@plt>
test   %rax,%rax
jle    113b <timeval_min+0x2b>
mov    (%rbx),%rax
mov    %rax,(%r14)
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

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

LLVM IR (-O2):
%struct.timeval = type { i64 }
define void @timeval_min(%struct.timeval* %0, %struct.timeval* %1) {
%3 = getelementptr inbounds %struct.timeval, %struct.timeval* %1, i64 0, i32 0
%4 = load i64, i64* %3
%5 = icmp eq i64 %4, 0
br i1 %5, label %17, label %6
6: ; preds = %2
%7 = getelementptr inbounds %struct.timeval, %struct.timeval* %0, i64 0, i32 0
%8 = load i64, i64* %7
%9 = icmp eq i64 %8, 0
br i1 %9, label %15, label %10
10: ; preds = %6
%11 = tail call i64 @timeval_compare(%struct.timeval* %0, %struct.timeval* %1)
%12 = icmp sgt i64 %11, 0
br i1 %12, label %13, label %17
13: ; preds = %10
%14 = load i64, i64* %3
br label %15
15: ; preds = %13, %6
%16 = phi i64 [ %14, %13 ], [ %4, %6 ]
store i64 %16, i64* %7
br label %17
17: ; preds = %2, %15, %10
ret void
}