#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_3__ TYPE_1__;

/* Type definitions */
typedef int /*<<< orphan*/ ttl;
struct timeb {
  int /*<<< orphan*/ time;
};
struct sockaddr_un {
  int dummy;
};
struct TYPE_3__ {
  int /*<<< orphan*/ s_addr;
};
struct sockaddr_in {
  TYPE_1__ sin_addr;
  int /*<<< orphan*/ sin_port;
  int /*<<< orphan*/ sin_family;
};
struct sockaddr {
  int dummy;
};
struct hostent {
  int /*<<< orphan*/ h_length;
  int /*<<< orphan*/ h_addr;
};
typedef int socklen_t;
typedef int /*<<< orphan*/ serv_addr;

/* Variables and functions */
int /*<<< orphan*/ IPPROTO_IP;
int /*<<< orphan*/ IP_MULTICAST_TTL;
int /*<<< orphan*/ PF_INET;
int /*<<< orphan*/ SOCK_DGRAM;
int /*<<< orphan*/ close(int);
char *ctime(int /*<<< orphan*/ *);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, char *);
int /*<<< orphan*/ ftime(struct timeb *);
scalar_t__ gethostbyname(char *);
int /*<<< orphan*/ htons(int);
int /*<<< orphan*/ inet_addr(char *);
char *inet_ntoa(TYPE_1__);
int /*<<< orphan*/ memcpy(TYPE_1__ *, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, char *);
int sendto(int, char *, int, int /*<<< orphan*/, struct sockaddr *, int);
scalar_t__ setsockopt(int, int /*<<< orphan*/, int /*<<< orphan*/, int *, int);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
int strlen(char *);
int main(int argc, char *argv[]) {
  int serverSocket, unixSocket, n, retread, ttl;
  struct sockaddr_in serv_addr;
  struct sockaddr_un unixAddr;
  char *data;
  char sendbuf[1500];
  struct timeb tp;
  struct hostent *hp;
  socklen_t len = sizeof(serv_addr);
  memset((char *)&serv_addr, 0, sizeof(serv_addr));
  serv_addr.sin_family = PF_INET;
  serv_addr.sin_addr.s_addr = inet_addr("239.137.194.111");
  serv_addr.sin_port = htons(88888);
  hp = (struct hostent *)gethostbyname("239.137.194.111");
  if (hp == NULL) {
    fprintf(stderr, "%s: %s non trouve dans in /etc/hosts ou dans le DNS\n",
            argv[0], argv[1]);
    exit(1);
  }
  memcpy(&serv_addr.sin_addr, hp->h_addr, hp->h_length);
  printf("IP address: %s\n", inet_ntoa(serv_addr.sin_addr));
  if ((serverSocket = socket(PF_INET, SOCK_DGRAM, 0)) < 0) {
    perror("erreur socket");
    exit(1);
  }
  ttl = 1;
  if (setsockopt(serverSocket, IPPROTO_IP, IP_MULTICAST_TTL, &ttl,
                 sizeof(ttl)) < 0) {
    perror("setsockopt");
    exit(1);
  }
  ftime(&tp);
  data = ctime(&tp.time);
  printf("%s\n", data);
  if ((n = sendto(serverSocket, data, strlen(data), 0,
                  (struct sockaddr *)&serv_addr, sizeof(serv_addr))) !=
      strlen(data)) {
    perror("erreur sendto");
    exit(1);
  }
  close(serverSocket);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x650,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0xc,-0x634(%rbp)
lea    -0x30(%rbp),%rdi
xor    %esi,%esi
mov    $0xc,%edx
call   1090 <memset@plt>
mov    0x2d76(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x28(%rbp)
lea    0xdaa(%rip),%rdi
call   10c0 <inet_addr@plt>
mov    %eax,-0x30(%rbp)
mov    $0x15b38,%edi
call   1070 <htons@plt>
mov    %eax,-0x2c(%rbp)
lea    0xd8e(%rip),%rdi
call   10d0 <gethostbyname@plt>
mov    %rax,-0x630(%rbp)
cmpq   $0x0,-0x630(%rbp)
jne    12ba <main+0xaa>
mov    0x2d3d(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%rdx
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rcx
lea    0xd65(%rip),%rsi
call   10e0 <fprintf@plt>
mov    $0x1,%edi
call   1110 <exit@plt>
lea    -0x30(%rbp),%rdi
mov    -0x630(%rbp),%rax
mov    0x4(%rax),%esi
mov    -0x630(%rbp),%rax
mov    (%rax),%edx
call   10f0 <memcpy@plt>
mov    -0x30(%rbp),%edi
call   1040 <inet_ntoa@plt>
mov    %rax,%rsi
lea    0xd5d(%rip),%rdi
call   1080 <printf@plt>
mov    0x2ccc(%rip),%rax
mov    (%rax),%edi
mov    0x2ce3(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1130 <socket@plt>
mov    %eax,-0x14(%rbp)
cmp    $0x0,%eax
jge    1328 <main+0x118>
lea    0xd3c(%rip),%rdi
call   1100 <perror@plt>
mov    $0x1,%edi
call   1110 <exit@plt>
movl   $0x1,-0x24(%rbp)
mov    -0x14(%rbp),%edi
mov    0x2caf(%rip),%rax
mov    (%rax),%esi
mov    0x2c86(%rip),%rax
mov    (%rax),%edx
lea    -0x24(%rbp),%rcx
mov    $0x4,%r8d
call   1030 <setsockopt@plt>
cmp    $0x0,%rax
jge    1373 <main+0x163>
lea    0xcff(%rip),%rdi
call   1100 <perror@plt>
mov    $0x1,%edi
call   1110 <exit@plt>
lea    -0x628(%rbp),%rdi
call   1120 <ftime@plt>
lea    -0x628(%rbp),%rdi
call   1050 <ctime@plt>
mov    %rax,-0x40(%rbp)
mov    -0x40(%rbp),%rsi
lea    0xcb7(%rip),%rdi
call   1080 <printf@plt>
mov    -0x14(%rbp),%eax
mov    %eax,-0x644(%rbp)
mov    -0x40(%rbp),%rax
mov    %rax,-0x640(%rbp)
mov    -0x40(%rbp),%rdi
call   1060 <strlen@plt>
mov    -0x644(%rbp),%edi
mov    -0x640(%rbp),%rsi
mov    %eax,%edx
lea    -0x30(%rbp),%r8
xor    %ecx,%ecx
mov    $0xc,%r9d
call   10a0 <sendto@plt>
mov    %eax,-0x638(%rbp)
mov    %eax,-0x1c(%rbp)
mov    -0x40(%rbp),%rdi
call   1060 <strlen@plt>
mov    %eax,%ecx
mov    -0x638(%rbp),%eax
cmp    %ecx,%eax
je     1414 <main+0x204>
lea    0xc69(%rip),%rdi
call   1100 <perror@plt>
mov    $0x1,%edi
call   1110 <exit@plt>
mov    -0x14(%rbp),%edi
call   10b0 <close@plt>
xor    %eax,%eax
add    $0x650,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%r14
mov    %rsp,%rdi
xor    %esi,%esi
mov    $0xc,%edx
call   1090 <memset@plt>
mov    0x2d8d(%rip),%rbp
mov    0x0(%rbp),%eax
mov    %eax,0x8(%rsp)
lea    0xdbf(%rip),%rbx
mov    %rbx,%rdi
call   10c0 <inet_addr@plt>
mov    %eax,(%rsp)
mov    $0x15b38,%edi
call   1070 <htons@plt>
mov    %eax,0x4(%rsp)
mov    %rbx,%rdi
call   10d0 <gethostbyname@plt>
test   %rax,%rax
je     134d <main+0x13d>
mov    (%rax),%edx
mov    0x4(%rax),%esi
mov    %rsp,%rdi
call   10f0 <memcpy@plt>
mov    (%rsp),%edi
call   1040 <inet_ntoa@plt>
lea    0xdbe(%rip),%rdi
mov    %rax,%rsi
call   1080 <printf@plt>
mov    0x0(%rbp),%edi
mov    0x2d47(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1130 <socket@plt>
test   %eax,%eax
js     1373 <main+0x163>
mov    %eax,%r15d
movl   $0x1,0xc(%rsp)
mov    0x2d2c(%rip),%rax
mov    (%rax),%esi
mov    0x2d03(%rip),%rax
mov    (%rax),%edx
lea    0xc(%rsp),%rcx
mov    %r15d,%edi
mov    $0x4,%r8d
call   1030 <setsockopt@plt>
test   %rax,%rax
js     137c <main+0x16c>
lea    0x10(%rsp),%r14
mov    %r14,%rdi
call   1120 <ftime@plt>
mov    %r14,%rdi
call   1050 <ctime@plt>
mov    %rax,%rbx
lea    0xd4f(%rip),%rdi
mov    %rax,%rsi
call   1080 <printf@plt>
mov    %rbx,%rdi
call   1060 <strlen@plt>
mov    %rsp,%r8
mov    %r15d,%edi
mov    %rbx,%rsi
mov    %eax,%edx
xor    %ecx,%ecx
mov    $0xc,%r9d
call   10a0 <sendto@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1060 <strlen@plt>
cmp    %eax,%ebp
jne    1385 <main+0x175>
mov    %r15d,%edi
call   10b0 <close@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2c7c(%rip),%rax
mov    (%rax),%edi
mov    (%r14),%rdx
mov    0x8(%r14),%rcx
lea    0xcac(%rip),%rsi
call   10e0 <fprintf@plt>
mov    $0x1,%edi
call   1110 <exit@plt>
lea    0xcdb(%rip),%rdi
jmp    138c <main+0x17c>
lea    0xce0(%rip),%rdi
jmp    138c <main+0x17c>
lea    0xce2(%rip),%rdi
call   1100 <perror@plt>
mov    $0x1,%edi
call   1110 <exit@plt>

LLVM IR (-O0):
%struct.sockaddr_in = type { %struct.TYPE_3__, i32, i32 }
%struct.TYPE_3__ = type { i32 }
%struct.sockaddr_un = type { i32 }
%struct.timeb = type { i32 }
%struct.hostent = type { i32, i32 }
%struct.sockaddr = type { i32 }
@PF_INET = global i32 0
@.str = [16 x i8] c"239.137.194.111\00"
@stderr = global i32 0
@.str.1 = [53 x i8] c"%s: %s non trouve dans in /etc/hosts ou dans le DNS\0A\00"
@.str.2 = [16 x i8] c"IP address: %s\0A\00"
@SOCK_DGRAM = global i32 0
@.str.3 = [14 x i8] c"erreur socket\00"
@IPPROTO_IP = global i32 0
@IP_MULTICAST_TTL = global i32 0
@.str.4 = [11 x i8] c"setsockopt\00"
@.str.5 = [4 x i8] c"%s\0A\00"
@.str.6 = [14 x i8] c"erreur sendto\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 %struct.sockaddr_in
%12 = alloca %struct.sockaddr_un
%13 = alloca i8*
%14 = alloca [1500 x i8]
%15 = alloca %struct.timeb
%16 = alloca %struct.hostent*
%17 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 12, i32* %17
%18 = bitcast %struct.sockaddr_in* %11 to i8*
%19 = call i32 @memset(i8* %18, i32 0, i32 12)
%20 = load i32, i32* @PF_INET
%21 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %11, i32 0, i32 2
store i32 %20, i32* %21
%22 = call i32 @inet_addr(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
%23 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %11, i32 0, i32 0
%24 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %23, i32 0, i32 0
store i32 %22, i32* %24
%25 = call i32 @htons(i32 88888)
%26 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %11, i32 0, i32 1
store i32 %25, i32* %26
%27 = call i64 @gethostbyname(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
%28 = inttoptr i64 %27 to %struct.hostent*
store %struct.hostent* %28, %struct.hostent** %16
%29 = load %struct.hostent*, %struct.hostent** %16
%30 = icmp eq %struct.hostent* %29, null
br i1 %30, label %31, label %41
31: ; preds = %2
%32 = load i32, i32* @stderr
%33 = load i8**, i8*** %5
%34 = getelementptr inbounds i8*, i8** %33, i64 0
%35 = load i8*, i8** %34
%36 = load i8**, i8*** %5
%37 = getelementptr inbounds i8*, i8** %36, i64 1
%38 = load i8*, i8** %37
%39 = call i32 @fprintf(i32 %32, i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.1, i64 0, i64 0), i8* %35, i8* %38)
%40 = call i32 @exit(i32 1)
unreachable
41: ; preds = %2
%42 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %11, i32 0, i32 0
%43 = load %struct.hostent*, %struct.hostent** %16
%44 = getelementptr inbounds %struct.hostent, %struct.hostent* %43, i32 0, i32 1
%45 = load i32, i32* %44
%46 = load %struct.hostent*, %struct.hostent** %16
%47 = getelementptr inbounds %struct.hostent, %struct.hostent* %46, i32 0, i32 0
%48 = load i32, i32* %47
%49 = call i32 @memcpy(%struct.TYPE_3__* %42, i32 %45, i32 %48)
%50 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %11, i32 0, i32 0
%51 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %50, i32 0, i32 0
%52 = load i32, i32* %51
%53 = call i8* @inet_ntoa(i32 %52)
%54 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i8* %53)
%55 = load i32, i32* @PF_INET
%56 = load i32, i32* @SOCK_DGRAM
%57 = call i32 @socket(i32 %55, i32 %56, i32 0)
store i32 %57, i32* %6
%58 = icmp slt i32 %57, 0
br i1 %58, label %59, label %62
59: ; preds = %41
%60 = call i32 @perror(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0))
%61 = call i32 @exit(i32 1)
unreachable
62: ; preds = %41
store i32 1, i32* %10
%63 = load i32, i32* %6
%64 = load i32, i32* @IPPROTO_IP
%65 = load i32, i32* @IP_MULTICAST_TTL
%66 = call i64 @setsockopt(i32 %63, i32 %64, i32 %65, i32* %10, i32 4)
%67 = icmp slt i64 %66, 0
br i1 %67, label %68, label %71
68: ; preds = %62
%69 = call i32 @perror(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0))
%70 = call i32 @exit(i32 1)
unreachable
71: ; preds = %62
%72 = call i32 @ftime(%struct.timeb* %15)
%73 = getelementptr inbounds %struct.timeb, %struct.timeb* %15, i32 0, i32 0
%74 = call i8* @ctime(i32* %73)
store i8* %74, i8** %13
%75 = load i8*, i8** %13
%76 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i8* %75)
%77 = load i32, i32* %6
%78 = load i8*, i8** %13
%79 = load i8*, i8** %13
%80 = call i32 @strlen(i8* %79)
%81 = bitcast %struct.sockaddr_in* %11 to %struct.sockaddr*
%82 = call i32 @sendto(i32 %77, i8* %78, i32 %80, i32 0, %struct.sockaddr* %81, i32 12)
store i32 %82, i32* %8
%83 = load i8*, i8** %13
%84 = call i32 @strlen(i8* %83)
%85 = icmp ne i32 %82, %84
br i1 %85, label %86, label %89
86: ; preds = %71
%87 = call i32 @perror(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.6, i64 0, i64 0))
%88 = call i32 @exit(i32 1)
unreachable
89: ; preds = %71
%90 = load i32, i32* %6
%91 = call i32 @close(i32 %90)
ret i32 0
}

