#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_5__ TYPE_2__;
typedef struct TYPE_4__ TYPE_1__;

/* Type definitions */
struct TYPE_5__ {
  TYPE_1__ *pVtab;
};
typedef TYPE_2__ sqlite3_vtab_cursor;
struct TYPE_4__ {
  char *zErrMsg;
};

/* Variables and functions */
int SQLITE_ERROR;
int /*<<< orphan*/ sqlite3_free(char *);
int setErrMsg(sqlite3_vtab_cursor *pCursor, char *pzErr) {
  if (pCursor->pVtab->zErrMsg)
    sqlite3_free(pCursor->pVtab->zErrMsg);
  pCursor->pVtab->zErrMsg = pzErr;
  return SQLITE_ERROR;
}


x86 assembly (clang, -O0):
<setErrMsg>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
cmpq   $0x0,(%rax)
je     1140 <setErrMsg+0x30>
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    (%rax),%rdi
call   1030 <sqlite3_free@plt>
mov    -0x10(%rbp),%rcx
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
mov    %rcx,(%rax)
mov    0x2e8b(%rip),%rax
mov    (%rax),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<setErrMsg>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
mov    (%rdi),%rax
mov    (%rax),%rdi
test   %rdi,%rdi
je     112d <setErrMsg+0x1d>
call   1030 <sqlite3_free@plt>
mov    (%rbx),%rax
mov    %r14,(%rax)
mov    0x2ea9(%rip),%rax
mov    (%rax),%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.TYPE_5__ = type { %struct.TYPE_4__* }
%struct.TYPE_4__ = type { i8* }
@SQLITE_ERROR = global i32 0
define i32 @setErrMsg(%struct.TYPE_5__* %0, i8* %1) {
%3 = alloca %struct.TYPE_5__*
%4 = alloca i8*
store %struct.TYPE_5__* %0, %struct.TYPE_5__** %3
store i8* %1, i8** %4
%5 = load %struct.TYPE_5__*, %struct.TYPE_5__** %3
%6 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %5, i32 0, i32 0
%7 = load %struct.TYPE_4__*, %struct.TYPE_4__** %6
%8 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %7, i32 0, i32 0
%9 = load i8*, i8** %8
%10 = icmp ne i8* %9, null
br i1 %10, label %11, label %18
11: ; preds = %2
%12 = load %struct.TYPE_5__*, %struct.TYPE_5__** %3
%13 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %12, i32 0, i32 0
%14 = load %struct.TYPE_4__*, %struct.TYPE_4__** %13
%15 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %14, i32 0, i32 0
%16 = load i8*, i8** %15
%17 = call i32 @sqlite3_free(i8* %16)
br label %18
18: ; preds = %11, %2
%19 = load i8*, i8** %4
%20 = load %struct.TYPE_5__*, %struct.TYPE_5__** %3
%21 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %20, i32 0, i32 0
%22 = load %struct.TYPE_4__*, %struct.TYPE_4__** %21
%23 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %22, i32 0, i32 0
store i8* %19, i8** %23
%24 = load i32, i32* @SQLITE_ERROR
ret i32 %24
}

LLVM IR (-O2):
%struct.TYPE_5__ = type { %struct.TYPE_4__* }
%struct.TYPE_4__ = type { i8* }
@SQLITE_ERROR = global i32 0
define i32 @setErrMsg(%struct.TYPE_5__* nocapture %0, i8* %1) {
%3 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %0, i64 0, i32 0
%4 = load %struct.TYPE_4__*, %struct.TYPE_4__** %3
%5 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %4, i64 0, i32 0
%6 = load i8*, i8** %5
%7 = icmp eq i8* %6, null
br i1 %7, label %11, label %8
8: ; preds = %2
%9 = tail call i32 @sqlite3_free(i8* %6)
%10 = load %struct.TYPE_4__*, %struct.TYPE_4__** %3
br label %11
11: ; preds = %8, %2
%12 = phi %struct.TYPE_4__* [ %10, %8 ], [ %4, %2 ]
%13 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %12, i64 0, i32 0
store i8* %1, i8** %13
%14 = load i32, i32* @SQLITE_ERROR
ret i32 %14
}