#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 */
typedef struct TYPE_11__ TYPE_1__;

/* Type definitions */
struct TYPE_11__ {
  int /*<<< orphan*/ length;
  int /*<<< orphan*/ data;
};
typedef TYPE_1__ BUF_MEM;
typedef TYPE_1__ BIO;

/* Variables and functions */
int /*<<< orphan*/ BIO_NOCLOSE;
int /*<<< orphan*/ BIO_free(TYPE_1__ *);
int /*<<< orphan*/ BIO_get_mem_ptr(TYPE_1__ *, TYPE_1__ **);
TYPE_1__ *BIO_new(int /*<<< orphan*/);
int /*<<< orphan*/ BIO_puts(TYPE_1__ *, char *);
int /*<<< orphan*/ BIO_s_mem();
int /*<<< orphan*/ BIO_set_close(TYPE_1__ *, int /*<<< orphan*/);
int /*<<< orphan*/ BUF_MEM_free(TYPE_1__ *);
int /*<<< orphan*/ test_int_eq(char *, int, char *, char *, int /*<<< orphan*/,
                               int);
int /*<<< orphan*/ test_int_gt(char *, int, char *, char *, int /*<<< orphan*/,
                               int /*<<< orphan*/);
int /*<<< orphan*/ test_mem_eq(char *, int, char *, char *, int /*<<< orphan*/,
                               int /*<<< orphan*/, char *, int);
int /*<<< orphan*/ test_ptr(char *, int, char *, TYPE_1__ *);
int test_bio_get_mem(void) {
  int ok = 0;
  BIO *bio = NULL;
  BUF_MEM *bufmem = NULL;
  bio = BIO_new(BIO_s_mem());
  if (!test_ptr("/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
                "outputs/2022-01-22/02-19-57/repos/jens-maus/amissl/refs/heads/"
                "master/openssl/test/bio_memleak_test.c",
                52, "bio", bio))
    goto finish;
  if (!test_int_eq("/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
                   "outputs/2022-01-22/02-19-57/repos/jens-maus/amissl/refs/"
                   "heads/master/openssl/test/bio_memleak_test.c",
                   54, "BIO_puts(bio, \"Hello World\\n\")", "12",
                   BIO_puts(bio, "Hello World\n"), 12))
    goto finish;
  BIO_get_mem_ptr(bio, &bufmem);
  if (!test_ptr("/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
                "outputs/2022-01-22/02-19-57/repos/jens-maus/amissl/refs/heads/"
                "master/openssl/test/bio_memleak_test.c",
                57, "bufmem", bufmem))
    goto finish;
  if (!test_int_gt("/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
                   "outputs/2022-01-22/02-19-57/repos/jens-maus/amissl/refs/"
                   "heads/master/openssl/test/bio_memleak_test.c",
                   59, "BIO_set_close(bio, BIO_NOCLOSE)", "0",
                   BIO_set_close(bio, BIO_NOCLOSE), 0))
    goto finish;
  BIO_free(bio);
  bio = NULL;
  if (!test_mem_eq("/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
                   "outputs/2022-01-22/02-19-57/repos/jens-maus/amissl/refs/"
                   "heads/master/openssl/test/bio_memleak_test.c",
                   63, "bufmem->data", "\"Hello World\\n\"", bufmem->data,
                   bufmem->length, "Hello World\n", 12))
    goto finish;
  ok = 1;
finish:
  BIO_free(bio);
  BUF_MEM_free(bufmem);
  return ok;
}


