#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 */
unsigned int UINT_MAX;
int /*<<< orphan*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ sprintf(char *, char *, unsigned int);
int /*<<< orphan*/ stdout;
scalar_t__ unlink(char *);
void unlink_randfiles(void) {
  unsigned int filenum = 0;
  while (filenum < UINT_MAX) {
    char filename[32];
    sprintf(filename, "random-%08u", filenum);
    if (unlink(filename) != 0)
      break;
    if (filenum == 0)
      printf("Removing old files .");
    else
      printf(".");
    fflush(stdout);
    ++filenum;
  }
  if (filenum > 0)
    printf(" total: %u.\n", filenum);
}


x86 assembly (clang, -O0):
<unlink_randfiles>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    0x2e8f(%rip),%rcx
cmp    (%rcx),%eax
jae    11d3 <unlink_randfiles+0x93>
lea    -0x30(%rbp),%rdi
mov    -0x4(%rbp),%edx
lea    0xe91(%rip),%rsi
call   1060 <sprintf@plt>
lea    -0x30(%rbp),%rdi
call   1030 <unlink@plt>
cmp    $0x0,%rax
je     118c <unlink_randfiles+0x4c>
jmp    11d3 <unlink_randfiles+0x93>
cmpl   $0x0,-0x4(%rbp)
jne    11a9 <unlink_randfiles+0x69>
lea    0xe6f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11b7 <unlink_randfiles+0x77>
lea    0xe6f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    0x2e1a(%rip),%rax
mov    (%rax),%edi
call   1050 <fflush@plt>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    114f <unlink_randfiles+0xf>
cmpl   $0x0,-0x4(%rbp)
jbe    11ee <unlink_randfiles+0xae>
mov    -0x4(%rbp),%esi
lea    0xe3a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<unlink_randfiles>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    0x2e83(%rip),%r13
cmpl   $0x0,0x0(%r13)
je     11f7 <unlink_randfiles+0xa7>
lea    0xe89(%rip),%r14
mov    %rsp,%r15
lea    0xe8b(%rip),%r12
mov    0x2e50(%rip),%rbp
xor    %ebx,%ebx
jmp    11ab <unlink_randfiles+0x5b>
nopl   0x0(%rax)
mov    $0x2e,%edi
call   1030 <putchar@plt>
mov    0x0(%rbp),%edi
call   1060 <fflush@plt>
add    $0x1,%ebx
cmp    0x0(%r13),%ebx
jae    11d9 <unlink_randfiles+0x89>
mov    %r15,%rdi
mov    %r14,%rsi
mov    %ebx,%edx
call   1070 <sprintf@plt>
mov    %r15,%rdi
call   1040 <unlink@plt>
test   %rax,%rax
jne    11d5 <unlink_randfiles+0x85>
test   %ebx,%ebx
jne    1190 <unlink_randfiles+0x40>
mov    %r12,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    119a <unlink_randfiles+0x4a>
test   %ebx,%ebx
je     11f7 <unlink_randfiles+0xa7>
lea    0xe41(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1050 <printf@plt>
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@UINT_MAX = global i32 0
@.str = [12 x i8] c"random-%08u\00"
@.str.1 = [21 x i8] c"Removing old files .\00"
@.str.2 = [2 x i8] c".\00"
@stdout = global i32 0
@.str.3 = [13 x i8] c" total: %u.\0A\00"
define void @unlink_randfiles() {
%1 = alloca i32
%2 = alloca [32 x i8]
store i32 0, i32* %1
br label %3
3: ; preds = %22, %0
%4 = load i32, i32* %1
%5 = load i32, i32* @UINT_MAX
%6 = icmp ult i32 %4, %5
br i1 %6, label %7, label %27
7: ; preds = %3
%8 = getelementptr inbounds [32 x i8], [32 x i8]* %2, i64 0, i64 0
%9 = load i32, i32* %1
%10 = call i32 @sprintf(i8* %8, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 %9)
%11 = getelementptr inbounds [32 x i8], [32 x i8]* %2, i64 0, i64 0
%12 = call i64 @unlink(i8* %11)
%13 = icmp ne i64 %12, 0
br i1 %13, label %14, label %15
14: ; preds = %7
br label %27
15: ; preds = %7
%16 = load i32, i32* %1
%17 = icmp eq i32 %16, 0
br i1 %17, label %18, label %20
18: ; preds = %15
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0))
br label %22
20: ; preds = %15
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %22
22: ; preds = %20, %18
%23 = load i32, i32* @stdout
%24 = call i32 @fflush(i32 %23)
%25 = load i32, i32* %1
%26 = add i32 %25, 1
store i32 %26, i32* %1
br label %3
27: ; preds = %14, %3
%28 = load i32, i32* %1
%29 = icmp ugt i32 %28, 0
br i1 %29, label %30, label %33
30: ; preds = %27
%31 = load i32, i32* %1
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), i32 %31)
br label %33
33: ; preds = %30, %27
ret void
}

LLVM IR (-O2):
@UINT_MAX = global i32 0
@.str = [12 x i8] c"random-%08u\00"
@.str.1 = [21 x i8] c"Removing old files .\00"
@stdout = global i32 0
@.str.3 = [13 x i8] c" total: %u.\0A\00"
define void @unlink_randfiles() {
%1 = alloca [32 x i8]
%2 = load i32, i32* @UINT_MAX
%3 = icmp eq i32 %2, 0
br i1 %3, label %28, label %4
4: ; preds = %0
%5 = getelementptr inbounds [32 x i8], [32 x i8]* %1, i64 0, i64 0
br label %6
6: ; preds = %4, %17
%7 = phi i32 [ 0, %4 ], [ %20, %17 ]
%8 = call i32 @sprintf(i8* %5, i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 %7)
%9 = call i64 @unlink(i8* %5)
%10 = icmp eq i64 %9, 0
br i1 %10, label %11, label %23
11: ; preds = %6
%12 = icmp eq i32 %7, 0
br i1 %12, label %13, label %15
13: ; preds = %11
%14 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0))
br label %17
15: ; preds = %11
%16 = tail call i32 @putchar(i32 46)
br label %17
17: ; preds = %13, %15
%18 = load i32, i32* @stdout
%19 = tail call i32 @fflush(i32 %18)
%20 = add nuw i32 %7, 1
%21 = load i32, i32* @UINT_MAX
%22 = icmp ult i32 %20, %21
br i1 %22, label %6, label %25
23: ; preds = %6
%24 = icmp eq i32 %7, 0
br i1 %24, label %28, label %25
25: ; preds = %17, %23
%26 = phi i32 [ %7, %23 ], [ %20, %17 ]
%27 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0), i32 %26)
br label %28
28: ; preds = %0, %25, %23
ret void
}