#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 */

/* Variables and functions */
scalar_t__ medusaSend(int, unsigned char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ writeError(int, char *, char *);
int MySQLSessionQuit(int hSocket) {
  unsigned char com_quit_packet[5] = {0x01, 0x00, 0x00, 0x00, 0x01};
  if (medusaSend(hSocket, com_quit_packet, 5, 0) < 0) {
    writeError(3, "%s failed: medusaSend was not successful", "mysql.mod");
    return -1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<MySQLSessionQuit>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
mov    0xecf(%rip),%eax
mov    %eax,-0xd(%rbp)
mov    0xeca(%rip),%al
mov    %al,-0x9(%rbp)
mov    -0x8(%rbp),%edi
lea    -0xd(%rbp),%rsi
mov    $0x5,%edx
xor    %ecx,%ecx
call   1040 <medusaSend@plt>
cmp    $0x0,%rax
jge    117e <MySQLSessionQuit+0x5e>
mov    $0x3,%edi
lea    0xe9f(%rip),%rsi
lea    0xec1(%rip),%rdx
call   1030 <writeError@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1185 <MySQLSessionQuit+0x65>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<MySQLSessionQuit>:
push   %rbx
sub    $0x10,%rsp
movb   $0x1,0xc(%rsp)
movl   $0x1,0x8(%rsp)
lea    0x8(%rsp),%rsi
xor    %ebx,%ebx
mov    $0x5,%edx
xor    %ecx,%ecx
call   1040 <medusaSend@plt>
test   %rax,%rax
jns    1167 <MySQLSessionQuit+0x47>
lea    0xeb4(%rip),%rsi
lea    0xed6(%rip),%rdx
mov    $0x3,%edi
call   1030 <writeError@plt>
mov    $0xffffffff,%ebx
mov    %ebx,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@__const.MySQLSessionQuit.com_quit_packet = [5 x i8] c"\01\00\00\00\01"
@.str = [41 x i8] c"%s failed: medusaSend was not successful\00"
@.str.1 = [10 x i8] c"mysql.mod\00"
define i32 @MySQLSessionQuit(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca [5 x i8]
store i32 %0, i32* %3
%5 = bitcast [5 x i8]* %4 to i8*
%6 = load i32, i32* %3
%7 = getelementptr inbounds [5 x i8], [5 x i8]* %4, i64 0, i64 0
%8 = call i64 @medusaSend(i32 %6, i8* %7, i32 5, i32 0)
%9 = icmp slt i64 %8, 0
br i1 %9, label %10, label %12
10: ; preds = %1
%11 = call i32 @writeError(i32 3, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
store i32 -1, i32* %2
br label %13
12: ; preds = %1
store i32 0, i32* %2
br label %13
13: ; preds = %12, %10
%14 = load i32, i32* %2
ret i32 %14
}

LLVM IR (-O2):
@__const.MySQLSessionQuit.com_quit_packet = [5 x i8] c"\01\00\00\00\01"
@.str = [41 x i8] c"%s failed: medusaSend was not successful\00"
@.str.1 = [10 x i8] c"mysql.mod\00"
define i32 @MySQLSessionQuit(i32 %0) {
%2 = alloca [5 x i8]
%3 = getelementptr inbounds [5 x i8], [5 x i8]* %2, i64 0, i64 0
%4 = call i64 @medusaSend(i32 %0, i8* %3, i32 5, i32 0)
%5 = icmp slt i64 %4, 0
br i1 %5, label %6, label %8
6: ; preds = %1
%7 = call i32 @writeError(i32 3, i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0))
br label %8
8: ; preds = %1, %6
%9 = phi i32 [ -1, %6 ], [ 0, %1 ]
ret i32 %9
}