#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*/ EXIT_FAILURE;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
char *mysql_error(int /*<<< orphan*/ *);
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 *, ...);
void ConnectMySQL(MYSQL *MySQLVector, char *cIP, char *cLogin, char *cPwd,
                  char *cDb) {
  mysql_init(MySQLVector);
  if (!mysql_real_connect(MySQLVector, cIP, cLogin, cPwd, cDb, 0, NULL, 0)) {
    printf("Fatal: failed to connect MySQL vector");
    printf("IP address    : %s\n", cIP);
    printf("Error message : %s\n", mysql_error(MySQLVector));
    exit(EXIT_FAILURE);
  }
}


x86 assembly (clang, -O0):
<ConnectMySQL>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <mysql_init@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rcx
mov    -0x28(%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    11f4 <ConnectMySQL+0xa4>
lea    0xe4d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%rsi
lea    0xe61(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%rdi
call   1060 <mysql_error@plt>
mov    %rax,%rsi
lea    0xe5b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    0x2df3(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ConnectMySQL>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %r8,%r12
mov    %rcx,%r13
mov    %rdx,%rbx
mov    %rsi,%r14
mov    %rdi,%r15
call   1050 <mysql_init@plt>
mov    %r15,%rdi
mov    %r14,%rsi
mov    %rbx,%rdx
mov    %r13,%rcx
mov    %r12,%r8
xor    %r9d,%r9d
push   $0x0
push   $0x0
call   1040 <mysql_real_connect@plt>
add    $0x10,%rsp
test   %eax,%eax
je     119a <ConnectMySQL+0x4a>
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret
lea    0xe5f(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xe77(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %r15,%rdi
call   1060 <mysql_error@plt>
lea    0xe72(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x2e07(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@.str = [38 x i8] c"Fatal: failed to connect MySQL vector\00"
@.str.1 = [20 x i8] c"IP address : %s\0A\00"
@.str.2 = [20 x i8] c"Error message : %s\0A\00"
@EXIT_FAILURE = global i32 0
define void @ConnectMySQL(i32* %0, i8* %1, i8* %2, i8* %3, i8* %4) {
%6 = alloca i32*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i8*
store i32* %0, i32** %6
store i8* %1, i8** %7
store i8* %2, i8** %8
store i8* %3, i8** %9
store i8* %4, i8** %10
%11 = load i32*, i32** %6
%12 = call i32 @mysql_init(i32* %11)
%13 = load i32*, i32** %6
%14 = load i8*, i8** %7
%15 = load i8*, i8** %8
%16 = load i8*, i8** %9
%17 = load i8*, i8** %10
%18 = call i32 @mysql_real_connect(i32* %13, i8* %14, i8* %15, i8* %16, i8* %17, i32 0, i32* null, i32 0)
%19 = icmp ne i32 %18, 0
br i1 %19, label %29, label %20
20: ; preds = %5
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0))
%22 = load i8*, i8** %7
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i8* %22)
%24 = load i32*, i32** %6
%25 = call i8* @mysql_error(i32* %24)
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), i8* %25)
%27 = load i32, i32* @EXIT_FAILURE
%28 = call i32 @exit(i32 %27)
unreachable
29: ; preds = %5
ret void
}

LLVM IR (-O2):
@.str = [38 x i8] c"Fatal: failed to connect MySQL vector\00"
@.str.1 = [20 x i8] c"IP address : %s\0A\00"
@.str.2 = [20 x i8] c"Error message : %s\0A\00"
@EXIT_FAILURE = global i32 0
define void @ConnectMySQL(i32* %0, i8* %1, i8* %2, i8* %3, i8* %4) {
%6 = tail call i32 @mysql_init(i32* %0)
%7 = tail call i32 @mysql_real_connect(i32* %0, i8* %1, i8* %2, i8* %3, i8* %4, i32 0, i32* null, i32 0)
%8 = icmp eq i32 %7, 0
br i1 %8, label %9, label %16
9: ; preds = %5
%10 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0))
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i8* %1)
%12 = tail call i8* @mysql_error(i32* %0)
%13 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), i8* %12)
%14 = load i32, i32* @EXIT_FAILURE
%15 = tail call i32 @exit(i32 %14)
unreachable
16: ; preds = %5
ret void
}