#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 */
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ shutdown(int, int /*<<< orphan*/);
int /*<<< orphan*/ sprintf(char *, char *, ...);
int /*<<< orphan*/ strcat(char *, char *);
int /*<<< orphan*/ system(char *);
void RTkillsocket(int socket, int pid) {
  char killcall[20];
  char process[5];
  shutdown(socket, 0);
  sprintf(killcall, "kill ");
  sprintf(process, "%i", pid);
  strcat(killcall, process);
  system(killcall);
  close(socket);
}


x86 assembly (clang, -O0):
<RTkillsocket>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    -0x4(%rbp),%edi
xor    %esi,%esi
call   1030 <shutdown@plt>
lea    -0x20(%rbp),%rdi
lea    0xe8d(%rip),%rsi
mov    $0x0,%al
call   1070 <sprintf@plt>
lea    -0x25(%rbp),%rdi
mov    -0x8(%rbp),%edx
lea    0xe7e(%rip),%rsi
mov    $0x0,%al
call   1070 <sprintf@plt>
lea    -0x20(%rbp),%rdi
lea    -0x25(%rbp),%rsi
call   1060 <strcat@plt>
lea    -0x20(%rbp),%rdi
call   1040 <system@plt>
mov    -0x4(%rbp),%edi
call   1050 <close@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<RTkillsocket>:
push   %rbp
push   %r14
push   %rbx
sub    $0x30,%rsp
mov    %esi,%ebx
mov    %edi,%ebp
xor    %esi,%esi
call   1030 <shutdown@plt>
movl   $0x6c6c696b,0x10(%rsp)
6c
movw   $0x20,0x14(%rsp)
lea    0xe8d(%rip),%rsi
lea    0xb(%rsp),%r14
mov    %r14,%rdi
mov    %ebx,%edx
xor    %eax,%eax
call   1070 <sprintf@plt>
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
mov    %r14,%rsi
call   1060 <strcat@plt>
mov    %rbx,%rdi
call   1040 <system@plt>
mov    %ebp,%edi
call   1050 <close@plt>
add    $0x30,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [6 x i8] c"kill \00"
@.str.1 = [3 x i8] c"%i\00"
define void @RTkillsocket(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca [20 x i8]
%6 = alloca [5 x i8]
store i32 %0, i32* %3
store i32 %1, i32* %4
%7 = load i32, i32* %3
%8 = call i32 @shutdown(i32 %7, i32 0)
%9 = getelementptr inbounds [20 x i8], [20 x i8]* %5, i64 0, i64 0
%10 = call i32 (i8*, i8*, ...) @sprintf(i8* %9, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%11 = getelementptr inbounds [5 x i8], [5 x i8]* %6, i64 0, i64 0
%12 = load i32, i32* %4
%13 = call i32 (i8*, i8*, ...) @sprintf(i8* %11, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %12)
%14 = getelementptr inbounds [20 x i8], [20 x i8]* %5, i64 0, i64 0
%15 = getelementptr inbounds [5 x i8], [5 x i8]* %6, i64 0, i64 0
%16 = call i32 @strcat(i8* %14, i8* %15)
%17 = getelementptr inbounds [20 x i8], [20 x i8]* %5, i64 0, i64 0
%18 = call i32 @system(i8* %17)
%19 = load i32, i32* %3
%20 = call i32 @close(i32 %19)
ret void
}

LLVM IR (-O2):
@.str = [6 x i8] c"kill \00"
@.str.1 = [3 x i8] c"%i\00"
define void @RTkillsocket(i32 %0, i32 %1) {
%3 = alloca [20 x i8]
%4 = alloca [5 x i8]
%5 = getelementptr inbounds [20 x i8], [20 x i8]* %3, i64 0, i64 0
%6 = getelementptr inbounds [5 x i8], [5 x i8]* %4, i64 0, i64 0
%7 = tail call i32 @shutdown(i32 %0, i32 0)
%8 = call i32 (i8*, i8*, ...) @sprintf(i8* %6, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %1)
%9 = call i32 @strcat(i8* %5, i8* %6)
%10 = call i32 @system(i8* %5)
%11 = call i32 @close(i32 %0)
ret void
}