x86 assembly (clang, -O0):
<test_bio_get_mem>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
movq   $0x0,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
mov    $0x0,%al
call   10d0 <BIO_s_mem@plt>
mov    %eax,%edi
call   1080 <BIO_new@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rcx
lea    0xe14(%rip),%rdi
mov    $0x34,%esi
lea    0xea5(%rip),%rdx
call   1050 <test_ptr@plt>
cmp    $0x0,%eax
jne    120b <test_bio_get_mem+0x5b>
jmp    1334 <test_bio_get_mem+0x184>
mov    -0x10(%rbp),%rdi
lea    0xead(%rip),%rsi
call   10b0 <BIO_puts@plt>
mov    %eax,%r8d
lea    0xddb(%rip),%rdi
mov    $0x36,%esi
lea    0xe70(%rip),%rdx
lea    0xe88(%rip),%rcx
mov    $0xc,%r9d
call   1060 <test_int_eq@plt>
cmp    $0x0,%eax
jne    1251 <test_bio_get_mem+0xa1>
jmp    1334 <test_bio_get_mem+0x184>
mov    -0x10(%rbp),%rdi
lea    -0x18(%rbp),%rsi
call   10c0 <BIO_get_mem_ptr@plt>
mov    -0x18(%rbp),%rcx
lea    0xd97(%rip),%rdi
mov    $0x39,%esi
lea    0xe5b(%rip),%rdx
call   1050 <test_ptr@plt>
cmp    $0x0,%eax
jne    1288 <test_bio_get_mem+0xd8>
jmp    1334 <test_bio_get_mem+0x184>
mov    -0x10(%rbp),%rdi
mov    0x2d55(%rip),%rax
mov    (%rax),%esi
call   1030 <BIO_set_close@plt>
mov    %eax,%r8d
lea    0xd5c(%rip),%rdi
mov    $0x3b,%esi
lea    0xe27(%rip),%rdx
lea    0xe40(%rip),%rcx
xor    %r9d,%r9d
call   1040 <test_int_gt@plt>
cmp    $0x0,%eax
jne    12cd <test_bio_get_mem+0x11d>
jmp    1334 <test_bio_get_mem+0x184>
mov    -0x10(%rbp),%rdi
call   1090 <BIO_free@plt>
movq   $0x0,-0x10(%rbp)
mov    -0x18(%rbp),%rax
mov    0x4(%rax),%r8d
mov    -0x18(%rbp),%rax
mov    (%rax),%r9d
lea    0xd0c(%rip),%rdi
mov    $0x3f,%esi
lea    0xdf9(%rip),%rdx
lea    0xdff(%rip),%rcx
lea    0xdb5(%rip),%rax
mov    %rax,(%rsp)
movl   $0xc,0x8(%rsp)
call   10a0 <test_mem_eq@plt>
cmp    $0x0,%eax
jne    132d <test_bio_get_mem+0x17d>
jmp    1334 <test_bio_get_mem+0x184>
movl   $0x1,-0x4(%rbp)
mov    -0x10(%rbp),%rdi
call   1090 <BIO_free@plt>
mov    -0x18(%rbp),%rdi
call   1070 <BUF_MEM_free@plt>
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_bio_get_mem>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
movq   $0x0,0x8(%rsp)
xor    %ebp,%ebp
xor    %eax,%eax
call   10d0 <BIO_s_mem@plt>
mov    %eax,%edi
call   1080 <BIO_new@plt>
mov    %rax,%rbx
lea    0xe25(%rip),%rdi
lea    0xebb(%rip),%rdx
mov    $0x34,%esi
mov    %rax,%rcx
call   1050 <test_ptr@plt>
test   %eax,%eax
je     12ec <test_bio_get_mem+0x13c>
lea    0xec5(%rip),%r14
mov    %rbx,%rdi
mov    %r14,%rsi
call   10b0 <BIO_puts@plt>
lea    0xdf0(%rip),%rdi
lea    0xe8a(%rip),%rdx
lea    0xea2(%rip),%rcx
mov    $0x36,%esi
mov    %eax,%r8d
mov    $0xc,%r9d
call   1060 <test_int_eq@plt>
test   %eax,%eax
je     12ec <test_bio_get_mem+0x13c>
lea    0x8(%rsp),%rsi
mov    %rbx,%rdi
call   10c0 <BIO_get_mem_ptr@plt>
mov    0x8(%rsp),%rcx
lea    0xdae(%rip),%rdi
lea    0xe77(%rip),%rdx
mov    $0x39,%esi
call   1050 <test_ptr@plt>
test   %eax,%eax
je     12ec <test_bio_get_mem+0x13c>
mov    0x2d76(%rip),%rax
mov    (%rax),%esi
mov    %rbx,%rdi
call   1030 <BIO_set_close@plt>
lea    0xd7d(%rip),%rdi
lea    0xe4d(%rip),%rdx
lea    0xe66(%rip),%rcx
xor    %ebp,%ebp
mov    $0x3b,%esi
mov    %eax,%r8d
xor    %r9d,%r9d
call   1040 <test_int_gt@plt>
test   %eax,%eax
je     12ec <test_bio_get_mem+0x13c>
mov    %rbx,%rdi
call   1090 <BIO_free@plt>
mov    0x8(%rsp),%rax
mov    (%rax),%r9d
mov    0x4(%rax),%r8d
lea    0xd3e(%rip),%rdi
lea    0xe30(%rip),%rdx
lea    0xe36(%rip),%rcx
mov    $0x3f,%esi
push   $0xc
push   %r14
call   10a0 <test_mem_eq@plt>
add    $0x10,%rsp
xor    %ebp,%ebp
test   %eax,%eax
setne  %bpl
xor    %ebx,%ebx
mov    %rbx,%rdi
call   1090 <BIO_free@plt>
mov    0x8(%rsp),%rdi
call   1070 <BUF_MEM_free@plt>
mov    %ebp,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
%struct.TYPE_11__ = type { i32, i32 }
@.str = [157 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/jens-maus/amissl/refs/heads/master/openssl/test/bio_memleak_test.c\00"
@.str.1 = [4 x i8] c"bio\00"
@.str.2 = [31 x i8] c"BIO_puts(bio, \22Hello World\\n\22)\00"
@.str.3 = [3 x i8] c"12\00"
@.str.4 = [13 x i8] c"Hello World\0A\00"
@.str.5 = [7 x i8] c"bufmem\00"
@.str.6 = [32 x i8] c"BIO_set_close(bio, BIO_NOCLOSE)\00"
@.str.7 = [2 x i8] c"0\00"
@BIO_NOCLOSE = global i32 0
@.str.8 = [13 x i8] c"bufmem->data\00"
@.str.9 = [16 x i8] c"\22Hello World\\n\22\00"
define i32 @test_bio_get_mem() {
%1 = alloca i32
%2 = alloca %struct.TYPE_11__*
%3 = alloca %struct.TYPE_11__*
store i32 0, i32* %1
store %struct.TYPE_11__* null, %struct.TYPE_11__** %2
store %struct.TYPE_11__* null, %struct.TYPE_11__** %3
%4 = call i32 (...) @BIO_s_mem()
%5 = call %struct.TYPE_11__* @BIO_new(i32 %4)
store %struct.TYPE_11__* %5, %struct.TYPE_11__** %2
%6 = load %struct.TYPE_11__*, %struct.TYPE_11__** %2
%7 = call i32 @test_ptr(i8* getelementptr inbounds ([157 x i8], [157 x i8]* @.str, i64 0, i64 0), i32 52, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), %struct.TYPE_11__* %6)
%8 = icmp ne i32 %7, 0
br i1 %8, label %10, label %9
9: ; preds = %0
br label %43
10: ; preds = %0
%11 = load %struct.TYPE_11__*, %struct.TYPE_11__** %2
%12 = call i32 @BIO_puts(%struct.TYPE_11__* %11, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0))
%13 = call i32 @test_int_eq(i8* getelementptr inbounds ([157 x i8], [157 x i8]* @.str, i64 0, i64 0), i32 54, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32 %12, i32 12)
%14 = icmp ne i32 %13, 0
br i1 %14, label %16, label %15
15: ; preds = %10
br label %43
16: ; preds = %10
%17 = load %struct.TYPE_11__*, %struct.TYPE_11__** %2
%18 = call i32 @BIO_get_mem_ptr(%struct.TYPE_11__* %17, %struct.TYPE_11__** %3)
%19 = load %struct.TYPE_11__*, %struct.TYPE_11__** %3
%20 = call i32 @test_ptr(i8* getelementptr inbounds ([157 x i8], [157 x i8]* @.str, i64 0, i64 0), i32 57, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0), %struct.TYPE_11__* %19)
%21 = icmp ne i32 %20, 0
br i1 %21, label %23, label %22
22: ; preds = %16
br label %43
23: ; preds = %16
%24 = load %struct.TYPE_11__*, %struct.TYPE_11__** %2
%25 = load i32, i32* @BIO_NOCLOSE
%26 = call i32 @BIO_set_close(%struct.TYPE_11__* %24, i32 %25)
%27 = call i32 @test_int_gt(i8* getelementptr inbounds ([157 x i8], [157 x i8]* @.str, i64 0, i64 0), i32 59, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0), i32 %26, i32 0)
%28 = icmp ne i32 %27, 0
br i1 %28, label %30, label %29
29: ; preds = %23
br label %43
30: ; preds = %23
%31 = load %struct.TYPE_11__*, %struct.TYPE_11__** %2
%32 = call i32 @BIO_free(%struct.TYPE_11__* %31)
store %struct.TYPE_11__* null, %struct.TYPE_11__** %2
%33 = load %struct.TYPE_11__*, %struct.TYPE_11__** %3
%34 = getelementptr inbounds %struct.TYPE_11__, %struct.TYPE_11__* %33, i32 0, i32 1
%35 = load i32, i32* %34
%36 = load %struct.TYPE_11__*, %struct.TYPE_11__** %3
%37 = getelementptr inbounds %struct.TYPE_11__, %struct.TYPE_11__* %36, i32 0, i32 0
%38 = load i32, i32* %37
%39 = call i32 @test_mem_eq(i8* getelementptr inbounds ([157 x i8], [157 x i8]* @.str, i64 0, i64 0), i32 63, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.9, i64 0, i64 0), i32 %35, i32 %38, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0), i32 12)
%40 = icmp ne i32 %39, 0
br i1 %40, label %42, label %41
41: ; preds = %30
br label %43
42: ; preds = %30
store i32 1, i32* %1
br label %43
43: ; preds = %42, %41, %29, %22, %15, %9
%44 = load %struct.TYPE_11__*, %struct.TYPE_11__** %2
%45 = call i32 @BIO_free(%struct.TYPE_11__* %44)
%46 = load %struct.TYPE_11__*, %struct.TYPE_11__** %3
%47 = call i32 @BUF_MEM_free(%struct.TYPE_11__* %46)
%48 = load i32, i32* %1
ret i32 %48
}

