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


x86 assembly (clang, -O0):
<unlink1>:
push   %rbp
mov    %rsp,%rbp
sub    $0x220,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x1,%edi
call   1080 <sleep@plt>
lea    -0x210(%rbp),%rdi
mov    -0x8(%rbp),%rdx
mov    -0x10(%rbp),%rcx
lea    0xe6d(%rip),%rsi
call   1050 <sprintf@plt>
lea    -0x210(%rbp),%rdi
call   1030 <unlink@plt>
cmp    $0x0,%rax
je     11ff <unlink1+0x9f>
mov    0x2e2b(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x21c(%rbp)
lea    -0x210(%rbp),%rax
mov    %rax,-0x218(%rbp)
mov    0x2e06(%rip),%rax
mov    (%rax),%edi
call   1070 <strerror@plt>
mov    -0x21c(%rbp),%edi
mov    -0x218(%rbp),%rdx
mov    %rax,%rcx
lea    0xe16(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0x1,%edi
call   1060 <exit@plt>
add    $0x220,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<unlink1>:
push   %r15
push   %r14
push   %rbx
sub    $0x200,%rsp
mov    %rsi,%r14
mov    %rdi,%rbx
mov    $0x1,%edi
call   1080 <sleep@plt>
lea    0xe7d(%rip),%rsi
mov    %rsp,%r15
mov    %r15,%rdi
mov    %rbx,%rdx
mov    %r14,%rcx
call   1050 <sprintf@plt>
mov    %r15,%rdi
call   1030 <unlink@plt>
test   %rax,%rax
jne    11ae <unlink1+0x4e>
add    $0x200,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret
mov    0x2e2b(%rip),%rax
mov    (%rax),%ebx
mov    0x2e1a(%rip),%rax
mov    (%rax),%edi
call   1070 <strerror@plt>
lea    0xe3a(%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 = [6 x i8] c"%s/%s\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 @unlink1(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca [512 x i8]
store i8* %0, i8** %3
store i8* %1, i8** %4
%6 = call i32 @sleep(i32 1)
%7 = getelementptr inbounds [512 x i8], [512 x i8]* %5, i64 0, i64 0
%8 = load i8*, i8** %3
%9 = load i8*, i8** %4
%10 = call i32 @sprintf(i8* %7, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %8, i8* %9)
%11 = getelementptr inbounds [512 x i8], [512 x i8]* %5, i64 0, i64 0
%12 = call i64 @unlink(i8* %11)
%13 = icmp ne i64 %12, 0
br i1 %13, label %14, label %21
14: ; preds = %2
%15 = load i32, i32* @stderr
%16 = getelementptr inbounds [512 x i8], [512 x i8]* %5, i64 0, i64 0
%17 = load i32, i32* @errno
%18 = call i8* @strerror(i32 %17)
%19 = call i32 @fprintf(i32 %15, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), i8* %16, i8* %18)
%20 = call i32 @exit(i32 1)
unreachable
21: ; preds = %2
ret void
}

LLVM IR (-O2):
@.str = [6 x i8] c"%s/%s\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 @unlink1(i8* %0, i8* %1) {
%3 = alloca [512 x i8]
%4 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 0
%5 = tail call i32 @sleep(i32 1)
%6 = call i32 @sprintf(i8* %4, i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %0, i8* %1)
%7 = call i64 @unlink(i8* %4)
%8 = icmp eq i64 %7, 0
br i1 %8, label %15, label %9
9: ; preds = %2
%10 = load i32, i32* @stderr
%11 = load i32, i32* @errno
%12 = tail call i8* @strerror(i32 %11)
%13 = call i32 @fprintf(i32 %10, i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.1, i64 0, i64 0), i8* %4, i8* %12)
%14 = call i32 @exit(i32 1)
unreachable
15: ; preds = %2
ret void
}