#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 sockaddr_in6 {
  scalar_t__ sin6_family;
};
struct sockaddr {
  int dummy;
};
typedef int ssize_t;

/* Variables and functions */
scalar_t__ AF_INET6;
int sendto(int const, void const *, size_t const, int /*<<< orphan*/,
           struct sockaddr *, int);
int inet6_tx_rcast(const int sock_fd, const void *pkt, const size_t pkt_len,
                   const struct sockaddr_in6 inet6_dests[]) {
  const struct sockaddr_in6 *sa6_dest;
  unsigned int tx_success = 0;
  ssize_t ret;
  {};
  sa6_dest = inet6_dests;
  while (sa6_dest->sin6_family == AF_INET6) {
    ret = sendto(sock_fd, pkt, pkt_len, 0, (struct sockaddr *)sa6_dest,
                 sizeof(struct sockaddr_in6));
    if (ret != -1) {
      tx_success++;
    }
    {};
    {};
    sa6_dest++;
  }
  {};
  return tx_success;
}


x86 assembly (clang, -O0):
<inet6_tx_rcast>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
mov    (%rax),%rax
mov    0x2ea4(%rip),%rcx
cmp    (%rcx),%rax
jne    1190 <inet6_tx_rcast+0x80>
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x28(%rbp),%r8
xor    %ecx,%ecx
mov    $0x8,%r9d
call   1030 <sendto@plt>
mov    %eax,-0x30(%rbp)
cmpl   $0xffffffff,-0x30(%rbp)
je     117f <inet6_tx_rcast+0x6f>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
mov    -0x28(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x28(%rbp)
jmp    1136 <inet6_tx_rcast+0x26>
mov    -0x2c(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<inet6_tx_rcast>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    (%rcx),%rax
mov    0x2ec3(%rip),%r13
xor    %ebp,%ebp
cmp    0x0(%r13),%rax
jne    1171 <inet6_tx_rcast+0x61>
mov    %rcx,%rbx
mov    %rdx,%r14
mov    %rsi,%r15
mov    %edi,%r12d
xor    %ebp,%ebp
nopl   0x0(%rax,%rax,1)
mov    %r12d,%edi
mov    %r15,%rsi
mov    %r14,%rdx
xor    %ecx,%ecx
mov    %rbx,%r8
mov    $0x8,%r9d
call   1030 <sendto@plt>
xor    %ecx,%ecx
cmp    $0xffffffff,%eax
setne  %cl
add    %ecx,%ebp
mov    0x8(%rbx),%rax
add    $0x8,%rbx
cmp    0x0(%r13),%rax
je     1140 <inet6_tx_rcast+0x30>
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.sockaddr_in6 = type { i64 }
%struct.sockaddr = type { i32 }
@AF_INET6 = global i64 0
define i32 @inet6_tx_rcast(i32 %0, i8* %1, i64 %2, %struct.sockaddr_in6* %3) {
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i64
%8 = alloca %struct.sockaddr_in6*
%9 = alloca %struct.sockaddr_in6*
%10 = alloca i32
%11 = alloca i32
store i32 %0, i32* %5
store i8* %1, i8** %6
store i64 %2, i64* %7
store %struct.sockaddr_in6* %3, %struct.sockaddr_in6** %8
store i32 0, i32* %10
%12 = load %struct.sockaddr_in6*, %struct.sockaddr_in6** %8
store %struct.sockaddr_in6* %12, %struct.sockaddr_in6** %9
br label %13
13: ; preds = %31, %4
%14 = load %struct.sockaddr_in6*, %struct.sockaddr_in6** %9
%15 = getelementptr inbounds %struct.sockaddr_in6, %struct.sockaddr_in6* %14, i32 0, i32 0
%16 = load i64, i64* %15
%17 = load i64, i64* @AF_INET6
%18 = icmp eq i64 %16, %17
br i1 %18, label %19, label %34
19: ; preds = %13
%20 = load i32, i32* %5
%21 = load i8*, i8** %6
%22 = load i64, i64* %7
%23 = load %struct.sockaddr_in6*, %struct.sockaddr_in6** %9
%24 = bitcast %struct.sockaddr_in6* %23 to %struct.sockaddr*
%25 = call i32 @sendto(i32 %20, i8* %21, i64 %22, i32 0, %struct.sockaddr* %24, i32 8)
store i32 %25, i32* %11
%26 = load i32, i32* %11
%27 = icmp ne i32 %26, -1
br i1 %27, label %28, label %31
28: ; preds = %19
%29 = load i32, i32* %10
%30 = add i32 %29, 1
store i32 %30, i32* %10
br label %31
31: ; preds = %28, %19
%32 = load %struct.sockaddr_in6*, %struct.sockaddr_in6** %9
%33 = getelementptr inbounds %struct.sockaddr_in6, %struct.sockaddr_in6* %32, i32 1
store %struct.sockaddr_in6* %33, %struct.sockaddr_in6** %9
br label %13
34: ; preds = %13
%35 = load i32, i32* %10
ret i32 %35
}

LLVM IR (-O2):
%struct.sockaddr_in6 = type { i64 }
%struct.sockaddr = type { i32 }
@AF_INET6 = global i64 0
define i32 @inet6_tx_rcast(i32 %0, i8* %1, i64 %2, %struct.sockaddr_in6* %3) {
%5 = getelementptr inbounds %struct.sockaddr_in6, %struct.sockaddr_in6* %3, i64 0, i32 0
%6 = load i64, i64* %5
%7 = load i64, i64* @AF_INET6
%8 = icmp eq i64 %6, %7
br i1 %8, label %9, label %22
9: ; preds = %4, %9
%10 = phi %struct.sockaddr_in6* [ %17, %9 ], [ %3, %4 ]
%11 = phi i32 [ %16, %9 ], [ 0, %4 ]
%12 = bitcast %struct.sockaddr_in6* %10 to %struct.sockaddr*
%13 = tail call i32 @sendto(i32 %0, i8* %1, i64 %2, i32 0, %struct.sockaddr* %12, i32 8)
%14 = icmp ne i32 %13, -1
%15 = zext i1 %14 to i32
%16 = add i32 %11, %15
%17 = getelementptr inbounds %struct.sockaddr_in6, %struct.sockaddr_in6* %10, i64 1
%18 = getelementptr inbounds %struct.sockaddr_in6, %struct.sockaddr_in6* %17, i64 0, i32 0
%19 = load i64, i64* %18
%20 = load i64, i64* @AF_INET6
%21 = icmp eq i64 %19, %20
br i1 %21, label %9, label %22
22: ; preds = %9, %4
%23 = phi i32 [ 0, %4 ], [ %16, %9 ]
ret i32 %23
}