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

/* Type definitions */
struct TYPE_3__ {
  int *err_data_flags;
  int *err_line;
  scalar_t__ bottom;
  scalar_t__ top;
  int /*<<< orphan*/ **err_file;
  int /*<<< orphan*/ **err_data;
  scalar_t__ *err_buffer;
  scalar_t__ *err_flags;
};
typedef TYPE_1__ ERR_STATE;

/* Variables and functions */
int ERR_NUM_ERRORS;
int ERR_TXT_MALLOCED;
TYPE_1__ *ERR_get_state();
int /*<<< orphan*/ free(int /*<<< orphan*/ *);
void ERR_clear_error(void) {
  int i;
  ERR_STATE *es;
  es = ERR_get_state();
  for (i = 0; i < ERR_NUM_ERRORS; i++) {
    do {
      (es)->err_flags[i] = 0;
      (es)->err_buffer[i] = 0;
      do {
        if (((es)->err_data[i] != NULL) &&
            (es)->err_data_flags[i] & ERR_TXT_MALLOCED) {
          free((es)->err_data[i]);
          (es)->err_data[i] = NULL;
        }
        (es)->err_data_flags[i] = 0;
      } while (0);
      (es)->err_file[i] = NULL;
      (es)->err_line[i] = -1;
    } while (0);
  }
  es->top = es->bottom = 0;
}


