#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 PATH_MAX;
int /*<<< orphan*/ err(char *);
scalar_t__ getpid();
int /*<<< orphan*/ sprintf(char *, char *, char *, long, int);
scalar_t__ unlink(char *);
void clean_up_queue(char *queue_dir) {
  int pce;
  char tname[PATH_MAX];
  err("discarding queued delta pieces");
  for (pce = 1;; pce++) {
    sprintf((tname), "%s/.%08ld.%03d", (queue_dir), (long)getpid(), (pce));
    if (unlink(tname) < 0)
      break;
  }
}


x86 assembly (clang, -O0):
<clean_up_queue>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    0x2e9d(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%rcx
mov    %rcx,-0x18(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x28(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x20(%rbp)
lea    0xe81(%rip),%rdi
call   1050 <err@plt>
movl   $0x1,-0xc(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    $0x0,%al
call   1040 <getpid@plt>
mov    -0x30(%rbp),%rdx
mov    -0x28(%rbp),%rdi
mov    %rax,%rcx
mov    -0xc(%rbp),%r8d
lea    0xe6f(%rip),%rsi
call   1060 <sprintf@plt>
mov    -0x28(%rbp),%rdi
call   1030 <unlink@plt>
cmp    $0x0,%rax
jge    11cd <clean_up_queue+0x8d>
jmp    11e0 <clean_up_queue+0xa0>
jmp    11d2 <clean_up_queue+0x92>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    118b <clean_up_queue+0x4b>
mov    -0x18(%rbp),%rax
mov    %rax,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<clean_up_queue>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rdi,%r14
mov    0x2e9b(%rip),%rax
mov    (%rax),%eax
mov    %rsp,%r15
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r15
mov    %r15,%rsp
lea    0xe91(%rip),%rdi
call   1050 <err@plt>
mov    $0x1,%ebx
lea    0xe9f(%rip),%r12
xor    %eax,%eax
call   1040 <getpid@plt>
mov    %r15,%rdi
mov    %r12,%rsi
mov    %r14,%rdx
mov    %rax,%rcx
mov    %ebx,%r8d
call   1060 <sprintf@plt>
mov    %r15,%rdi
call   1030 <unlink@plt>
add    $0x1,%ebx
test   %rax,%rax
jns    1180 <clean_up_queue+0x40>
lea    -0x20(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@PATH_MAX = global i32 0
@.str = [31 x i8] c"discarding queued delta pieces\00"
@.str.1 = [15 x i8] c"%s/.%08ld.%03d\00"
define void @clean_up_queue(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i64
store i8* %0, i8** %2
%6 = load i32, i32* @PATH_MAX
%7 = zext i32 %6 to i64
%8 = call i8* @llvm.stacksave()
store i8* %8, i8** %4
%9 = alloca i8, i64 %7
store i64 %7, i64* %5
%10 = call i32 @err(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %3
br label %11
11: ; preds = %20, %1
%12 = load i8*, i8** %2
%13 = call i64 (...) @getpid()
%14 = load i32, i32* %3
%15 = call i32 @sprintf(i8* %9, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i8* %12, i64 %13, i32 %14)
%16 = call i64 @unlink(i8* %9)
%17 = icmp slt i64 %16, 0
br i1 %17, label %18, label %19
18: ; preds = %11
br label %23
19: ; preds = %11
br label %20
20: ; preds = %19
%21 = load i32, i32* %3
%22 = add nsw i32 %21, 1
store i32 %22, i32* %3
br label %11
23: ; preds = %18
%24 = load i8*, i8** %4
ret void
}

LLVM IR (-O2):
@PATH_MAX = global i32 0
@.str = [31 x i8] c"discarding queued delta pieces\00"
@.str.1 = [15 x i8] c"%s/.%08ld.%03d\00"
define void @clean_up_queue(i8* %0) {
%2 = load i32, i32* @PATH_MAX
%3 = zext i32 %2 to i64
%4 = alloca i8, i64 %3
%5 = tail call i32 @err(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0))
br label %6
6: ; preds = %6, %1
%7 = phi i32 [ 1, %1 ], [ %12, %6 ]
%8 = tail call i64 (...) @getpid()
%9 = call i32 @sprintf(i8* %4, i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i8* %0, i64 %8, i32 %7)
%10 = call i64 @unlink(i8* %4)
%11 = icmp slt i64 %10, 0
%12 = add nuw nsw i32 %7, 1
br i1 %11, label %13, label %6
13: ; preds = %6
ret void
}