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

/* Variables and functions */
int /*<<< orphan*/ _log(char *, char *, ...);
char *am_malloc(unsigned long);
int /*<<< orphan*/ memcpy(char *, int /*<<< orphan*/, unsigned long);
int /*<<< orphan*/ mysql_errno(int /*<<< orphan*/ *);
int /*<<< orphan*/ mysql_error(int /*<<< orphan*/ *);
unsigned long *mysql_fetch_lengths(int /*<<< orphan*/ *);
int /*<<< orphan*/ *mysql_fetch_row(int /*<<< orphan*/ *);
scalar_t__ mysql_field_count(int /*<<< orphan*/ *);
int /*<<< orphan*/ mysql_free_result(int /*<<< orphan*/ *);
int mysql_num_fields(int /*<<< orphan*/ *);
int mysql_num_rows(int /*<<< orphan*/ *);
scalar_t__ mysql_query(int /*<<< orphan*/ *, char *);
int /*<<< orphan*/ *mysql_store_result(int /*<<< orphan*/ *);
char *_am_mysql_query_return_row_0(MYSQL *mysql, char *fmt_query) {
  MYSQL_RES *result = 0;
  MYSQL_ROW row;
  unsigned long *lengths;
  char *res = 0;
  my_ulonglong num_rows;
  if (mysql_query(mysql, fmt_query)) {
    res = 0;
    _log("ERROR", "Failed to execute query: Error (%d): %s\n",
         mysql_errno(mysql), mysql_error(mysql));
    goto _query_return_row_0_free;
  }
  if ((result = mysql_store_result(mysql)) == 0) {
    if (mysql_field_count(mysql) == 0) {
      res = 0;
      goto _query_return_row_0_free;
    } else {
      res = 0;
      _log("ERROR", "Failed to store query results: Error (%d): %s\n",
           mysql_errno(mysql), mysql_error(mysql));
      goto _query_return_row_0_free;
    }
  }
  num_rows = mysql_num_rows(result);
  if (num_rows > 1) {
    res = 0;
    _log("ERROR", "Many results were found while only 1 was expected!\n");
    goto _query_return_row_0_free;
  }
  if (num_rows == 0) {
    res = 0;
    goto _query_return_row_0_free;
  }
  if (mysql_num_fields(result) < 1) {
    res = 0;
    _log("ERROR", "No field encountered in MySQL result!\n");
    goto _query_return_row_0_free;
  }
  row = mysql_fetch_row(result);
  if (row == 0) {
    res = 0;
    _log("ERROR", "Failed to return first row, Error (%d): %s\n",
         mysql_errno(mysql), mysql_error(mysql));
    goto _query_return_row_0_free;
  }
  lengths = mysql_fetch_lengths(result);
  if (lengths[0] != 0) {
    res = am_malloc(lengths[0] + 1);
    if (res == 0) {
      _log("ERROR", "Could not allocate memory for result\n");
    } else {
      memcpy(res, row[0], lengths[0]);
      res[lengths[0]] = '\0';
    }
  } else {
    res = 0;
  }
_query_return_row_0_free:
  if (result != 0)
    mysql_free_result(result);
  return res;
}


