#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*/ fsexists(char *);
int /*<<< orphan*/ miderrstr();
int /*<<< orphan*/ pr(char *, char *, int /*<<< orphan*/);
scalar_t__ unlink(char *);
char *zonefile(int);
void zonecleanup(int zmax) {
  for (int i = 0; i <= zmax; i++) {
    char *zfile = zonefile(i);
    if (!fsexists(zfile))
      continue;
    if (unlink(zfile) < 0)
      pr("Failed to remove zone file [%s]: %s", zfile, miderrstr());
  }
}


x86 assembly (clang, -O0):
<zonecleanup>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0x4(%rbp),%eax
jg     11d8 <zonecleanup+0x88>
mov    -0x8(%rbp),%edi
call   1050 <zonefile@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1060 <fsexists@plt>
cmp    $0x0,%eax
jne    1191 <zonecleanup+0x41>
jmp    11ca <zonecleanup+0x7a>
mov    -0x10(%rbp),%rdi
call   1030 <unlink@plt>
cmp    $0x0,%rax
jge    11c5 <zonecleanup+0x75>
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    $0x0,%al
call   1070 <miderrstr@plt>
mov    -0x18(%rbp),%rsi
mov    %eax,%edx
lea    0xe40(%rip),%rdi
call   1040 <pr@plt>
jmp    11ca <zonecleanup+0x7a>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1162 <zonecleanup+0x12>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<zonecleanup>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
test   %edi,%edi
js     11b1 <zonecleanup+0x61>
mov    %edi,%r15d
add    $0x1,%r15d
lea    0xe97(%rip),%r14
xor    %ebp,%ebp
jmp    1178 <zonecleanup+0x28>
nopl   (%rax)
add    $0x1,%ebp
cmp    %ebp,%r15d
je     11b1 <zonecleanup+0x61>
mov    %ebp,%edi
call   1050 <zonefile@plt>
mov    %rax,%rbx
mov    %rax,%rdi
call   1060 <fsexists@plt>
test   %eax,%eax
je     1170 <zonecleanup+0x20>
mov    %rbx,%rdi
call   1030 <unlink@plt>
test   %rax,%rax
jns    1170 <zonecleanup+0x20>
xor    %eax,%eax
call   1070 <miderrstr@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
mov    %eax,%edx
call   1040 <pr@plt>
jmp    1170 <zonecleanup+0x20>
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [36 x i8] c"Failed to remove zone file [%s]: %s\00"
define void @zonecleanup(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i8*
store i32 %0, i32* %2
store i32 0, i32* %3
br label %5
5: ; preds = %25, %1
%6 = load i32, i32* %3
%7 = load i32, i32* %2
%8 = icmp sle i32 %6, %7
br i1 %8, label %9, label %28
9: ; preds = %5
%10 = load i32, i32* %3
%11 = call i8* @zonefile(i32 %10)
store i8* %11, i8** %4
%12 = load i8*, i8** %4
%13 = call i32 @fsexists(i8* %12)
%14 = icmp ne i32 %13, 0
br i1 %14, label %16, label %15
15: ; preds = %9
br label %25
16: ; preds = %9
%17 = load i8*, i8** %4
%18 = call i64 @unlink(i8* %17)
%19 = icmp slt i64 %18, 0
br i1 %19, label %20, label %24
20: ; preds = %16
%21 = load i8*, i8** %4
%22 = call i32 (...) @miderrstr()
%23 = call i32 @pr(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0), i8* %21, i32 %22)
br label %24
24: ; preds = %20, %16
br label %25
25: ; preds = %24, %15
%26 = load i32, i32* %3
%27 = add nsw i32 %26, 1
store i32 %27, i32* %3
br label %5
28: ; preds = %5
ret void
}

LLVM IR (-O2):
@.str = [36 x i8] c"Failed to remove zone file [%s]: %s\00"
define void @zonecleanup(i32 %0) {
%2 = icmp slt i32 %0, 0
br i1 %2, label %3, label %4
3: ; preds = %15, %1
ret void
4: ; preds = %1, %15
%5 = phi i32 [ %16, %15 ], [ 0, %1 ]
%6 = tail call i8* @zonefile(i32 %5)
%7 = tail call i32 @fsexists(i8* %6)
%8 = icmp eq i32 %7, 0
br i1 %8, label %15, label %9
9: ; preds = %4
%10 = tail call i64 @unlink(i8* %6)
%11 = icmp slt i64 %10, 0
br i1 %11, label %12, label %15
12: ; preds = %9
%13 = tail call i32 (...) @miderrstr()
%14 = tail call i32 @pr(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0), i8* %6, i32 %13)
br label %15
15: ; preds = %9, %12, %4
%16 = add nuw i32 %5, 1
%17 = icmp eq i32 %5, %0
br i1 %17, label %3, label %4
}