#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;
  scalar_t__ tv_usec;
};
typedef int /*<<< orphan*/ SSL;

/* Variables and functions */
int /*<<< orphan*/ *dtls1_get_timeout(int /*<<< orphan*/ *, struct timeval *);
int dtls1_is_timer_expired(SSL *s) {
  struct timeval timeleft;
  if (dtls1_get_timeout(s, &timeleft) == NULL) {
    return 0;
  }
  if (timeleft.tv_sec > 0 || timeleft.tv_usec > 0) {
    return 0;
  }
  return 1;
}


x86 assembly (clang, -O0):
<dtls1_is_timer_expired>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x20(%rbp),%rsi
call   1030 <dtls1_get_timeout@plt>
cmp    $0x0,%rax
jne    113f <dtls1_is_timer_expired+0x2f>
movl   $0x0,-0x4(%rbp)
jmp    1168 <dtls1_is_timer_expired+0x58>
cmpq   $0x0,-0x20(%rbp)
jg     1155 <dtls1_is_timer_expired+0x45>
cmpq   $0x0,-0x18(%rbp)
jle    1161 <dtls1_is_timer_expired+0x51>
movl   $0x0,-0x4(%rbp)
jmp    1168 <dtls1_is_timer_expired+0x58>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dtls1_is_timer_expired>:
sub    $0x18,%rsp
lea    0x8(%rsp),%rsi
call   1030 <dtls1_get_timeout@plt>
test   %rax,%rax
je     113f <dtls1_is_timer_expired+0x2f>
cmpq   $0x0,0x8(%rsp)
setle  %al
cmpq   $0x0,0x10(%rsp)
setle  %cl
and    %al,%cl
movzbl %cl,%eax
add    $0x18,%rsp
ret
xor    %eax,%eax
add    $0x18,%rsp
ret

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

LLVM IR (-O2):
%struct.timeval = type { i64, i64 }
define i32 @dtls1_is_timer_expired(i32* %0) {
%2 = alloca %struct.timeval
%3 = bitcast %struct.timeval* %2 to i8*
%4 = call i32* @dtls1_get_timeout(i32* %0, %struct.timeval* %2)
%5 = icmp eq i32* %4, null
br i1 %5, label %15, label %6
6: ; preds = %1
%7 = getelementptr inbounds %struct.timeval, %struct.timeval* %2, i64 0, i32 0
%8 = load i64, i64* %7
%9 = icmp slt i64 %8, 1
%10 = getelementptr inbounds %struct.timeval, %struct.timeval* %2, i64 0, i32 1
%11 = load i64, i64* %10
%12 = icmp slt i64 %11, 1
%13 = select i1 %9, i1 %12, i1 false
%14 = zext i1 %13 to i32
br label %15
15: ; preds = %6, %1
%16 = phi i32 [ 0, %1 ], [ %14, %6 ]
ret i32 %16
}