x86 assembly (clang, -O0):
<_am_mysql_query_return_row_0>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
movq   $0x0,-0x30(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1040 <mysql_query@plt>
cmp    $0x0,%rax
je     1243 <_am_mysql_query_return_row_0+0x73>
movq   $0x0,-0x30(%rbp)
mov    -0x8(%rbp),%rdi
call   1080 <mysql_errno@plt>
mov    %eax,-0x38(%rbp)
mov    -0x8(%rbp),%rdi
call   10c0 <mysql_error@plt>
mov    -0x38(%rbp),%edx
mov    %eax,%ecx
lea    0xdd0(%rip),%rdi
lea    0xdcf(%rip),%rsi
mov    $0x0,%al
call   1030 <_log@plt>
jmp    1418 <_am_mysql_query_return_row_0+0x248>
mov    -0x8(%rbp),%rdi
call   10f0 <mysql_store_result@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jne    12b6 <_am_mysql_query_return_row_0+0xe6>
mov    -0x8(%rbp),%rdi
call   10a0 <mysql_field_count@plt>
cmp    $0x0,%rax
jne    127a <_am_mysql_query_return_row_0+0xaa>
movq   $0x0,-0x30(%rbp)
jmp    1418 <_am_mysql_query_return_row_0+0x248>
movq   $0x0,-0x30(%rbp)
mov    -0x8(%rbp),%rdi
call   1080 <mysql_errno@plt>
mov    %eax,-0x3c(%rbp)
mov    -0x8(%rbp),%rdi
call   10c0 <mysql_error@plt>
mov    -0x3c(%rbp),%edx
mov    %eax,%ecx
lea    0xd5d(%rip),%rdi
lea    0xd85(%rip),%rsi
mov    $0x0,%al
call   1030 <_log@plt>
jmp    1418 <_am_mysql_query_return_row_0+0x248>
mov    -0x18(%rbp),%rdi
call   10e0 <mysql_num_rows@plt>
mov    %eax,-0x34(%rbp)
cmpl   $0x1,-0x34(%rbp)
jle    12ee <_am_mysql_query_return_row_0+0x11e>
movq   $0x0,-0x30(%rbp)
lea    0xd25(%rip),%rdi
lea    0xd7c(%rip),%rsi
mov    $0x0,%al
call   1030 <_log@plt>
jmp    1418 <_am_mysql_query_return_row_0+0x248>
cmpl   $0x0,-0x34(%rbp)
jne    1305 <_am_mysql_query_return_row_0+0x135>
movq   $0x0,-0x30(%rbp)
jmp    1418 <_am_mysql_query_return_row_0+0x248>
mov    -0x18(%rbp),%rdi
call   1060 <mysql_num_fields@plt>
cmp    $0x1,%eax
jge    1339 <_am_mysql_query_return_row_0+0x169>
movq   $0x0,-0x30(%rbp)
lea    0xcda(%rip),%rdi
lea    0xd65(%rip),%rsi
mov    $0x0,%al
call   1030 <_log@plt>
jmp    1418 <_am_mysql_query_return_row_0+0x248>
mov    -0x18(%rbp),%rdi
call   1050 <mysql_fetch_row@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    138d <_am_mysql_query_return_row_0+0x1bd>
movq   $0x0,-0x30(%rbp)
mov    -0x8(%rbp),%rdi
call   1080 <mysql_errno@plt>
mov    %eax,-0x40(%rbp)
mov    -0x8(%rbp),%rdi
call   10c0 <mysql_error@plt>
mov    -0x40(%rbp),%edx
mov    %eax,%ecx
lea    0xc86(%rip),%rdi
lea    0xd38(%rip),%rsi
mov    $0x0,%al
call   1030 <_log@plt>
jmp    1418 <_am_mysql_query_return_row_0+0x248>
mov    -0x18(%rbp),%rdi
call   1070 <mysql_fetch_lengths@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
cmpq   $0x0,(%rax)
je     140b <_am_mysql_query_return_row_0+0x23b>
mov    -0x28(%rbp),%rax
mov    (%rax),%rdi
add    $0x1,%rdi
call   10d0 <am_malloc@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jne    13e1 <_am_mysql_query_return_row_0+0x211>
lea    0xc32(%rip),%rdi
lea    0xd10(%rip),%rsi
mov    $0x0,%al
call   1030 <_log@plt>
jmp    1406 <_am_mysql_query_return_row_0+0x236>
mov    -0x30(%rbp),%rdi
mov    -0x20(%rbp),%rax
mov    (%rax),%esi
mov    -0x28(%rbp),%rax
mov    (%rax),%rdx
call   1090 <memcpy@plt>
mov    -0x30(%rbp),%rax
mov    -0x28(%rbp),%rcx
mov    (%rcx),%rcx
movb   $0x0,(%rax,%rcx,1)
jmp    1413 <_am_mysql_query_return_row_0+0x243>
movq   $0x0,-0x30(%rbp)
jmp    1418 <_am_mysql_query_return_row_0+0x248>
cmpq   $0x0,-0x18(%rbp)
je     142c <_am_mysql_query_return_row_0+0x25c>
mov    -0x18(%rbp),%rdi
call   10b0 <mysql_free_result@plt>
mov    -0x30(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<_am_mysql_query_return_row_0>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rdi,%rbx
call   1040 <mysql_query@plt>
mov    %rbx,%rdi
test   %rax,%rax
je     1217 <_am_mysql_query_return_row_0+0x47>
call   1080 <mysql_errno@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
call   10c0 <mysql_error@plt>
lea    0xe02(%rip),%rdi
lea    0xe01(%rip),%rsi
xor    %ebx,%ebx
mov    %ebp,%edx
mov    %eax,%ecx
xor    %eax,%eax
call   1030 <_log@plt>
jmp    132d <_am_mysql_query_return_row_0+0x15d>
call   10f0 <mysql_store_result@plt>
test   %rax,%rax
je     124d <_am_mysql_query_return_row_0+0x7d>
mov    %rax,%r14
mov    %rax,%rdi
call   10e0 <mysql_num_rows@plt>
cmp    $0x2,%eax
jl     1280 <_am_mysql_query_return_row_0+0xb0>
lea    0xdc8(%rip),%rdi
lea    0xe1f(%rip),%rsi
xor    %ebx,%ebx
xor    %eax,%eax
call   1030 <_log@plt>
jmp    1325 <_am_mysql_query_return_row_0+0x155>
mov    %rbx,%rdi
call   10a0 <mysql_field_count@plt>
test   %rax,%rax
je     12e1 <_am_mysql_query_return_row_0+0x111>
mov    %rbx,%rdi
call   1080 <mysql_errno@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
call   10c0 <mysql_error@plt>
lea    0xd89(%rip),%rdi
lea    0xdb1(%rip),%rsi
jmp    1205 <_am_mysql_query_return_row_0+0x35>
test   %eax,%eax
je     12dd <_am_mysql_query_return_row_0+0x10d>
mov    %r14,%rdi
call   1060 <mysql_num_fields@plt>
test   %eax,%eax
jle    12e5 <_am_mysql_query_return_row_0+0x115>
mov    %r14,%rdi
call   1050 <mysql_fetch_row@plt>
test   %rax,%rax
je     12f8 <_am_mysql_query_return_row_0+0x128>
mov    %rax,%r15
mov    %r14,%rdi
call   1070 <mysql_fetch_lengths@plt>
mov    (%rax),%rdi
test   %rdi,%rdi
je     12dd <_am_mysql_query_return_row_0+0x10d>
mov    %rax,%r12
add    $0x1,%rdi
call   10d0 <am_malloc@plt>
test   %rax,%rax
je     1339 <_am_mysql_query_return_row_0+0x169>
mov    %rax,%rbx
mov    (%r15),%esi
mov    (%r12),%rdx
mov    %rax,%rdi
call   1090 <memcpy@plt>
mov    (%r12),%rax
movb   $0x0,(%rbx,%rax,1)
jmp    1325 <_am_mysql_query_return_row_0+0x155>
xor    %ebx,%ebx
jmp    1325 <_am_mysql_query_return_row_0+0x155>
xor    %ebx,%ebx
jmp    132d <_am_mysql_query_return_row_0+0x15d>
lea    0xd14(%rip),%rdi
lea    0xd9f(%rip),%rsi
jmp    123f <_am_mysql_query_return_row_0+0x6f>
mov    %rbx,%rdi
call   1080 <mysql_errno@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
call   10c0 <mysql_error@plt>
lea    0xcef(%rip),%rdi
lea    0xda1(%rip),%rsi
xor    %ebx,%ebx
mov    %ebp,%edx
mov    %eax,%ecx
xor    %eax,%eax
call   1030 <_log@plt>
mov    %r14,%rdi
call   10b0 <mysql_free_result@plt>
mov    %rbx,%rax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xcc0(%rip),%rdi
lea    0xd9e(%rip),%rsi
jmp    123f <_am_mysql_query_return_row_0+0x6f>

LLVM IR (-O0):
@.str = [6 x i8] c"ERROR\00"
@.str.1 = [41 x i8] c"Failed to execute query: Error (%d): %s\0A\00"
@.str.2 = [47 x i8] c"Failed to store query results: Error (%d): %s\0A\00"
@.str.3 = [52 x i8] c"Many results were found while only 1 was expected!\0A\00"
@.str.4 = [39 x i8] c"No field encountered in MySQL result!\0A\00"
@.str.5 = [44 x i8] c"Failed to return first row, Error (%d): %s\0A\00"
@.str.6 = [38 x i8] c"Could not allocate memory for result\0A\00"
define i8* @_am_mysql_query_return_row_0(i32* %0, i8* %1) {
%3 = alloca i32*
%4 = alloca i8*
%5 = alloca i32*
%6 = alloca i32*
%7 = alloca i64*
%8 = alloca i8*
%9 = alloca i32
store i32* %0, i32** %3
store i8* %1, i8** %4
store i32* null, i32** %5
store i8* null, i8** %8
%10 = load i32*, i32** %3
%11 = load i8*, i8** %4
%12 = call i64 @mysql_query(i32* %10, i8* %11)
%13 = icmp ne i64 %12, 0
br i1 %13, label %14, label %20
14: ; preds = %2
store i8* null, i8** %8
%15 = load i32*, i32** %3
%16 = call i32 @mysql_errno(i32* %15)
%17 = load i32*, i32** %3
%18 = call i32 @mysql_error(i32* %17)
%19 = call i32 (i8*, i8*, ...) @_log(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.1, i64 0, i64 0), i32 %16, i32 %18)
br label %97
20: ; preds = %2
%21 = load i32*, i32** %3
%22 = call i32* @mysql_store_result(i32* %21)
store i32* %22, i32** %5
%23 = icmp eq i32* %22, null
br i1 %23, label %24, label %35
24: ; preds = %20
%25 = load i32*, i32** %3
%26 = call i64 @mysql_field_count(i32* %25)
%27 = icmp eq i64 %26, 0
br i1 %27, label %28, label %29
28: ; preds = %24
store i8* null, i8** %8
br label %97
29: ; preds = %24
store i8* null, i8** %8
%30 = load i32*, i32** %3
%31 = call i32 @mysql_errno(i32* %30)
%32 = load i32*, i32** %3
%33 = call i32 @mysql_error(i32* %32)
%34 = call i32 (i8*, i8*, ...) @_log(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.2, i64 0, i64 0), i32 %31, i32 %33)
br label %97
35: ; preds = %20
%36 = load i32*, i32** %5
%37 = call i32 @mysql_num_rows(i32* %36)
store i32 %37, i32* %9
%38 = load i32, i32* %9
%39 = icmp sgt i32 %38, 1
br i1 %39, label %40, label %42
40: ; preds = %35
store i8* null, i8** %8
%41 = call i32 (i8*, i8*, ...) @_log(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.3, i64 0, i64 0))
br label %97
42: ; preds = %35
%43 = load i32, i32* %9
%44 = icmp eq i32 %43, 0
br i1 %44, label %45, label %46
45: ; preds = %42
store i8* null, i8** %8
br label %97
46: ; preds = %42
%47 = load i32*, i32** %5
%48 = call i32 @mysql_num_fields(i32* %47)
%49 = icmp slt i32 %48, 1
br i1 %49, label %50, label %52
50: ; preds = %46
store i8* null, i8** %8
%51 = call i32 (i8*, i8*, ...) @_log(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.4, i64 0, i64 0))
br label %97
52: ; preds = %46
%53 = load i32*, i32** %5
%54 = call i32* @mysql_fetch_row(i32* %53)
store i32* %54, i32** %6
%55 = load i32*, i32** %6
%56 = icmp eq i32* %55, null
br i1 %56, label %57, label %63
57: ; preds = %52
store i8* null, i8** %8
%58 = load i32*, i32** %3
%59 = call i32 @mysql_errno(i32* %58)
%60 = load i32*, i32** %3
%61 = call i32 @mysql_error(i32* %60)
%62 = call i32 (i8*, i8*, ...) @_log(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.5, i64 0, i64 0), i32 %59, i32 %61)
br label %97
63: ; preds = %52
%64 = load i32*, i32** %5
%65 = call i64* @mysql_fetch_lengths(i32* %64)
store i64* %65, i64** %7
%66 = load i64*, i64** %7
%67 = getelementptr inbounds i64, i64* %66, i64 0
%68 = load i64, i64* %67
%69 = icmp ne i64 %68, 0
br i1 %69, label %70, label %95
70: ; preds = %63
%71 = load i64*, i64** %7
%72 = getelementptr inbounds i64, i64* %71, i64 0
%73 = load i64, i64* %72
%74 = add i64 %73, 1
%75 = call i8* @am_malloc(i64 %74)
store i8* %75, i8** %8
%76 = load i8*, i8** %8
%77 = icmp eq i8* %76, null
br i1 %77, label %78, label %80
78: ; preds = %70
%79 = call i32 (i8*, i8*, ...) @_log(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.6, i64 0, i64 0))
br label %94
80: ; preds = %70
%81 = load i8*, i8** %8
%82 = load i32*, i32** %6
%83 = getelementptr inbounds i32, i32* %82, i64 0
%84 = load i32, i32* %83
%85 = load i64*, i64** %7
%86 = getelementptr inbounds i64, i64* %85, i64 0
%87 = load i64, i64* %86
%88 = call i32 @memcpy(i8* %81, i32 %84, i64 %87)
%89 = load i8*, i8** %8
%90 = load i64*, i64** %7
%91 = getelementptr inbounds i64, i64* %90, i64 0
%92 = load i64, i64* %91
%93 = getelementptr inbounds i8, i8* %89, i64 %92
store i8 0, i8* %93
br label %94
94: ; preds = %80, %78
br label %96
95: ; preds = %63
store i8* null, i8** %8
br label %96
96: ; preds = %95, %94
br label %97
97: ; preds = %96, %57, %50, %45, %40, %29, %28, %14
%98 = load i32*, i32** %5
%99 = icmp ne i32* %98, null
br i1 %99, label %100, label %103
100: ; preds = %97
%101 = load i32*, i32** %5
%102 = call i32 @mysql_free_result(i32* %101)
br label %103
103: ; preds = %100, %97
%104 = load i8*, i8** %8
ret i8* %104
}

