#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*/ _log(char *, int, int, int /*<<< orphan*/);
int mysql_errno(int /*<<< orphan*/ *);
int /*<<< orphan*/ mysql_error(int /*<<< orphan*/ *);
void mysql_error_report(MYSQL dbc[], int n_dbc) {
  int i, errno;
  for (i = 0; i < n_dbc; i++) {
    if ((errno = mysql_errno(&dbc[i])) != 0) {
      _log("MYSQL_ERROR(connection:%d)[errno:%d] : %s\n", i, errno,
           mysql_error(&dbc[i]));
    }
  }
}


x86 assembly (clang, -O0):
<mysql_error_report>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11b9 <mysql_error_report+0x89>
mov    -0x8(%rbp),%rdi
movslq -0x10(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rdi
call   1040 <mysql_errno@plt>
mov    %eax,-0x14(%rbp)
cmp    $0x0,%eax
je     11a6 <mysql_error_report+0x76>
mov    -0x10(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
movslq -0x10(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rdi
call   1050 <mysql_error@plt>
mov    -0x1c(%rbp),%esi
mov    -0x18(%rbp),%edx
mov    %eax,%ecx
lea    0xe5f(%rip),%rdi
call   1030 <_log@plt>
jmp    11ab <mysql_error_report+0x7b>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1146 <mysql_error_report+0x16>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mysql_error_report>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
test   %esi,%esi
jle    1183 <mysql_error_report+0x53>
mov    %rdi,%r14
mov    %esi,%r12d
xor    %ebx,%ebx
lea    0xeb5(%rip),%r15
jmp    115d <mysql_error_report+0x2d>
nopl   (%rax)
add    $0x1,%rbx
add    $0x4,%r14
cmp    %rbx,%r12
je     1183 <mysql_error_report+0x53>
mov    %r14,%rdi
call   1040 <mysql_errno@plt>
test   %eax,%eax
je     1150 <mysql_error_report+0x20>
mov    %eax,%ebp
mov    %r14,%rdi
call   1050 <mysql_error@plt>
mov    %r15,%rdi
mov    %ebx,%esi
mov    %ebp,%edx
mov    %eax,%ecx
call   1030 <_log@plt>
jmp    1150 <mysql_error_report+0x20>
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [43 x i8] c"MYSQL_ERROR(connection:%d)[errno:%d] : %s\0A\00"
define void @mysql_error_report(i32* %0, i32 %1) {
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32* %0, i32** %3
store i32 %1, i32* %4
store i32 0, i32* %5
br label %7
7: ; preds = %28, %2
%8 = load i32, i32* %5
%9 = load i32, i32* %4
%10 = icmp slt i32 %8, %9
br i1 %10, label %11, label %31
11: ; preds = %7
%12 = load i32*, i32** %3
%13 = load i32, i32* %5
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds i32, i32* %12, i64 %14
%16 = call i32 @mysql_errno(i32* %15)
store i32 %16, i32* %6
%17 = icmp ne i32 %16, 0
br i1 %17, label %18, label %27
18: ; preds = %11
%19 = load i32, i32* %5
%20 = load i32, i32* %6
%21 = load i32*, i32** %3
%22 = load i32, i32* %5
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds i32, i32* %21, i64 %23
%25 = call i32 @mysql_error(i32* %24)
%26 = call i32 @_log(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str, i64 0, i64 0), i32 %19, i32 %20, i32 %25)
br label %27
27: ; preds = %18, %11
br label %28
28: ; preds = %27
%29 = load i32, i32* %5
%30 = add nsw i32 %29, 1
store i32 %30, i32* %5
br label %7
31: ; preds = %7
ret void
}

LLVM IR (-O2):
@.str = [43 x i8] c"MYSQL_ERROR(connection:%d)[errno:%d] : %s\0A\00"
define void @mysql_error_report(i32* %0, i32 %1) {
%3 = icmp sgt i32 %1, 0
br i1 %3, label %4, label %18
4: ; preds = %2
%5 = zext i32 %1 to i64
br label %6
6: ; preds = %4, %15
%7 = phi i64 [ 0, %4 ], [ %16, %15 ]
%8 = getelementptr inbounds i32, i32* %0, i64 %7
%9 = tail call i32 @mysql_errno(i32* %8)
%10 = icmp eq i32 %9, 0
br i1 %10, label %15, label %11
11: ; preds = %6
%12 = tail call i32 @mysql_error(i32* %8)
%13 = trunc i64 %7 to i32
%14 = tail call i32 @_log(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str, i64 0, i64 0), i32 %13, i32 %9, i32 %12)
br label %15
15: ; preds = %6, %11
%16 = add nuw nsw i64 %7, 1
%17 = icmp eq i64 %16, %5
br i1 %17, label %18, label %6
18: ; preds = %15, %2
ret void
}