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

/* Type definitions */
struct TYPE_2__ {
  int /*<<< orphan*/ s_addr;
};
struct sockaddr_in {
  TYPE_1__ sin_addr;
  int /*<<< orphan*/ sin_port;
  int /*<<< orphan*/ sin_family;
};
struct sockaddr {
  int dummy;
};
typedef int /*<<< orphan*/ broadcast_address;

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
int /*<<< orphan*/ EXIT_FAILURE;
int /*<<< orphan*/ INADDR_BROADCAST;
int /*<<< orphan*/ LOG_ERR;
int /*<<< orphan*/ errno;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ htons(long);
int /*<<< orphan*/ memset(struct sockaddr_in *, int /*<<< orphan*/, int);
int sendto(int, char const *, int /*<<< orphan*/, int /*<<< orphan*/,
           struct sockaddr *, int);
int /*<<< orphan*/ sleep(long);
int /*<<< orphan*/ strerror(int /*<<< orphan*/);
int /*<<< orphan*/ strlen(char const *);
long strtol(char const *, int /*<<< orphan*/ *, int);
int /*<<< orphan*/ syslog(int /*<<< orphan*/, char *, int /*<<< orphan*/);
void send_broadcast(int fd_socket, const char *dgram_message,
                    const char *dgram_port, long sleep_sec) {
  struct sockaddr_in broadcast_address;
  long port = 0;
  int error = 0;
  port = strtol(dgram_port, NULL, 10);
  memset(&broadcast_address, 0, sizeof(broadcast_address));
  broadcast_address.sin_family = AF_INET;
  broadcast_address.sin_port = htons(port);
  broadcast_address.sin_addr.s_addr = INADDR_BROADCAST;
  while (1) {
    error = sendto(fd_socket, dgram_message, strlen(dgram_message), 0,
                   (struct sockaddr *)&broadcast_address,
                   sizeof(broadcast_address));
    if (error < 0) {
      syslog(LOG_ERR, "sendto: %s\n", strerror(errno));
      exit(EXIT_FAILURE);
    }
    sleep(sleep_sec);
  }
}


