#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 */
char *mysql_error(int /*<<< orphan*/ *);
int /*<<< orphan*/ mysql_init(int /*<<< orphan*/ *);
int /*<<< orphan*/ mysql_real_connect(int /*<<< orphan*/ *, char const *,
                                      char const *, char const *, char const *,
                                      int /*<<< orphan*/, int /*<<< orphan*/ *,
                                      int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int database_init_and_connect(MYSQL *mysql) {
  const char *host = "localhost";
  const char *user = "root";
  const char *pass = "root";
  const char *db = "fgap_config";
  mysql_init(mysql);
  if (!mysql_real_connect(mysql, host, user, pass, db, 0, NULL, 0)) {
    printf("%s", mysql_error(mysql));
    return -1;
  } else {
  }
  printf("connect success .... ");
  return 0;
}


x86 assembly (clang, -O0):
<database_init_and_connect>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
lea    0xead(%rip),%rax
mov    %rax,-0x18(%rbp)
lea    0xeac(%rip),%rax
mov    %rax,-0x20(%rbp)
lea    0xea1(%rip),%rax
mov    %rax,-0x28(%rbp)
lea    0xe9b(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <mysql_init@plt>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
mov    -0x28(%rbp),%rcx
mov    -0x30(%rbp),%r8
xor    %r9d,%r9d
xor    %eax,%eax
movq   $0x0,(%rsp)
movl   $0x0,0x8(%rsp)
call   1040 <mysql_real_connect@plt>
cmp    $0x0,%eax
jne    11de <database_init_and_connect+0x9e>
mov    -0x10(%rbp),%rdi
call   1060 <mysql_error@plt>
mov    %rax,%rsi
lea    0xe50(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    11f8 <database_init_and_connect+0xb8>
jmp    11e3 <database_init_and_connect+0xa3>
lea    0xe34(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<database_init_and_connect>:
push   %rbp
push   %rbx
push   %rax
mov    %rdi,%rbx
call   1050 <mysql_init@plt>
lea    0xeae(%rip),%rsi
lea    0xeb1(%rip),%rcx
lea    0xeaf(%rip),%r8
xor    %ebp,%ebp
mov    %rbx,%rdi
mov    %rcx,%rdx
xor    %r9d,%r9d
push   $0x0
push   $0x0
call   1040 <mysql_real_connect@plt>
add    $0x10,%rsp
test   %eax,%eax
je     118c <database_init_and_connect+0x4c>
lea    0xe9b(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
jmp    11aa <database_init_and_connect+0x6a>
mov    %rbx,%rdi
call   1060 <mysql_error@plt>
lea    0xe80(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1030 <printf@plt>
mov    $0xffffffff,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [10 x i8] c"localhost\00"
@.str.1 = [5 x i8] c"root\00"
@.str.2 = [12 x i8] c"fgap_config\00"
@.str.3 = [3 x i8] c"%s\00"
@.str.4 = [22 x i8] c"connect success .... \00"
define i32 @database_init_and_connect(i32* %0) {
%2 = alloca i32
%3 = alloca i32*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
store i32* %0, i32** %3
store i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8** %4
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8** %5
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8** %6
store i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i8** %7
%8 = load i32*, i32** %3
%9 = call i32 @mysql_init(i32* %8)
%10 = load i32*, i32** %3
%11 = load i8*, i8** %4
%12 = load i8*, i8** %5
%13 = load i8*, i8** %6
%14 = load i8*, i8** %7
%15 = call i32 @mysql_real_connect(i32* %10, i8* %11, i8* %12, i8* %13, i8* %14, i32 0, i32* null, i32 0)
%16 = icmp ne i32 %15, 0
br i1 %16, label %21, label %17
17: ; preds = %1
%18 = load i32*, i32** %3
%19 = call i8* @mysql_error(i32* %18)
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %19)
store i32 -1, i32* %2
br label %24
21: ; preds = %1
br label %22
22: ; preds = %21
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.4, i64 0, i64 0))
store i32 0, i32* %2
br label %24
24: ; preds = %22, %17
%25 = load i32, i32* %2
ret i32 %25
}

LLVM IR (-O2):
@.str = [10 x i8] c"localhost\00"
@.str.1 = [5 x i8] c"root\00"
@.str.2 = [12 x i8] c"fgap_config\00"
@.str.3 = [3 x i8] c"%s\00"
@.str.4 = [22 x i8] c"connect success .... \00"
define i32 @database_init_and_connect(i32* %0) {
%2 = tail call i32 @mysql_init(i32* %0)
%3 = tail call i32 @mysql_real_connect(i32* %0, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i32 0, i32* null, i32 0)
%4 = icmp eq i32 %3, 0
br i1 %4, label %5, label %8
5: ; preds = %1
%6 = tail call i8* @mysql_error(i32* %0)
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %6)
br label %10
8: ; preds = %1
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.4, i64 0, i64 0))
br label %10
10: ; preds = %8, %5
%11 = phi i32 [ 0, %8 ], [ -1, %5 ]
ret i32 %11
}