#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*/ uh_dport;
  int /*<<< orphan*/ uh_sport;
};
struct sockaddr_in {
  int /*<<< orphan*/ sin_addr;
};
struct sockaddr {
  int dummy;
};
struct ip {
  int ip_hl;
  scalar_t__ ip_p;
};
struct icmp {
  int icmp_type;
  int icmp_code;
};
typedef int /*<<< orphan*/ source;
typedef int socklen_t;
typedef int /*<<< orphan*/ fromAddr;

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
#define ICMP_ECHO 132
#define ICMP_ECHOREPLY 131
#define ICMP_TIMXCEED 130
#define ICMP_UNREACH 129
#define ICMP_UNREACH_PORT 128
int /*<<< orphan*/ IPPROTO_ICMP;
scalar_t__ IPPROTO_UDP;
int /*<<< orphan*/ PF_INET;
int /*<<< orphan*/ SOCK_RAW;
int /*<<< orphan*/ exit(int);
scalar_t__ inet_ntop(int /*<<< orphan*/, void const *, char *, int);
int ntohs(int /*<<< orphan*/);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, ...);
int recvfrom(int, char *, int, int /*<<< orphan*/, struct sockaddr *, int *);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int main(int argc, char *argv[]) {
  int rawSocket, n, lenIPHeader, lenIPHeader2, sport, dport;
  struct sockaddr_in fromAddr;
  socklen_t len;
  char source[1500], rcvbuffer[1500];
  ;
  struct ip *ip, *ip2;
  struct icmp *icmp;
  struct udphdr *udp;
  if ((rawSocket = socket(AF_INET, SOCK_RAW, IPPROTO_ICMP)) < 0) {
    perror("erreur socket");
    exit(1);
  }
  for (;;) {
    len = sizeof(fromAddr);
    if ((n = recvfrom(rawSocket, rcvbuffer, 1500, 0,
                      (struct sockaddr *)&fromAddr, &len)) < 0) {
      printf("erreur recvfrom");
      exit(1);
    }
    if (inet_ntop(PF_INET, (const void *)&fromAddr.sin_addr, source,
                  sizeof(source)) < 0) {
      printf("erreur inet_ntop");
      exit(1);
    }
    printf("%d octets ICMP de %s: \n", n, source);
    ip = (struct ip *)rcvbuffer;
    lenIPHeader = ip->ip_hl * 4;
    icmp = (struct icmp *)(rcvbuffer + lenIPHeader);
    ip2 = (struct ip *)(rcvbuffer + lenIPHeader + 8);
    lenIPHeader2 = ip2->ip_hl * 4;
    if (ip2->ip_p == IPPROTO_UDP) {
      udp = (struct udphdr *)(rcvbuffer + lenIPHeader + 8 + lenIPHeader2);
      sport = ntohs(udp->uh_sport);
      dport = ntohs(udp->uh_dport);
      printf(" port source = %d et port destination = %d \n", sport, dport);
    }
    switch (icmp->icmp_type) {
    case ICMP_UNREACH: {
      printf("destination unreachable \n");
      switch (icmp->icmp_code) {
      case ICMP_UNREACH_PORT:
        printf(" bad port \n");
        break;
      default:
        printf("type %d, code = %d\n", icmp->icmp_type, icmp->icmp_code);
        break;
      }
    } break;
    case ICMP_ECHO:
      printf(" echo service  \n");
      break;
    case ICMP_ECHOREPLY:
      printf(" echo reply  \n");
      break;
    case ICMP_TIMXCEED:
      printf(" Time Exceed \n");
      break;
    default:
      printf("type %d, code = %d\n", icmp->icmp_type, icmp->icmp_code);
    }
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xc20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2e58(%rip),%rax
mov    (%rax),%edi
mov    0x2e47(%rip),%rax
mov    (%rax),%esi
mov    0x2e36(%rip),%rax
mov    (%rax),%edx
call   1090 <socket@plt>
mov    %eax,-0x14(%rbp)
cmp    $0x0,%eax
jge    11cb <main+0x5b>
lea    0xe54(%rip),%rdi
call   1070 <perror@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
jmp    11d0 <main+0x60>
movl   $0x4,-0x34(%rbp)
mov    -0x14(%rbp),%edi
lea    -0xbf0(%rbp),%rsi
lea    -0x30(%rbp),%r8
mov    $0x5dc,%edx
xor    %ecx,%ecx
lea    -0x34(%rbp),%r9
call   1050 <recvfrom@plt>
mov    %eax,-0x18(%rbp)
cmp    $0x0,%eax
jge    1219 <main+0xa9>
lea    0xe16(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
mov    0x2da8(%rip),%rax
mov    (%rax),%edi
lea    -0x30(%rbp),%rsi
lea    -0x610(%rbp),%rdx
mov    $0x5dc,%ecx
call   1030 <inet_ntop@plt>
cmp    $0x0,%rax
jge    1259 <main+0xe9>
lea    0xde6(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x1,%edi
call   1080 <exit@plt>
mov    -0x18(%rbp),%esi
lea    -0x610(%rbp),%rdx
lea    0xdd5(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0xbf0(%rbp),%rax
mov    %rax,-0xbf8(%rbp)
mov    -0xbf8(%rbp),%rax
mov    (%rax),%eax
shl    $0x2,%eax
mov    %eax,-0x1c(%rbp)
lea    -0xbf0(%rbp),%rax
movslq -0x1c(%rbp),%rcx
add    %rcx,%rax
mov    %rax,-0xc08(%rbp)
lea    -0xbf0(%rbp),%rax
movslq -0x1c(%rbp),%rcx
add    %rcx,%rax
add    $0x8,%rax
mov    %rax,-0xc00(%rbp)
mov    -0xc00(%rbp),%rax
mov    (%rax),%eax
shl    $0x2,%eax
mov    %eax,-0x20(%rbp)
mov    -0xc00(%rbp),%rax
mov    0x8(%rax),%rax
mov    0x2cdb(%rip),%rcx
cmp    (%rcx),%rax
jne    133d <main+0x1cd>
lea    -0xbf0(%rbp),%rax
movslq -0x1c(%rbp),%rcx
add    %rcx,%rax
add    $0x8,%rax
movslq -0x20(%rbp),%rcx
add    %rcx,%rax
mov    %rax,-0xc10(%rbp)
mov    -0xc10(%rbp),%rax
mov    0x4(%rax),%edi
call   1060 <ntohs@plt>
mov    %eax,-0x24(%rbp)
mov    -0xc10(%rbp),%rax
mov    (%rax),%edi
call   1060 <ntohs@plt>
mov    %eax,-0x28(%rbp)
mov    -0x24(%rbp),%esi
mov    -0x28(%rbp),%edx
lea    0xd21(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0xc08(%rbp),%rax
mov    (%rax),%eax
add    $0xffffff7f,%eax
mov    %eax,%ecx
mov    %rcx,-0xc18(%rbp)
sub    $0x3,%eax
ja     140e <main+0x29e>
mov    -0xc18(%rbp),%rax
lea    0xc95(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xd09(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    -0xc08(%rbp),%rax
mov    0x4(%rax),%eax
sub    $0x80,%eax
jne    13af <main+0x23f>
jmp    139c <main+0x22c>
lea    0xcfb(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    13d0 <main+0x260>
mov    -0xc08(%rbp),%rax
mov    (%rax),%esi
mov    -0xc08(%rbp),%rax
mov    0x4(%rax),%edx
lea    0xce1(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    142f <main+0x2bf>
lea    0xce2(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    142f <main+0x2bf>
lea    0xce0(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    142f <main+0x2bf>
lea    0xcdc(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    142f <main+0x2bf>
mov    -0xc08(%rbp),%rax
mov    (%rax),%esi
mov    -0xc08(%rbp),%rax
mov    0x4(%rax),%edx
lea    0xc82(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11d0 <main+0x60>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xbd8,%rsp
mov    0x2e50(%rip),%rax
mov    (%rax),%edi
mov    0x2e3f(%rip),%rax
mov    (%rax),%esi
mov    0x2e2e(%rip),%rax
mov    (%rax),%edx
call   10a0 <socket@plt>
test   %eax,%eax
jns    11cb <main+0x4b>
lea    0xe54(%rip),%rdi
call   1080 <perror@plt>
mov    $0x1,%edi
call   1090 <exit@plt>
mov    %eax,%r14d
movl   $0x4,0x4(%rsp)
lea    0x5f0(%rsp),%rsi
lea    0x8(%rsp),%r8
lea    0x4(%rsp),%r9
mov    %eax,%edi
mov    $0x5dc,%edx
xor    %ecx,%ecx
call   1060 <recvfrom@plt>
test   %eax,%eax
jns    1206 <main+0x86>
lea    0xe1d(%rip),%rdi
jmp    137e <main+0x1fe>
mov    %eax,%r15d
mov    0x2db8(%rip),%r13
lea    0x8(%rsp),%r12
lea    0x10(%rsp),%rbx
jmp    125b <main+0xdb>
lea    0xe75(%rip),%rdi
call   1040 <puts@plt>
lea    0x10(%rsp),%rbx
movl   $0x4,0x4(%rsp)
mov    %r14d,%edi
lea    0x5f0(%rsp),%rsi
mov    $0x5dc,%edx
xor    %ecx,%ecx
mov    %r12,%r8
lea    0x4(%rsp),%r9
call   1060 <recvfrom@plt>
mov    %eax,%r15d
test   %eax,%eax
js     11fa <main+0x7a>
mov    0x0(%r13),%edi
mov    %r12,%rsi
mov    %rbx,%rdx
mov    $0x5dc,%ecx
call   1030 <inet_ntop@plt>
test   %rax,%rax
js     1377 <main+0x1f7>
lea    0xdc0(%rip),%rdi
mov    %r15d,%esi
mov    %rbx,%rdx
xor    %eax,%eax
call   1050 <printf@plt>
movslq 0x5f0(%rsp),%rbp
mov    0x600(%rsp,%rbp,4),%rax
mov    0x2d15(%rip),%rcx
cmp    (%rcx),%rax
jne    12f3 <main+0x173>
lea    (%rsp,%rbp,4),%rbx
add    $0x5f8,%rbx
mov    %r12,%r15
mov    %r13,%r12
mov    %r14d,%r13d
movslq (%rbx),%r14
mov    0x4(%rbx,%r14,4),%edi
call   1070 <ntohs@plt>
mov    %eax,0xc(%rsp)
mov    (%rbx,%r14,4),%edi
mov    %r13d,%r14d
mov    %r12,%r13
mov    %r15,%r12
call   1070 <ntohs@plt>
lea    0xd71(%rip),%rdi
mov    0xc(%rsp),%esi
mov    %eax,%edx
xor    %eax,%eax
call   1050 <printf@plt>
lea    (%rsp,%rbp,4),%rbx
add    $0x5f0,%rbx
mov    (%rbx),%esi
lea    -0x81(%rsi),%eax
cmp    $0x3,%eax
ja     1356 <main+0x1d6>
lea    0xcee(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xda2(%rip),%rdi
call   1040 <puts@plt>
mov    0x4(%rbx),%edx
cmp    $0x80,%edx
jne    1362 <main+0x1e2>
lea    0xda4(%rip),%rdi
jmp    1223 <main+0xa3>
lea    0xd61(%rip),%rdi
jmp    1223 <main+0xa3>
lea    0xd63(%rip),%rdi
jmp    1223 <main+0xa3>
mov    0x4(%rbx),%edx
lea    0xd24(%rip),%rdi
jmp    136b <main+0x1eb>
mov    (%rbx),%esi
lea    0xd19(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    1228 <main+0xa8>
lea    0xcb0(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0x1,%edi
call   1090 <exit@plt>

LLVM IR (-O0):
%struct.sockaddr_in = type { i32 }
%struct.ip = type { i32, i64 }
%struct.icmp = type { i32, i32 }
%struct.udphdr = type { i32, i32 }
%struct.sockaddr = type { i32 }
@AF_INET = global i32 0
@SOCK_RAW = global i32 0
@IPPROTO_ICMP = global i32 0
@.str = [14 x i8] c"erreur socket\00"
@.str.1 = [16 x i8] c"erreur recvfrom\00"
@PF_INET = global i32 0
@.str.2 = [17 x i8] c"erreur inet_ntop\00"
@.str.3 = [24 x i8] c"%d octets ICMP de %s: \0A\00"
@IPPROTO_UDP = global i64 0
@.str.4 = [45 x i8] c" port source = %d et port destination = %d \0A\00"
@.str.5 = [26 x i8] c"destination unreachable \0A\00"
@.str.6 = [12 x i8] c" bad port \0A\00"
@.str.7 = [20 x i8] c"type %d, code = %d\0A\00"
@.str.8 = [17 x i8] c" echo service \0A\00"
@.str.9 = [15 x i8] c" echo reply \0A\00"
@.str.10 = [15 x i8] c" Time Exceed \0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca %struct.sockaddr_in
%13 = alloca i32
%14 = alloca [1500 x i8]
%15 = alloca [1500 x i8]
%16 = alloca %struct.ip*
%17 = alloca %struct.ip*
%18 = alloca %struct.icmp*
%19 = alloca %struct.udphdr*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%20 = load i32, i32* @AF_INET
%21 = load i32, i32* @SOCK_RAW
%22 = load i32, i32* @IPPROTO_ICMP
%23 = call i32 @socket(i32 %20, i32 %21, i32 %22)
store i32 %23, i32* %6
%24 = icmp slt i32 %23, 0
br i1 %24, label %25, label %28
25: ; preds = %2
%26 = call i32 @perror(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
%27 = call i32 @exit(i32 1)
unreachable
28: ; preds = %2
br label %29
29: ; preds = %133, %28
store i32 4, i32* %13
%30 = load i32, i32* %6
%31 = getelementptr inbounds [1500 x i8], [1500 x i8]* %15, i64 0, i64 0
%32 = bitcast %struct.sockaddr_in* %12 to %struct.sockaddr*
%33 = call i32 @recvfrom(i32 %30, i8* %31, i32 1500, i32 0, %struct.sockaddr* %32, i32* %13)
store i32 %33, i32* %7
%34 = icmp slt i32 %33, 0
br i1 %34, label %35, label %38
35: ; preds = %29
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0))
%37 = call i32 @exit(i32 1)
unreachable
38: ; preds = %29
%39 = load i32, i32* @PF_INET
%40 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %12, i32 0, i32 0
%41 = bitcast i32* %40 to i8*
%42 = getelementptr inbounds [1500 x i8], [1500 x i8]* %14, i64 0, i64 0
%43 = call i64 @inet_ntop(i32 %39, i8* %41, i8* %42, i32 1500)
%44 = icmp slt i64 %43, 0
br i1 %44, label %45, label %48
45: ; preds = %38
%46 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0))
%47 = call i32 @exit(i32 1)
unreachable
48: ; preds = %38
%49 = load i32, i32* %7
%50 = getelementptr inbounds [1500 x i8], [1500 x i8]* %14, i64 0, i64 0
%51 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0), i32 %49, i8* %50)
%52 = getelementptr inbounds [1500 x i8], [1500 x i8]* %15, i64 0, i64 0
%53 = bitcast i8* %52 to %struct.ip*
store %struct.ip* %53, %struct.ip** %16
%54 = load %struct.ip*, %struct.ip** %16
%55 = getelementptr inbounds %struct.ip, %struct.ip* %54, i32 0, i32 0
%56 = load i32, i32* %55
%57 = mul nsw i32 %56, 4
store i32 %57, i32* %8
%58 = getelementptr inbounds [1500 x i8], [1500 x i8]* %15, i64 0, i64 0
%59 = load i32, i32* %8
%60 = sext i32 %59 to i64
%61 = getelementptr inbounds i8, i8* %58, i64 %60
%62 = bitcast i8* %61 to %struct.icmp*
store %struct.icmp* %62, %struct.icmp** %18
%63 = getelementptr inbounds [1500 x i8], [1500 x i8]* %15, i64 0, i64 0
%64 = load i32, i32* %8
%65 = sext i32 %64 to i64
%66 = getelementptr inbounds i8, i8* %63, i64 %65
%67 = getelementptr inbounds i8, i8* %66, i64 8
%68 = bitcast i8* %67 to %struct.ip*
store %struct.ip* %68, %struct.ip** %17
%69 = load %struct.ip*, %struct.ip** %17
%70 = getelementptr inbounds %struct.ip, %struct.ip* %69, i32 0, i32 0
%71 = load i32, i32* %70
%72 = mul nsw i32 %71, 4
store i32 %72, i32* %9
%73 = load %struct.ip*, %struct.ip** %17
%74 = getelementptr inbounds %struct.ip, %struct.ip* %73, i32 0, i32 1
%75 = load i64, i64* %74
%76 = load i64, i64* @IPPROTO_UDP
%77 = icmp eq i64 %75, %76
br i1 %77, label %78, label %99
78: ; preds = %48
%79 = getelementptr inbounds [1500 x i8], [1500 x i8]* %15, i64 0, i64 0
%80 = load i32, i32* %8
%81 = sext i32 %80 to i64
%82 = getelementptr inbounds i8, i8* %79, i64 %81
%83 = getelementptr inbounds i8, i8* %82, i64 8
%84 = load i32, i32* %9
%85 = sext i32 %84 to i64
%86 = getelementptr inbounds i8, i8* %83, i64 %85
%87 = bitcast i8* %86 to %struct.udphdr*
store %struct.udphdr* %87, %struct.udphdr** %19
%88 = load %struct.udphdr*, %struct.udphdr** %19
%89 = getelementptr inbounds %struct.udphdr, %struct.udphdr* %88, i32 0, i32 1
%90 = load i32, i32* %89
%91 = call i32 @ntohs(i32 %90)
store i32 %91, i32* %10
%92 = load %struct.udphdr*, %struct.udphdr** %19
%93 = getelementptr inbounds %struct.udphdr, %struct.udphdr* %92, i32 0, i32 0
%94 = load i32, i32* %93
%95 = call i32 @ntohs(i32 %94)
store i32 %95, i32* %11
%96 = load i32, i32* %10
%97 = load i32, i32* %11
%98 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.4, i64 0, i64 0), i32 %96, i32 %97)
br label %99
99: ; preds = %78, %48
%100 = load %struct.icmp*, %struct.icmp** %18
%101 = getelementptr inbounds %struct.icmp, %struct.icmp* %100, i32 0, i32 0
%102 = load i32, i32* %101
switch i32 %102, label %125 [
i32 129, label %103
i32 132, label %119
i32 131, label %121
i32 130, label %123
]
103: ; preds = %99
%104 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.5, i64 0, i64 0))
%105 = load %struct.icmp*, %struct.icmp** %18
%106 = getelementptr inbounds %struct.icmp, %struct.icmp* %105, i32 0, i32 1
%107 = load i32, i32* %106
switch i32 %107, label %110 [
i32 128, label %108
]
108: ; preds = %103
%109 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.6, i64 0, i64 0))
br label %118
110: ; preds = %103
%111 = load %struct.icmp*, %struct.icmp** %18
%112 = getelementptr inbounds %struct.icmp, %struct.icmp* %111, i32 0, i32 0
%113 = load i32, i32* %112
%114 = load %struct.icmp*, %struct.icmp** %18
%115 = getelementptr inbounds %struct.icmp, %struct.icmp* %114, i32 0, i32 1
%116 = load i32, i32* %115
%117 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.7, i64 0, i64 0), i32 %113, i32 %116)
br label %118
118: ; preds = %110, %108
br label %133
119: ; preds = %99
%120 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.8, i64 0, i64 0))
br label %133
121: ; preds = %99
%122 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.9, i64 0, i64 0))
br label %133
123: ; preds = %99
%124 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.10, i64 0, i64 0))
br label %133
125: ; preds = %99
%126 = load %struct.icmp*, %struct.icmp** %18
%127 = getelementptr inbounds %struct.icmp, %struct.icmp* %126, i32 0, i32 0
%128 = load i32, i32* %127
%129 = load %struct.icmp*, %struct.icmp** %18
%130 = getelementptr inbounds %struct.icmp, %struct.icmp* %129, i32 0, i32 1
%131 = load i32, i32* %130
%132 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.7, i64 0, i64 0), i32 %128, i32 %131)
br label %133
133: ; preds = %125, %123, %121, %119, %118
br label %29
}