x86 assembly (clang, -O0):
<send_broadcast>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
movq   $0x0,-0x38(%rbp)
movl   $0x0,-0x3c(%rbp)
mov    -0x18(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0xa,%edx
call   1070 <strtol@plt>
mov    %rax,-0x38(%rbp)
lea    -0x30(%rbp),%rdi
xor    %esi,%esi
mov    $0xc,%edx
call   1050 <memset@plt>
mov    0x2e05(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x28(%rbp)
mov    -0x38(%rbp),%rdi
call   1040 <htons@plt>
mov    %eax,-0x2c(%rbp)
mov    0x2de5(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x30(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0x4c(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x4c(%rbp),%edi
mov    -0x48(%rbp),%rsi
mov    %eax,%edx
lea    -0x30(%rbp),%r8
xor    %ecx,%ecx
mov    $0xc,%r9d
call   1060 <sendto@plt>
mov    %eax,-0x3c(%rbp)
cmpl   $0x0,-0x3c(%rbp)
jge    1277 <send_broadcast+0xe7>
mov    0x2d73(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x50(%rbp)
mov    0x2d7f(%rip),%rax
mov    (%rax),%edi
call   10a0 <strerror@plt>
mov    -0x50(%rbp),%edi
mov    %eax,%edx
lea    0xd9c(%rip),%rsi
call   1080 <syslog@plt>
mov    0x2d58(%rip),%rax
mov    (%rax),%edi
call   1090 <exit@plt>
mov    -0x20(%rbp),%rdi
call   10b0 <sleep@plt>
jmp    1200 <send_broadcast+0x70>

x86 assembly (clang, -O2):
<send_broadcast>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %rcx,%r14
mov    %rsi,%rbx
mov    %edi,%ebp
mov    %rdx,%rdi
xor    %esi,%esi
mov    $0xa,%edx
call   1070 <strtol@plt>
mov    %rax,%r15
mov    %rsp,%r12
mov    %r12,%rdi
xor    %esi,%esi
mov    $0xc,%edx
call   1050 <memset@plt>
mov    0x2e19(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x8(%rsp)
mov    %r15,%rdi
call   1040 <htons@plt>
mov    %eax,0x4(%rsp)
mov    0x2df8(%rip),%rax
mov    (%rax),%eax
mov    %eax,(%rsp)
mov    %rbx,%rdi
call   1030 <strlen@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %eax,%edx
xor    %ecx,%ecx
mov    %r12,%r8
mov    $0xc,%r9d
call   1060 <sendto@plt>
test   %eax,%eax
js     124b <send_broadcast+0xbb>
mov    %rsp,%r15
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %r14,%rdi
call   10b0 <sleep@plt>
mov    %rbx,%rdi
call   1030 <strlen@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %eax,%edx
xor    %ecx,%ecx
mov    %r15,%r8
mov    $0xc,%r9d
call   1060 <sendto@plt>
test   %eax,%eax
jns    1220 <send_broadcast+0x90>
mov    0x2d66(%rip),%rax
mov    (%rax),%ebx
mov    0x2d75(%rip),%rax
mov    (%rax),%edi
call   10a0 <strerror@plt>
lea    0xd97(%rip),%rsi
mov    %ebx,%edi
mov    %eax,%edx
call   1080 <syslog@plt>
mov    0x2d4f(%rip),%rax
mov    (%rax),%edi
call   1090 <exit@plt>

LLVM IR (-O0):
%struct.sockaddr_in = type { %struct.TYPE_2__, i32, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.sockaddr = type { i32 }
@AF_INET = global i32 0
@INADDR_BROADCAST = global i32 0
@LOG_ERR = global i32 0
@.str = [12 x i8] c"sendto: %s\0A\00"
@errno = global i32 0
@EXIT_FAILURE = global i32 0
define void @send_broadcast(i32 %0, i8* %1, i8* %2, i64 %3) {
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i64
%9 = alloca %struct.sockaddr_in
%10 = alloca i64
%11 = alloca i32
store i32 %0, i32* %5
store i8* %1, i8** %6
store i8* %2, i8** %7
store i64 %3, i64* %8
store i64 0, i64* %10
store i32 0, i32* %11
%12 = load i8*, i8** %7
%13 = call i64 @strtol(i8* %12, i32* null, i32 10)
store i64 %13, i64* %10
%14 = call i32 @memset(%struct.sockaddr_in* %9, i32 0, i32 12)
%15 = load i32, i32* @AF_INET
%16 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %9, i32 0, i32 2
store i32 %15, i32* %16
%17 = load i64, i64* %10
%18 = call i32 @htons(i64 %17)
%19 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %9, i32 0, i32 1
store i32 %18, i32* %19
%20 = load i32, i32* @INADDR_BROADCAST
%21 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %9, i32 0, i32 0
%22 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %21, i32 0, i32 0
store i32 %20, i32* %22
br label %23
23: ; preds = %4, %39
%24 = load i32, i32* %5
%25 = load i8*, i8** %6
%26 = load i8*, i8** %6
%27 = call i32 @strlen(i8* %26)
%28 = bitcast %struct.sockaddr_in* %9 to %struct.sockaddr*
%29 = call i32 @sendto(i32 %24, i8* %25, i32 %27, i32 0, %struct.sockaddr* %28, i32 12)
store i32 %29, i32* %11
%30 = load i32, i32* %11
%31 = icmp slt i32 %30, 0
br i1 %31, label %32, label %39
32: ; preds = %23
%33 = load i32, i32* @LOG_ERR
%34 = load i32, i32* @errno
%35 = call i32 @strerror(i32 %34)
%36 = call i32 @syslog(i32 %33, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 %35)
%37 = load i32, i32* @EXIT_FAILURE
%38 = call i32 @exit(i32 %37)
unreachable
39: ; preds = %23
%40 = load i64, i64* %8
%41 = call i32 @sleep(i64 %40)
br label %23
}

LLVM IR (-O2):
%struct.sockaddr_in = type { %struct.TYPE_2__, i32, i32 }
%struct.TYPE_2__ = type { i32 }
%struct.sockaddr = type { i32 }
@AF_INET = global i32 0
@INADDR_BROADCAST = global i32 0
@LOG_ERR = global i32 0
@.str = [12 x i8] c"sendto: %s\0A\00"
@errno = global i32 0
@EXIT_FAILURE = global i32 0
define void @send_broadcast(i32 %0, i8* %1, i8* nocapture %2, i64 %3) {
%5 = alloca %struct.sockaddr_in
%6 = bitcast %struct.sockaddr_in* %5 to i8*
%7 = tail call i64 @strtol(i8* nocapture %2, i32* null, i32 10)
%8 = call i32 @memset(%struct.sockaddr_in* %5, i32 0, i32 12)
%9 = load i32, i32* @AF_INET
%10 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %5, i64 0, i32 2
store i32 %9, i32* %10
%11 = call i32 @htons(i64 %7)
%12 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %5, i64 0, i32 1
store i32 %11, i32* %12
%13 = load i32, i32* @INADDR_BROADCAST
%14 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %5, i64 0, i32 0, i32 0
store i32 %13, i32* %14
%15 = call i32 @strlen(i8* %1)
%16 = bitcast %struct.sockaddr_in* %5 to %struct.sockaddr*
%17 = call i32 @sendto(i32 %0, i8* %1, i32 %15, i32 0, %struct.sockaddr* %16, i32 12)
%18 = icmp slt i32 %17, 0
br i1 %18, label %19, label %26
19: ; preds = %26, %4
%20 = load i32, i32* @LOG_ERR
%21 = load i32, i32* @errno
%22 = call i32 @strerror(i32 %21)
%23 = call i32 @syslog(i32 %20, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 %22)
%24 = load i32, i32* @EXIT_FAILURE
%25 = call i32 @exit(i32 %24)
unreachable
26: ; preds = %4, %26
%27 = call i32 @sleep(i64 %3)
%28 = call i32 @strlen(i8* %1)
%29 = call i32 @sendto(i32 %0, i8* %1, i32 %28, i32 0, %struct.sockaddr* %16, i32 12)
%30 = icmp slt i32 %29, 0
br i1 %30, label %19, label %26
}