#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 udphdr {
  scalar_t__ check;
  void *len;
  void *dest;
  void *source;
};

/* Variables and functions */
void *htons(int);
int /*<<< orphan*/ memset(struct udphdr *, char, int);
void init_udphdr(struct udphdr *udp, int src, int dest, int len) {
  udp->source = htons(src);
  udp->dest = htons(dest);
  udp->len = htons(len);
  udp->check = 0;
  memset(udp + 8, 'a', len - 8);
}


x86 assembly (clang, -O0):
<init_udphdr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
mov    -0xc(%rbp),%edi
call   1030 <htons@plt>
mov    %rax,%rcx
mov    -0x8(%rbp),%rax
mov    %rcx,0x18(%rax)
mov    -0x10(%rbp),%edi
call   1030 <htons@plt>
mov    %rax,%rcx
mov    -0x8(%rbp),%rax
mov    %rcx,0x10(%rax)
mov    -0x14(%rbp),%edi
call   1030 <htons@plt>
mov    %rax,%rcx
mov    -0x8(%rbp),%rax
mov    %rcx,0x8(%rax)
mov    -0x8(%rbp),%rax
movq   $0x0,(%rax)
mov    -0x8(%rbp),%rdi
add    $0x100,%rdi
mov    -0x14(%rbp),%edx
sub    $0x8,%edx
mov    $0x61,%esi
call   1040 <memset@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<init_udphdr>:
push   %rbp
push   %r14
push   %rbx
mov    %ecx,%ebx
mov    %edx,%r14d
mov    %rdi,%rbp
mov    %esi,%edi
call   1030 <htons@plt>
mov    %rax,0x18(%rbp)
mov    %r14d,%edi
call   1030 <htons@plt>
mov    %rax,0x10(%rbp)
mov    %ebx,%edi
call   1030 <htons@plt>
mov    %rax,0x8(%rbp)
movq   $0x0,0x0(%rbp)
add    $0x100,%rbp
add    $0xfffffff8,%ebx
mov    %rbp,%rdi
mov    $0x61,%esi
mov    %ebx,%edx
pop    %rbx
pop    %r14
pop    %rbp
jmp    1040 <memset@plt>

LLVM IR (-O0):
%struct.udphdr = type { i64, i8*, i8*, i8* }
define void @init_udphdr(%struct.udphdr* %0, i32 %1, i32 %2, i32 %3) {
%5 = alloca %struct.udphdr*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store %struct.udphdr* %0, %struct.udphdr** %5
store i32 %1, i32* %6
store i32 %2, i32* %7
store i32 %3, i32* %8
%9 = load i32, i32* %6
%10 = call i8* @htons(i32 %9)
%11 = load %struct.udphdr*, %struct.udphdr** %5
%12 = getelementptr inbounds %struct.udphdr, %struct.udphdr* %11, i32 0, i32 3
store i8* %10, i8** %12
%13 = load i32, i32* %7
%14 = call i8* @htons(i32 %13)
%15 = load %struct.udphdr*, %struct.udphdr** %5
%16 = getelementptr inbounds %struct.udphdr, %struct.udphdr* %15, i32 0, i32 2
store i8* %14, i8** %16
%17 = load i32, i32* %8
%18 = call i8* @htons(i32 %17)
%19 = load %struct.udphdr*, %struct.udphdr** %5
%20 = getelementptr inbounds %struct.udphdr, %struct.udphdr* %19, i32 0, i32 1
store i8* %18, i8** %20
%21 = load %struct.udphdr*, %struct.udphdr** %5
%22 = getelementptr inbounds %struct.udphdr, %struct.udphdr* %21, i32 0, i32 0
store i64 0, i64* %22
%23 = load %struct.udphdr*, %struct.udphdr** %5
%24 = getelementptr inbounds %struct.udphdr, %struct.udphdr* %23, i64 8
%25 = load i32, i32* %8
%26 = sub nsw i32 %25, 8
%27 = call i32 @memset(%struct.udphdr* %24, i8 signext 97, i32 %26)
ret void
}

LLVM IR (-O2):
%struct.udphdr = type { i64, i8*, i8*, i8* }
define void @init_udphdr(%struct.udphdr* %0, i32 %1, i32 %2, i32 %3) {
%5 = tail call i8* @htons(i32 %1)
%6 = getelementptr inbounds %struct.udphdr, %struct.udphdr* %0, i64 0, i32 3
store i8* %5, i8** %6
%7 = tail call i8* @htons(i32 %2)
%8 = getelementptr inbounds %struct.udphdr, %struct.udphdr* %0, i64 0, i32 2
store i8* %7, i8** %8
%9 = tail call i8* @htons(i32 %3)
%10 = getelementptr inbounds %struct.udphdr, %struct.udphdr* %0, i64 0, i32 1
store i8* %9, i8** %10
%11 = getelementptr inbounds %struct.udphdr, %struct.udphdr* %0, i64 0, i32 0
store i64 0, i64* %11
%12 = getelementptr inbounds %struct.udphdr, %struct.udphdr* %0, i64 8
%13 = add nsw i32 %3, -8
%14 = tail call i32 @memset(%struct.udphdr* %12, i8 signext 97, i32 %13)
ret void
}