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

/* Variables and functions */
int /*<<< orphan*/ mysqlErrAndExit(int /*<<< orphan*/ *, char *);
int /*<<< orphan*/ *mysql_init(int /*<<< orphan*/ *);
int /*<<< orphan*/ *mysql_real_connect(int /*<<< orphan*/ *, char *, char *,
                                       char *, char *, int /*<<< orphan*/,
                                       int /*<<< orphan*/ *,
                                       int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *);
MYSQL *getMysqlConn() {
  MYSQL *dbconn = mysql_init(NULL);
  if (dbconn == NULL) {
    mysqlErrAndExit(dbconn, "init");
  }
  printf("Connecting to database... ");
  dbconn = mysql_real_connect(dbconn, "", "", "", "FAH", 0, NULL, 0);
  if (dbconn == NULL) {
    printf("[ FAIL ]\n");
    mysqlErrAndExit(dbconn, "connect");
  }
  printf("[ OK ]\n");
  return dbconn;
}


x86 assembly (clang, -O0):
<getMysqlConn>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
xor    %eax,%eax
mov    %eax,%edi
call   1050 <mysql_init@plt>
mov    %rax,-0x8(%rbp)
cmpq   $0x0,-0x8(%rbp)
jne    1170 <getMysqlConn+0x30>
mov    -0x8(%rbp),%rdi
lea    0xe95(%rip),%rsi
call   1060 <mysqlErrAndExit@plt>
lea    0xe8e(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%rdi
lea    0xeb6(%rip),%rcx
lea    0xe92(%rip),%r8
xor    %r9d,%r9d
xor    %eax,%eax
mov    %rcx,%rsi
mov    %rcx,%rdx
movq   $0x0,(%rsp)
movl   $0x0,0x8(%rsp)
call   1040 <mysql_real_connect@plt>
mov    %rax,-0x8(%rbp)
cmpq   $0x0,-0x8(%rbp)
jne    11d9 <getMysqlConn+0x99>
lea    0xe60(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%rdi
lea    0xe5a(%rip),%rsi
call   1060 <mysqlErrAndExit@plt>
lea    0xe56(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getMysqlConn>:
push   %rbx
xor    %edi,%edi
call   1060 <mysql_init@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    116e <getMysqlConn+0x1e>
lea    0xe99(%rip),%rsi
xor    %edi,%edi
call   1070 <mysqlErrAndExit@plt>
lea    0xe90(%rip),%rdi
call   1040 <printf@plt>
lea    0xe9e(%rip),%rcx
lea    0xe98(%rip),%r8
mov    %rbx,%rdi
mov    %rcx,%rsi
mov    %rcx,%rdx
xor    %r9d,%r9d
push   $0x0
push   $0x0
call   1050 <mysql_real_connect@plt>
add    $0x10,%rsp
mov    %rax,%rbx
test   %rax,%rax
jne    11c3 <getMysqlConn+0x73>
lea    0xe83(%rip),%rdi
call   1030 <puts@plt>
lea    0xe68(%rip),%rsi
xor    %edi,%edi
call   1070 <mysqlErrAndExit@plt>
lea    0xe62(%rip),%rdi
call   1030 <puts@plt>
mov    %rbx,%rax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [5 x i8] c"init\00"
@.str.1 = [27 x i8] c"Connecting to database... \00"
@.str.2 = [1 x i8] zeroinitializer
@.str.3 = [4 x i8] c"FAH\00"
@.str.4 = [10 x i8] c"[ FAIL ]\0A\00"
@.str.5 = [8 x i8] c"connect\00"
@.str.6 = [8 x i8] c"[ OK ]\0A\00"
define i32* @getMysqlConn() {
%1 = alloca i32*
%2 = call i32* @mysql_init(i32* null)
store i32* %2, i32** %1
%3 = load i32*, i32** %1
%4 = icmp eq i32* %3, null
br i1 %4, label %5, label %8
5: ; preds = %0
%6 = load i32*, i32** %1
%7 = call i32 @mysqlErrAndExit(i32* %6, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
br label %8
8: ; preds = %5, %0
%9 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0))
%10 = load i32*, i32** %1
%11 = call i32* @mysql_real_connect(i32* %10, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 0, i32* null, i32 0)
store i32* %11, i32** %1
%12 = load i32*, i32** %1
%13 = icmp eq i32* %12, null
br i1 %13, label %14, label %18
14: ; preds = %8
%15 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0))
%16 = load i32*, i32** %1
%17 = call i32 @mysqlErrAndExit(i32* %16, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0))
br label %18
18: ; preds = %14, %8
%19 = call i32 @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.6, i64 0, i64 0))
%20 = load i32*, i32** %1
ret i32* %20
}

LLVM IR (-O2):
@.str = [5 x i8] c"init\00"
@.str.1 = [27 x i8] c"Connecting to database... \00"
@.str.2 = [1 x i8] zeroinitializer
@.str.3 = [4 x i8] c"FAH\00"
@.str.5 = [8 x i8] c"connect\00"
@str = [7 x i8] c"[ OK ]\00"
@str.7 = [9 x i8] c"[ FAIL ]\00"
define i32* @getMysqlConn() {
%1 = tail call i32* @mysql_init(i32* null)
%2 = icmp eq i32* %1, null
br i1 %2, label %3, label %5
3: ; preds = %0
%4 = tail call i32 @mysqlErrAndExit(i32* null, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
br label %5
5: ; preds = %3, %0
%6 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0))
%7 = tail call i32* @mysql_real_connect(i32* %1, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32 0, i32* null, i32 0)
%8 = icmp eq i32* %7, null
br i1 %8, label %9, label %12
9: ; preds = %5
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @str.7, i64 0, i64 0))
%11 = tail call i32 @mysqlErrAndExit(i32* null, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0))
br label %12
12: ; preds = %9, %5
%13 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @str, i64 0, i64 0))
ret i32* %7
}