#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 */
typedef scalar_t__ uint8_t;
typedef int /*<<< orphan*/ time_t;
struct tm {
  int tm_year;
  int tm_mon;
  int tm_mday;
};
struct stat {
  int dummy;
};
typedef int /*<<< orphan*/ prefix;

/* Variables and functions */
scalar_t__ ENOENT;
scalar_t__ errno;
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ localtime_r(int /*<<< orphan*/ *, struct tm *);
char *malloc(int);
int /*<<< orphan*/ snprintf(char *, int, char *, ...);
int stat(char *, struct stat *);
scalar_t__ strlen(char const *);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
char *bot_fileutils_get_unique_filename(const char *path, const char *basename,
                                        uint8_t time_prefix,
                                        const char *extension) {
  char prefix[256];
  if (time_prefix) {
    time_t t = time(NULL);
    struct tm ti;
    localtime_r(&t, &ti);
    if (path)
      snprintf(prefix, sizeof(prefix), "%s/%d-%02d-%02d-%s", path,
               ti.tm_year + 1900, ti.tm_mon + 1, ti.tm_mday, basename);
    else
      snprintf(prefix, sizeof(prefix), "%d-%02d-%02d-%s", ti.tm_year + 1900,
               ti.tm_mon + 1, ti.tm_mday, basename);
  } else {
    if (path)
      snprintf(prefix, sizeof(prefix), "%s/%s", path, basename);
    else
      snprintf(prefix, sizeof(prefix), "%s", basename);
  }
  int maxlen = sizeof(prefix) + 4;
  if (extension)
    maxlen += strlen(extension);
  char *filename = malloc(maxlen);
  int res;
  int filenum = 0;
  do {
    struct stat statbuf;
    if (extension)
      snprintf(filename, maxlen, "%s.%02d.%s", prefix, filenum, extension);
    else
      snprintf(filename, maxlen, "%s.%02d", prefix, filenum);
    res = stat(filename, &statbuf);
    filenum++;
  } while (res == 0 && filenum < 100);
  if (filenum >= 100) {
    free(filename);
    return NULL;
  }
  if (errno != ENOENT) {
    free(filename);
    return NULL;
  }
  return filename;
}