LLVM IR (-O2):
%struct.TYPE_11__ = type { i32, i32 }
@.str = [157 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/jens-maus/amissl/refs/heads/master/openssl/test/bio_memleak_test.c\00"
@.str.1 = [4 x i8] c"bio\00"
@.str.2 = [31 x i8] c"BIO_puts(bio, \22Hello World\\n\22)\00"
@.str.3 = [3 x i8] c"12\00"
@.str.4 = [13 x i8] c"Hello World\0A\00"
@.str.5 = [7 x i8] c"bufmem\00"
@.str.6 = [32 x i8] c"BIO_set_close(bio, BIO_NOCLOSE)\00"
@.str.7 = [2 x i8] c"0\00"
@BIO_NOCLOSE = global i32 0
@.str.8 = [13 x i8] c"bufmem->data\00"
@.str.9 = [16 x i8] c"\22Hello World\\n\22\00"
define i32 @test_bio_get_mem() {
%1 = alloca %struct.TYPE_11__*
%2 = bitcast %struct.TYPE_11__** %1 to i8*
store %struct.TYPE_11__* null, %struct.TYPE_11__** %1
%3 = tail call i32 (...) @BIO_s_mem()
%4 = tail call %struct.TYPE_11__* @BIO_new(i32 %3)
%5 = tail call i32 @test_ptr(i8* getelementptr inbounds ([157 x i8], [157 x i8]* @.str, i64 0, i64 0), i32 52, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), %struct.TYPE_11__* %4)
%6 = icmp eq i32 %5, 0
br i1 %6, label %31, label %7
7: ; preds = %0
%8 = tail call i32 @BIO_puts(%struct.TYPE_11__* %4, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0))
%9 = tail call i32 @test_int_eq(i8* getelementptr inbounds ([157 x i8], [157 x i8]* @.str, i64 0, i64 0), i32 54, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32 %8, i32 12)
%10 = icmp eq i32 %9, 0
br i1 %10, label %31, label %11
11: ; preds = %7
%12 = call i32 @BIO_get_mem_ptr(%struct.TYPE_11__* %4, %struct.TYPE_11__** %1)
%13 = load %struct.TYPE_11__*, %struct.TYPE_11__** %1
%14 = call i32 @test_ptr(i8* getelementptr inbounds ([157 x i8], [157 x i8]* @.str, i64 0, i64 0), i32 57, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.5, i64 0, i64 0), %struct.TYPE_11__* %13)
%15 = icmp eq i32 %14, 0
br i1 %15, label %31, label %16
16: ; preds = %11
%17 = load i32, i32* @BIO_NOCLOSE
%18 = call i32 @BIO_set_close(%struct.TYPE_11__* %4, i32 %17)
%19 = call i32 @test_int_gt(i8* getelementptr inbounds ([157 x i8], [157 x i8]* @.str, i64 0, i64 0), i32 59, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0), i32 %18, i32 0)
%20 = icmp eq i32 %19, 0
br i1 %20, label %31, label %21
21: ; preds = %16
%22 = call i32 @BIO_free(%struct.TYPE_11__* %4)
%23 = load %struct.TYPE_11__*, %struct.TYPE_11__** %1
%24 = getelementptr inbounds %struct.TYPE_11__, %struct.TYPE_11__* %23, i64 0, i32 1
%25 = load i32, i32* %24
%26 = getelementptr inbounds %struct.TYPE_11__, %struct.TYPE_11__* %23, i64 0, i32 0
%27 = load i32, i32* %26
%28 = call i32 @test_mem_eq(i8* getelementptr inbounds ([157 x i8], [157 x i8]* @.str, i64 0, i64 0), i32 63, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.8, i64 0, i64 0), i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.9, i64 0, i64 0), i32 %25, i32 %27, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.4, i64 0, i64 0), i32 12)
%29 = icmp ne i32 %28, 0
%30 = zext i1 %29 to i32
br label %31
31: ; preds = %21, %16, %11, %7, %0
%32 = phi i32 [ 0, %16 ], [ 0, %11 ], [ 0, %7 ], [ 0, %0 ], [ %30, %21 ]
%33 = phi %struct.TYPE_11__* [ %4, %16 ], [ %4, %11 ], [ %4, %7 ], [ %4, %0 ], [ null, %21 ]
%34 = call i32 @BIO_free(%struct.TYPE_11__* %33)
%35 = load %struct.TYPE_11__*, %struct.TYPE_11__** %1
%36 = call i32 @BUF_MEM_free(%struct.TYPE_11__* %35)
ret i32 %32
}