#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 */

/* Type definitions */
typedef int /*<<< orphan*/ MYSQL_RES;
typedef int /*<<< orphan*/ MYSQL;

/* Variables and functions */
int /*<<< orphan*/ *connectMysqlCheck(int /*<<< orphan*/ *);
int /*<<< orphan*/ mysql_query(int /*<<< orphan*/ *, char *);
int /*<<< orphan*/ *mysql_store_result(int /*<<< orphan*/ *);
MYSQL_RES *executeQuery(MYSQL *conn, char *query) {
  if (conn == NULL) {
    if ((conn = connectMysqlCheck(conn)) == NULL) {
      return NULL;
    }
  }
  mysql_query(conn, query);
  return mysql_store_result(conn);
}


x86 assembly (clang, -O0):
<executeQuery>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1174 <executeQuery+0x44>
mov    -0x10(%rbp),%rdi
call   1040 <connectMysqlCheck@plt>
mov    %rax,-0x10(%rbp)
cmp    $0x0,%rax
jne    116f <executeQuery+0x3f>
movq   $0x0,-0x8(%rbp)
jmp    118e <executeQuery+0x5e>
jmp    1174 <executeQuery+0x44>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <mysql_query@plt>
mov    -0x10(%rbp),%rdi
call   1050 <mysql_store_result@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<executeQuery>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%rbx
test   %rdi,%rdi
jne    114e <executeQuery+0x1e>
xor    %edi,%edi
call   1040 <connectMysqlCheck@plt>
mov    %rax,%rbx
test   %rax,%rax
je     1168 <executeQuery+0x38>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1030 <mysql_query@plt>
mov    %rbx,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1050 <mysql_store_result@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i32* @executeQuery(i32* %0, i8* %1) {
%3 = alloca i32*
%4 = alloca i32*
%5 = alloca i8*
store i32* %0, i32** %4
store i8* %1, i8** %5
%6 = load i32*, i32** %4
%7 = icmp eq i32* %6, null
br i1 %7, label %8, label %14
8: ; preds = %2
%9 = load i32*, i32** %4
%10 = call i32* @connectMysqlCheck(i32* %9)
store i32* %10, i32** %4
%11 = icmp eq i32* %10, null
br i1 %11, label %12, label %13
12: ; preds = %8
store i32* null, i32** %3
br label %20
13: ; preds = %8
br label %14
14: ; preds = %13, %2
%15 = load i32*, i32** %4
%16 = load i8*, i8** %5
%17 = call i32 @mysql_query(i32* %15, i8* %16)
%18 = load i32*, i32** %4
%19 = call i32* @mysql_store_result(i32* %18)
store i32* %19, i32** %3
br label %20
20: ; preds = %14, %12
%21 = load i32*, i32** %3
ret i32* %21
}

LLVM IR (-O2):
define i32* @executeQuery(i32* %0, i8* %1) {
%3 = icmp eq i32* %0, null
br i1 %3, label %4, label %7
4: ; preds = %2
%5 = tail call i32* @connectMysqlCheck(i32* null)
%6 = icmp eq i32* %5, null
br i1 %6, label %11, label %7
7: ; preds = %4, %2
%8 = phi i32* [ %5, %4 ], [ %0, %2 ]
%9 = tail call i32 @mysql_query(i32* %8, i8* %1)
%10 = tail call i32* @mysql_store_result(i32* %8)
br label %11
11: ; preds = %4, %7
%12 = phi i32* [ %10, %7 ], [ null, %4 ]
ret i32* %12
}