#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*/ sa;
typedef int /*<<< orphan*/ da;

/* Variables and functions */
int INET6_ADDRSTRLEN;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, int, char *, char *);
char *inet_ntop(int, void *, char *, int);
int /*<<< orphan*/ stderr;
void print_pktinfo(int family, int ifindex, void *saddr, void *daddr) {
  char sa[INET6_ADDRSTRLEN], da[INET6_ADDRSTRLEN];
  fprintf(stderr, "         pktinfo: ifindex=%u src=%s dst=%s\n", ifindex,
          saddr ? inet_ntop(family, saddr, sa, sizeof(sa)) : "unknown",
          daddr ? inet_ntop(family, daddr, da, sizeof(da)) : "unknown");
}


x86 assembly (clang, -O0):
<print_pktinfo>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
mov    %rcx,-0x18(%rbp)
mov    0x2eab(%rip),%rax
mov    (%rax),%ecx
mov    %rcx,-0x58(%rbp)
mov    %rsp,%rdx
mov    %rdx,-0x20(%rbp)
mov    %rcx,%rsi
add    $0xf,%rsi
and    $0xfffffffffffffff0,%rsi
mov    %rsp,%rdx
sub    %rsi,%rdx
mov    %rdx,-0x50(%rbp)
mov    %rdx,%rsp
mov    %rcx,-0x28(%rbp)
mov    (%rax),%eax
mov    %rax,-0x48(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x40(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x30(%rbp)
mov    0x2e49(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x38(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x34(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     11c4 <print_pktinfo+0xa4>
mov    -0x50(%rbp),%rdx
mov    -0x58(%rbp),%rax
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    %eax,%ecx
call   1030 <inet_ntop@plt>
mov    %rax,-0x60(%rbp)
jmp    11d4 <print_pktinfo+0xb4>
lea    0xe61(%rip),%rax
mov    %rax,-0x60(%rbp)
jmp    11d4 <print_pktinfo+0xb4>
mov    -0x60(%rbp),%rax
mov    %rax,-0x68(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     1206 <print_pktinfo+0xe6>
mov    -0x40(%rbp),%rdx
mov    -0x48(%rbp),%rax
mov    -0x4(%rbp),%edi
mov    -0x18(%rbp),%rsi
mov    %eax,%ecx
call   1030 <inet_ntop@plt>
mov    %rax,-0x70(%rbp)
jmp    1216 <print_pktinfo+0xf6>
lea    0xe1f(%rip),%rax
mov    %rax,-0x70(%rbp)
jmp    1216 <print_pktinfo+0xf6>
mov    -0x68(%rbp),%rcx
mov    -0x34(%rbp),%edx
mov    -0x38(%rbp),%edi
mov    -0x70(%rbp),%r8
lea    0xdd5(%rip),%rsi
call   1040 <fprintf@plt>
mov    -0x20(%rbp),%rax
mov    %rax,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_pktinfo>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rcx,%r8
mov    %esi,-0x30(%rbp)
mov    0x2ead(%rip),%rax
mov    (%rax),%r15d
mov    %rsp,%rax
mov    %r15,%rcx
add    $0xf,%rcx
and    $0xfffffffffffffff0,%rcx
sub    %rcx,%rax
mov    %rax,%rsp
mov    %rsp,%r13
sub    %rcx,%r13
mov    %r13,%rsp
mov    0x2e76(%rip),%rcx
mov    (%rcx),%ebx
lea    0xec1(%rip),%r14
mov    %r14,%r12
test   %rdx,%rdx
je     1194 <print_pktinfo+0x74>
mov    %ebx,-0x2c(%rbp)
mov    %edi,%ebx
mov    %rdx,%rsi
mov    %rax,%rdx
mov    %r15d,%ecx
mov    %r8,%r12
call   1030 <inet_ntop@plt>
mov    %r12,%r8
mov    %ebx,%edi
mov    -0x2c(%rbp),%ebx
mov    %rax,%r12
test   %r8,%r8
je     11aa <print_pktinfo+0x8a>
mov    %r8,%rsi
mov    %r13,%rdx
mov    %r15d,%ecx
call   1030 <inet_ntop@plt>
mov    %rax,%r14
lea    0xe4f(%rip),%rsi
mov    %ebx,%edi
mov    -0x30(%rbp),%edx
mov    %r12,%rcx
mov    %r14,%r8
call   1040 <fprintf@plt>
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@INET6_ADDRSTRLEN = global i32 0
@stderr = global i32 0
@.str = [44 x i8] c" pktinfo: ifindex=%u src=%s dst=%s\0A\00"
@.str.1 = [8 x i8] c"unknown\00"
define void @print_pktinfo(i32 %0, i32 %1, i8* %2, i8* %3) {
%5 = alloca i32
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i64
%11 = alloca i64
store i32 %0, i32* %5
store i32 %1, i32* %6
store i8* %2, i8** %7
store i8* %3, i8** %8
%12 = load i32, i32* @INET6_ADDRSTRLEN
%13 = zext i32 %12 to i64
%14 = call i8* @llvm.stacksave()
store i8* %14, i8** %9
%15 = alloca i8, i64 %13
store i64 %13, i64* %10
%16 = load i32, i32* @INET6_ADDRSTRLEN
%17 = zext i32 %16 to i64
%18 = alloca i8, i64 %17
store i64 %17, i64* %11
%19 = load i32, i32* @stderr
%20 = load i32, i32* %6
%21 = load i8*, i8** %7
%22 = icmp ne i8* %21, null
br i1 %22, label %23, label %28
23: ; preds = %4
%24 = load i32, i32* %5
%25 = load i8*, i8** %7
%26 = trunc i64 %13 to i32
%27 = call i8* @inet_ntop(i32 %24, i8* %25, i8* %15, i32 %26)
br label %29
28: ; preds = %4
br label %29
29: ; preds = %28, %23
%30 = phi i8* [ %27, %23 ], [ getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), %28 ]
%31 = load i8*, i8** %8
%32 = icmp ne i8* %31, null
br i1 %32, label %33, label %38
33: ; preds = %29
%34 = load i32, i32* %5
%35 = load i8*, i8** %8
%36 = trunc i64 %17 to i32
%37 = call i8* @inet_ntop(i32 %34, i8* %35, i8* %18, i32 %36)
br label %39
38: ; preds = %29
br label %39
39: ; preds = %38, %33
%40 = phi i8* [ %37, %33 ], [ getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), %38 ]
%41 = call i32 @fprintf(i32 %19, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str, i64 0, i64 0), i32 %20, i8* %30, i8* %40)
%42 = load i8*, i8** %9
ret void
}

LLVM IR (-O2):
@INET6_ADDRSTRLEN = global i32 0
@stderr = global i32 0
@.str = [44 x i8] c" pktinfo: ifindex=%u src=%s dst=%s\0A\00"
@.str.1 = [8 x i8] c"unknown\00"
define void @print_pktinfo(i32 %0, i32 %1, i8* %2, i8* %3) {
%5 = load i32, i32* @INET6_ADDRSTRLEN
%6 = zext i32 %5 to i64
%7 = alloca i8, i64 %6
%8 = alloca i8, i64 %6
%9 = load i32, i32* @stderr
%10 = icmp eq i8* %2, null
br i1 %10, label %13, label %11
11: ; preds = %4
%12 = call i8* @inet_ntop(i32 %0, i8* %2, i8* %7, i32 %5)
br label %13
13: ; preds = %4, %11
%14 = phi i8* [ %12, %11 ], [ getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), %4 ]
%15 = icmp eq i8* %3, null
br i1 %15, label %18, label %16
16: ; preds = %13
%17 = call i8* @inet_ntop(i32 %0, i8* %3, i8* %8, i32 %5)
br label %18
18: ; preds = %13, %16
%19 = phi i8* [ %17, %16 ], [ getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), %13 ]
%20 = call i32 @fprintf(i32 %9, i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str, i64 0, i64 0), i32 %1, i8* %14, i8* %19)
ret void
}