#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 char **MYSQL_ROW;
typedef int /*<<< orphan*/ MYSQL_RES;
typedef int /*<<< orphan*/ MYSQL;

/* Variables and functions */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ mysql_close(int /*<<< orphan*/ *);
char *mysql_error(int /*<<< orphan*/ *);
char **mysql_fetch_row(int /*<<< orphan*/ *);
int /*<<< orphan*/ mysql_free_result(int /*<<< orphan*/ *);
int /*<<< orphan*/ *mysql_init(int /*<<< orphan*/ *);
scalar_t__ mysql_query(int /*<<< orphan*/ *, char *);
int /*<<< orphan*/ mysql_real_connect(int /*<<< orphan*/ *, char *, char *,
                                      char *, char *, int /*<<< orphan*/,
                                      int /*<<< orphan*/ *, int /*<<< orphan*/);
int /*<<< orphan*/ *mysql_use_result(int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stderr;
int main(void) {
  MYSQL *conn;
  MYSQL_RES *res;
  MYSQL_ROW row;
  char *server = "localhost";
  char *user = "root";
  char *password = "omni";
  char *database = "omniPresence";
  conn = mysql_init(NULL);
  if (!mysql_real_connect(conn, server, user, password, database, 0, NULL, 0)) {
    fprintf(stderr, "%s\n", mysql_error(conn));
    return 1;
  }
  if (mysql_query(conn, "select * from developers")) {
    fprintf(stderr, "%s\n", mysql_error(conn));
    return 1;
  }
  res = mysql_use_result(conn);
  printf("Developers of omniPresence are:\n");
  while ((row = mysql_fetch_row(res)) != NULL)
    printf("%s\t%s\t\t%s\t%s\t%s\n", row[0], row[1], row[2], row[3], row[4]);
  mysql_free_result(res);
  mysql_close(conn);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe4a(%rip),%rax
mov    %rax,-0x28(%rbp)
lea    0xe49(%rip),%rax
mov    %rax,-0x30(%rbp)
lea    0xe43(%rip),%rax
mov    %rax,-0x38(%rbp)
lea    0xe3d(%rip),%rax
mov    %rax,-0x40(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1090 <mysql_init@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    -0x30(%rbp),%rdx
mov    -0x38(%rbp),%rcx
mov    -0x40(%rbp),%r8
xor    %r9d,%r9d
xor    %eax,%eax
movq   $0x0,(%rsp)
movl   $0x0,0x8(%rsp)
call   1070 <mysql_real_connect@plt>
cmp    $0x0,%eax
jne    1252 <main+0xb2>
mov    0x2dba(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x44(%rbp)
mov    -0x10(%rbp),%rdi
call   10c0 <mysql_error@plt>
mov    -0x44(%rbp),%edi
mov    %rax,%rdx
lea    0xe27(%rip),%rsi
call   1060 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1324 <main+0x184>
mov    -0x10(%rbp),%rdi
lea    0xdc4(%rip),%rsi
call   1030 <mysql_query@plt>
cmp    $0x0,%rax
je     129f <main+0xff>
mov    0x2d6d(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x48(%rbp)
mov    -0x10(%rbp),%rdi
call   10c0 <mysql_error@plt>
mov    -0x48(%rbp),%edi
mov    %rax,%rdx
lea    0xdda(%rip),%rsi
call   1060 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1324 <main+0x184>
mov    -0x10(%rbp),%rdi
call   10b0 <mysql_use_result@plt>
mov    %rax,-0x18(%rbp)
lea    0xd87(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x18(%rbp),%rdi
call   1040 <mysql_fetch_row@plt>
mov    %rax,-0x20(%rbp)
cmp    $0x0,%rax
je     130b <main+0x16b>
mov    -0x20(%rbp),%rax
mov    (%rax),%rsi
mov    -0x20(%rbp),%rax
mov    0x8(%rax),%rdx
mov    -0x20(%rbp),%rax
mov    0x10(%rax),%rcx
mov    -0x20(%rbp),%rax
mov    0x18(%rax),%r8
mov    -0x20(%rbp),%rax
mov    0x20(%rax),%r9
lea    0xd5c(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    12ba <main+0x11a>
mov    -0x18(%rbp),%rdi
call   10a0 <mysql_free_result@plt>
mov    -0x10(%rbp),%rdi
call   1080 <mysql_close@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
xor    %edi,%edi
call   10a0 <mysql_init@plt>
mov    %rax,%r14
lea    0xe3a(%rip),%rsi
lea    0xe3d(%rip),%rdx
lea    0xe3b(%rip),%rcx
lea    0xe39(%rip),%r8
mov    %rax,%rdi
xor    %r9d,%r9d
push   $0x0
push   $0x0
call   1080 <mysql_real_connect@plt>
add    $0x10,%rsp
test   %eax,%eax
je     1206 <main+0x56>
lea    0xe28(%rip),%rsi
mov    %r14,%rdi
call   1040 <mysql_query@plt>
test   %rax,%rax
je     122f <main+0x7f>
mov    0x2dd3(%rip),%rax
mov    (%rax),%ebx
mov    %r14,%rdi
call   10d0 <mysql_error@plt>
lea    0xe29(%rip),%rsi
mov    %ebx,%edi
mov    %rax,%rdx
call   1070 <fprintf@plt>
mov    $0x1,%eax
jmp    129c <main+0xec>
mov    %r14,%rdi
call   10c0 <mysql_use_result@plt>
mov    %rax,%rbx
lea    0xe0a(%rip),%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
call   1050 <mysql_fetch_row@plt>
test   %rax,%rax
je     128a <main+0xda>
lea    0xde0(%rip),%r15
nopw   0x0(%rax,%rax,1)
mov    (%rax),%rsi
mov    0x8(%rax),%rdx
mov    0x10(%rax),%rcx
mov    0x18(%rax),%r8
mov    0x20(%rax),%r9
mov    %r15,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %rbx,%rdi
call   1050 <mysql_fetch_row@plt>
test   %rax,%rax
jne    1260 <main+0xb0>
mov    %rbx,%rdi
call   10b0 <mysql_free_result@plt>
mov    %r14,%rdi
call   1090 <mysql_close@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [10 x i8] c"localhost\00"
@.str.1 = [5 x i8] c"root\00"
@.str.2 = [5 x i8] c"omni\00"
@.str.3 = [13 x i8] c"omniPresence\00"
@stderr = global i32 0
@.str.4 = [4 x i8] c"%s\0A\00"
@.str.5 = [25 x i8] c"select * from developers\00"
@.str.6 = [33 x i8] c"Developers of omniPresence are:\0A\00"
@.str.7 = [17 x i8] c"%s\09%s\09\09%s\09%s\09%s\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca i32*
%4 = alloca i8**
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
store i32 0, i32* %1
store i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, 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 ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8** %7
store i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), i8** %8
%9 = call i32* @mysql_init(i32* null)
store i32* %9, i32** %2
%10 = load i32*, i32** %2
%11 = load i8*, i8** %5
%12 = load i8*, i8** %6
%13 = load i8*, i8** %7
%14 = load i8*, i8** %8
%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 %22, label %17
17: ; preds = %0
%18 = load i32, i32* @stderr
%19 = load i32*, i32** %2
%20 = call i8* @mysql_error(i32* %19)
%21 = call i32 @fprintf(i32 %18, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i8* %20)
store i32 1, i32* %1
br label %61
22: ; preds = %0
%23 = load i32*, i32** %2
%24 = call i64 @mysql_query(i32* %23, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.5, i64 0, i64 0))
%25 = icmp ne i64 %24, 0
br i1 %25, label %26, label %31
26: ; preds = %22
%27 = load i32, i32* @stderr
%28 = load i32*, i32** %2
%29 = call i8* @mysql_error(i32* %28)
%30 = call i32 @fprintf(i32 %27, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i8* %29)
store i32 1, i32* %1
br label %61
31: ; preds = %22
%32 = load i32*, i32** %2
%33 = call i32* @mysql_use_result(i32* %32)
store i32* %33, i32** %3
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.6, i64 0, i64 0))
br label %35
35: ; preds = %39, %31
%36 = load i32*, i32** %3
%37 = call i8** @mysql_fetch_row(i32* %36)
store i8** %37, i8*** %4
%38 = icmp ne i8** %37, null
br i1 %38, label %39, label %56
39: ; preds = %35
%40 = load i8**, i8*** %4
%41 = getelementptr inbounds i8*, i8** %40, i64 0
%42 = load i8*, i8** %41
%43 = load i8**, i8*** %4
%44 = getelementptr inbounds i8*, i8** %43, i64 1
%45 = load i8*, i8** %44
%46 = load i8**, i8*** %4
%47 = getelementptr inbounds i8*, i8** %46, i64 2
%48 = load i8*, i8** %47
%49 = load i8**, i8*** %4
%50 = getelementptr inbounds i8*, i8** %49, i64 3
%51 = load i8*, i8** %50
%52 = load i8**, i8*** %4
%53 = getelementptr inbounds i8*, i8** %52, i64 4
%54 = load i8*, i8** %53
%55 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.7, i64 0, i64 0), i8* %42, i8* %45, i8* %48, i8* %51, i8* %54)
br label %35
56: ; preds = %35
%57 = load i32*, i32** %3
%58 = call i32 @mysql_free_result(i32* %57)
%59 = load i32*, i32** %2
%60 = call i32 @mysql_close(i32* %59)
store i32 0, i32* %1
br label %61
61: ; preds = %56, %26, %17
%62 = load i32, i32* %1
ret i32 %62
}

