#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 {
  int /*<<< orphan*/ len;
  int /*<<< orphan*/ dest;
  int /*<<< orphan*/ source;
};

/* Variables and functions */
int ntohs(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
void printUdpHeader(struct udphdr *udphdr) {
  printf("\n\n/********** UDP HEADER **********/\n");
  printf("udphdr.source = %d\n", ntohs(udphdr->source));
  printf("udphdr.dest = %d\n", ntohs(udphdr->dest));
  printf("udphdr.len = %d\n", ntohs(udphdr->len));
  printf("/***************************/\n\n");
}


x86 assembly (clang, -O0):
<printUdpHeader>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
lea    0xecd(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%edi
call   1040 <ntohs@plt>
mov    %eax,%esi
lea    0xed7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%rax
mov    0x4(%rax),%edi
call   1040 <ntohs@plt>
mov    %eax,%esi
lea    0xecf(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%rax
mov    (%rax),%edi
call   1040 <ntohs@plt>
mov    %eax,%esi
lea    0xec6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xec9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printUdpHeader>:
push   %rbx
mov    %rdi,%rbx
lea    0xefc(%rip),%rdi
call   1030 <puts@plt>
mov    0x8(%rbx),%edi
call   1050 <ntohs@plt>
lea    0xeb1(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x4(%rbx),%edi
call   1050 <ntohs@plt>
lea    0xead(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    (%rbx),%edi
call   1050 <ntohs@plt>
lea    0xea8(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xece(%rip),%rdi
pop    %rbx
jmp    1030 <puts@plt>

LLVM IR (-O0):
%struct.udphdr = type { i32, i32, i32 }
@.str = [38 x i8] c"\0A\0A/********** UDP HEADER **********/\0A\00"
@.str.1 = [20 x i8] c"udphdr.source = %d\0A\00"
@.str.2 = [18 x i8] c"udphdr.dest = %d\0A\00"
@.str.3 = [17 x i8] c"udphdr.len = %d\0A\00"
@.str.4 = [32 x i8] c"/***************************/\0A\0A\00"
define void @printUdpHeader(%struct.udphdr* %0) {
%2 = alloca %struct.udphdr*
store %struct.udphdr* %0, %struct.udphdr** %2
%3 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str, i64 0, i64 0))
%4 = load %struct.udphdr*, %struct.udphdr** %2
%5 = getelementptr inbounds %struct.udphdr, %struct.udphdr* %4, i32 0, i32 2
%6 = load i32, i32* %5
%7 = call i32 @ntohs(i32 %6)
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i32 %7)
%9 = load %struct.udphdr*, %struct.udphdr** %2
%10 = getelementptr inbounds %struct.udphdr, %struct.udphdr* %9, i32 0, i32 1
%11 = load i32, i32* %10
%12 = call i32 @ntohs(i32 %11)
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i32 %12)
%14 = load %struct.udphdr*, %struct.udphdr** %2
%15 = getelementptr inbounds %struct.udphdr, %struct.udphdr* %14, i32 0, i32 0
%16 = load i32, i32* %15
%17 = call i32 @ntohs(i32 %16)
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0), i32 %17)
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.4, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
%struct.udphdr = type { i32, i32, i32 }
@.str.1 = [20 x i8] c"udphdr.source = %d\0A\00"
@.str.2 = [18 x i8] c"udphdr.dest = %d\0A\00"
@.str.3 = [17 x i8] c"udphdr.len = %d\0A\00"
@str = [37 x i8] c"\0A\0A/********** UDP HEADER **********/\00"
@str.5 = [31 x i8] c"/***************************/\0A\00"
define void @printUdpHeader(%struct.udphdr* nocapture %0) {
%2 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @str, i64 0, i64 0))
%3 = getelementptr inbounds %struct.udphdr, %struct.udphdr* %0, i64 0, i32 2
%4 = load i32, i32* %3
%5 = tail call i32 @ntohs(i32 %4)
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i32 %5)
%7 = getelementptr inbounds %struct.udphdr, %struct.udphdr* %0, i64 0, i32 1
%8 = load i32, i32* %7
%9 = tail call i32 @ntohs(i32 %8)
%10 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i32 %9)
%11 = getelementptr inbounds %struct.udphdr, %struct.udphdr* %0, i64 0, i32 0
%12 = load i32, i32* %11
%13 = tail call i32 @ntohs(i32 %12)
%14 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0), i32 %13)
%15 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @str.5, i64 0, i64 0))
ret void
}