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

/* Variables and functions */
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ recvSync(int, char *, char **);
int /*<<< orphan*/ sendServer(int, char *, int /*<<< orphan*/);
int /*<<< orphan*/ snprintf(char *, int, char *);
int /*<<< orphan*/ strlen(char *);
void disconnectServer(int sockfd) {
  char string[8];
  char *ptr;
  snprintf(string, sizeof(string), "quit\n");
  sendServer(sockfd, string, strlen(string));
  recvSync(sockfd, "good bye!\n", &ptr);
  free(ptr);
  close(sockfd);
}


x86 assembly (clang, -O0):
<disconnectServer>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
lea    -0xc(%rbp),%rdi
mov    $0x8,%esi
lea    0xe85(%rip),%rdx
call   1060 <snprintf@plt>
mov    -0x4(%rbp),%eax
mov    %eax,-0x24(%rbp)
lea    -0xc(%rbp),%rax
mov    %rax,-0x20(%rbp)
lea    -0xc(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0x24(%rbp),%edi
mov    -0x20(%rbp),%rsi
mov    %eax,%edx
call   1040 <sendServer@plt>
mov    -0x4(%rbp),%edi
lea    0xe57(%rip),%rsi
lea    -0x18(%rbp),%rdx
call   1080 <recvSync@plt>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
mov    -0x4(%rbp),%edi
call   1070 <close@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<disconnectServer>:
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %edi,%ebx
lea    0xe90(%rip),%rdx
lea    0x10(%rsp),%r14
mov    %r14,%rdi
mov    $0x8,%esi
call   1060 <snprintf@plt>
mov    %r14,%rdi
call   1050 <strlen@plt>
mov    %ebx,%edi
mov    %r14,%rsi
mov    %eax,%edx
call   1040 <sendServer@plt>
lea    0xe69(%rip),%rsi
lea    0x8(%rsp),%rdx
mov    %ebx,%edi
call   1080 <recvSync@plt>
mov    0x8(%rsp),%rdi
call   1030 <free@plt>
mov    %ebx,%edi
call   1070 <close@plt>
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [6 x i8] c"quit\0A\00"
@.str.1 = [11 x i8] c"good bye!\0A\00"
define void @disconnectServer(i32 %0) {
%2 = alloca i32
%3 = alloca [8 x i8]
%4 = alloca i8*
store i32 %0, i32* %2
%5 = getelementptr inbounds [8 x i8], [8 x i8]* %3, i64 0, i64 0
%6 = call i32 @snprintf(i8* %5, i32 8, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%7 = load i32, i32* %2
%8 = getelementptr inbounds [8 x i8], [8 x i8]* %3, i64 0, i64 0
%9 = getelementptr inbounds [8 x i8], [8 x i8]* %3, i64 0, i64 0
%10 = call i32 @strlen(i8* %9)
%11 = call i32 @sendServer(i32 %7, i8* %8, i32 %10)
%12 = load i32, i32* %2
%13 = call i32 @recvSync(i32 %12, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i8** %4)
%14 = load i8*, i8** %4
%15 = call i32 @free(i8* %14)
%16 = load i32, i32* %2
%17 = call i32 @close(i32 %16)
ret void
}

LLVM IR (-O2):
@.str = [6 x i8] c"quit\0A\00"
@.str.1 = [11 x i8] c"good bye!\0A\00"
define void @disconnectServer(i32 %0) {
%2 = alloca [8 x i8]
%3 = alloca i8*
%4 = getelementptr inbounds [8 x i8], [8 x i8]* %2, i64 0, i64 0
%5 = bitcast i8** %3 to i8*
%6 = call i32 @snprintf(i8* %4, i32 8, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%7 = call i32 @strlen(i8* %4)
%8 = call i32 @sendServer(i32 %0, i8* %4, i32 %7)
%9 = call i32 @recvSync(i32 %0, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i8** %3)
%10 = load i8*, i8** %3
%11 = call i32 @free(i8* %10)
%12 = call i32 @close(i32 %0)
ret void
}