#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 top;
  char **err_data;
  int *err_data_flags;
};
typedef TYPE_1__ ERR_STATE;

/* Variables and functions */
int ERR_NUM_ERRORS;
TYPE_1__ *ERR_get_state();
void ERR_set_error_data(char *data, int flags) {
  ERR_STATE *es;
  int i;
  es = ERR_get_state();
  i = es->top;
  if (i == 0)
    i = ERR_NUM_ERRORS - 1;
  es->err_data[i] = data;
  es->err_data_flags[es->top] = flags;
}


x86 assembly (clang, -O0):
<ERR_set_error_data>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    $0x0,%al
call   1030 <ERR_get_state@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jne    114c <ERR_set_error_data+0x3c>
mov    0x2eac(%rip),%rax
mov    (%rax),%eax
sub    $0x1,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x8(%rbp),%rdx
mov    -0x18(%rbp),%rax
mov    0x8(%rax),%rax
movslq -0x1c(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0xc(%rbp),%edx
mov    -0x18(%rbp),%rax
mov    0x10(%rax),%rax
mov    -0x18(%rbp),%rcx
movslq (%rcx),%rcx
mov    %edx,(%rax,%rcx,4)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ERR_set_error_data>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebp
mov    %rdi,%rbx
xor    %eax,%eax
call   1030 <ERR_get_state@plt>
movslq (%rax),%rcx
mov    0x2ec7(%rip),%rdx
mov    (%rdx),%edx
add    $0xffffffff,%edx
test   %rcx,%rcx
cmovne %ecx,%edx
mov    0x8(%rax),%rsi
movslq %edx,%rdx
mov    %rbx,(%rsi,%rdx,8)
mov    0x10(%rax),%rax
mov    %ebp,(%rax,%rcx,4)
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
%struct.TYPE_3__ = type { i32, i8**, i32* }
@ERR_NUM_ERRORS = global i32 0
define void @ERR_set_error_data(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca %struct.TYPE_3__*
%6 = alloca i32
store i8* %0, i8** %3
store i32 %1, i32* %4
%7 = call %struct.TYPE_3__* (...) @ERR_get_state()
store %struct.TYPE_3__* %7, %struct.TYPE_3__** %5
%8 = load %struct.TYPE_3__*, %struct.TYPE_3__** %5
%9 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %8, i32 0, i32 0
%10 = load i32, i32* %9
store i32 %10, i32* %6
%11 = load i32, i32* %6
%12 = icmp eq i32 %11, 0
br i1 %12, label %13, label %16
13: ; preds = %2
%14 = load i32, i32* @ERR_NUM_ERRORS
%15 = sub nsw i32 %14, 1
store i32 %15, i32* %6
br label %16
16: ; preds = %13, %2
%17 = load i8*, i8** %3
%18 = load %struct.TYPE_3__*, %struct.TYPE_3__** %5
%19 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %18, i32 0, i32 1
%20 = load i8**, i8*** %19
%21 = load i32, i32* %6
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds i8*, i8** %20, i64 %22
store i8* %17, i8** %23
%24 = load i32, i32* %4
%25 = load %struct.TYPE_3__*, %struct.TYPE_3__** %5
%26 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %25, i32 0, i32 2
%27 = load i32*, i32** %26
%28 = load %struct.TYPE_3__*, %struct.TYPE_3__** %5
%29 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %28, i32 0, i32 0
%30 = load i32, i32* %29
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds i32, i32* %27, i64 %31
store i32 %24, i32* %32
ret void
}

LLVM IR (-O2):
%struct.TYPE_3__ = type { i32, i8**, i32* }
@ERR_NUM_ERRORS = global i32 0
define void @ERR_set_error_data(i8* %0, i32 %1) {
%3 = tail call %struct.TYPE_3__* (...) @ERR_get_state()
%4 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %3, i64 0, i32 0
%5 = load i32, i32* %4
%6 = icmp eq i32 %5, 0
%7 = load i32, i32* @ERR_NUM_ERRORS
%8 = add nsw i32 %7, -1
%9 = select i1 %6, i32 %8, i32 %5
%10 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %3, i64 0, i32 1
%11 = load i8**, i8*** %10
%12 = sext i32 %9 to i64
%13 = getelementptr inbounds i8*, i8** %11, i64 %12
store i8* %0, i8** %13
%14 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %3, i64 0, i32 2
%15 = load i32*, i32** %14
%16 = sext i32 %5 to i64
%17 = getelementptr inbounds i32, i32* %15, i64 %16
store i32 %1, i32* %17
ret void
}