#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 */
struct sockaddr_storage {
  int dummy;
};
struct sockaddr_in {
  int dummy;
};
typedef int /*<<< orphan*/ addrs;

/* Variables and functions */
int /*<<< orphan*/ bcopy(struct sockaddr_in *, struct sockaddr_storage *, int);
int sysctlbyname(char *, int /*<<< orphan*/ *, int /*<<< orphan*/,
                 struct sockaddr_storage *, int);
int tcp_drop(struct sockaddr_in *sin_local, struct sockaddr_in *sin_remote) {
  struct sockaddr_storage addrs[2];
  bcopy(sin_remote, &addrs[0], sizeof(*sin_remote));
  bcopy(sin_local, &addrs[1], sizeof(*sin_local));
  return (sysctlbyname("net.inet.tcp.drop", NULL, 0, addrs, sizeof(addrs)));
}


x86 assembly (clang, -O0):
<tcp_drop>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x18(%rbp),%rsi
mov    $0x4,%edx
call   1030 <bcopy@plt>
mov    -0x8(%rbp),%rdi
lea    -0x18(%rbp),%rsi
add    $0x4,%rsi
mov    $0x4,%edx
call   1030 <bcopy@plt>
lea    -0x18(%rbp),%rcx
lea    0xe9d(%rip),%rdi
xor    %eax,%eax
mov    %eax,%esi
xor    %edx,%edx
mov    $0x8,%r8d
call   1040 <sysctlbyname@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<tcp_drop>:
push   %rax
mov    (%rsi),%eax
mov    %eax,(%rsp)
mov    (%rdi),%eax
mov    %eax,0x4(%rsp)
lea    0xedd(%rip),%rdi
mov    %rsp,%rcx
xor    %esi,%esi
xor    %edx,%edx
mov    $0x8,%r8d
call   1030 <sysctlbyname@plt>
pop    %rcx
ret

LLVM IR (-O0):
%struct.sockaddr_in = type { i32 }
%struct.sockaddr_storage = type { i32 }
@.str = [18 x i8] c"net.inet.tcp.drop\00"
define i32 @tcp_drop(%struct.sockaddr_in* %0, %struct.sockaddr_in* %1) {
%3 = alloca %struct.sockaddr_in*
%4 = alloca %struct.sockaddr_in*
%5 = alloca [2 x %struct.sockaddr_storage]
store %struct.sockaddr_in* %0, %struct.sockaddr_in** %3
store %struct.sockaddr_in* %1, %struct.sockaddr_in** %4
%6 = load %struct.sockaddr_in*, %struct.sockaddr_in** %4
%7 = getelementptr inbounds [2 x %struct.sockaddr_storage], [2 x %struct.sockaddr_storage]* %5, i64 0, i64 0
%8 = call i32 @bcopy(%struct.sockaddr_in* %6, %struct.sockaddr_storage* %7, i32 4)
%9 = load %struct.sockaddr_in*, %struct.sockaddr_in** %3
%10 = getelementptr inbounds [2 x %struct.sockaddr_storage], [2 x %struct.sockaddr_storage]* %5, i64 0, i64 1
%11 = call i32 @bcopy(%struct.sockaddr_in* %9, %struct.sockaddr_storage* %10, i32 4)
%12 = getelementptr inbounds [2 x %struct.sockaddr_storage], [2 x %struct.sockaddr_storage]* %5, i64 0, i64 0
%13 = call i32 @sysctlbyname(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i32* null, i32 0, %struct.sockaddr_storage* %12, i32 8)
ret i32 %13
}

LLVM IR (-O2):
%struct.sockaddr_in = type { i32 }
%struct.sockaddr_storage = type { i32 }
@.str = [18 x i8] c"net.inet.tcp.drop\00"
define i32 @tcp_drop(%struct.sockaddr_in* nocapture %0, %struct.sockaddr_in* nocapture %1) {
%3 = alloca [2 x %struct.sockaddr_storage]
%4 = bitcast [2 x %struct.sockaddr_storage]* %3 to i8*
%5 = getelementptr inbounds [2 x %struct.sockaddr_storage], [2 x %struct.sockaddr_storage]* %3, i64 0, i64 0
%6 = getelementptr %struct.sockaddr_in, %struct.sockaddr_in* %1, i64 0, i32 0
%7 = getelementptr inbounds [2 x %struct.sockaddr_storage], [2 x %struct.sockaddr_storage]* %3, i64 0, i64 0, i32 0
%8 = load i32, i32* %6
store i32 %8, i32* %7
%9 = getelementptr %struct.sockaddr_in, %struct.sockaddr_in* %0, i64 0, i32 0
%10 = getelementptr inbounds [2 x %struct.sockaddr_storage], [2 x %struct.sockaddr_storage]* %3, i64 0, i64 1, i32 0
%11 = load i32, i32* %9
store i32 %11, i32* %10
%12 = call i32 @sysctlbyname(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i32* null, i32 0, %struct.sockaddr_storage* %5, i32 8)
ret i32 %12
}