#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*/ __u16;
typedef int /*<<< orphan*/ __be32;

/* Variables and functions */
int ETH_ALEN;
char *hw2str(char *);
char *ip2str(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
scalar_t__ recv_arp(int *, int /*<<< orphan*/ *, int /*<<< orphan*/ *,
                    int /*<<< orphan*/ *, char *, int /*<<< orphan*/ *, char *);
void process_arp(void) {
  int ifindex;
  __u16 type, op;
  __be32 sip, tip;
  char sha[ETH_ALEN], tha[ETH_ALEN];
  if (recv_arp(&ifindex, &type, &op, &sip, sha, &tip, tha) < 0)
    return;
  printf("rcvd if %d type %hd op %hd\n", ifindex, type, op);
  printf("  sender hw %s ip %s\n", hw2str(sha), ip2str(sip));
  printf("  target hw %s ip %s\n", hw2str(tha), ip2str(tip));
}


x86 assembly (clang, -O0):
<process_arp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    0x2e99(%rip),%rax
mov    (%rax),%ecx
mov    %rsp,%rdx
mov    %rdx,-0x20(%rbp)
mov    %rcx,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%r8
sub    %rdx,%r8
mov    %r8,-0x48(%rbp)
mov    %r8,%rsp
mov    %rcx,-0x28(%rbp)
mov    (%rax),%eax
mov    %eax,%ecx
mov    %rcx,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rax
sub    %rdx,%rax
mov    %rax,-0x40(%rbp)
mov    %rax,%rsp
mov    %rcx,-0x30(%rbp)
lea    -0x4(%rbp),%rdi
lea    -0x8(%rbp),%rsi
lea    -0xc(%rbp),%rdx
lea    -0x10(%rbp),%rcx
lea    -0x14(%rbp),%r9
sub    $0x10,%rsp
mov    %rax,(%rsp)
call   1050 <recv_arp@plt>
add    $0x10,%rsp
cmp    $0x0,%rax
jge    11cf <process_arp+0x8f>
movl   $0x1,-0x34(%rbp)
jmp    1241 <process_arp+0x101>
mov    -0x4(%rbp),%esi
mov    -0x8(%rbp),%edx
mov    -0xc(%rbp),%ecx
lea    0xe21(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x48(%rbp),%rdi
call   1060 <hw2str@plt>
mov    %rax,-0x58(%rbp)
mov    -0x10(%rbp),%edi
call   1040 <ip2str@plt>
mov    -0x58(%rbp),%rsi
mov    %rax,%rdx
lea    0xe13(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x40(%rbp),%rdi
call   1060 <hw2str@plt>
mov    %rax,-0x50(%rbp)
mov    -0x14(%rbp),%edi
call   1040 <ip2str@plt>
mov    -0x50(%rbp),%rsi
mov    %rax,%rdx
lea    0xdff(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x34(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<process_arp>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %rsp,%r15
mov    0x2e91(%rip),%rax
mov    (%rax),%ecx
mov    %rsp,%rbx
add    $0xf,%rcx
and    $0xfffffffffffffff0,%rcx
sub    %rcx,%rbx
mov    %rbx,%rsp
mov    (%rax),%eax
mov    %rsp,%r14
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r14
mov    %r14,%rsp
sub    $0x8,%rsp
lea    -0x2c(%rbp),%rdi
lea    -0x28(%rbp),%rsi
lea    -0x24(%rbp),%rdx
lea    -0x20(%rbp),%rcx
lea    -0x1c(%rbp),%r9
mov    %rbx,%r8
push   %r14
call   1050 <recv_arp@plt>
add    $0x10,%rsp
test   %rax,%rax
js     120d <process_arp+0xcd>
mov    -0x2c(%rbp),%esi
mov    -0x28(%rbp),%edx
mov    -0x24(%rbp),%ecx
lea    0xe48(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %rbx,%rdi
call   1060 <hw2str@plt>
mov    %rax,%rbx
mov    -0x20(%rbp),%edi
call   1040 <ip2str@plt>
lea    0xe43(%rip),%rdi
mov    %rbx,%rsi
mov    %rax,%rdx
xor    %eax,%eax
call   1030 <printf@plt>
mov    %r14,%rdi
call   1060 <hw2str@plt>
mov    %rax,%rbx
mov    -0x1c(%rbp),%edi
call   1040 <ip2str@plt>
lea    0xe32(%rip),%rdi
mov    %rbx,%rsi
mov    %rax,%rdx
xor    %eax,%eax
call   1030 <printf@plt>
mov    %r15,%rsp
lea    -0x18(%rbp),%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@ETH_ALEN = global i32 0
@.str = [28 x i8] c"rcvd if %d type %hd op %hd\0A\00"
@.str.1 = [22 x i8] c" sender hw %s ip %s\0A\00"
@.str.2 = [22 x i8] c" target hw %s ip %s\0A\00"
define void @process_arp() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i64
%8 = alloca i64
%9 = alloca i32
%10 = load i32, i32* @ETH_ALEN
%11 = zext i32 %10 to i64
%12 = call i8* @llvm.stacksave()
store i8* %12, i8** %6
%13 = alloca i8, i64 %11
store i64 %11, i64* %7
%14 = load i32, i32* @ETH_ALEN
%15 = zext i32 %14 to i64
%16 = alloca i8, i64 %15
store i64 %15, i64* %8
%17 = call i64 @recv_arp(i32* %1, i32* %2, i32* %3, i32* %4, i8* %13, i32* %5, i8* %16)
%18 = icmp slt i64 %17, 0
br i1 %18, label %19, label %20
19: ; preds = %0
store i32 1, i32* %9
br label %33
20: ; preds = %0
%21 = load i32, i32* %1
%22 = load i32, i32* %2
%23 = load i32, i32* %3
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), i32 %21, i32 %22, i32 %23)
%25 = call i8* @hw2str(i8* %13)
%26 = load i32, i32* %4
%27 = call i8* @ip2str(i32 %26)
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i8* %25, i8* %27)
%29 = call i8* @hw2str(i8* %16)
%30 = load i32, i32* %5
%31 = call i8* @ip2str(i32 %30)
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0), i8* %29, i8* %31)
store i32 0, i32* %9
br label %33
33: ; preds = %20, %19
%34 = load i8*, i8** %6
%35 = load i32, i32* %9
switch i32 %35, label %37 [
i32 0, label %36
i32 1, label %36
]
36: ; preds = %33, %33
ret void
37: ; preds = %33
unreachable
}

