int connect_tracker(int *sockfd, long int *connection_id) {
  char *packet = malloc(16);
  int action = htonl(0), num;
  int transaction_id = htonl(8388608);
  memcpy(packet, connection_id, 8);
  memcpy(packet + 8, &action, 4);
  memcpy(packet + 12, &transaction_id, 4);
  if (send(*sockfd, packet, 16, 0) == 16) {
    if ((num = recv(*sockfd, packet, 16, 0)) == 16) {
      memcpy(&action, packet, 4);
      memcpy(&transaction_id, packet + 4, 4);
      memcpy(connection_id, packet + 8, 8);
    }
  }
  free(packet);
  return htonl(action);
}


x86 assembly (clang, -O0):
<connect_tracker>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x10,%edi
call   1070 <malloc@plt>
mov    %rax,-0x18(%rbp)
xor    %edi,%edi
mov    $0x0,%al
call   1060 <htonl@plt>
mov    %eax,-0x1c(%rbp)
mov    $0x800000,%edi
mov    $0x0,%al
call   1060 <htonl@plt>
mov    %eax,-0x24(%rbp)
mov    -0x18(%rbp),%rax
mov    -0x10(%rbp),%rcx
mov    (%rcx),%rcx
mov    %rcx,(%rax)
mov    -0x18(%rbp),%rax
mov    -0x1c(%rbp),%ecx
mov    %ecx,0x8(%rax)
mov    -0x18(%rbp),%rax
mov    -0x24(%rbp),%ecx
mov    %ecx,0xc(%rax)
mov    -0x8(%rbp),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%rsi
mov    $0x10,%edx
xor    %ecx,%ecx
mov    $0x0,%al
call   1050 <send@plt>
cmp    $0x10,%eax
jne    1217 <connect_tracker+0xc7>
mov    -0x8(%rbp),%rax
mov    (%rax),%edi
mov    -0x18(%rbp),%rsi
mov    $0x10,%edx
xor    %ecx,%ecx
mov    $0x0,%al
call   1040 <recv@plt>
mov    %eax,-0x20(%rbp)
cmp    $0x10,%eax
jne    1212 <connect_tracker+0xc2>
mov    -0x18(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%rax
mov    0x4(%rax),%eax
mov    %eax,-0x24(%rbp)
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%rcx
mov    0x8(%rcx),%rcx
mov    %rcx,(%rax)
jmp    1217 <connect_tracker+0xc7>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
mov    -0x1c(%rbp),%edi
mov    $0x0,%al
call   1060 <htonl@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<connect_tracker>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%r15
mov    $0x10,%edi
call   1070 <malloc@plt>
mov    %rax,%rbx
xor    %edi,%edi
xor    %eax,%eax
call   1060 <htonl@plt>
mov    %eax,%ebp
mov    $0x800000,%edi
xor    %eax,%eax
call   1060 <htonl@plt>
mov    (%r14),%rcx
mov    %rcx,(%rbx)
mov    %ebp,0x8(%rbx)
mov    %eax,0xc(%rbx)
mov    (%r15),%edi
mov    %rbx,%rsi
mov    $0x10,%edx
xor    %ecx,%ecx
xor    %eax,%eax
call   1050 <send@plt>
cmp    $0x10,%eax
jne    11c8 <connect_tracker+0x78>
mov    (%r15),%edi
mov    %rbx,%rsi
mov    $0x10,%edx
xor    %ecx,%ecx
xor    %eax,%eax
call   1040 <recv@plt>
cmp    $0x10,%eax
jne    11c8 <connect_tracker+0x78>
mov    (%rbx),%ebp
mov    0x8(%rbx),%rax
mov    %rax,(%r14)
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %ebp,%edi
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1060 <htonl@plt>

LLVM IR (-O0):
define i32 @connect_tracker(i32* %0, i64* %1) {
%3 = alloca i32*
%4 = alloca i64*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32* %0, i32** %3
store i64* %1, i64** %4
%9 = call i8* @malloc(i64 16)
store i8* %9, i8** %5
%10 = call i32 (i32, ...) bitcast (i32 (...)* @htonl to i32 (i32, ...)*)(i32 0)
store i32 %10, i32* %6
%11 = call i32 (i32, ...) bitcast (i32 (...)* @htonl to i32 (i32, ...)*)(i32 8388608)
store i32 %11, i32* %8
%12 = load i8*, i8** %5
%13 = load i64*, i64** %4
%14 = bitcast i64* %13 to i8*
%15 = load i8*, i8** %5
%16 = getelementptr inbounds i8, i8* %15, i64 8
%17 = bitcast i32* %6 to i8*
%18 = load i8*, i8** %5
%19 = getelementptr inbounds i8, i8* %18, i64 12
%20 = bitcast i32* %8 to i8*
%21 = load i32*, i32** %3
%22 = load i32, i32* %21
%23 = load i8*, i8** %5
%24 = call i32 (i32, i8*, i32, i32, ...) bitcast (i32 (...)* @send to i32 (i32, i8*, i32, i32, ...)*)(i32 %22, i8* %23, i32 16, i32 0)
%25 = icmp eq i32 %24, 16
br i1 %25, label %26, label %43
26: ; preds = %2
%27 = load i32*, i32** %3
%28 = load i32, i32* %27
%29 = load i8*, i8** %5
%30 = call i32 (i32, i8*, i32, i32, ...) bitcast (i32 (...)* @recv to i32 (i32, i8*, i32, i32, ...)*)(i32 %28, i8* %29, i32 16, i32 0)
store i32 %30, i32* %7
%31 = icmp eq i32 %30, 16
br i1 %31, label %32, label %42
32: ; preds = %26
%33 = bitcast i32* %6 to i8*
%34 = load i8*, i8** %5
%35 = bitcast i32* %8 to i8*
%36 = load i8*, i8** %5
%37 = getelementptr inbounds i8, i8* %36, i64 4
%38 = load i64*, i64** %4
%39 = bitcast i64* %38 to i8*
%40 = load i8*, i8** %5
%41 = getelementptr inbounds i8, i8* %40, i64 8
br label %42
42: ; preds = %32, %26
br label %43
43: ; preds = %42, %2
%44 = load i8*, i8** %5
%45 = load i32, i32* %6
%46 = call i32 (i32, ...) bitcast (i32 (...)* @htonl to i32 (i32, ...)*)(i32 %45)
ret i32 %46
}

LLVM IR (-O2):
define i32 @connect_tracker(i32* nocapture %0, i64* nocapture %1) {
%3 = tail call dereferenceable_or_null(16) i8* @malloc(i64 16)
%4 = tail call i32 (i32, ...) bitcast (i32 (...)* @htonl to i32 (i32, ...)*)(i32 0)
%5 = tail call i32 (i32, ...) bitcast (i32 (...)* @htonl to i32 (i32, ...)*)(i32 8388608)
%6 = bitcast i8* %3 to i64*
%7 = load i64, i64* %1
store i64 %7, i64* %6
%8 = getelementptr inbounds i8, i8* %3, i64 8
%9 = bitcast i8* %8 to i32*
store i32 %4, i32* %9
%10 = getelementptr inbounds i8, i8* %3, i64 12
%11 = bitcast i8* %10 to i32*
store i32 %5, i32* %11
%12 = load i32, i32* %0
%13 = tail call i32 (i32, i8*, i32, i32, ...) bitcast (i32 (...)* @send to i32 (i32, i8*, i32, i32, ...)*)(i32 %12, i8* %3, i32 16, i32 0)
%14 = icmp eq i32 %13, 16
br i1 %14, label %15, label %24
15: ; preds = %2
%16 = load i32, i32* %0
%17 = tail call i32 (i32, i8*, i32, i32, ...) bitcast (i32 (...)* @recv to i32 (i32, i8*, i32, i32, ...)*)(i32 %16, i8* %3, i32 16, i32 0)
%18 = icmp eq i32 %17, 16
br i1 %18, label %19, label %24
19: ; preds = %15
%20 = bitcast i8* %3 to i32*
%21 = load i32, i32* %20
%22 = bitcast i8* %8 to i64*
%23 = load i64, i64* %22
store i64 %23, i64* %1
br label %24
24: ; preds = %15, %19, %2
%25 = phi i32 [ %21, %19 ], [ %4, %15 ], [ %4, %2 ]
tail call void @free(i8* %3)
%26 = tail call i32 (i32, ...) bitcast (i32 (...)* @htonl to i32 (i32, ...)*)(i32 %25)
ret i32 %26
}