#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_4__ TYPE_1__;

/* Type definitions */
struct TYPE_4__ {
  int *err_data_flags;
  struct TYPE_4__ **err_data;
};
typedef TYPE_1__ ERR_STATE;

/* Variables and functions */
int ERR_NUM_ERRORS;
int ERR_TXT_MALLOCED;
int /*<<< orphan*/ OPENSSL_free(TYPE_1__ *);
void ERR_STATE_free(ERR_STATE *s) {
  int i;
  if (s == NULL)
    return;
  for (i = 0; i < ERR_NUM_ERRORS; i++) {
    do {
      if (((s)->err_data[i] != NULL) &&
          (s)->err_data_flags[i] & ERR_TXT_MALLOCED) {
        OPENSSL_free((s)->err_data[i]);
        (s)->err_data[i] = NULL;
      }
      (s)->err_data_flags[i] = 0;
    } while (0);
  }
  OPENSSL_free(s);
}


x86 assembly (clang, -O0):
<ERR_STATE_free>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
cmpq   $0x0,-0x8(%rbp)
jne    112c <ERR_STATE_free+0x1c>
jmp    11d8 <ERR_STATE_free+0xc8>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    0x2eb3(%rip),%rcx
cmp    (%rcx),%eax
jge    11cf <ERR_STATE_free+0xbf>
jmp    114a <ERR_STATE_free+0x3a>
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%rax
movslq -0xc(%rbp),%rcx
cmpq   $0x0,(%rax,%rcx,8)
je     11aa <ERR_STATE_free+0x9a>
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
movslq -0xc(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
mov    0x2e5a(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     11aa <ERR_STATE_free+0x9a>
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%rax
movslq -0xc(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1030 <OPENSSL_free@plt>
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%rax
movslq -0xc(%rbp),%rcx
movq   $0x0,(%rax,%rcx,8)
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
movslq -0xc(%rbp),%rcx
movl   $0x0,(%rax,%rcx,4)
jmp    11c1 <ERR_STATE_free+0xb1>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1133 <ERR_STATE_free+0x23>
mov    -0x8(%rbp),%rdi
call   1030 <OPENSSL_free@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ERR_STATE_free>:
test   %rdi,%rdi
je     1195 <ERR_STATE_free+0x85>
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdi,%r15
mov    0x2ec5(%rip),%r14
cmpl   $0x0,(%r14)
jle    1182 <ERR_STATE_free+0x72>
xor    %ebx,%ebx
mov    0x2e96(%rip),%r12
jmp    1156 <ERR_STATE_free+0x46>
nopl   0x0(%rax)
mov    (%r15),%rax
movl   $0x0,(%rax,%rbx,4)
add    $0x1,%rbx
movslq (%r14),%rax
cmp    %rax,%rbx
jge    1182 <ERR_STATE_free+0x72>
mov    0x8(%r15),%rax
mov    (%rax,%rbx,8),%rdi
test   %rdi,%rdi
je     1140 <ERR_STATE_free+0x30>
mov    (%r15),%rax
mov    (%r12),%ecx
test   %ecx,(%rax,%rbx,4)
je     1140 <ERR_STATE_free+0x30>
call   1030 <OPENSSL_free@plt>
mov    0x8(%r15),%rax
movq   $0x0,(%rax,%rbx,8)
jmp    1140 <ERR_STATE_free+0x30>
mov    %r15,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1030 <OPENSSL_free@plt>
ret

LLVM IR (-O0):
%struct.TYPE_4__ = type { i32*, %struct.TYPE_4__** }
@ERR_NUM_ERRORS = global i32 0
@ERR_TXT_MALLOCED = global i32 0
define void @ERR_STATE_free(%struct.TYPE_4__* %0) {
%2 = alloca %struct.TYPE_4__*
%3 = alloca i32
store %struct.TYPE_4__* %0, %struct.TYPE_4__** %2
%4 = load %struct.TYPE_4__*, %struct.TYPE_4__** %2
%5 = icmp eq %struct.TYPE_4__* %4, null
br i1 %5, label %6, label %7
6: ; preds = %1
br label %62
7: ; preds = %1
store i32 0, i32* %3
br label %8
8: ; preds = %56, %7
%9 = load i32, i32* %3
%10 = load i32, i32* @ERR_NUM_ERRORS
%11 = icmp slt i32 %9, %10
br i1 %11, label %12, label %59
12: ; preds = %8
br label %13
13: ; preds = %12
%14 = load %struct.TYPE_4__*, %struct.TYPE_4__** %2
%15 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %14, i32 0, i32 1
%16 = load %struct.TYPE_4__**, %struct.TYPE_4__*** %15
%17 = load i32, i32* %3
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds %struct.TYPE_4__*, %struct.TYPE_4__** %16, i64 %18
%20 = load %struct.TYPE_4__*, %struct.TYPE_4__** %19
%21 = icmp ne %struct.TYPE_4__* %20, null
br i1 %21, label %22, label %48
22: ; preds = %13
%23 = load %struct.TYPE_4__*, %struct.TYPE_4__** %2
%24 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %23, i32 0, i32 0
%25 = load i32*, i32** %24
%26 = load i32, i32* %3
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds i32, i32* %25, i64 %27
%29 = load i32, i32* %28
%30 = load i32, i32* @ERR_TXT_MALLOCED
%31 = and i32 %29, %30
%32 = icmp ne i32 %31, 0
br i1 %32, label %33, label %48
33: ; preds = %22
%34 = load %struct.TYPE_4__*, %struct.TYPE_4__** %2
%35 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %34, i32 0, i32 1
%36 = load %struct.TYPE_4__**, %struct.TYPE_4__*** %35
%37 = load i32, i32* %3
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds %struct.TYPE_4__*, %struct.TYPE_4__** %36, i64 %38
%40 = load %struct.TYPE_4__*, %struct.TYPE_4__** %39
%41 = call i32 @OPENSSL_free(%struct.TYPE_4__* %40)
%42 = load %struct.TYPE_4__*, %struct.TYPE_4__** %2
%43 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %42, i32 0, i32 1
%44 = load %struct.TYPE_4__**, %struct.TYPE_4__*** %43
%45 = load i32, i32* %3
%46 = sext i32 %45 to i64
%47 = getelementptr inbounds %struct.TYPE_4__*, %struct.TYPE_4__** %44, i64 %46
store %struct.TYPE_4__* null, %struct.TYPE_4__** %47
br label %48
48: ; preds = %33, %22, %13
%49 = load %struct.TYPE_4__*, %struct.TYPE_4__** %2
%50 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %49, i32 0, i32 0
%51 = load i32*, i32** %50
%52 = load i32, i32* %3
%53 = sext i32 %52 to i64
%54 = getelementptr inbounds i32, i32* %51, i64 %53
store i32 0, i32* %54
br label %55
55: ; preds = %48
br label %56
56: ; preds = %55
%57 = load i32, i32* %3
%58 = add nsw i32 %57, 1
store i32 %58, i32* %3
br label %8
59: ; preds = %8
%60 = load %struct.TYPE_4__*, %struct.TYPE_4__** %2
%61 = call i32 @OPENSSL_free(%struct.TYPE_4__* %60)
br label %62
62: ; preds = %59, %6
ret void
}

LLVM IR (-O2):
%struct.TYPE_4__ = type { i32*, %struct.TYPE_4__** }
@ERR_NUM_ERRORS = global i32 0
@ERR_TXT_MALLOCED = global i32 0
define void @ERR_STATE_free(%struct.TYPE_4__* %0) {
%2 = icmp eq %struct.TYPE_4__* %0, null
br i1 %2, label %35, label %3
3: ; preds = %1
%4 = load i32, i32* @ERR_NUM_ERRORS
%5 = icmp sgt i32 %4, 0
br i1 %5, label %6, label %33
6: ; preds = %3
%7 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %0, i64 0, i32 1
%8 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %0, i64 0, i32 0
br label %9
9: ; preds = %6, %26
%10 = phi i64 [ 0, %6 ], [ %29, %26 ]
%11 = load %struct.TYPE_4__**, %struct.TYPE_4__*** %7
%12 = getelementptr inbounds %struct.TYPE_4__*, %struct.TYPE_4__** %11, i64 %10
%13 = load %struct.TYPE_4__*, %struct.TYPE_4__** %12
%14 = icmp eq %struct.TYPE_4__* %13, null
br i1 %14, label %26, label %15
15: ; preds = %9
%16 = load i32*, i32** %8
%17 = getelementptr inbounds i32, i32* %16, i64 %10
%18 = load i32, i32* %17
%19 = load i32, i32* @ERR_TXT_MALLOCED
%20 = and i32 %19, %18
%21 = icmp eq i32 %20, 0
br i1 %21, label %26, label %22
22: ; preds = %15
%23 = tail call i32 @OPENSSL_free(%struct.TYPE_4__* %13)
%24 = load %struct.TYPE_4__**, %struct.TYPE_4__*** %7
%25 = getelementptr inbounds %struct.TYPE_4__*, %struct.TYPE_4__** %24, i64 %10
store %struct.TYPE_4__* null, %struct.TYPE_4__** %25
br label %26
26: ; preds = %22, %15, %9
%27 = load i32*, i32** %8
%28 = getelementptr inbounds i32, i32* %27, i64 %10
store i32 0, i32* %28
%29 = add nuw nsw i64 %10, 1
%30 = load i32, i32* @ERR_NUM_ERRORS
%31 = sext i32 %30 to i64
%32 = icmp slt i64 %29, %31
br i1 %32, label %9, label %33
33: ; preds = %26, %3
%34 = tail call i32 @OPENSSL_free(%struct.TYPE_4__* %0)
br label %35
35: ; preds = %1, %33
ret void
}