#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 */
#define CR_COMMANDS_OUT_OF_SYNC 131
#define CR_SERVER_GONE_ERROR 130
#define CR_SERVER_LOST 129
#define CR_UNKNOWN_ERROR 128
int /*<<< orphan*/ exit(int);
int mysql_errno(int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, ...);
void print_error(MYSQL mysql, char *query) {
  switch (mysql_errno(&mysql)) {
  case CR_COMMANDS_OUT_OF_SYNC:
    printf("CR_COMMANDS_OUT_OF_SYNC: ");
    break;
  case CR_SERVER_GONE_ERROR:
    printf("CR_SERVER_GONE_ERROR: ");
    break;
  case CR_SERVER_LOST:
    printf("CR_SERVER_LOST: ");
    break;
  case CR_UNKNOWN_ERROR:
    printf("CR_UNKNOWN_ERROR: ");
    break;
  }
  printf("%s\n\n", query);
  exit(3);
}


x86 assembly (clang, -O0):
<print_error>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x4(%rbp),%rdi
call   1040 <mysql_errno@plt>
add    $0xffffff80,%eax
mov    %eax,%ecx
mov    %rcx,-0x18(%rbp)
sub    $0x3,%eax
ja     11b5 <print_error+0x85>
mov    -0x18(%rbp),%rax
lea    0xe9b(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xe9b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11b5 <print_error+0x85>
lea    0xea2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11b5 <print_error+0x85>
lea    0xea6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11b5 <print_error+0x85>
lea    0xea4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%rsi
lea    0xea5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x3,%edi
call   1050 <exit@plt>

x86 assembly (clang, -O2):
<print_error>:
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%rbx
mov    %edi,0xc(%rsp)
lea    0xc(%rsp),%rdi
call   1040 <mysql_errno@plt>
add    $0xffffff80,%eax
cmp    $0x3,%eax
ja     1165 <print_error+0x35>
cltq
lea    0xf05(%rip),%rcx
movslq (%rcx,%rax,4),%rdi
add    %rcx,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xee9(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1030 <printf@plt>
mov    $0x3,%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@.str = [26 x i8] c"CR_COMMANDS_OUT_OF_SYNC: \00"
@.str.1 = [23 x i8] c"CR_SERVER_GONE_ERROR: \00"
@.str.2 = [17 x i8] c"CR_SERVER_LOST: \00"
@.str.3 = [19 x i8] c"CR_UNKNOWN_ERROR: \00"
@.str.4 = [5 x i8] c"%s\0A\0A\00"
define void @print_error(i32 %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
store i32 %0, i32* %3
store i8* %1, i8** %4
%5 = call i32 @mysql_errno(i32* %3)
switch i32 %5, label %14 [
i32 131, label %6
i32 130, label %8
i32 129, label %10
i32 128, label %12
]
6: ; preds = %2
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
br label %14
8: ; preds = %2
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0))
br label %14
10: ; preds = %2
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0))
br label %14
12: ; preds = %2
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0))
br label %14
14: ; preds = %2, %12, %10, %8, %6
%15 = load i8*, i8** %4
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i8* %15)
%17 = call i32 @exit(i32 3)
unreachable
}

LLVM IR (-O2):
@.str = [26 x i8] c"CR_COMMANDS_OUT_OF_SYNC: \00"
@.str.1 = [23 x i8] c"CR_SERVER_GONE_ERROR: \00"
@.str.2 = [17 x i8] c"CR_SERVER_LOST: \00"
@.str.3 = [19 x i8] c"CR_UNKNOWN_ERROR: \00"
@.str.4 = [5 x i8] c"%s\0A\0A\00"
@reltable.print_error = [4 x i32] [i32 trunc (i64 sub (i64 ptrtoint ([19 x i8]* @.str.3 to i64), i64 ptrtoint ([4 x i32]* @reltable.print_error to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([17 x i8]* @.str.2 to i64), i64 ptrtoint ([4 x i32]* @reltable.print_error to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([23 x i8]* @.str.1 to i64), i64 ptrtoint ([4 x i32]* @reltable.print_error to i64)) to i32), i32 trunc (i64 sub (i64 ptrtoint ([26 x i8]* @.str to i64), i64 ptrtoint ([4 x i32]* @reltable.print_error to i64)) to i32)]
define void @print_error(i32 %0, i8* %1) {
%3 = alloca i32
store i32 %0, i32* %3
%4 = call i32 @mysql_errno(i32* %3)
%5 = add i32 %4, -128
%6 = icmp ult i32 %5, 4
br i1 %6, label %7, label %12
7: ; preds = %2
%8 = sext i32 %5 to i64
%9 = shl i64 %8, 2
%10 = call i8* @llvm.load.relative.i64(i8* bitcast ([4 x i32]* @reltable.print_error to i8*), i64 %9)
%11 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) %10)
br label %12
12: ; preds = %2, %7
%13 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i8* %1)
%14 = call i32 @exit(i32 3)
unreachable
}