#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*/ uint8_t;

/* Variables and functions */
int /*<<< orphan*/ perror(char *);
int send(int const, int /*<<< orphan*/ const *, int, int /*<<< orphan*/);
void send_to_all_tcp_clients(const int list_client_sockets[],
                             const uint8_t message[], int message_length) {
  int max_number_clients = sizeof(&list_client_sockets) / sizeof(int);
  for (int i = 0; i < max_number_clients; i++) {
    if (list_client_sockets[i] > 0) {
      if (send(list_client_sockets[i], message, message_length, 0) !=
          message_length) {
        perror("DB_TCP_SERVER: Sending message via TCP");
      }
    }
  }
}


x86 assembly (clang, -O0):
<send_to_all_tcp_clients>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
movl   $0x2,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x18(%rbp),%eax
jge    11a5 <send_to_all_tcp_clients+0x85>
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
cmpl   $0x0,(%rax,%rcx,4)
jle    1192 <send_to_all_tcp_clients+0x72>
mov    -0x8(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,4),%edi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
xor    %ecx,%ecx
call   1030 <send@plt>
cmp    -0x14(%rbp),%eax
je     118d <send_to_all_tcp_clients+0x6d>
lea    0xe78(%rip),%rdi
call   1040 <perror@plt>
jmp    1192 <send_to_all_tcp_clients+0x72>
jmp    1197 <send_to_all_tcp_clients+0x77>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1141 <send_to_all_tcp_clients+0x21>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<send_to_all_tcp_clients>:
push   %rbp
push   %r14
push   %rbx
mov    %edx,%ebp
mov    %rsi,%r14
mov    %rdi,%rbx
mov    (%rdi),%edi
test   %edi,%edi
jle    1142 <send_to_all_tcp_clients+0x22>
mov    %r14,%rsi
mov    %ebp,%edx
xor    %ecx,%ecx
call   1030 <send@plt>
cmp    %ebp,%eax
jne    115e <send_to_all_tcp_clients+0x3e>
mov    0x4(%rbx),%edi
test   %edi,%edi
jle    1159 <send_to_all_tcp_clients+0x39>
mov    %r14,%rsi
mov    %ebp,%edx
xor    %ecx,%ecx
call   1030 <send@plt>
cmp    %ebp,%eax
jne    116c <send_to_all_tcp_clients+0x4c>
pop    %rbx
pop    %r14
pop    %rbp
ret
lea    0xe9b(%rip),%rdi
call   1040 <perror@plt>
jmp    1142 <send_to_all_tcp_clients+0x22>
lea    0xe8d(%rip),%rdi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1040 <perror@plt>

LLVM IR (-O0):
@.str = [39 x i8] c"DB_TCP_SERVER: Sending message via TCP\00"
define void @send_to_all_tcp_clients(i32* %0, i32* %1, i32 %2) {
%4 = alloca i32*
%5 = alloca i32*
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
store i32* %0, i32** %4
store i32* %1, i32** %5
store i32 %2, i32* %6
store i32 2, i32* %7
store i32 0, i32* %8
br label %9
9: ; preds = %35, %3
%10 = load i32, i32* %8
%11 = load i32, i32* %7
%12 = icmp slt i32 %10, %11
br i1 %12, label %13, label %38
13: ; preds = %9
%14 = load i32*, i32** %4
%15 = load i32, i32* %8
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds i32, i32* %14, i64 %16
%18 = load i32, i32* %17
%19 = icmp sgt i32 %18, 0
br i1 %19, label %20, label %34
20: ; preds = %13
%21 = load i32*, i32** %4
%22 = load i32, i32* %8
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds i32, i32* %21, i64 %23
%25 = load i32, i32* %24
%26 = load i32*, i32** %5
%27 = load i32, i32* %6
%28 = call i32 @send(i32 %25, i32* %26, i32 %27, i32 0)
%29 = load i32, i32* %6
%30 = icmp ne i32 %28, %29
br i1 %30, label %31, label %33
31: ; preds = %20
%32 = call i32 @perror(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0))
br label %33
33: ; preds = %31, %20
br label %34
34: ; preds = %33, %13
br label %35
35: ; preds = %34
%36 = load i32, i32* %8
%37 = add nsw i32 %36, 1
store i32 %37, i32* %8
br label %9
38: ; preds = %9
ret void
}

LLVM IR (-O2):
@.str = [39 x i8] c"DB_TCP_SERVER: Sending message via TCP\00"
define void @send_to_all_tcp_clients(i32* nocapture %0, i32* %1, i32 %2) {
%4 = load i32, i32* %0
%5 = icmp sgt i32 %4, 0
br i1 %5, label %6, label %11
6: ; preds = %3
%7 = tail call i32 @send(i32 %4, i32* %1, i32 %2, i32 0)
%8 = icmp eq i32 %7, %2
br i1 %8, label %11, label %9
9: ; preds = %6
%10 = tail call i32 @perror(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0))
br label %11
11: ; preds = %3, %9, %6
%12 = getelementptr inbounds i32, i32* %0, i64 1
%13 = load i32, i32* %12
%14 = icmp sgt i32 %13, 0
br i1 %14, label %15, label %20
15: ; preds = %11
%16 = tail call i32 @send(i32 %13, i32* %1, i32 %2, i32 0)
%17 = icmp eq i32 %16, %2
br i1 %17, label %20, label %18
18: ; preds = %15
%19 = tail call i32 @perror(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0))
br label %20
20: ; preds = %18, %15, %11
ret void
}