LLVM IR (-O2):
%struct.sockaddr_in = type { i32 }
%struct.sockaddr = type { i32 }
@AF_INET = global i32 0
@SOCK_RAW = global i32 0
@IPPROTO_ICMP = global i32 0
@.str = [14 x i8] c"erreur socket\00"
@.str.1 = [16 x i8] c"erreur recvfrom\00"
@PF_INET = global i32 0
@.str.2 = [17 x i8] c"erreur inet_ntop\00"
@.str.3 = [24 x i8] c"%d octets ICMP de %s: \0A\00"
@IPPROTO_UDP = global i64 0
@.str.4 = [45 x i8] c" port source = %d et port destination = %d \0A\00"
@.str.7 = [20 x i8] c"type %d, code = %d\0A\00"
@str = [14 x i8] c" Time Exceed \00"
@str.11 = [14 x i8] c" echo reply \00"
@str.12 = [16 x i8] c" echo service \00"
@str.13 = [25 x i8] c"destination unreachable \00"
@str.14 = [11 x i8] c" bad port \00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca %struct.sockaddr_in
%4 = alloca i32
%5 = alloca [1500 x i8]
%6 = alloca [1500 x i8]
%7 = bitcast %struct.sockaddr_in* %3 to i8*
%8 = bitcast i32* %4 to i8*
%9 = getelementptr inbounds [1500 x i8], [1500 x i8]* %5, i64 0, i64 0
%10 = getelementptr inbounds [1500 x i8], [1500 x i8]* %6, i64 0, i64 0
%11 = load i32, i32* @AF_INET
%12 = load i32, i32* @SOCK_RAW
%13 = load i32, i32* @IPPROTO_ICMP
%14 = tail call i32 @socket(i32 %11, i32 %12, i32 %13)
%15 = icmp slt i32 %14, 0
br i1 %15, label %22, label %16
16: ; preds = %2
%17 = bitcast %struct.sockaddr_in* %3 to %struct.sockaddr*
store i32 4, i32* %4
%18 = call i32 @recvfrom(i32 %14, i8* %10, i32 1500, i32 0, %struct.sockaddr* %17, i32* %4)
%19 = icmp slt i32 %18, 0
br i1 %19, label %25, label %20
20: ; preds = %16
%21 = bitcast [1500 x i8]* %6 to i32*
br label %28
22: ; preds = %2
%23 = tail call i32 @perror(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
%24 = tail call i32 @exit(i32 1)
unreachable
25: ; preds = %87, %16
%26 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0))
%27 = call i32 @exit(i32 1)
unreachable
28: ; preds = %20, %87
%29 = phi i32 [ %18, %20 ], [ %88, %87 ]
%30 = load i32, i32* @PF_INET
%31 = call i64 @inet_ntop(i32 %30, i8* %7, i8* %9, i32 1500)
%32 = icmp slt i64 %31, 0
br i1 %32, label %33, label %36
33: ; preds = %28
%34 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0))
%35 = call i32 @exit(i32 1)
unreachable
36: ; preds = %28
%37 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0), i32 %29, i8* %9)
%38 = load i32, i32* %21
%39 = shl nsw i32 %38, 2
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds [1500 x i8], [1500 x i8]* %6, i64 0, i64 %40
%42 = getelementptr inbounds i8, i8* %41, i64 8
%43 = getelementptr inbounds i8, i8* %41, i64 16
%44 = bitcast i8* %43 to i64*
%45 = load i64, i64* %44
%46 = load i64, i64* @IPPROTO_UDP
%47 = icmp eq i64 %45, %46
br i1 %47, label %48, label %62
48: ; preds = %36
%49 = bitcast i8* %42 to i32*
%50 = load i32, i32* %49
%51 = shl nsw i32 %50, 2
%52 = sext i32 %51 to i64
%53 = getelementptr inbounds i8, i8* %42, i64 %52
%54 = getelementptr inbounds i8, i8* %53, i64 4
%55 = bitcast i8* %54 to i32*
%56 = load i32, i32* %55
%57 = call i32 @ntohs(i32 %56)
%58 = bitcast i8* %53 to i32*
%59 = load i32, i32* %58
%60 = call i32 @ntohs(i32 %59)
%61 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @.str.4, i64 0, i64 0), i32 %57, i32 %60)
br label %62
62: ; preds = %48, %36
%63 = bitcast i8* %41 to i32*
%64 = load i32, i32* %63
switch i32 %64, label %82 [
i32 129, label %65
i32 132, label %76
i32 131, label %78
i32 130, label %80
]
65: ; preds = %62
%66 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str.13, i64 0, i64 0))
%67 = getelementptr inbounds i8, i8* %41, i64 4
%68 = bitcast i8* %67 to i32*
%69 = load i32, i32* %68
%70 = icmp eq i32 %69, 128
br i1 %70, label %71, label %73
71: ; preds = %65
%72 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @str.14, i64 0, i64 0))
br label %87
73: ; preds = %65
%74 = load i32, i32* %63
%75 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.7, i64 0, i64 0), i32 %74, i32 %69)
br label %87
76: ; preds = %62
%77 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str.12, i64 0, i64 0))
br label %87
78: ; preds = %62
%79 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str.11, i64 0, i64 0))
br label %87
80: ; preds = %62
%81 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str, i64 0, i64 0))
br label %87
82: ; preds = %62
%83 = getelementptr inbounds i8, i8* %41, i64 4
%84 = bitcast i8* %83 to i32*
%85 = load i32, i32* %84
%86 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.7, i64 0, i64 0), i32 %64, i32 %85)
br label %87
87: ; preds = %71, %73, %82, %80, %78, %76
store i32 4, i32* %4
%88 = call i32 @recvfrom(i32 %14, i8* %10, i32 1500, i32 0, %struct.sockaddr* %17, i32* %4)
%89 = icmp slt i32 %88, 0
br i1 %89, label %25, label %28
}