#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*/ errno;
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, char *);
int /*<<< orphan*/ sleep(int);
int /*<<< orphan*/ sprintf(char *, char *, char const *, char const *, int);
int /*<<< orphan*/ stderr;
char *strerror(int /*<<< orphan*/);
scalar_t__ unlink(char *);
void unlinkn(const char *d, const char *prefix, int nf) {
  char n[512];
  int i;
  sleep(1);
  for (i = 0; i < nf; i++) {
    sprintf(n, "%s/%s-%d", d, prefix, i);
    if (unlink(n) != 0) {
      fprintf(stderr, "test-lab-3-c: unlink(%s): %s\n", n, strerror(errno));
      exit(1);
    }
  }
}


x86 assembly (clang, -O0):
<unlinkn>:
push   %rbp
mov    %rsp,%rbp
sub    $0x240,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    $0x1,%edi
call   1080 <sleep@plt>
movl   $0x0,-0x224(%rbp)
mov    -0x224(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    123b <unlinkn+0xdb>
lea    -0x220(%rbp),%rdi
mov    -0x8(%rbp),%rdx
mov    -0x10(%rbp),%rcx
mov    -0x224(%rbp),%r8d
lea    0xe4a(%rip),%rsi
call   1050 <sprintf@plt>
lea    -0x220(%rbp),%rdi
call   1030 <unlink@plt>
cmp    $0x0,%rax
je     1222 <unlinkn+0xc2>
mov    0x2e08(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x234(%rbp)
lea    -0x220(%rbp),%rax
mov    %rax,-0x230(%rbp)
mov    0x2de3(%rip),%rax
mov    (%rax),%edi
call   1070 <strerror@plt>
mov    -0x234(%rbp),%edi
mov    -0x230(%rbp),%rdx
mov    %rax,%rcx
lea    0xdf6(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0x1,%edi
call   1060 <exit@plt>
jmp    1227 <unlinkn+0xc7>
mov    -0x224(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x224(%rbp)
jmp    118a <unlinkn+0x2a>
add    $0x240,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<unlinkn>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x208,%rsp
mov    %edx,%r13d
mov    %rsi,%r14
mov    %rdi,%r15
mov    $0x1,%edi
call   1080 <sleep@plt>
test   %r13d,%r13d
jle    11c9 <unlinkn+0x69>
xor    %ebp,%ebp
lea    0xe6e(%rip),%r12
mov    %rsp,%rbx
cs nopw 0x0(%rax,%rax,1)
nop
mov    %rbx,%rdi
mov    %r12,%rsi
mov    %r15,%rdx
mov    %r14,%rcx
mov    %ebp,%r8d
call   1050 <sprintf@plt>
mov    %rbx,%rdi
call   1030 <unlink@plt>
test   %rax,%rax
jne    11db <unlinkn+0x7b>
add    $0x1,%ebp
cmp    %ebp,%r13d
jne    11a0 <unlinkn+0x40>
add    $0x208,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2dfe(%rip),%rax
mov    (%rax),%ebx
mov    0x2ded(%rip),%rax
mov    (%rax),%edi
call   1070 <strerror@plt>
lea    0xe10(%rip),%rsi
mov    %rsp,%rdx
mov    %ebx,%edi
mov    %rax,%rcx
call   1040 <fprintf@plt>
mov    $0x1,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@.str = [9 x i8] c"%s/%s-%d\00"
@stderr = global i32 0
@.str.1 = [30 x i8] c"test-lab-3-c: unlink(%s): %s\0A\00"
@errno = global i32 0
define void @unlinkn(i8* %0, i8* %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca [512 x i8]
%8 = alloca i32
store i8* %0, i8** %4
store i8* %1, i8** %5
store i32 %2, i32* %6
%9 = call i32 @sleep(i32 1)
store i32 0, i32* %8
br label %10
10: ; preds = %31, %3
%11 = load i32, i32* %8
%12 = load i32, i32* %6
%13 = icmp slt i32 %11, %12
br i1 %13, label %14, label %34
14: ; preds = %10
%15 = getelementptr inbounds [512 x i8], [512 x i8]* %7, i64 0, i64 0
%16 = load i8*, i8** %4
%17 = load i8*, i8** %5
%18 = load i32, i32* %8
%19 = call i32 @sprintf(i8* %15, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* %16, i8* %17, i32 %18)
%20 = getelementptr inbounds [512 x i8], [512 x i8]* %7, i64 0, i64 0
%21 = call i64 @unlink(i8* %20)
%22 = icmp ne i64 %21, 0
br i1 %22, label %23, label %30
23: ; preds = %14
%24 = load i32, i32* @stderr
%25 = getelementptr inbounds [512 x i8], [512 x i8]* %7, i64 0, i64 0
%26 = load i32, i32* @errno
%27 = call i8* @strerror(i32 %26)
%28 = call i32 @fprintf(i32 %24, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), i8* %25, i8* %27)
%29 = call i32 @exit(i32 1)
unreachable
30: ; preds = %14
br label %31
31: ; preds = %30
%32 = load i32, i32* %8
%33 = add nsw i32 %32, 1
store i32 %33, i32* %8
br label %10
34: ; preds = %10
ret void
}

LLVM IR (-O2):
@.str = [9 x i8] c"%s/%s-%d\00"
@stderr = global i32 0
@.str.1 = [30 x i8] c"test-lab-3-c: unlink(%s): %s\0A\00"
@errno = global i32 0
define void @unlinkn(i8* %0, i8* %1, i32 %2) {
%4 = alloca [512 x i8]
%5 = getelementptr inbounds [512 x i8], [512 x i8]* %4, i64 0, i64 0
%6 = tail call i32 @sleep(i32 1)
%7 = icmp sgt i32 %2, 0
br i1 %7, label %10, label %22
8: ; preds = %10
%9 = icmp eq i32 %15, %2
br i1 %9, label %22, label %10
10: ; preds = %3, %8
%11 = phi i32 [ %15, %8 ], [ 0, %3 ]
%12 = call i32 @sprintf(i8* %5, i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* %0, i8* %1, i32 %11)
%13 = call i64 @unlink(i8* %5)
%14 = icmp eq i64 %13, 0
%15 = add nuw nsw i32 %11, 1
br i1 %14, label %8, label %16
16: ; preds = %10
%17 = load i32, i32* @stderr
%18 = load i32, i32* @errno
%19 = tail call i8* @strerror(i32 %18)
%20 = call i32 @fprintf(i32 %17, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), i8* %5, i8* %19)
%21 = call i32 @exit(i32 1)
unreachable
22: ; preds = %8, %3
ret void
}