#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*/ assert(int /*<<< orphan*/);
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ free(int *);
void closeUDPListenSockets(int *pSockArr) {
  register int i;
  assert(pSockArr != NULL);
  if (pSockArr != NULL) {
    for (i = 0; i < *pSockArr; i++)
      close(pSockArr[i + 1]);
    free(pSockArr);
  }
}


x86 assembly (clang, -O0):
<closeUDPListenSockets>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
cmpq   $0x0,-0x8(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <assert@plt>
cmpq   $0x0,-0x8(%rbp)
je     119b <closeUDPListenSockets+0x6b>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    -0x8(%rbp),%rcx
cmp    (%rcx),%eax
jge    1192 <closeUDPListenSockets+0x62>
mov    -0x8(%rbp),%rax
mov    -0xc(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,4),%edi
call   1040 <close@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1160 <closeUDPListenSockets+0x30>
mov    -0x8(%rbp),%rdi
call   1030 <free@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<closeUDPListenSockets>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
xor    %edi,%edi
test   %r14,%r14
setne  %dil
call   1050 <assert@plt>
test   %r14,%r14
je     1185 <closeUDPListenSockets+0x55>
cmpl   $0x0,(%r14)
jle    1176 <closeUDPListenSockets+0x46>
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    0x4(%r14,%rbx,4),%edi
add    $0x1,%rbx
call   1040 <close@plt>
movslq (%r14),%rax
cmp    %rax,%rbx
jl     1160 <closeUDPListenSockets+0x30>
mov    %r14,%rdi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <free@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define void @closeUDPListenSockets(i32* %0) {
%2 = alloca i32*
%3 = alloca i32
store i32* %0, i32** %2
%4 = load i32*, i32** %2
%5 = icmp ne i32* %4, null
%6 = zext i1 %5 to i32
%7 = call i32 @assert(i32 %6)
%8 = load i32*, i32** %2
%9 = icmp ne i32* %8, null
br i1 %9, label %10, label %30
10: ; preds = %1
store i32 0, i32* %3
br label %11
11: ; preds = %24, %10
%12 = load i32, i32* %3
%13 = load i32*, i32** %2
%14 = load i32, i32* %13
%15 = icmp slt i32 %12, %14
br i1 %15, label %16, label %27
16: ; preds = %11
%17 = load i32*, i32** %2
%18 = load i32, i32* %3
%19 = add nsw i32 %18, 1
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds i32, i32* %17, i64 %20
%22 = load i32, i32* %21
%23 = call i32 @close(i32 %22)
br label %24
24: ; preds = %16
%25 = load i32, i32* %3
%26 = add nsw i32 %25, 1
store i32 %26, i32* %3
br label %11
27: ; preds = %11
%28 = load i32*, i32** %2
%29 = call i32 @free(i32* %28)
br label %30
30: ; preds = %27, %1
ret void
}

LLVM IR (-O2):
define void @closeUDPListenSockets(i32* %0) {
%2 = icmp ne i32* %0, null
%3 = zext i1 %2 to i32
%4 = tail call i32 @assert(i32 %3)
br i1 %2, label %5, label %19
5: ; preds = %1
%6 = load i32, i32* %0
%7 = icmp sgt i32 %6, 0
br i1 %7, label %8, label %17
8: ; preds = %5, %8
%9 = phi i64 [ %10, %8 ], [ 0, %5 ]
%10 = add nuw nsw i64 %9, 1
%11 = getelementptr inbounds i32, i32* %0, i64 %10
%12 = load i32, i32* %11
%13 = tail call i32 @close(i32 %12)
%14 = load i32, i32* %0
%15 = sext i32 %14 to i64
%16 = icmp slt i64 %10, %15
br i1 %16, label %8, label %17
17: ; preds = %8, %5
%18 = tail call i32 @free(i32* %0)
br label %19
19: ; preds = %17, %1
ret void
}