#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 */
typedef struct TYPE_4__ TYPE_2__;
typedef struct TYPE_3__ TYPE_1__;

/* Type definitions */
struct ip {
  int /*<<< orphan*/ ip_dst;
  int /*<<< orphan*/ ip_src;
};
struct TYPE_3__ {
  int sequence;
};
struct TYPE_4__ {
  TYPE_1__ echo;
};
struct icmphdr {
  int type;
  int code;
  TYPE_2__ un;
};
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
char *inet_ntoa(int /*<<< orphan*/);
void print_icmp(FILE *dst, const struct ip *ip, const struct icmphdr *icmp) {
  fprintf(dst, "ICMP:\t %s ", inet_ntoa(ip->ip_src));
  fprintf(dst, " --> %s ", inet_ntoa(ip->ip_dst));
  fprintf(dst, "Type %d , code %d", icmp->type, icmp->code);
  if (icmp->type == 0 && icmp->code == 0) {
    fprintf(dst, " echo reply: SEQNR = %d ", icmp->un.echo.sequence);
  }
  if (icmp->type == 8 && icmp->code == 0) {
    fprintf(dst, " echo reqest: SEQNR = %d ", icmp->un.echo.sequence);
  }
  fprintf(dst, "\n");
}


x86 assembly (clang, -O0):
<print_icmp>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rax
mov    0x4(%rax),%edi
call   1030 <inet_ntoa@plt>
mov    -0x28(%rbp),%rdi
mov    %rax,%rdx
lea    0xeaa(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%edi
call   1030 <inet_ntoa@plt>
mov    -0x20(%rbp),%rdi
mov    %rax,%rdx
lea    0xe8d(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rax
mov    (%rax),%edx
mov    -0x18(%rbp),%rax
mov    0x4(%rax),%ecx
lea    0xe77(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x18(%rbp),%rax
cmpl   $0x0,(%rax)
jne    11d8 <print_icmp+0xb8>
mov    -0x18(%rbp),%rax
cmpl   $0x0,0x4(%rax)
jne    11d8 <print_icmp+0xb8>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rax
mov    0x8(%rax),%edx
lea    0xe55(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x18(%rbp),%rax
cmpl   $0x8,(%rax)
jne    120c <print_icmp+0xec>
mov    -0x18(%rbp),%rax
cmpl   $0x0,0x4(%rax)
jne    120c <print_icmp+0xec>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rax
mov    0x8(%rax),%edx
lea    0xe3a(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x8(%rbp),%rdi
lea    0xe42(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_icmp>:
push   %r15
push   %r14
push   %rbx
mov    %rdx,%r15
mov    %rsi,%rbx
mov    %rdi,%r14
mov    0x4(%rsi),%edi
call   1030 <inet_ntoa@plt>
lea    0xeb3(%rip),%rsi
mov    %r14,%rdi
mov    %rax,%rdx
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    (%rbx),%edi
call   1030 <inet_ntoa@plt>
lea    0xea3(%rip),%rsi
mov    %r14,%rdi
mov    %rax,%rdx
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    (%r15),%edx
mov    0x4(%r15),%ecx
lea    0xe91(%rip),%rsi
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    (%r15),%eax
test   %eax,%eax
je     11b7 <print_icmp+0x87>
cmp    $0x8,%eax
jne    11db <print_icmp+0xab>
cmpl   $0x0,0x4(%r15)
jne    11db <print_icmp+0xab>
mov    0x8(%r15),%edx
lea    0xe94(%rip),%rsi
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <fprintf@plt>
jmp    11db <print_icmp+0xab>
cmpl   $0x0,0x4(%r15)
jne    11db <print_icmp+0xab>
mov    0x8(%r15),%edx
lea    0xe5d(%rip),%rsi
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    (%r15),%eax
cmp    $0x8,%eax
je     1199 <print_icmp+0x69>
mov    $0xa,%edi
mov    %r14,%rsi
pop    %rbx
pop    %r14
pop    %r15
jmp    1040 <fputc@plt>

LLVM IR (-O0):
%struct.ip = type { i32, i32 }
%struct.icmphdr = type { i32, i32, %struct.TYPE_4__ }
%struct.TYPE_4__ = type { %struct.TYPE_3__ }
%struct.TYPE_3__ = type { i32 }
@.str = [11 x i8] c"ICMP:\09 %s \00"
@.str.1 = [9 x i8] c" --> %s \00"
@.str.2 = [18 x i8] c"Type %d , code %d\00"
@.str.3 = [25 x i8] c" echo reply: SEQNR = %d \00"
@.str.4 = [26 x i8] c" echo reqest: SEQNR = %d \00"
@.str.5 = [2 x i8] c"\0A\00"
define void @print_icmp(i32* %0, %struct.ip* %1, %struct.icmphdr* %2) {
%4 = alloca i32*
%5 = alloca %struct.ip*
%6 = alloca %struct.icmphdr*
store i32* %0, i32** %4
store %struct.ip* %1, %struct.ip** %5
store %struct.icmphdr* %2, %struct.icmphdr** %6
%7 = load i32*, i32** %4
%8 = load %struct.ip*, %struct.ip** %5
%9 = getelementptr inbounds %struct.ip, %struct.ip* %8, i32 0, i32 1
%10 = load i32, i32* %9
%11 = call i8* @inet_ntoa(i32 %10)
%12 = call i32 (i32*, i8*, ...) @fprintf(i32* %7, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* %11)
%13 = load i32*, i32** %4
%14 = load %struct.ip*, %struct.ip** %5
%15 = getelementptr inbounds %struct.ip, %struct.ip* %14, i32 0, i32 0
%16 = load i32, i32* %15
%17 = call i8* @inet_ntoa(i32 %16)
%18 = call i32 (i32*, i8*, ...) @fprintf(i32* %13, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8* %17)
%19 = load i32*, i32** %4
%20 = load %struct.icmphdr*, %struct.icmphdr** %6
%21 = getelementptr inbounds %struct.icmphdr, %struct.icmphdr* %20, i32 0, i32 0
%22 = load i32, i32* %21
%23 = load %struct.icmphdr*, %struct.icmphdr** %6
%24 = getelementptr inbounds %struct.icmphdr, %struct.icmphdr* %23, i32 0, i32 1
%25 = load i32, i32* %24
%26 = call i32 (i32*, i8*, ...) @fprintf(i32* %19, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i32 %22, i32 %25)
%27 = load %struct.icmphdr*, %struct.icmphdr** %6
%28 = getelementptr inbounds %struct.icmphdr, %struct.icmphdr* %27, i32 0, i32 0
%29 = load i32, i32* %28
%30 = icmp eq i32 %29, 0
br i1 %30, label %31, label %44
31: ; preds = %3
%32 = load %struct.icmphdr*, %struct.icmphdr** %6
%33 = getelementptr inbounds %struct.icmphdr, %struct.icmphdr* %32, i32 0, i32 1
%34 = load i32, i32* %33
%35 = icmp eq i32 %34, 0
br i1 %35, label %36, label %44
36: ; preds = %31
%37 = load i32*, i32** %4
%38 = load %struct.icmphdr*, %struct.icmphdr** %6
%39 = getelementptr inbounds %struct.icmphdr, %struct.icmphdr* %38, i32 0, i32 2
%40 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %39, i32 0, i32 0
%41 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %40, i32 0, i32 0
%42 = load i32, i32* %41
%43 = call i32 (i32*, i8*, ...) @fprintf(i32* %37, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0), i32 %42)
br label %44
44: ; preds = %36, %31, %3
%45 = load %struct.icmphdr*, %struct.icmphdr** %6
%46 = getelementptr inbounds %struct.icmphdr, %struct.icmphdr* %45, i32 0, i32 0
%47 = load i32, i32* %46
%48 = icmp eq i32 %47, 8
br i1 %48, label %49, label %62
49: ; preds = %44
%50 = load %struct.icmphdr*, %struct.icmphdr** %6
%51 = getelementptr inbounds %struct.icmphdr, %struct.icmphdr* %50, i32 0, i32 1
%52 = load i32, i32* %51
%53 = icmp eq i32 %52, 0
br i1 %53, label %54, label %62
54: ; preds = %49
%55 = load i32*, i32** %4
%56 = load %struct.icmphdr*, %struct.icmphdr** %6
%57 = getelementptr inbounds %struct.icmphdr, %struct.icmphdr* %56, i32 0, i32 2
%58 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %57, i32 0, i32 0
%59 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %58, i32 0, i32 0
%60 = load i32, i32* %59
%61 = call i32 (i32*, i8*, ...) @fprintf(i32* %55, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.4, i64 0, i64 0), i32 %60)
br label %62
62: ; preds = %54, %49, %44
%63 = load i32*, i32** %4
%64 = call i32 (i32*, i8*, ...) @fprintf(i32* %63, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
%struct.ip = type { i32, i32 }
%struct.icmphdr = type { i32, i32, %struct.TYPE_4__ }
%struct.TYPE_4__ = type { %struct.TYPE_3__ }
%struct.TYPE_3__ = type { i32 }
@.str = [11 x i8] c"ICMP:\09 %s \00"
@.str.1 = [9 x i8] c" --> %s \00"
@.str.2 = [18 x i8] c"Type %d , code %d\00"
@.str.3 = [25 x i8] c" echo reply: SEQNR = %d \00"
@.str.4 = [26 x i8] c" echo reqest: SEQNR = %d \00"
define void @print_icmp(i32* nocapture %0, %struct.ip* nocapture %1, %struct.icmphdr* nocapture %2) {
%4 = getelementptr inbounds %struct.ip, %struct.ip* %1, i64 0, i32 1
%5 = load i32, i32* %4
%6 = tail call i8* @inet_ntoa(i32 %5)
%7 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* %6)
%8 = getelementptr inbounds %struct.ip, %struct.ip* %1, i64 0, i32 0
%9 = load i32, i32* %8
%10 = tail call i8* @inet_ntoa(i32 %9)
%11 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8* %10)
%12 = getelementptr inbounds %struct.icmphdr, %struct.icmphdr* %2, i64 0, i32 0
%13 = load i32, i32* %12
%14 = getelementptr inbounds %struct.icmphdr, %struct.icmphdr* %2, i64 0, i32 1
%15 = load i32, i32* %14
%16 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0), i32 %13, i32 %15)
%17 = load i32, i32* %12
%18 = icmp eq i32 %17, 0
br i1 %18, label %19, label %27
19: ; preds = %3
%20 = load i32, i32* %14
%21 = icmp eq i32 %20, 0
br i1 %21, label %22, label %37
22: ; preds = %19
%23 = getelementptr inbounds %struct.icmphdr, %struct.icmphdr* %2, i64 0, i32 2, i32 0, i32 0
%24 = load i32, i32* %23
%25 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.3, i64 0, i64 0), i32 %24)
%26 = load i32, i32* %12
br label %27
27: ; preds = %22, %3
%28 = phi i32 [ %26, %22 ], [ %17, %3 ]
%29 = icmp eq i32 %28, 8
br i1 %29, label %30, label %37
30: ; preds = %27
%31 = load i32, i32* %14
%32 = icmp eq i32 %31, 0
br i1 %32, label %33, label %37
33: ; preds = %30
%34 = getelementptr inbounds %struct.icmphdr, %struct.icmphdr* %2, i64 0, i32 2, i32 0, i32 0
%35 = load i32, i32* %34
%36 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.4, i64 0, i64 0), i32 %35)
br label %37
37: ; preds = %19, %33, %30, %27
%38 = tail call i32 @fputc(i32 10, i32* %0)
ret void
}