LLVM IR (-O2):
@.str = [6 x i8] c"ERROR\00"
@.str.1 = [41 x i8] c"Failed to execute query: Error (%d): %s\0A\00"
@.str.2 = [47 x i8] c"Failed to store query results: Error (%d): %s\0A\00"
@.str.3 = [52 x i8] c"Many results were found while only 1 was expected!\0A\00"
@.str.4 = [39 x i8] c"No field encountered in MySQL result!\0A\00"
@.str.5 = [44 x i8] c"Failed to return first row, Error (%d): %s\0A\00"
@.str.6 = [38 x i8] c"Could not allocate memory for result\0A\00"
define i8* @_am_mysql_query_return_row_0(i32* %0, i8* %1) {
%3 = tail call i64 @mysql_query(i32* %0, i8* %1)
%4 = icmp eq i64 %3, 0
br i1 %4, label %9, label %5
5: ; preds = %2
%6 = tail call i32 @mysql_errno(i32* %0)
%7 = tail call i32 @mysql_error(i32* %0)
%8 = tail call i32 (i8*, i8*, ...) @_log(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.1, i64 0, i64 0), i32 %6, i32 %7)
br label %57
9: ; preds = %2
%10 = tail call i32* @mysql_store_result(i32* %0)
%11 = icmp eq i32* %10, null
br i1 %11, label %12, label %19
12: ; preds = %9
%13 = tail call i64 @mysql_field_count(i32* %0)
%14 = icmp eq i64 %13, 0
br i1 %14, label %57, label %15
15: ; preds = %12
%16 = tail call i32 @mysql_errno(i32* %0)
%17 = tail call i32 @mysql_error(i32* %0)
%18 = tail call i32 (i8*, i8*, ...) @_log(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.2, i64 0, i64 0), i32 %16, i32 %17)
br label %57
19: ; preds = %9
%20 = tail call i32 @mysql_num_rows(i32* %10)
%21 = icmp sgt i32 %20, 1
br i1 %21, label %22, label %24
22: ; preds = %19
%23 = tail call i32 (i8*, i8*, ...) @_log(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.3, i64 0, i64 0))
br label %54
24: ; preds = %19
%25 = icmp eq i32 %20, 0
br i1 %25, label %54, label %26
26: ; preds = %24
%27 = tail call i32 @mysql_num_fields(i32* %10)
%28 = icmp slt i32 %27, 1
br i1 %28, label %29, label %31
29: ; preds = %26
%30 = tail call i32 (i8*, i8*, ...) @_log(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.4, i64 0, i64 0))
br label %54
31: ; preds = %26
%32 = tail call i32* @mysql_fetch_row(i32* %10)
%33 = icmp eq i32* %32, null
br i1 %33, label %34, label %38
34: ; preds = %31
%35 = tail call i32 @mysql_errno(i32* %0)
%36 = tail call i32 @mysql_error(i32* %0)
%37 = tail call i32 (i8*, i8*, ...) @_log(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.5, i64 0, i64 0), i32 %35, i32 %36)
br label %54
38: ; preds = %31
%39 = tail call i64* @mysql_fetch_lengths(i32* %10)
%40 = load i64, i64* %39
%41 = icmp eq i64 %40, 0
br i1 %41, label %54, label %42
42: ; preds = %38
%43 = add i64 %40, 1
%44 = tail call i8* @am_malloc(i64 %43)
%45 = icmp eq i8* %44, null
br i1 %45, label %46, label %48
46: ; preds = %42
%47 = tail call i32 (i8*, i8*, ...) @_log(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.6, i64 0, i64 0))
br label %54
48: ; preds = %42
%49 = load i32, i32* %32
%50 = load i64, i64* %39
%51 = tail call i32 @memcpy(i8* %44, i32 %49, i64 %50)
%52 = load i64, i64* %39
%53 = getelementptr inbounds i8, i8* %44, i64 %52
store i8 0, i8* %53
br label %54
54: ; preds = %22, %29, %34, %46, %48, %24, %38
%55 = phi i8* [ null, %38 ], [ null, %24 ], [ %44, %48 ], [ null, %46 ], [ null, %34 ], [ null, %29 ], [ null, %22 ]
%56 = tail call i32 @mysql_free_result(i32* %10)
br label %57
57: ; preds = %5, %15, %12, %54
%58 = phi i8* [ %55, %54 ], [ null, %5 ], [ null, %15 ], [ null, %12 ]
ret i8* %58
}