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

/* Variables and functions */
int /*<<< orphan*/ MW_UDPBegin(unsigned int);
int /*<<< orphan*/ MW_UDPFinalWrite(unsigned char *, int, unsigned char,
                                    unsigned char, unsigned char, unsigned char,
                                    unsigned int);
void udpWriteEnergia(unsigned char *data, int dataSize, unsigned int localPort,
                     unsigned int remotePort, unsigned char remoteIP1,
                     unsigned char remoteIP2, unsigned char remoteIP3,
                     unsigned char remoteIP4) {
  static int only_one_ethernet_begin;
  if (only_one_ethernet_begin == 0) {
    MW_UDPBegin(localPort);
    only_one_ethernet_begin++;
  }
  MW_UDPFinalWrite(data, dataSize, remoteIP1, remoteIP2, remoteIP3, remoteIP4,
                   remotePort);
}


x86 assembly (clang, -O0):
<udpWriteEnergia>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %r8d,-0x28(%rbp)
mov    %ecx,%eax
mov    -0x28(%rbp),%ecx
mov    %eax,-0x24(%rbp)
mov    %edx,%eax
mov    -0x24(%rbp),%edx
mov    %eax,-0x20(%rbp)
mov    %esi,%eax
mov    -0x20(%rbp),%esi
mov    %eax,-0x1c(%rbp)
mov    %rdi,%r8
mov    -0x1c(%rbp),%edi
mov    %r9b,%al
mov    0x18(%rbp),%r9b
mov    0x10(%rbp),%r9b
mov    %r8,-0x8(%rbp)
mov    %edi,-0xc(%rbp)
mov    %esi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %cl,-0x15(%rbp)
mov    %al,-0x16(%rbp)
cmpl   $0x0,0x2ec5(%rip)
jne    118c <udpWriteEnergia+0x6c>
mov    -0x10(%rbp),%edi
call   1040 <MW_UDPBegin@plt>
mov    0x2eb1(%rip),%eax
add    $0x1,%eax
mov    %eax,0x2ea8(%rip)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x15(%rbp),%dl
mov    -0x16(%rbp),%cl
mov    0x10(%rbp),%r8b
mov    0x18(%rbp),%r9b
mov    -0x14(%rbp),%eax
movzbl %dl,%edx
movzbl %cl,%ecx
movzbl %r8b,%r8d
movzbl %r9b,%r9d
mov    %eax,(%rsp)
call   1030 <MW_UDPFinalWrite@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<udpWriteEnergia>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r9d,%r15d
mov    %r8d,%ebp
mov    %ecx,%ebx
mov    %esi,%r14d
mov    %rdi,%r12
mov    0x48(%rsp),%al
mov    0x40(%rsp),%r13b
cmpl   $0x0,0x2eeb(%rip)
jne    115d <udpWriteEnergia+0x3d>
mov    %edx,%edi
call   1040 <MW_UDPBegin@plt>
mov    0x48(%rsp),%al
addl   $0x1,0x2ed7(%rip)
mov    %ebx,(%rsp)
movzbl %bpl,%edx
movzbl %r15b,%ecx
movzbl %r13b,%r8d
movzbl %al,%r9d
mov    %r12,%rdi
mov    %r14d,%esi
call   1030 <MW_UDPFinalWrite@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@udpWriteEnergia.only_one_ethernet_begin = internal global i32 0
define void @udpWriteEnergia(i8* %0, i32 %1, i32 %2, i32 %3, i8 zeroext %4, i8 zeroext %5, i8 zeroext %6, i8 zeroext %7) {
%9 = alloca i8*
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i8
%14 = alloca i8
%15 = alloca i8
%16 = alloca i8
store i8* %0, i8** %9
store i32 %1, i32* %10
store i32 %2, i32* %11
store i32 %3, i32* %12
store i8 %4, i8* %13
store i8 %5, i8* %14
store i8 %6, i8* %15
store i8 %7, i8* %16
%17 = load i32, i32* @udpWriteEnergia.only_one_ethernet_begin
%18 = icmp eq i32 %17, 0
br i1 %18, label %19, label %24
19: ; preds = %8
%20 = load i32, i32* %11
%21 = call i32 @MW_UDPBegin(i32 %20)
%22 = load i32, i32* @udpWriteEnergia.only_one_ethernet_begin
%23 = add nsw i32 %22, 1
store i32 %23, i32* @udpWriteEnergia.only_one_ethernet_begin
br label %24
24: ; preds = %19, %8
%25 = load i8*, i8** %9
%26 = load i32, i32* %10
%27 = load i8, i8* %13
%28 = load i8, i8* %14
%29 = load i8, i8* %15
%30 = load i8, i8* %16
%31 = load i32, i32* %12
%32 = call i32 @MW_UDPFinalWrite(i8* %25, i32 %26, i8 zeroext %27, i8 zeroext %28, i8 zeroext %29, i8 zeroext %30, i32 %31)
ret void
}

LLVM IR (-O2):
@udpWriteEnergia.only_one_ethernet_begin = internal unnamed_addr global i32 0
define void @udpWriteEnergia(i8* %0, i32 %1, i32 %2, i32 %3, i8 zeroext %4, i8 zeroext %5, i8 zeroext %6, i8 zeroext %7) {
%9 = load i32, i32* @udpWriteEnergia.only_one_ethernet_begin
%10 = icmp eq i32 %9, 0
br i1 %10, label %11, label %15
11: ; preds = %8
%12 = tail call i32 @MW_UDPBegin(i32 %2)
%13 = load i32, i32* @udpWriteEnergia.only_one_ethernet_begin
%14 = add nsw i32 %13, 1
store i32 %14, i32* @udpWriteEnergia.only_one_ethernet_begin
br label %15
15: ; preds = %11, %8
%16 = tail call i32 @MW_UDPFinalWrite(i8* %0, i32 %1, i8 zeroext %4, i8 zeroext %5, i8 zeroext %6, i8 zeroext %7, i32 %3)
ret void
}