LLVM IR (-O2):
@ETH_ALEN = global i32 0
@.str = [28 x i8] c"rcvd if %d type %hd op %hd\0A\00"
@.str.1 = [22 x i8] c" sender hw %s ip %s\0A\00"
@.str.2 = [22 x i8] c" target hw %s ip %s\0A\00"
define void @process_arp() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = bitcast i32* %1 to i8*
%7 = bitcast i32* %2 to i8*
%8 = bitcast i32* %3 to i8*
%9 = bitcast i32* %4 to i8*
%10 = bitcast i32* %5 to i8*
%11 = load i32, i32* @ETH_ALEN
%12 = zext i32 %11 to i64
%13 = tail call i8* @llvm.stacksave()
%14 = alloca i8, i64 %12
%15 = load i32, i32* @ETH_ALEN
%16 = zext i32 %15 to i64
%17 = alloca i8, i64 %16
%18 = call i64 @recv_arp(i32* %1, i32* %2, i32* %3, i32* %4, i8* %14, i32* %5, i8* %17)
%19 = icmp slt i64 %18, 0
br i1 %19, label %33, label %20
20: ; preds = %0
%21 = load i32, i32* %1
%22 = load i32, i32* %2
%23 = load i32, i32* %3
%24 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), i32 %21, i32 %22, i32 %23)
%25 = call i8* @hw2str(i8* %14)
%26 = load i32, i32* %4
%27 = call i8* @ip2str(i32 %26)
%28 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i8* %25, i8* %27)
%29 = call i8* @hw2str(i8* %17)
%30 = load i32, i32* %5
%31 = call i8* @ip2str(i32 %30)
%32 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0), i8* %29, i8* %31)
br label %33
33: ; preds = %0, %20
ret void
}