#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*/ close(int);
void dev_clean_all(int *fds, int max) {
  for (int i = 0; i < max; i++) {
    if (fds != 0) {
      close(fds[i]);
      fds[i] = 0;
    }
  }
}


x86 assembly (clang, -O0):
<dev_clean_all>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    116f <dev_clean_all+0x5f>
cmpq   $0x0,-0x8(%rbp)
je     115c <dev_clean_all+0x4c>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
mov    (%rax,%rcx,4),%edi
call   1030 <close@plt>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
movl   $0x0,(%rax,%rcx,4)
jmp    1161 <dev_clean_all+0x51>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1126 <dev_clean_all+0x16>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dev_clean_all>:
push   %r15
push   %r14
push   %rbx
test   %esi,%esi
jle    1151 <dev_clean_all+0x41>
mov    %rdi,%r15
mov    %esi,%r14d
xor    %ebx,%ebx
jmp    1139 <dev_clean_all+0x29>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
add    $0x1,%rbx
cmp    %rbx,%r14
je     1151 <dev_clean_all+0x41>
test   %r15,%r15
je     1130 <dev_clean_all+0x20>
mov    (%r15,%rbx,4),%edi
call   1030 <close@plt>
movl   $0x0,(%r15,%rbx,4)
jmp    1130 <dev_clean_all+0x20>
pop    %rbx
pop    %r14
pop    %r15
ret

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

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