x86 assembly (clang, -O0):
<bot_fileutils_get_unique_filename>:
push   %rbp
mov    %rsp,%rbp
sub    $0x180,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     1258 <bot_fileutils_get_unique_filename+0xe8>
xor    %eax,%eax
mov    %eax,%edi
call   1080 <time@plt>
mov    %eax,-0x134(%rbp)
lea    -0x134(%rbp),%rdi
lea    -0x140(%rbp),%rsi
call   1040 <localtime_r@plt>
cmpq   $0x0,-0x10(%rbp)
je     1213 <bot_fileutils_get_unique_filename+0xa3>
lea    -0x130(%rbp),%rdi
mov    -0x10(%rbp),%rcx
mov    -0x140(%rbp),%r8d
add    $0x76c,%r8d
mov    -0x13c(%rbp),%r9d
add    $0x1,%r9d
mov    -0x138(%rbp),%r10d
mov    -0x18(%rbp),%rax
mov    $0x100,%esi
lea    0xe02(%rip),%rdx
mov    %r10d,(%rsp)
mov    %rax,0x8(%rsp)
mov    $0x0,%al
call   1060 <snprintf@plt>
jmp    1253 <bot_fileutils_get_unique_filename+0xe3>
lea    -0x130(%rbp),%rdi
mov    -0x140(%rbp),%ecx
add    $0x76c,%ecx
mov    -0x13c(%rbp),%r8d
add    $0x1,%r8d
mov    -0x138(%rbp),%r9d
mov    -0x18(%rbp),%rax
mov    $0x100,%esi
lea    0xdbb(%rip),%rdx
mov    %rax,(%rsp)
mov    $0x0,%al
call   1060 <snprintf@plt>
jmp    12ad <bot_fileutils_get_unique_filename+0x13d>
cmpq   $0x0,-0x10(%rbp)
je     128a <bot_fileutils_get_unique_filename+0x11a>
lea    -0x130(%rbp),%rdi
mov    -0x10(%rbp),%rcx
mov    -0x18(%rbp),%r8
mov    $0x100,%esi
lea    0xd95(%rip),%rdx
mov    $0x0,%al
call   1060 <snprintf@plt>
jmp    12a8 <bot_fileutils_get_unique_filename+0x138>
lea    -0x130(%rbp),%rdi
mov    -0x18(%rbp),%rcx
mov    $0x100,%esi
lea    0xd6f(%rip),%rdx
mov    $0x0,%al
call   1060 <snprintf@plt>
jmp    12ad <bot_fileutils_get_unique_filename+0x13d>
movl   $0x104,-0x144(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     12de <bot_fileutils_get_unique_filename+0x16e>
mov    -0x28(%rbp),%rdi
call   1050 <strlen@plt>
mov    %rax,%rcx
movslq -0x144(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0x144(%rbp)
mov    -0x144(%rbp),%edi
call   1090 <malloc@plt>
mov    %rax,-0x150(%rbp)
movl   $0x0,-0x158(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     1337 <bot_fileutils_get_unique_filename+0x1c7>
mov    -0x150(%rbp),%rdi
mov    -0x144(%rbp),%esi
lea    -0x130(%rbp),%rcx
mov    -0x158(%rbp),%r8d
mov    -0x28(%rbp),%r9
lea    0xcee(%rip),%rdx
mov    $0x0,%al
call   1060 <snprintf@plt>
jmp    1360 <bot_fileutils_get_unique_filename+0x1f0>
mov    -0x150(%rbp),%rdi
mov    -0x144(%rbp),%esi
lea    -0x130(%rbp),%rcx
mov    -0x158(%rbp),%r8d
lea    0xccb(%rip),%rdx
mov    $0x0,%al
call   1060 <snprintf@plt>
mov    -0x150(%rbp),%rdi
lea    -0x160(%rbp),%rsi
call   1070 <stat@plt>
mov    %eax,-0x154(%rbp)
mov    -0x158(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x158(%rbp)
xor    %eax,%eax
cmpl   $0x0,-0x154(%rbp)
mov    %al,-0x161(%rbp)
jne    13ad <bot_fileutils_get_unique_filename+0x23d>
cmpl   $0x64,-0x158(%rbp)
setl   %al
mov    %al,-0x161(%rbp)
mov    -0x161(%rbp),%al
test   $0x1,%al
jne    12fa <bot_fileutils_get_unique_filename+0x18a>
cmpl   $0x64,-0x158(%rbp)
jl     13e1 <bot_fileutils_get_unique_filename+0x271>
mov    -0x150(%rbp),%rdi
call   1030 <free@plt>
movq   $0x0,-0x8(%rbp)
jmp    141f <bot_fileutils_get_unique_filename+0x2af>
mov    0x2bf8(%rip),%rax
mov    (%rax),%rax
mov    0x2bde(%rip),%rcx
cmp    (%rcx),%rax
je     1414 <bot_fileutils_get_unique_filename+0x2a4>
mov    -0x150(%rbp),%rdi
call   1030 <free@plt>
movq   $0x0,-0x8(%rbp)
jmp    141f <bot_fileutils_get_unique_filename+0x2af>
mov    -0x150(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x180,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<bot_fileutils_get_unique_filename>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x128,%rsp
mov    %rcx,%r15
mov    %rsi,%r14
mov    %rdi,%rbx
test   %rdx,%rdx
je     11e6 <bot_fileutils_get_unique_filename+0x76>
xor    %edi,%edi
call   1080 <time@plt>
mov    %eax,0xc(%rsp)
lea    0xc(%rsp),%rdi
lea    0x10(%rsp),%rsi
call   1040 <localtime_r@plt>
mov    $0x76c,%r8d
add    0x10(%rsp),%r8d
mov    0x14(%rsp),%r9d
mov    0x18(%rsp),%ebp
add    $0x1,%r9d
test   %rbx,%rbx
je     121a <bot_fileutils_get_unique_filename+0xaa>
lea    0xe33(%rip),%rdx
lea    0x20(%rsp),%rdi
mov    $0x100,%esi
mov    %rbx,%rcx
xor    %eax,%eax
push   %r14
push   %rbp
call   1060 <snprintf@plt>
jmp    1241 <bot_fileutils_get_unique_filename+0xd1>
test   %rbx,%rbx
je     1312 <bot_fileutils_get_unique_filename+0x1a2>
lea    0xe1d(%rip),%rdx
lea    0x20(%rsp),%rdi
mov    $0x100,%esi
mov    %rbx,%rcx
mov    %r14,%r8
xor    %eax,%eax
call   1060 <snprintf@plt>
test   %r15,%r15
jne    124a <bot_fileutils_get_unique_filename+0xda>
mov    $0x104,%r14d
jmp    125c <bot_fileutils_get_unique_filename+0xec>
sub    $0x8,%rsp
lea    0xdde(%rip),%rdx
lea    0x28(%rsp),%rdi
mov    $0x100,%esi
mov    %r8d,%ecx
mov    %r9d,%r8d
mov    %ebp,%r9d
xor    %eax,%eax
push   %r14
call   1060 <snprintf@plt>
add    $0x10,%rsp
test   %r15,%r15
je     1212 <bot_fileutils_get_unique_filename+0xa2>
mov    %r15,%rdi
call   1050 <strlen@plt>
mov    %rax,%r14
add    $0x104,%r14d
mov    %r14d,%edi
call   1090 <malloc@plt>
mov    %rax,%rbx
mov    $0xffffffff,%ebp
lea    0x20(%rsp),%r13
lea    0x10(%rsp),%r12
cs nopw 0x0(%rax,%rax,1)
add    $0x1,%ebp
mov    %rbx,%rdi
mov    %r14d,%esi
test   %r15,%r15
je     12b0 <bot_fileutils_get_unique_filename+0x140>
lea    0xd84(%rip),%rdx
mov    %r13,%rcx
mov    %ebp,%r8d
mov    %r15,%r9
xor    %eax,%eax
call   1060 <snprintf@plt>
jmp    12c4 <bot_fileutils_get_unique_filename+0x154>
nopw   0x0(%rax,%rax,1)
lea    0xd6d(%rip),%rdx
mov    %r13,%rcx
mov    %ebp,%r8d
xor    %eax,%eax
call   1060 <snprintf@plt>
mov    %rbx,%rdi
mov    %r12,%rsi
call   1070 <stat@plt>
test   %eax,%eax
jne    12d8 <bot_fileutils_get_unique_filename+0x168>
cmp    $0x63,%ebp
jb     1280 <bot_fileutils_get_unique_filename+0x110>
cmp    $0x62,%ebp
ja     12f3 <bot_fileutils_get_unique_filename+0x183>
mov    0x2cfc(%rip),%rax
mov    (%rax),%rax
mov    0x2ce2(%rip),%rcx
cmp    (%rcx),%rax
je     12fd <bot_fileutils_get_unique_filename+0x18d>
mov    %rbx,%rdi
call   1030 <free@plt>
xor    %ebx,%ebx
mov    %rbx,%rax
add    $0x128,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xcf7(%rip),%rdx
lea    0x20(%rsp),%rdi
mov    $0x100,%esi
mov    %r14,%rcx
xor    %eax,%eax
call   1060 <snprintf@plt>
test   %r15,%r15
jne    124a <bot_fileutils_get_unique_filename+0xda>
jmp    1212 <bot_fileutils_get_unique_filename+0xa2>

LLVM IR (-O0):
%struct.tm = type { i32, i32, i32 }
%struct.stat = type { i32 }
@.str = [19 x i8] c"%s/%d-%02d-%02d-%s\00"
@.str.1 = [16 x i8] c"%d-%02d-%02d-%s\00"
@.str.2 = [6 x i8] c"%s/%s\00"
@.str.3 = [3 x i8] c"%s\00"
@.str.4 = [11 x i8] c"%s.%02d.%s\00"
@.str.5 = [8 x i8] c"%s.%02d\00"
@errno = global i64 0
@ENOENT = global i64 0
define i8* @bot_fileutils_get_unique_filename(i8* %0, i8* %1, i64 %2, i8* %3) {
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i64
%9 = alloca i8*
%10 = alloca [256 x i8]
%11 = alloca i32
%12 = alloca %struct.tm
%13 = alloca i32
%14 = alloca i8*
%15 = alloca i32
%16 = alloca i32
%17 = alloca %struct.stat
store i8* %0, i8** %6
store i8* %1, i8** %7
store i64 %2, i64* %8
store i8* %3, i8** %9
%18 = load i64, i64* %8
%19 = icmp ne i64 %18, 0
br i1 %19, label %20, label %51
20: ; preds = %4
%21 = call i32 @time(i32* null)
store i32 %21, i32* %11
%22 = call i32 @localtime_r(i32* %11, %struct.tm* %12)
%23 = load i8*, i8** %6
%24 = icmp ne i8* %23, null
br i1 %24, label %25, label %38
25: ; preds = %20
%26 = getelementptr inbounds [256 x i8], [256 x i8]* %10, i64 0, i64 0
%27 = load i8*, i8** %6
%28 = getelementptr inbounds %struct.tm, %struct.tm* %12, i32 0, i32 0
%29 = load i32, i32* %28
%30 = add nsw i32 %29, 1900
%31 = getelementptr inbounds %struct.tm, %struct.tm* %12, i32 0, i32 1
%32 = load i32, i32* %31
%33 = add nsw i32 %32, 1
%34 = getelementptr inbounds %struct.tm, %struct.tm* %12, i32 0, i32 2
%35 = load i32, i32* %34
%36 = load i8*, i8** %7
%37 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %26, i32 256, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i8* %27, i32 %30, i32 %33, i32 %35, i8* %36)
br label %50
38: ; preds = %20
%39 = getelementptr inbounds [256 x i8], [256 x i8]* %10, i64 0, i64 0
%40 = getelementptr inbounds %struct.tm, %struct.tm* %12, i32 0, i32 0
%41 = load i32, i32* %40
%42 = add nsw i32 %41, 1900
%43 = getelementptr inbounds %struct.tm, %struct.tm* %12, i32 0, i32 1
%44 = load i32, i32* %43
%45 = add nsw i32 %44, 1
%46 = getelementptr inbounds %struct.tm, %struct.tm* %12, i32 0, i32 2
%47 = load i32, i32* %46
%48 = load i8*, i8** %7
%49 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %39, i32 256, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i32 %42, i32 %45, i32 %47, i8* %48)
br label %50
50: ; preds = %38, %25
br label %64
51: ; preds = %4
%52 = load i8*, i8** %6
%53 = icmp ne i8* %52, null
br i1 %53, label %54, label %59
54: ; preds = %51
%55 = getelementptr inbounds [256 x i8], [256 x i8]* %10, i64 0, i64 0
%56 = load i8*, i8** %6
%57 = load i8*, i8** %7
%58 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %55, i32 256, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8* %56, i8* %57)
br label %63
59: ; preds = %51
%60 = getelementptr inbounds [256 x i8], [256 x i8]* %10, i64 0, i64 0
%61 = load i8*, i8** %7
%62 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %60, i32 256, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %61)
br label %63
63: ; preds = %59, %54
br label %64
64: ; preds = %63, %50
store i32 260, i32* %13
%65 = load i8*, i8** %9
%66 = icmp ne i8* %65, null
br i1 %66, label %67, label %74
67: ; preds = %64
%68 = load i8*, i8** %9
%69 = call i64 @strlen(i8* %68)
%70 = load i32, i32* %13
%71 = sext i32 %70 to i64
%72 = add nsw i64 %71, %69
%73 = trunc i64 %72 to i32
store i32 %73, i32* %13
br label %74
74: ; preds = %67, %64
%75 = load i32, i32* %13
%76 = call i8* @malloc(i32 %75)
store i8* %76, i8** %14
store i32 0, i32* %16
br label %77
77: ; preds = %104, %74
%78 = load i8*, i8** %9
%79 = icmp ne i8* %78, null
br i1 %79, label %80, label %87
80: ; preds = %77
%81 = load i8*, i8** %14
%82 = load i32, i32* %13
%83 = getelementptr inbounds [256 x i8], [256 x i8]* %10, i64 0, i64 0
%84 = load i32, i32* %16
%85 = load i8*, i8** %9
%86 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %81, i32 %82, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0), i8* %83, i32 %84, i8* %85)
br label %93
87: ; preds = %77
%88 = load i8*, i8** %14
%89 = load i32, i32* %13
%90 = getelementptr inbounds [256 x i8], [256 x i8]* %10, i64 0, i64 0
%91 = load i32, i32* %16
%92 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %88, i32 %89, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0), i8* %90, i32 %91)
br label %93
93: ; preds = %87, %80
%94 = load i8*, i8** %14
%95 = call i32 @stat(i8* %94, %struct.stat* %17)
store i32 %95, i32* %15
%96 = load i32, i32* %16
%97 = add nsw i32 %96, 1
store i32 %97, i32* %16
br label %98
98: ; preds = %93
%99 = load i32, i32* %15
%100 = icmp eq i32 %99, 0
br i1 %100, label %101, label %104
101: ; preds = %98
%102 = load i32, i32* %16
%103 = icmp slt i32 %102, 100
br label %104
104: ; preds = %101, %98
%105 = phi i1 [ false, %98 ], [ %103, %101 ]
br i1 %105, label %77, label %106
106: ; preds = %104
%107 = load i32, i32* %16
%108 = icmp sge i32 %107, 100
br i1 %108, label %109, label %112
109: ; preds = %106
%110 = load i8*, i8** %14
%111 = call i32 @free(i8* %110)
store i8* null, i8** %5
br label %121
112: ; preds = %106
%113 = load i64, i64* @errno
%114 = load i64, i64* @ENOENT
%115 = icmp ne i64 %113, %114
br i1 %115, label %116, label %119
116: ; preds = %112
%117 = load i8*, i8** %14
%118 = call i32 @free(i8* %117)
store i8* null, i8** %5
br label %121
119: ; preds = %112
%120 = load i8*, i8** %14
store i8* %120, i8** %5
br label %121
121: ; preds = %119, %116, %109
%122 = load i8*, i8** %5
ret i8* %122
}