x86 assembly (clang, -O0):
<ERR_clear_error>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x0,%al
call   1040 <ERR_get_state@plt>
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    0x2eac(%rip),%rcx
cmp    (%rcx),%eax
jge    1225 <ERR_clear_error+0x105>
jmp    1151 <ERR_clear_error+0x31>
mov    -0x10(%rbp),%rax
mov    0x38(%rax),%rax
movslq -0x4(%rbp),%rcx
movq   $0x0,(%rax,%rcx,8)
mov    -0x10(%rbp),%rax
mov    0x30(%rax),%rax
movslq -0x4(%rbp),%rcx
movq   $0x0,(%rax,%rcx,8)
mov    -0x10(%rbp),%rax
mov    0x28(%rax),%rax
movslq -0x4(%rbp),%rcx
cmpq   $0x0,(%rax,%rcx,8)
je     11d9 <ERR_clear_error+0xb9>
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
movslq -0x4(%rbp),%rcx
mov    (%rax,%rcx,4),%eax
mov    0x2e2b(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     11d9 <ERR_clear_error+0xb9>
mov    -0x10(%rbp),%rax
mov    0x28(%rax),%rax
movslq -0x4(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1030 <free@plt>
mov    -0x10(%rbp),%rax
mov    0x28(%rax),%rax
movslq -0x4(%rbp),%rcx
movq   $0x0,(%rax,%rcx,8)
mov    -0x10(%rbp),%rax
mov    (%rax),%rax
movslq -0x4(%rbp),%rcx
movl   $0x0,(%rax,%rcx,4)
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rax
movslq -0x4(%rbp),%rcx
movq   $0x0,(%rax,%rcx,8)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
movslq -0x4(%rbp),%rcx
movl   $0xffffffff,(%rax,%rcx,4)
jmp    1217 <ERR_clear_error+0xf7>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    113a <ERR_clear_error+0x1a>
mov    -0x10(%rbp),%rax
movq   $0x0,0x10(%rax)
mov    -0x10(%rbp),%rax
movq   $0x0,0x18(%rax)
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ERR_clear_error>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
xor    %eax,%eax
call   1040 <ERR_get_state@plt>
mov    %rax,%r15
mov    0x2eb7(%rip),%r14
cmpl   $0x0,(%r14)
jle    11c1 <ERR_clear_error+0xa1>
xor    %ebx,%ebx
mov    0x2e84(%rip),%r12
jmp    117d <ERR_clear_error+0x5d>
xchg   %ax,%ax
mov    (%r15),%rax
movl   $0x0,(%rax,%rbx,4)
mov    0x20(%r15),%rax
movq   $0x0,(%rax,%rbx,8)
mov    0x8(%r15),%rax
movl   $0xffffffff,(%rax,%rbx,4)
add    $0x1,%rbx
movslq (%r14),%rax
cmp    %rax,%rbx
jge    11c1 <ERR_clear_error+0xa1>
mov    0x38(%r15),%rax
movq   $0x0,(%rax,%rbx,8)
mov    0x30(%r15),%rax
movq   $0x0,(%rax,%rbx,8)
mov    0x28(%r15),%rax
mov    (%rax,%rbx,8),%rdi
test   %rdi,%rdi
je     1150 <ERR_clear_error+0x30>
mov    (%r15),%rax
mov    (%r12),%ecx
test   %ecx,(%rax,%rbx,4)
je     1150 <ERR_clear_error+0x30>
call   1030 <free@plt>
mov    0x28(%r15),%rax
movq   $0x0,(%rax,%rbx,8)
jmp    1150 <ERR_clear_error+0x30>
xorps  %xmm0,%xmm0
movups %xmm0,0x10(%r15)
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.TYPE_3__ = type { i32*, i32*, i64, i64, i32**, i32**, i64*, i64* }
@ERR_NUM_ERRORS = global i32 0
@ERR_TXT_MALLOCED = global i32 0
define void @ERR_clear_error() {
%1 = alloca i32
%2 = alloca %struct.TYPE_3__*
%3 = call %struct.TYPE_3__* (...) @ERR_get_state()
store %struct.TYPE_3__* %3, %struct.TYPE_3__** %2
store i32 0, i32* %1
br label %4
4: ; preds = %78, %0
%5 = load i32, i32* %1
%6 = load i32, i32* @ERR_NUM_ERRORS
%7 = icmp slt i32 %5, %6
br i1 %7, label %8, label %81
8: ; preds = %4
br label %9
9: ; preds = %8
%10 = load %struct.TYPE_3__*, %struct.TYPE_3__** %2
%11 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %10, i32 0, i32 7
%12 = load i64*, i64** %11
%13 = load i32, i32* %1
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds i64, i64* %12, i64 %14
store i64 0, i64* %15
%16 = load %struct.TYPE_3__*, %struct.TYPE_3__** %2
%17 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %16, i32 0, i32 6
%18 = load i64*, i64** %17
%19 = load i32, i32* %1
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds i64, i64* %18, i64 %20
store i64 0, i64* %21
br label %22
22: ; preds = %9
%23 = load %struct.TYPE_3__*, %struct.TYPE_3__** %2
%24 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %23, i32 0, i32 5
%25 = load i32**, i32*** %24
%26 = load i32, i32* %1
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds i32*, i32** %25, i64 %27
%29 = load i32*, i32** %28
%30 = icmp ne i32* %29, null
br i1 %30, label %31, label %57
31: ; preds = %22
%32 = load %struct.TYPE_3__*, %struct.TYPE_3__** %2
%33 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %32, i32 0, i32 0
%34 = load i32*, i32** %33
%35 = load i32, i32* %1
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds i32, i32* %34, i64 %36
%38 = load i32, i32* %37
%39 = load i32, i32* @ERR_TXT_MALLOCED
%40 = and i32 %38, %39
%41 = icmp ne i32 %40, 0
br i1 %41, label %42, label %57
42: ; preds = %31
%43 = load %struct.TYPE_3__*, %struct.TYPE_3__** %2
%44 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %43, i32 0, i32 5
%45 = load i32**, i32*** %44
%46 = load i32, i32* %1
%47 = sext i32 %46 to i64
%48 = getelementptr inbounds i32*, i32** %45, i64 %47
%49 = load i32*, i32** %48
%50 = call i32 @free(i32* %49)
%51 = load %struct.TYPE_3__*, %struct.TYPE_3__** %2
%52 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %51, i32 0, i32 5
%53 = load i32**, i32*** %52
%54 = load i32, i32* %1
%55 = sext i32 %54 to i64
%56 = getelementptr inbounds i32*, i32** %53, i64 %55
store i32* null, i32** %56
br label %57
57: ; preds = %42, %31, %22
%58 = load %struct.TYPE_3__*, %struct.TYPE_3__** %2
%59 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %58, i32 0, i32 0
%60 = load i32*, i32** %59
%61 = load i32, i32* %1
%62 = sext i32 %61 to i64
%63 = getelementptr inbounds i32, i32* %60, i64 %62
store i32 0, i32* %63
br label %64
64: ; preds = %57
%65 = load %struct.TYPE_3__*, %struct.TYPE_3__** %2
%66 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %65, i32 0, i32 4
%67 = load i32**, i32*** %66
%68 = load i32, i32* %1
%69 = sext i32 %68 to i64
%70 = getelementptr inbounds i32*, i32** %67, i64 %69
store i32* null, i32** %70
%71 = load %struct.TYPE_3__*, %struct.TYPE_3__** %2
%72 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %71, i32 0, i32 1
%73 = load i32*, i32** %72
%74 = load i32, i32* %1
%75 = sext i32 %74 to i64
%76 = getelementptr inbounds i32, i32* %73, i64 %75
store i32 -1, i32* %76
br label %77
77: ; preds = %64
br label %78
78: ; preds = %77
%79 = load i32, i32* %1
%80 = add nsw i32 %79, 1
store i32 %80, i32* %1
br label %4
81: ; preds = %4
%82 = load %struct.TYPE_3__*, %struct.TYPE_3__** %2
%83 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %82, i32 0, i32 2
store i64 0, i64* %83
%84 = load %struct.TYPE_3__*, %struct.TYPE_3__** %2
%85 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %84, i32 0, i32 3
store i64 0, i64* %85
ret void
}

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