#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 *,
                                       int /*<<< orphan*/, int /*<<< orphan*/ *,
                                       int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int main(int argc, const char *argv[]) {
  MYSQL mysql;
  if (mysql_init(&mysql) == NULL) {
    printf("mysql_init() : %s\n", mysql_error(&mysql));
    return -1;
  }
  if (mysql_real_connect(&mysql, argv[1], argv[2], argv[3], "demo", 0, NULL,
                         0) == NULL) {
    printf("mysql_real_connect() : %s\n", mysql_error(&mysql));
    return -1;
  }
  printf("connect success!!!\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x14(%rbp),%rdi
call   1050 <mysql_init@plt>
cmp    $0x0,%rax
jne    118f <main+0x4f>
lea    -0x14(%rbp),%rdi
call   1060 <mysql_error@plt>
mov    %rax,%rsi
lea    0xe84(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1211 <main+0xd1>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdx
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rcx
lea    -0x14(%rbp),%rdi
lea    0xe61(%rip),%r8
xor    %r9d,%r9d
xor    %eax,%eax
movq   $0x0,(%rsp)
movl   $0x0,0x8(%rsp)
call   1040 <mysql_real_connect@plt>
cmp    $0x0,%rax
jne    11fc <main+0xbc>
lea    -0x14(%rbp),%rdi
call   1060 <mysql_error@plt>
mov    %rax,%rsi
lea    0xe2f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1211 <main+0xd1>
lea    0xe30(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%rbx
lea    0xc(%rsp),%rdi
call   1060 <mysql_init@plt>
test   %rax,%rax
je     11a4 <main+0x54>
mov    0x8(%rbx),%rsi
mov    0x10(%rbx),%rdx
mov    0x18(%rbx),%rcx
lea    0xe99(%rip),%r8
lea    0xc(%rsp),%rdi
xor    %ebx,%ebx
xor    %r9d,%r9d
push   $0x0
push   $0x0
call   1050 <mysql_real_connect@plt>
add    $0x10,%rsp
test   %rax,%rax
je     11b7 <main+0x67>
lea    0xe96(%rip),%rdi
call   1030 <puts@plt>
jmp    11d7 <main+0x87>
lea    0xc(%rsp),%rdi
call   1070 <mysql_error@plt>
lea    0xe4b(%rip),%rdi
jmp    11c8 <main+0x78>
lea    0xc(%rsp),%rdi
call   1070 <mysql_error@plt>
lea    0xe50(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0xffffffff,%ebx
mov    %ebx,%eax
add    $0x10,%rsp
pop    %rbx
ret

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

LLVM IR (-O2):
@.str = [19 x i8] c"mysql_init() : %s\0A\00"
@.str.1 = [5 x i8] c"demo\00"
@.str.2 = [27 x i8] c"mysql_real_connect() : %s\0A\00"
@str = [19 x i8] c"connect success!!!\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
%5 = call i32* @mysql_init(i32* %3)
%6 = icmp eq i32* %5, null
br i1 %6, label %7, label %10
7: ; preds = %2
%8 = call i8* @mysql_error(i32* %3)
%9 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i8* %8)
br label %24
10: ; preds = %2
%11 = getelementptr inbounds i8*, i8** %1, i64 1
%12 = load i8*, i8** %11
%13 = getelementptr inbounds i8*, i8** %1, i64 2
%14 = load i8*, i8** %13
%15 = getelementptr inbounds i8*, i8** %1, i64 3
%16 = load i8*, i8** %15
%17 = call i32* @mysql_real_connect(i32* %3, i8* %12, i8* %14, i8* %16, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 0, i32* null, i32 0)
%18 = icmp eq i32* %17, null
br i1 %18, label %19, label %22
19: ; preds = %10
%20 = call i8* @mysql_error(i32* %3)
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0), i8* %20)
br label %24
22: ; preds = %10
%23 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str, i64 0, i64 0))
br label %24
24: ; preds = %22, %19, %7
%25 = phi i32 [ -1, %7 ], [ -1, %19 ], [ 0, %22 ]
ret i32 %25
}