LLVM IR (-O2):
%struct.tm = type { i32, i32, i32 }
%struct.stat = type { i32 }
@.str = [19 x i8] c"%s/%d-%02d-%02d-%s\00"
@.str.1 = [16 x i8] c"%d-%02d-%02d-%s\00"
@.str.2 = [6 x i8] c"%s/%s\00"
@.str.3 = [3 x i8] c"%s\00"
@.str.4 = [11 x i8] c"%s.%02d.%s\00"
@.str.5 = [8 x i8] c"%s.%02d\00"
@errno = global i64 0
@ENOENT = global i64 0
define i8* @bot_fileutils_get_unique_filename(i8* %0, i8* %1, i64 %2, i8* %3) {
%5 = alloca [256 x i8]
%6 = alloca i32
%7 = alloca %struct.tm
%8 = alloca %struct.stat
%9 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 0
%10 = icmp eq i64 %2, 0
br i1 %10, label %30, label %11
11: ; preds = %4
%12 = bitcast i32* %6 to i8*
%13 = tail call i32 @time(i32* null)
store i32 %13, i32* %6
%14 = bitcast %struct.tm* %7 to i8*
%15 = call i32 @localtime_r(i32* %6, %struct.tm* %7)
%16 = icmp eq i8* %0, null
%17 = getelementptr inbounds %struct.tm, %struct.tm* %7, i64 0, i32 0
%18 = load i32, i32* %17
%19 = add nsw i32 %18, 1900
%20 = getelementptr inbounds %struct.tm, %struct.tm* %7, i64 0, i32 1
%21 = load i32, i32* %20
%22 = add nsw i32 %21, 1
%23 = getelementptr inbounds %struct.tm, %struct.tm* %7, i64 0, i32 2
%24 = load i32, i32* %23
br i1 %16, label %27, label %25
25: ; preds = %11
%26 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %9, i32 256, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i8* %0, i32 %19, i32 %22, i32 %24, i8* %1)
br label %29
27: ; preds = %11
%28 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %9, i32 256, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i32 %19, i32 %22, i32 %24, i8* %1)
br label %29
29: ; preds = %27, %25
br label %36
30: ; preds = %4
%31 = icmp eq i8* %0, null
br i1 %31, label %34, label %32
32: ; preds = %30
%33 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %9, i32 256, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0), i8* %0, i8* %1)
br label %36
34: ; preds = %30
%35 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %9, i32 256, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* %1)
br label %36
36: ; preds = %32, %34, %29
%37 = icmp eq i8* %3, null
br i1 %37, label %42, label %38
38: ; preds = %36
%39 = call i64 @strlen(i8* %3)
%40 = trunc i64 %39 to i32
%41 = add i32 %40, 260
br label %42
42: ; preds = %38, %36
%43 = phi i32 [ %41, %38 ], [ 260, %36 ]
%44 = call i8* @malloc(i32 %43)
%45 = bitcast %struct.stat* %8 to i8*
br label %46
46: ; preds = %52, %42
%47 = phi i32 [ 0, %42 ], [ %54, %52 ]
br i1 %37, label %50, label %48
48: ; preds = %46
%49 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %44, i32 %43, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.4, i64 0, i64 0), i8* %9, i32 %47, i8* %3)
br label %52
50: ; preds = %46
%51 = call i32 (i8*, i32, i8*, ...) @snprintf(i8* %44, i32 %43, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.5, i64 0, i64 0), i8* %9, i32 %47)
br label %52
52: ; preds = %50, %48
%53 = call i32 @stat(i8* %44, %struct.stat* %8)
%54 = add nuw nsw i32 %47, 1
%55 = icmp eq i32 %53, 0
%56 = icmp ult i32 %47, 99
%57 = select i1 %55, i1 %56, i1 false
br i1 %57, label %46, label %58
58: ; preds = %52
%59 = icmp ugt i32 %47, 98
br i1 %59, label %64, label %60
60: ; preds = %58
%61 = load i64, i64* @errno
%62 = load i64, i64* @ENOENT
%63 = icmp eq i64 %61, %62
br i1 %63, label %66, label %64
64: ; preds = %60, %58
%65 = call i32 @free(i8* %44)
br label %66
66: ; preds = %64, %60
%67 = phi i8* [ %44, %60 ], [ null, %64 ]
ret i8* %67
}