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

/* Variables and functions */
int /*<<< orphan*/ medusaDisconnect(int);
scalar_t__ medusaSend(int, unsigned char *, int /*<<< orphan*/,
                      int /*<<< orphan*/);
int /*<<< orphan*/ memset(unsigned char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ sprintf(char *, char *);
int /*<<< orphan*/ strlen(char *);
int /*<<< orphan*/ writeError(int, char *, char *);
int terminateConnection(int hSocket) {
  unsigned char bufSend[300];
  memset(bufSend, 0, sizeof(bufSend));
  sprintf((char *)bufSend, "QUIT\r\n");
  if (medusaSend(hSocket, bufSend, strlen((char *)bufSend), 0) < 0) {
    writeError(3, "[%s] failed: medusaSend was not successful", "nntp.mod");
  }
  medusaDisconnect(hSocket);
  return 0;
}


x86 assembly (clang, -O0):
<terminateConnection>:
push   %rbp
mov    %rsp,%rbp
sub    $0x140,%rsp
mov    %edi,-0x4(%rbp)
lea    -0x130(%rbp),%rdi
xor    %esi,%esi
mov    $0x12c,%edx
call   1040 <memset@plt>
lea    -0x130(%rbp),%rdi
lea    0xe71(%rip),%rsi
call   1070 <sprintf@plt>
mov    -0x4(%rbp),%eax
mov    %eax,-0x13c(%rbp)
lea    -0x130(%rbp),%rax
mov    %rax,-0x138(%rbp)
lea    -0x130(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x13c(%rbp),%edi
mov    -0x138(%rbp),%rsi
mov    %eax,%edx
xor    %ecx,%ecx
call   1080 <medusaSend@plt>
cmp    $0x0,%rax
jge    11ef <terminateConnection+0x8f>
mov    $0x3,%edi
lea    0xe24(%rip),%rsi
lea    0xe48(%rip),%rdx
call   1050 <writeError@plt>
mov    -0x4(%rbp),%edi
call   1060 <medusaDisconnect@plt>
xor    %eax,%eax
add    $0x140,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<terminateConnection>:
push   %rbp
push   %rbx
sub    $0x138,%rsp
mov    %edi,%ebp
mov    %rsp,%rbx
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x12c,%edx
call   1040 <memset@plt>
movl   $0x54495551,(%rsp)
movl   $0xa0d54,0x3(%rsp)
mov    %rbx,%rdi
call   1030 <strlen@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %eax,%edx
xor    %ecx,%ecx
call   1070 <medusaSend@plt>
test   %rax,%rax
jns    11af <terminateConnection+0x5f>
lea    0xe69(%rip),%rsi
lea    0xe8d(%rip),%rdx
mov    $0x3,%edi
call   1050 <writeError@plt>
mov    %ebp,%edi
call   1060 <medusaDisconnect@plt>
xor    %eax,%eax
add    $0x138,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [7 x i8] c"QUIT\0D\0A\00"
@.str.1 = [43 x i8] c"[%s] failed: medusaSend was not successful\00"
@.str.2 = [9 x i8] c"nntp.mod\00"
define i32 @terminateConnection(i32 %0) {
%2 = alloca i32
%3 = alloca [300 x i8]
store i32 %0, i32* %2
%4 = getelementptr inbounds [300 x i8], [300 x i8]* %3, i64 0, i64 0
%5 = call i32 @memset(i8* %4, i32 0, i32 300)
%6 = getelementptr inbounds [300 x i8], [300 x i8]* %3, i64 0, i64 0
%7 = call i32 @sprintf(i8* %6, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%8 = load i32, i32* %2
%9 = getelementptr inbounds [300 x i8], [300 x i8]* %3, i64 0, i64 0
%10 = getelementptr inbounds [300 x i8], [300 x i8]* %3, i64 0, i64 0
%11 = call i32 @strlen(i8* %10)
%12 = call i64 @medusaSend(i32 %8, i8* %9, i32 %11, i32 0)
%13 = icmp slt i64 %12, 0
br i1 %13, label %14, label %16
14: ; preds = %1
%15 = call i32 @writeError(i32 3, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
br label %16
16: ; preds = %14, %1
%17 = load i32, i32* %2
%18 = call i32 @medusaDisconnect(i32 %17)
ret i32 0
}

LLVM IR (-O2):
@.str = [7 x i8] c"QUIT\0D\0A\00"
@.str.1 = [43 x i8] c"[%s] failed: medusaSend was not successful\00"
@.str.2 = [9 x i8] c"nntp.mod\00"
define i32 @terminateConnection(i32 %0) {
%2 = alloca [300 x i8]
%3 = getelementptr inbounds [300 x i8], [300 x i8]* %2, i64 0, i64 0
%4 = call i32 @memset(i8* %3, i32 0, i32 300)
%5 = call i32 @strlen(i8* %3)
%6 = call i64 @medusaSend(i32 %0, i8* %3, i32 %5, i32 0)
%7 = icmp slt i64 %6, 0
br i1 %7, label %8, label %10
8: ; preds = %1
%9 = call i32 @writeError(i32 3, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.2, i64 0, i64 0))
br label %10
10: ; preds = %8, %1
%11 = call i32 @medusaDisconnect(i32 %0)
ret i32 0
}