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

/* Variables and functions */
int /*<<< orphan*/ BIO_NOCLOSE;
int /*<<< orphan*/ *BIO_new(int /*<<< orphan*/);
int /*<<< orphan*/ BIO_s_socket();
int /*<<< orphan*/ BIO_set_fd(int /*<<< orphan*/ *, int, int /*<<< orphan*/);
int /*<<< orphan*/ ERR_R_BUF_LIB;
int /*<<< orphan*/ SSL_error_internal(int /*<<< orphan*/ *, int /*<<< orphan*/,
                                      char *, int);
int /*<<< orphan*/ SSL_set_bio(int /*<<< orphan*/ *, int /*<<< orphan*/ *,
                               int /*<<< orphan*/ *);
int SSL_set_fd(SSL *s, int fd) {
  int ret = 0;
  BIO *bio = NULL;
  bio = BIO_new(BIO_s_socket());
  if (bio == NULL) {
    SSL_error_internal(
        s, ERR_R_BUF_LIB,
        "/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.7.2/ssl/ssl_lib.c",
        650);
    goto err;
  }
  BIO_set_fd(bio, fd, BIO_NOCLOSE);
  SSL_set_bio(s, bio, bio);
  ret = 1;
err:
  return (ret);
}


x86 assembly (clang, -O0):
<SSL_set_fd>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
mov    $0x0,%al
call   1040 <BIO_s_socket@plt>
mov    %eax,%edi
call   1050 <BIO_new@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    11ae <SSL_set_fd+0x5e>
mov    -0x8(%rbp),%rdi
mov    0x2e62(%rip),%rax
mov    (%rax),%esi
lea    0xe61(%rip),%rdx
mov    $0x28a,%ecx
call   1030 <SSL_error_internal@plt>
jmp    11db <SSL_set_fd+0x8b>
mov    -0x18(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    0x2e24(%rip),%rax
mov    (%rax),%edx
call   1060 <BIO_set_fd@plt>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x18(%rbp),%rdx
call   1070 <SSL_set_bio@plt>
movl   $0x1,-0x10(%rbp)
mov    -0x10(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<SSL_set_fd>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %esi,%r14d
mov    %rdi,%r15
xor    %ebp,%ebp
xor    %eax,%eax
call   1040 <BIO_s_socket@plt>
mov    %eax,%edi
call   1050 <BIO_new@plt>
test   %rax,%rax
je     119e <SSL_set_fd+0x4e>
mov    %rax,%rbx
mov    0x2e64(%rip),%rax
mov    (%rax),%edx
mov    %rbx,%rdi
mov    %r14d,%esi
call   1060 <BIO_set_fd@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
mov    %rbx,%rdx
call   1070 <SSL_set_bio@plt>
mov    $0x1,%ebp
jmp    11bb <SSL_set_fd+0x6b>
mov    0x2e53(%rip),%rax
mov    (%rax),%esi
lea    0xe52(%rip),%rdx
mov    %r15,%rdi
mov    $0x28a,%ecx
call   1030 <SSL_error_internal@plt>
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@ERR_R_BUF_LIB = global i32 0
@.str = [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.7.2/ssl/ssl_lib.c\00"
@BIO_NOCLOSE = global i32 0
define i32 @SSL_set_fd(i32* %0, i32 %1) {
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32*
store i32* %0, i32** %3
store i32 %1, i32* %4
store i32 0, i32* %5
store i32* null, i32** %6
%7 = call i32 (...) @BIO_s_socket()
%8 = call i32* @BIO_new(i32 %7)
store i32* %8, i32** %6
%9 = load i32*, i32** %6
%10 = icmp eq i32* %9, null
br i1 %10, label %11, label %15
11: ; preds = %2
%12 = load i32*, i32** %3
%13 = load i32, i32* @ERR_R_BUF_LIB
%14 = call i32 @SSL_error_internal(i32* %12, i32 %13, i8* getelementptr inbounds ([171 x i8], [171 x i8]* @.str, i64 0, i64 0), i32 650)
br label %24
15: ; preds = %2
%16 = load i32*, i32** %6
%17 = load i32, i32* %4
%18 = load i32, i32* @BIO_NOCLOSE
%19 = call i32 @BIO_set_fd(i32* %16, i32 %17, i32 %18)
%20 = load i32*, i32** %3
%21 = load i32*, i32** %6
%22 = load i32*, i32** %6
%23 = call i32 @SSL_set_bio(i32* %20, i32* %21, i32* %22)
store i32 1, i32* %5
br label %24
24: ; preds = %15, %11
%25 = load i32, i32* %5
ret i32 %25
}

LLVM IR (-O2):
@ERR_R_BUF_LIB = global i32 0
@.str = [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.7.2/ssl/ssl_lib.c\00"
@BIO_NOCLOSE = global i32 0
define i32 @SSL_set_fd(i32* %0, i32 %1) {
%3 = tail call i32 (...) @BIO_s_socket()
%4 = tail call i32* @BIO_new(i32 %3)
%5 = icmp eq i32* %4, null
br i1 %5, label %6, label %9
6: ; preds = %2
%7 = load i32, i32* @ERR_R_BUF_LIB
%8 = tail call i32 @SSL_error_internal(i32* %0, i32 %7, i8* getelementptr inbounds ([171 x i8], [171 x i8]* @.str, i64 0, i64 0), i32 650)
br label %13
9: ; preds = %2
%10 = load i32, i32* @BIO_NOCLOSE
%11 = tail call i32 @BIO_set_fd(i32* %4, i32 %1, i32 %10)
%12 = tail call i32 @SSL_set_bio(i32* %0, i32* %4, i32* %4)
br label %13
13: ; preds = %9, %6
%14 = phi i32 [ 0, %6 ], [ 1, %9 ]
ret i32 %14
}