#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;
struct sockaddr {
  int dummy;
};
typedef int /*<<< orphan*/ socklen_t;
typedef int /*<<< orphan*/ rec_data;

/* Variables and functions */
int recvfrom(int, int /*<<< orphan*/ **, int, int /*<<< orphan*/,
             struct sockaddr *, int /*<<< orphan*/ *);
int sendto(int, int /*<<< orphan*/ *, int, int /*<<< orphan*/,
           struct sockaddr *, int /*<<< orphan*/);
void transmit_reqs_once(int num_of_reqs, uint8_t *reqs, int *req_size_arr,
                        int socket, struct sockaddr *si_other, socklen_t slen) {
  uint8_t *req_addr;
  uint8_t rec_data[4096];
  int sent_items, rec_items;
  int i;
  char req_str[100];
  i = 0;
  req_addr = reqs;
  do {
    sent_items = sendto(socket, req_addr, req_size_arr[i], 0, si_other, slen);
    req_addr += req_size_arr[i];
    rec_items =
        recvfrom(socket, &rec_data, sizeof(rec_data), 0, si_other, &slen);
    i++;
  } while (i < num_of_reqs);
}


x86 assembly (clang, -O0):
<transmit_reqs_once>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40b0,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9d,-0x2c(%rbp)
movl   $0x0,-0x404c(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x1c(%rbp),%edi
mov    -0x38(%rbp),%rsi
mov    -0x18(%rbp),%rax
movslq -0x404c(%rbp),%rcx
mov    (%rax,%rcx,4),%edx
mov    -0x28(%rbp),%r8
mov    -0x2c(%rbp),%r9d
xor    %ecx,%ecx
call   1030 <sendto@plt>
mov    %eax,-0x4044(%rbp)
mov    -0x18(%rbp),%rax
movslq -0x404c(%rbp),%rcx
mov    (%rax,%rcx,4),%ecx
mov    -0x38(%rbp),%rax
movslq %ecx,%rcx
shl    $0x2,%rcx
add    %rcx,%rax
mov    %rax,-0x38(%rbp)
mov    -0x1c(%rbp),%edi
lea    -0x4040(%rbp),%rsi
mov    -0x28(%rbp),%r8
mov    $0x4000,%edx
xor    %ecx,%ecx
lea    -0x2c(%rbp),%r9
call   1040 <recvfrom@plt>
mov    %eax,-0x4048(%rbp)
mov    -0x404c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x404c(%rbp)
mov    -0x404c(%rbp),%eax
cmp    -0x4(%rbp),%eax
jl     1153 <transmit_reqs_once+0x33>
add    $0x40b0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<transmit_reqs_once>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x4018,%rsp
mov    %r8,%r14
mov    %ecx,%r15d
mov    %rdx,%rbx
mov    %rsi,%rbp
mov    %r9d,0x4(%rsp)
cmp    $0x2,%edi
mov    $0x1,%eax
cmovge %edi,%eax
add    $0xffffffffffffffff,%rax
mov    %rax,0x8(%rsp)
xor    %r13d,%r13d
nopl   0x0(%rax)
mov    (%rbx,%r13,4),%edx
mov    %r15d,%edi
mov    %rbp,%rsi
xor    %ecx,%ecx
mov    %r14,%r8
call   1030 <sendto@plt>
movslq (%rbx,%r13,4),%r12
mov    %r15d,%edi
lea    0x10(%rsp),%rsi
mov    $0x4000,%edx
xor    %ecx,%ecx
mov    %r14,%r8
lea    0x4(%rsp),%r9
call   1040 <recvfrom@plt>
cmp    %r13,0x8(%rsp)
je     11ab <transmit_reqs_once+0x8b>
lea    0x0(%rbp,%r12,4),%rbp
mov    0x4(%rsp),%r9d
add    $0x1,%r13
jmp    1160 <transmit_reqs_once+0x40>
add    $0x4018,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.sockaddr = type { i32 }
define void @transmit_reqs_once(i32 %0, i32* %1, i32* %2, i32 %3, %struct.sockaddr* %4, i32 %5) {
%7 = alloca i32
%8 = alloca i32*
%9 = alloca i32*
%10 = alloca i32
%11 = alloca %struct.sockaddr*
%12 = alloca i32
%13 = alloca i32*
%14 = alloca [4096 x i32]
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32
%18 = alloca [100 x i8]
store i32 %0, i32* %7
store i32* %1, i32** %8
store i32* %2, i32** %9
store i32 %3, i32* %10
store %struct.sockaddr* %4, %struct.sockaddr** %11
store i32 %5, i32* %12
store i32 0, i32* %17
%19 = load i32*, i32** %8
store i32* %19, i32** %13
br label %20
20: ; preds = %45, %6
%21 = load i32, i32* %10
%22 = load i32*, i32** %13
%23 = load i32*, i32** %9
%24 = load i32, i32* %17
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds i32, i32* %23, i64 %25
%27 = load i32, i32* %26
%28 = load %struct.sockaddr*, %struct.sockaddr** %11
%29 = load i32, i32* %12
%30 = call i32 @sendto(i32 %21, i32* %22, i32 %27, i32 0, %struct.sockaddr* %28, i32 %29)
store i32 %30, i32* %15
%31 = load i32*, i32** %9
%32 = load i32, i32* %17
%33 = sext i32 %32 to i64
%34 = getelementptr inbounds i32, i32* %31, i64 %33
%35 = load i32, i32* %34
%36 = load i32*, i32** %13
%37 = sext i32 %35 to i64
%38 = getelementptr inbounds i32, i32* %36, i64 %37
store i32* %38, i32** %13
%39 = load i32, i32* %10
%40 = bitcast [4096 x i32]* %14 to i32**
%41 = load %struct.sockaddr*, %struct.sockaddr** %11
%42 = call i32 @recvfrom(i32 %39, i32** %40, i32 16384, i32 0, %struct.sockaddr* %41, i32* %12)
store i32 %42, i32* %16
%43 = load i32, i32* %17
%44 = add nsw i32 %43, 1
store i32 %44, i32* %17
br label %45
45: ; preds = %20
%46 = load i32, i32* %17
%47 = load i32, i32* %7
%48 = icmp slt i32 %46, %47
br i1 %48, label %20, label %49
49: ; preds = %45
ret void
}

LLVM IR (-O2):
%struct.sockaddr = type { i32 }
define void @transmit_reqs_once(i32 %0, i32* %1, i32* nocapture %2, i32 %3, %struct.sockaddr* %4, i32 %5) {
%7 = alloca i32
%8 = alloca [4096 x i32]
store i32 %5, i32* %7
%9 = bitcast [4096 x i32]* %8 to i8*
%10 = bitcast [4096 x i32]* %8 to i32**
%11 = call i32 @llvm.smax.i32(i32 %0, i32 1)
%12 = zext i32 %11 to i64
br label %13
13: ; preds = %24, %6
%14 = phi i32 [ %27, %24 ], [ %5, %6 ]
%15 = phi i64 [ %22, %24 ], [ 0, %6 ]
%16 = phi i32* [ %26, %24 ], [ %1, %6 ]
%17 = getelementptr inbounds i32, i32* %2, i64 %15
%18 = load i32, i32* %17
%19 = call i32 @sendto(i32 %3, i32* %16, i32 %18, i32 0, %struct.sockaddr* %4, i32 %14)
%20 = load i32, i32* %17
%21 = call i32 @recvfrom(i32 %3, i32** %10, i32 16384, i32 0, %struct.sockaddr* %4, i32* %7)
%22 = add nuw nsw i64 %15, 1
%23 = icmp eq i64 %22, %12
br i1 %23, label %28, label %24
24: ; preds = %13
%25 = sext i32 %20 to i64
%26 = getelementptr inbounds i32, i32* %16, i64 %25
%27 = load i32, i32* %7
br label %13
28: ; preds = %13
ret void
}