#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*/ Free(TYPE_1__ *);
void ERR_STATE_free(ERR_STATE *s) {
  int i;
  if (s == NULL)
    return;
  for (i = 0; i < ERR_NUM_ERRORS; i++) {
    if (((s)->err_data[i] != NULL) &&
        (s)->err_data_flags[i] & ERR_TXT_MALLOCED) {
      Free((s)->err_data[i]);
      (s)->err_data[i] = NULL;
    }
    (s)->err_data_flags[i] = 0;
    ;
  }
  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    11ce <ERR_STATE_free+0xbe>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    0x2eb3(%rip),%rcx
cmp    (%rcx),%eax
jge    11c5 <ERR_STATE_free+0xb5>
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%rax
movslq -0xc(%rbp),%rcx
cmpq   $0x0,(%rax,%rcx,8)
je     11a5 <ERR_STATE_free+0x95>
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
movslq -0xc(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
mov    0x2e5f(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     11a5 <ERR_STATE_free+0x95>
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%rax
movslq -0xc(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1030 <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)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1133 <ERR_STATE_free+0x23>
mov    -0x8(%rbp),%rdi
call   1030 <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 <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 <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 %60
7: ; preds = %1
store i32 0, i32* %3
br label %8
8: ; preds = %54, %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 %57
12: ; preds = %8
%13 = load %struct.TYPE_4__*, %struct.TYPE_4__** %2
%14 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %13, i32 0, i32 1
%15 = load %struct.TYPE_4__**, %struct.TYPE_4__*** %14
%16 = load i32, i32* %3
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds %struct.TYPE_4__*, %struct.TYPE_4__** %15, i64 %17
%19 = load %struct.TYPE_4__*, %struct.TYPE_4__** %18
%20 = icmp ne %struct.TYPE_4__* %19, null
br i1 %20, label %21, label %47
21: ; preds = %12
%22 = load %struct.TYPE_4__*, %struct.TYPE_4__** %2
%23 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %22, i32 0, i32 0
%24 = load i32*, i32** %23
%25 = load i32, i32* %3
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds i32, i32* %24, i64 %26
%28 = load i32, i32* %27
%29 = load i32, i32* @ERR_TXT_MALLOCED
%30 = and i32 %28, %29
%31 = icmp ne i32 %30, 0
br i1 %31, label %32, label %47
32: ; preds = %21
%33 = load %struct.TYPE_4__*, %struct.TYPE_4__** %2
%34 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %33, i32 0, i32 1
%35 = load %struct.TYPE_4__**, %struct.TYPE_4__*** %34
%36 = load i32, i32* %3
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds %struct.TYPE_4__*, %struct.TYPE_4__** %35, i64 %37
%39 = load %struct.TYPE_4__*, %struct.TYPE_4__** %38
%40 = call i32 @Free(%struct.TYPE_4__* %39)
%41 = load %struct.TYPE_4__*, %struct.TYPE_4__** %2
%42 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %41, i32 0, i32 1
%43 = load %struct.TYPE_4__**, %struct.TYPE_4__*** %42
%44 = load i32, i32* %3
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds %struct.TYPE_4__*, %struct.TYPE_4__** %43, i64 %45
store %struct.TYPE_4__* null, %struct.TYPE_4__** %46
br label %47
47: ; preds = %32, %21, %12
%48 = load %struct.TYPE_4__*, %struct.TYPE_4__** %2
%49 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %48, i32 0, i32 0
%50 = load i32*, i32** %49
%51 = load i32, i32* %3
%52 = sext i32 %51 to i64
%53 = getelementptr inbounds i32, i32* %50, i64 %52
store i32 0, i32* %53
br label %54
54: ; preds = %47
%55 = load i32, i32* %3
%56 = add nsw i32 %55, 1
store i32 %56, i32* %3
br label %8
57: ; preds = %8
%58 = load %struct.TYPE_4__*, %struct.TYPE_4__** %2
%59 = call i32 @Free(%struct.TYPE_4__* %58)
br label %60
60: ; preds = %57, %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 @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 @Free(%struct.TYPE_4__* %0)
br label %35
35: ; preds = %1, %33
ret void
}