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

/* Variables and functions */
int /*<<< orphan*/ BIO_FLAGS_READ;
int /*<<< orphan*/ BIO_set_flags(int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ SSL_get_rbio(int /*<<< orphan*/ *);
int /*<<< orphan*/ SSL_in_init(int /*<<< orphan*/ *);
int dtls1_handle_timeout(int /*<<< orphan*/ *);
int /*<<< orphan*/ dtls1_is_timer_expired(int /*<<< orphan*/ *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, int);
int /*<<< orphan*/ stderr;
int dtls1_read_failed(SSL *s, int code) {
  if (code > 0) {
    fprintf(stderr, "invalid state reached %s:%d",
            "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
            "2022-01-22/02-19-57/repos/GaloisInc/hacrypto/refs/heads/master/"
            "src/C/libressl/libressl-2.1.6/ssl/d1_both.c",
            1072);
    return 1;
  }
  if (!dtls1_is_timer_expired(s)) {
    return code;
  }
  if (!SSL_in_init(s)) {
    BIO_set_flags(SSL_get_rbio(s), BIO_FLAGS_READ);
    return code;
  }
  return dtls1_handle_timeout(s);
}


x86 assembly (clang, -O0):
<dtls1_read_failed>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jle    11a6 <dtls1_read_failed+0x46>
mov    0x2e60(%rip),%rax
mov    (%rax),%edi
lea    0xe77(%rip),%rsi
lea    0xe8c(%rip),%rdx
mov    $0x430,%ecx
call   1060 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1205 <dtls1_read_failed+0xa5>
mov    -0x10(%rbp),%rdi
call   1030 <dtls1_is_timer_expired@plt>
cmp    $0x0,%eax
jne    11c3 <dtls1_read_failed+0x63>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1205 <dtls1_read_failed+0xa5>
mov    -0x10(%rbp),%rdi
call   1080 <SSL_in_init@plt>
cmp    $0x0,%eax
jne    11f9 <dtls1_read_failed+0x99>
mov    -0x10(%rbp),%rdi
call   1070 <SSL_get_rbio@plt>
mov    %eax,%edi
mov    0x2de9(%rip),%rax
mov    (%rax),%esi
call   1050 <BIO_set_flags@plt>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1205 <dtls1_read_failed+0xa5>
mov    -0x10(%rbp),%rdi
call   1040 <dtls1_handle_timeout@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dtls1_read_failed>:
push   %r14
push   %rbx
push   %rax
test   %esi,%esi
jle    1198 <dtls1_read_failed+0x38>
mov    0x2e71(%rip),%rax
mov    (%rax),%edi
lea    0xe88(%rip),%rsi
lea    0xe9d(%rip),%rdx
mov    $0x430,%ecx
call   1060 <fprintf@plt>
mov    $0x1,%ebx
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
mov    %esi,%ebx
mov    %rdi,%r14
call   1030 <dtls1_is_timer_expired@plt>
test   %eax,%eax
je     118e <dtls1_read_failed+0x2e>
mov    %r14,%rdi
call   1080 <SSL_in_init@plt>
mov    %r14,%rdi
test   %eax,%eax
je     11c1 <dtls1_read_failed+0x61>
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1040 <dtls1_handle_timeout@plt>
call   1070 <SSL_get_rbio@plt>
mov    0x2e03(%rip),%rcx
mov    (%rcx),%esi
mov    %eax,%edi
call   1050 <BIO_set_flags@plt>
jmp    118e <dtls1_read_failed+0x2e>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [28 x i8] c"invalid state reached %s:%d\00"
@.str.1 = [171 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/GaloisInc/hacrypto/refs/heads/master/src/C/libressl/libressl-2.1.6/ssl/d1_both.c\00"
@BIO_FLAGS_READ = global i32 0
define i32 @dtls1_read_failed(i32* %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32*
%5 = alloca i32
store i32* %0, i32** %4
store i32 %1, i32* %5
%6 = load i32, i32* %5
%7 = icmp sgt i32 %6, 0
br i1 %7, label %8, label %11
8: ; preds = %2
%9 = load i32, i32* @stderr
%10 = call i32 @fprintf(i32 %9, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([171 x i8], [171 x i8]* @.str.1, i64 0, i64 0), i32 1072)
store i32 1, i32* %3
br label %30
11: ; preds = %2
%12 = load i32*, i32** %4
%13 = call i32 @dtls1_is_timer_expired(i32* %12)
%14 = icmp ne i32 %13, 0
br i1 %14, label %17, label %15
15: ; preds = %11
%16 = load i32, i32* %5
store i32 %16, i32* %3
br label %30
17: ; preds = %11
%18 = load i32*, i32** %4
%19 = call i32 @SSL_in_init(i32* %18)
%20 = icmp ne i32 %19, 0
br i1 %20, label %27, label %21
21: ; preds = %17
%22 = load i32*, i32** %4
%23 = call i32 @SSL_get_rbio(i32* %22)
%24 = load i32, i32* @BIO_FLAGS_READ
%25 = call i32 @BIO_set_flags(i32 %23, i32 %24)
%26 = load i32, i32* %5
store i32 %26, i32* %3
br label %30
27: ; preds = %17
%28 = load i32*, i32** %4
%29 = call i32 @dtls1_handle_timeout(i32* %28)
store i32 %29, i32* %3
br label %30
30: ; preds = %27, %21, %15, %8
%31 = load i32, i32* %3
ret i32 %31
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [28 x i8] c"invalid state reached %s:%d\00"
@.str.1 = [171 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/GaloisInc/hacrypto/refs/heads/master/src/C/libressl/libressl-2.1.6/ssl/d1_both.c\00"
@BIO_FLAGS_READ = global i32 0
define i32 @dtls1_read_failed(i32* %0, i32 %1) {
%3 = icmp sgt i32 %1, 0
br i1 %3, label %4, label %7
4: ; preds = %2
%5 = load i32, i32* @stderr
%6 = tail call i32 @fprintf(i32 %5, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([171 x i8], [171 x i8]* @.str.1, i64 0, i64 0), i32 1072)
br label %19
7: ; preds = %2
%8 = tail call i32 @dtls1_is_timer_expired(i32* %0)
%9 = icmp eq i32 %8, 0
br i1 %9, label %19, label %10
10: ; preds = %7
%11 = tail call i32 @SSL_in_init(i32* %0)
%12 = icmp eq i32 %11, 0
br i1 %12, label %13, label %17
13: ; preds = %10
%14 = tail call i32 @SSL_get_rbio(i32* %0)
%15 = load i32, i32* @BIO_FLAGS_READ
%16 = tail call i32 @BIO_set_flags(i32 %14, i32 %15)
br label %19
17: ; preds = %10
%18 = tail call i32 @dtls1_handle_timeout(i32* %0)
br label %19
19: ; preds = %7, %17, %13, %4
%20 = phi i32 [ 1, %4 ], [ %18, %17 ], [ %1, %13 ], [ %1, %7 ]
ret i32 %20
}