LLVM IR (-O2):
%struct.sockaddr_in = type { %struct.TYPE_3__, i32, i32 }
%struct.TYPE_3__ = type { i32 }
%struct.timeb = type { i32 }
%struct.hostent = type { i32, i32 }
%struct.sockaddr = type { i32 }
@PF_INET = global i32 0
@.str = [16 x i8] c"239.137.194.111\00"
@stderr = global i32 0
@.str.1 = [53 x i8] c"%s: %s non trouve dans in /etc/hosts ou dans le DNS\0A\00"
@.str.2 = [16 x i8] c"IP address: %s\0A\00"
@SOCK_DGRAM = global i32 0
@.str.3 = [14 x i8] c"erreur socket\00"
@IPPROTO_IP = global i32 0
@IP_MULTICAST_TTL = global i32 0
@.str.4 = [11 x i8] c"setsockopt\00"
@.str.5 = [4 x i8] c"%s\0A\00"
@.str.6 = [14 x i8] c"erreur sendto\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = alloca %struct.sockaddr_in
%5 = alloca %struct.timeb
%6 = bitcast i32* %3 to i8*
%7 = bitcast %struct.sockaddr_in* %4 to i8*
%8 = bitcast %struct.timeb* %5 to i8*
%9 = call i32 @memset(i8* %7, i32 0, i32 12)
%10 = load i32, i32* @PF_INET
%11 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %4, i64 0, i32 2
store i32 %10, i32* %11
%12 = call i32 @inet_addr(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
%13 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %4, i64 0, i32 0, i32 0
store i32 %12, i32* %13
%14 = call i32 @htons(i32 88888)
%15 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %4, i64 0, i32 1
store i32 %14, i32* %15
%16 = call i64 @gethostbyname(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
%17 = inttoptr i64 %16 to %struct.hostent*
%18 = icmp eq i64 %16, 0
br i1 %18, label %19, label %26
19: ; preds = %2
%20 = load i32, i32* @stderr
%21 = load i8*, i8** %1
%22 = getelementptr inbounds i8*, i8** %1, i64 1
%23 = load i8*, i8** %22
%24 = call i32 @fprintf(i32 %20, i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.1, i64 0, i64 0), i8* %21, i8* %23)
%25 = call i32 @exit(i32 1)
unreachable
26: ; preds = %2
%27 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %4, i64 0, i32 0
%28 = getelementptr inbounds %struct.hostent, %struct.hostent* %17, i64 0, i32 1
%29 = load i32, i32* %28
%30 = getelementptr inbounds %struct.hostent, %struct.hostent* %17, i64 0, i32 0
%31 = load i32, i32* %30
%32 = call i32 @memcpy(%struct.TYPE_3__* %27, i32 %29, i32 %31)
%33 = load i32, i32* %13
%34 = call i8* @inet_ntoa(i32 %33)
%35 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i8* %34)
%36 = load i32, i32* @PF_INET
%37 = load i32, i32* @SOCK_DGRAM
%38 = call i32 @socket(i32 %36, i32 %37, i32 0)
%39 = icmp slt i32 %38, 0
br i1 %39, label %40, label %43
40: ; preds = %26
%41 = call i32 @perror(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0))
%42 = call i32 @exit(i32 1)
unreachable
43: ; preds = %26
store i32 1, i32* %3
%44 = load i32, i32* @IPPROTO_IP
%45 = load i32, i32* @IP_MULTICAST_TTL
%46 = call i64 @setsockopt(i32 %38, i32 %44, i32 %45, i32* %3, i32 4)
%47 = icmp slt i64 %46, 0
br i1 %47, label %48, label %51
48: ; preds = %43
%49 = call i32 @perror(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0))
%50 = call i32 @exit(i32 1)
unreachable
51: ; preds = %43
%52 = call i32 @ftime(%struct.timeb* %5)
%53 = getelementptr inbounds %struct.timeb, %struct.timeb* %5, i64 0, i32 0
%54 = call i8* @ctime(i32* %53)
%55 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i8* %54)
%56 = call i32 @strlen(i8* %54)
%57 = bitcast %struct.sockaddr_in* %4 to %struct.sockaddr*
%58 = call i32 @sendto(i32 %38, i8* %54, i32 %56, i32 0, %struct.sockaddr* %57, i32 12)
%59 = call i32 @strlen(i8* %54)
%60 = icmp eq i32 %58, %59
br i1 %60, label %64, label %61
61: ; preds = %51
%62 = call i32 @perror(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.6, i64 0, i64 0))
%63 = call i32 @exit(i32 1)
unreachable
64: ; preds = %51
%65 = call i32 @close(i32 %38)
ret i32 0
}