LLVM IR (-O2):
@.str = [10 x i8] c"localhost\00"
@.str.1 = [5 x i8] c"root\00"
@.str.2 = [5 x i8] c"omni\00"
@.str.3 = [13 x i8] c"omniPresence\00"
@stderr = global i32 0
@.str.4 = [4 x i8] c"%s\0A\00"
@.str.5 = [25 x i8] c"select * from developers\00"
@.str.7 = [17 x i8] c"%s\09%s\09\09%s\09%s\09%s\0A\00"
@str = [32 x i8] c"Developers of omniPresence are:\00"
define i32 @main() {
%1 = tail call i32* @mysql_init(i32* null)
%2 = tail call i32 @mysql_real_connect(i32* %1, 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.2, i64 0, i64 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), i32 0, i32* null, i32 0)
%3 = icmp eq i32 %2, 0
br i1 %3, label %4, label %8
4: ; preds = %0
%5 = load i32, i32* @stderr
%6 = tail call i8* @mysql_error(i32* %1)
%7 = tail call i32 @fprintf(i32 %5, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i8* %6)
br label %37
8: ; preds = %0
%9 = tail call i64 @mysql_query(i32* %1, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.5, i64 0, i64 0))
%10 = icmp eq i64 %9, 0
br i1 %10, label %15, label %11
11: ; preds = %8
%12 = load i32, i32* @stderr
%13 = tail call i8* @mysql_error(i32* %1)
%14 = tail call i32 @fprintf(i32 %12, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i8* %13)
br label %37
15: ; preds = %8
%16 = tail call i32* @mysql_use_result(i32* %1)
%17 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @str, i64 0, i64 0))
%18 = tail call i8** @mysql_fetch_row(i32* %16)
%19 = icmp eq i8** %18, null
br i1 %19, label %34, label %20
20: ; preds = %15, %20
%21 = phi i8** [ %32, %20 ], [ %18, %15 ]
%22 = load i8*, i8** %21
%23 = getelementptr inbounds i8*, i8** %21, i64 1
%24 = load i8*, i8** %23
%25 = getelementptr inbounds i8*, i8** %21, i64 2
%26 = load i8*, i8** %25
%27 = getelementptr inbounds i8*, i8** %21, i64 3
%28 = load i8*, i8** %27
%29 = getelementptr inbounds i8*, i8** %21, i64 4
%30 = load i8*, i8** %29
%31 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.7, i64 0, i64 0), i8* %22, i8* %24, i8* %26, i8* %28, i8* %30)
%32 = tail call i8** @mysql_fetch_row(i32* %16)
%33 = icmp eq i8** %32, null
br i1 %33, label %34, label %20
34: ; preds = %20, %15
%35 = tail call i32 @mysql_free_result(i32* %16)
%36 = tail call i32 @mysql_close(i32* %1)
br label %37
37: ; preds = %34, %11, %4
%38 = phi i32 [ 1, %11 ], [ 0, %34 ], [ 1, %4 ]
ret i32 %38
}