#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 */
struct stat {
  int st_size;
};
struct dirent {
  int d_type;
  char const *d_name;
};
typedef int /*<<< orphan*/ fullname;
typedef int /*<<< orphan*/ buf;
typedef int /*<<< orphan*/ DIR;

/* Variables and functions */
int DT_DIR;
scalar_t__ SockAPI_SendHttpResp(int, int, char *, char *, int /*<<< orphan*/ *,
                                char *, size_t);
int /*<<< orphan*/ memcpy(char *, char const *, int);
int /*<<< orphan*/ *opendir(char const *);
struct dirent *readdir(int /*<<< orphan*/ *);
size_t sprintf(char *, char *, ...);
scalar_t__ stat(char *, struct stat *);
void *strlen(char const *);
int parse_indexreq(int sd, const char *rootdir) {
  char fullname[512];
  char *pname = NULL;
  char buf[81920];
  size_t offset = 0;
  struct dirent *dent;
  DIR *dir = opendir(rootdir);
  size_t fnamemax;
  if (!dir) {
    if (SockAPI_SendHttpResp(sd, 500, "get dir list fail", NULL, NULL, NULL,
                             0) != 0)
      return -1;
    return 0;
  }
  fnamemax = strlen(rootdir);
  pname = fullname + fnamemax;
  memcpy(fullname, rootdir, fnamemax);
  if (pname[-1] != '/') {
    *pname++ = '/';
    fnamemax++;
  }
  fnamemax = sizeof(fullname) - fnamemax - 1;
  offset = sprintf(
      buf, "<html><head><title>iOS Log list</title></head><body><table>");
  while (dent = readdir(dir)) {
    int hasset = 0;
    int dnamelen;
    struct stat stat_buf;
    if (dent->d_type & DT_DIR) {
      continue;
    }
    dnamelen = strlen(dent->d_name);
    if (offset + dnamelen * 2 + 100 > sizeof(buf))
      break;
    if (dnamelen < fnamemax) {
      memcpy(pname, dent->d_name, dnamelen + 1);
      if (stat(fullname, &stat_buf) == 0) {
        offset +=
            sprintf(buf + offset,
                    "<tr><td><a href=\"%s\">%s</a></td><td>%u kb</td><td> <a "
                    "href=\"%s&act=del\">Delete</a></td></tr>\n",
                    dent->d_name, dent->d_name,
                    (stat_buf.st_size + 1023) / 1024, dent->d_name);
        hasset = 1;
      }
    }
    if (!hasset) {
      offset += sprintf(buf + offset,
                        "<tr><td><a href=\"%s\">%s</a></td><td></td><td> <a "
                        "href=\"%s&act=del\">Delete</a></td></tr>\n",
                        dent->d_name, dent->d_name, dent->d_name);
    }
  }
  offset += sprintf(buf + offset, "</table></body></html>");
  return SockAPI_SendHttpResp(sd, 200, "OK", "text/html", NULL, buf, offset) ==
                 0
             ? 0
             : -1;
}


x86 assembly (clang, -O0):
<parse_indexreq>:
push   %rbp
mov    %rsp,%rbp
sub    $0x14260,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x218(%rbp)
movq   $0x0,-0x14228(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <opendir@plt>
mov    %rax,-0x14238(%rbp)
cmpq   $0x0,-0x14238(%rbp)
jne    11ff <parse_indexreq+0x8f>
mov    -0x8(%rbp),%edi
mov    $0x1f4,%esi
lea    0xe3b(%rip),%rdx
xor    %eax,%eax
mov    %eax,%r9d
mov    %r9,%rcx
mov    %r9,%r8
movq   $0x0,(%rsp)
call   1080 <SockAPI_SendHttpResp@plt>
cmp    $0x0,%rax
je     11f3 <parse_indexreq+0x83>
movl   $0xffffffff,-0x4(%rbp)
jmp    14d0 <parse_indexreq+0x360>
movl   $0x0,-0x4(%rbp)
jmp    14d0 <parse_indexreq+0x360>
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    %rax,-0x14240(%rbp)
lea    -0x210(%rbp),%rax
add    -0x14240(%rbp),%rax
mov    %rax,-0x218(%rbp)
lea    -0x210(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x14240(%rbp),%rax
mov    %eax,%edx
call   1060 <memcpy@plt>
mov    -0x218(%rbp),%rax
movsbl -0x1(%rax),%eax
cmp    $0x2f,%eax
je     127b <parse_indexreq+0x10b>
mov    -0x218(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x218(%rbp)
movb   $0x2f,(%rax)
mov    -0x14240(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x14240(%rbp)
mov    $0x200,%eax
sub    -0x14240(%rbp),%rax
sub    $0x1,%rax
mov    %rax,-0x14240(%rbp)
lea    -0x14220(%rbp),%rdi
lea    0xd72(%rip),%rsi
mov    $0x0,%al
call   1090 <sprintf@plt>
mov    %rax,-0x14228(%rbp)
mov    -0x14238(%rbp),%rdi
call   1070 <readdir@plt>
mov    %rax,-0x14230(%rbp)
cmp    $0x0,%rax
je     1462 <parse_indexreq+0x2f2>
movl   $0x0,-0x14244(%rbp)
mov    -0x14230(%rbp),%rax
mov    (%rax),%eax
mov    0x2cfb(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
je     12f5 <parse_indexreq+0x185>
jmp    12ae <parse_indexreq+0x13e>
mov    -0x14230(%rbp),%rax
mov    0x8(%rax),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x14248(%rbp)
mov    -0x14228(%rbp),%rax
mov    -0x14248(%rbp),%ecx
shl    $0x1,%ecx
movslq %ecx,%rcx
add    %rcx,%rax
add    $0x64,%rax
cmp    $0x14000,%rax
jbe    1336 <parse_indexreq+0x1c6>
jmp    1462 <parse_indexreq+0x2f2>
movslq -0x14248(%rbp),%rax
cmp    -0x14240(%rbp),%rax
jae    1405 <parse_indexreq+0x295>
mov    -0x218(%rbp),%rdi
mov    -0x14230(%rbp),%rax
mov    0x8(%rax),%rsi
mov    -0x14248(%rbp),%edx
add    $0x1,%edx
call   1060 <memcpy@plt>
lea    -0x210(%rbp),%rdi
lea    -0x14250(%rbp),%rsi
call   1050 <stat@plt>
cmp    $0x0,%rax
jne    1400 <parse_indexreq+0x290>
lea    -0x14220(%rbp),%rdi
add    -0x14228(%rbp),%rdi
mov    -0x14230(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x14258(%rbp)
mov    -0x14230(%rbp),%rax
mov    0x8(%rax),%rcx
mov    -0x14250(%rbp),%eax
add    $0x3ff,%eax
mov    $0x400,%esi
cltd
idiv   %esi
mov    -0x14258(%rbp),%rdx
mov    %eax,%r8d
mov    -0x14230(%rbp),%rax
mov    0x8(%rax),%r9
lea    0xc6d(%rip),%rsi
mov    $0x0,%al
call   1090 <sprintf@plt>
add    -0x14228(%rbp),%rax
mov    %rax,-0x14228(%rbp)
movl   $0x1,-0x14244(%rbp)
jmp    1405 <parse_indexreq+0x295>
cmpl   $0x0,-0x14244(%rbp)
jne    145d <parse_indexreq+0x2ed>
lea    -0x14220(%rbp),%rdi
add    -0x14228(%rbp),%rdi
mov    -0x14230(%rbp),%rax
mov    0x8(%rax),%rdx
mov    -0x14230(%rbp),%rax
mov    0x8(%rax),%rcx
mov    -0x14230(%rbp),%rax
mov    0x8(%rax),%r8
lea    0xc64(%rip),%rsi
mov    $0x0,%al
call   1090 <sprintf@plt>
add    -0x14228(%rbp),%rax
mov    %rax,-0x14228(%rbp)
jmp    12ae <parse_indexreq+0x13e>
lea    -0x14220(%rbp),%rdi
add    -0x14228(%rbp),%rdi
lea    0xc8e(%rip),%rsi
mov    $0x0,%al
call   1090 <sprintf@plt>
add    -0x14228(%rbp),%rax
mov    %rax,-0x14228(%rbp)
mov    -0x8(%rbp),%edi
lea    -0x14220(%rbp),%r9
mov    -0x14228(%rbp),%rax
mov    $0xc8,%esi
lea    0xc73(%rip),%rdx
lea    0xc6f(%rip),%rcx
xor    %r8d,%r8d
mov    %rax,(%rsp)
call   1080 <SockAPI_SendHttpResp@plt>
mov    %rax,%rdx
mov    $0xffffffff,%eax
xor    %ecx,%ecx
cmp    $0x0,%rdx
cmove  %ecx,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x14260,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_indexreq>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x14218,%rsp
mov    %rsi,%rbp
mov    %edi,%r14d
mov    %rsi,%rdi
call   1030 <opendir@plt>
test   %rax,%rax
je     133e <parse_indexreq+0x1ce>
mov    %rax,%rbx
mov    %rbp,%rdi
call   1040 <strlen@plt>
mov    %rax,%r12
lea    (%rsp,%rax,1),%r15
add    $0x10,%r15
lea    0x10(%rsp),%rdi
mov    %rbp,%rsi
mov    %r12d,%edx
call   1060 <memcpy@plt>
cmpb   $0x2f,0xf(%rsp,%r12,1)
je     11d2 <parse_indexreq+0x62>
movb   $0x2f,(%r15)
add    $0x1,%r15
add    $0x1,%r12
mov    %r14d,0xc(%rsp)
lea    0xe34(%rip),%rsi
lea    0x210(%rsp),%rdi
xor    %eax,%eax
call   1090 <sprintf@plt>
mov    %rax,%rbp
mov    %rbx,%rdi
call   1070 <readdir@plt>
test   %rax,%rax
je     12fa <parse_indexreq+0x18a>
mov    %rax,%r13
mov    $0x1ff,%r14d
sub    %r12,%r14
mov    0x2dcc(%rip),%r12
jmp    125a <parse_indexreq+0xea>
cs nopw 0x0(%rax,%rax,1)
lea    (%rsp,%rbp,1),%rdi
add    $0x210,%rdi
mov    0x8(%r13),%rcx
lea    0xe76(%rip),%rsi
mov    %rcx,%rdx
mov    %rcx,%r8
xor    %eax,%eax
call   1090 <sprintf@plt>
add    %rax,%rbp
mov    %rbx,%rdi
call   1070 <readdir@plt>
mov    %rax,%r13
test   %rax,%rax
je     12fa <parse_indexreq+0x18a>
mov    (%r12),%eax
test   %eax,0x0(%r13)
jne    1246 <parse_indexreq+0xd6>
mov    0x8(%r13),%rdi
call   1040 <strlen@plt>
lea    (%rax,%rax,1),%ecx
movslq %ecx,%rcx
add    %rbp,%rcx
add    $0xfffffffffffec063,%rcx
cmp    $0xfffffffffffebffe,%rcx
jbe    12fa <parse_indexreq+0x18a>
movslq %eax,%rcx
cmp    %r14,%rcx
jae    1220 <parse_indexreq+0xb0>
mov    0x8(%r13),%rsi
lea    0x1(%rax),%edx
mov    %r15,%rdi
call   1060 <memcpy@plt>
lea    0x10(%rsp),%rdi
lea    0x8(%rsp),%rsi
call   1050 <stat@plt>
test   %rax,%rax
jne    1220 <parse_indexreq+0xb0>
lea    (%rsp,%rbp,1),%rdi
add    $0x210,%rdi
mov    0x8(%r13),%rcx
mov    0x8(%rsp),%r8d
lea    0x3ff(%r8),%eax
add    $0x7fe,%r8d
test   %eax,%eax
cmovns %eax,%r8d
sar    $0xa,%r8d
lea    0xd66(%rip),%rsi
mov    %rcx,%rdx
mov    %rcx,%r9
xor    %eax,%eax
call   1090 <sprintf@plt>
jmp    1243 <parse_indexreq+0xd3>
lea    (%rsp,%rbp,1),%rdi
add    $0x210,%rdi
lea    0xdf9(%rip),%rsi
xor    %eax,%eax
call   1090 <sprintf@plt>
add    %rbp,%rax
mov    %rax,(%rsp)
lea    0xdfb(%rip),%rdx
lea    0xdf7(%rip),%rcx
lea    0x210(%rsp),%r9
mov    0xc(%rsp),%edi
mov    $0xc8,%esi
xor    %r8d,%r8d
jmp    135d <parse_indexreq+0x1ed>
movq   $0x0,(%rsp)
lea    0xcb3(%rip),%rdx
mov    %r14d,%edi
mov    $0x1f4,%esi
xor    %ecx,%ecx
xor    %r8d,%r8d
xor    %r9d,%r9d
call   1080 <SockAPI_SendHttpResp@plt>
neg    %rax
sbb    %eax,%eax
add    $0x14218,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.dirent = type { i32, i8* }
%struct.stat = type { i32 }
@.str = [18 x i8] c"get dir list fail\00"
@.str.1 = [60 x i8] c"<html><head><title>iOS Log list</title></head><body><table>\00"
@DT_DIR = global i32 0
@.str.2 = [94 x i8] c"<tr><td><a href=\22%s\22>%s</a></td><td>%u kb</td><td> <a href=\22%s&act=del\22>Delete</a></td></tr>\0A\00"
@.str.3 = [89 x i8] c"<tr><td><a href=\22%s\22>%s</a></td><td></td><td> <a href=\22%s&act=del\22>Delete</a></td></tr>\0A\00"
@.str.4 = [23 x i8] c"</table></body></html>\00"
@.str.5 = [3 x i8] c"OK\00"
@.str.6 = [10 x i8] c"text/html\00"
define i32 @parse_indexreq(i32 %0, i8* %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8*
%6 = alloca [512 x i8]
%7 = alloca i8*
%8 = alloca [81920 x i8]
%9 = alloca i64
%10 = alloca %struct.dirent*
%11 = alloca i32*
%12 = alloca i64
%13 = alloca i32
%14 = alloca i32
%15 = alloca %struct.stat
store i32 %0, i32* %4
store i8* %1, i8** %5
store i8* null, i8** %7
store i64 0, i64* %9
%16 = load i8*, i8** %5
%17 = call i32* @opendir(i8* %16)
store i32* %17, i32** %11
%18 = load i32*, i32** %11
%19 = icmp ne i32* %18, null
br i1 %19, label %26, label %20
20: ; preds = %2
%21 = load i32, i32* %4
%22 = call i64 @SockAPI_SendHttpResp(i32 %21, i32 500, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* null, i32* null, i8* null, i64 0)
%23 = icmp ne i64 %22, 0
br i1 %23, label %24, label %25
24: ; preds = %20
store i32 -1, i32* %3
br label %151
25: ; preds = %20
store i32 0, i32* %3
br label %151
26: ; preds = %2
%27 = load i8*, i8** %5
%28 = call i8* @strlen(i8* %27)
%29 = ptrtoint i8* %28 to i64
store i64 %29, i64* %12
%30 = getelementptr inbounds [512 x i8], [512 x i8]* %6, i64 0, i64 0
%31 = load i64, i64* %12
%32 = getelementptr inbounds i8, i8* %30, i64 %31
store i8* %32, i8** %7
%33 = getelementptr inbounds [512 x i8], [512 x i8]* %6, i64 0, i64 0
%34 = load i8*, i8** %5
%35 = load i64, i64* %12
%36 = trunc i64 %35 to i32
%37 = call i32 @memcpy(i8* %33, i8* %34, i32 %36)
%38 = load i8*, i8** %7
%39 = getelementptr inbounds i8, i8* %38, i64 -1
%40 = load i8, i8* %39
%41 = sext i8 %40 to i32
%42 = icmp ne i32 %41, 47
br i1 %42, label %43, label %48
43: ; preds = %26
%44 = load i8*, i8** %7
%45 = getelementptr inbounds i8, i8* %44, i32 1
store i8* %45, i8** %7
store i8 47, i8* %44
%46 = load i64, i64* %12
%47 = add i64 %46, 1
store i64 %47, i64* %12
br label %48
48: ; preds = %43, %26
%49 = load i64, i64* %12
%50 = sub i64 512, %49
%51 = sub i64 %50, 1
store i64 %51, i64* %12
%52 = getelementptr inbounds [81920 x i8], [81920 x i8]* %8, i64 0, i64 0
%53 = call i64 (i8*, i8*, ...) @sprintf(i8* %52, i8* getelementptr inbounds ([60 x i8], [60 x i8]* @.str.1, i64 0, i64 0))
store i64 %53, i64* %9
br label %54
54: ; preds = %136, %65, %48
%55 = load i32*, i32** %11
%56 = call %struct.dirent* @readdir(i32* %55)
store %struct.dirent* %56, %struct.dirent** %10
%57 = icmp ne %struct.dirent* %56, null
br i1 %57, label %58, label %137
58: ; preds = %54
store i32 0, i32* %13
%59 = load %struct.dirent*, %struct.dirent** %10
%60 = getelementptr inbounds %struct.dirent, %struct.dirent* %59, i32 0, i32 0
%61 = load i32, i32* %60
%62 = load i32, i32* @DT_DIR
%63 = and i32 %61, %62
%64 = icmp ne i32 %63, 0
br i1 %64, label %65, label %66
65: ; preds = %58
br label %54
66: ; preds = %58
%67 = load %struct.dirent*, %struct.dirent** %10
%68 = getelementptr inbounds %struct.dirent, %struct.dirent* %67, i32 0, i32 1
%69 = load i8*, i8** %68
%70 = call i8* @strlen(i8* %69)
%71 = ptrtoint i8* %70 to i32
store i32 %71, i32* %14
%72 = load i64, i64* %9
%73 = load i32, i32* %14
%74 = mul nsw i32 %73, 2
%75 = sext i32 %74 to i64
%76 = add i64 %72, %75
%77 = add i64 %76, 100
%78 = icmp ugt i64 %77, 81920
br i1 %78, label %79, label %80
79: ; preds = %66
br label %137
80: ; preds = %66
%81 = load i32, i32* %14
%82 = sext i32 %81 to i64
%83 = load i64, i64* %12
%84 = icmp ult i64 %82, %83
br i1 %84, label %85, label %117
85: ; preds = %80
%86 = load i8*, i8** %7
%87 = load %struct.dirent*, %struct.dirent** %10
%88 = getelementptr inbounds %struct.dirent, %struct.dirent* %87, i32 0, i32 1
%89 = load i8*, i8** %88
%90 = load i32, i32* %14
%91 = add nsw i32 %90, 1
%92 = call i32 @memcpy(i8* %86, i8* %89, i32 %91)
%93 = getelementptr inbounds [512 x i8], [512 x i8]* %6, i64 0, i64 0
%94 = call i64 @stat(i8* %93, %struct.stat* %15)
%95 = icmp eq i64 %94, 0
br i1 %95, label %96, label %116
96: ; preds = %85
%97 = getelementptr inbounds [81920 x i8], [81920 x i8]* %8, i64 0, i64 0
%98 = load i64, i64* %9
%99 = getelementptr inbounds i8, i8* %97, i64 %98
%100 = load %struct.dirent*, %struct.dirent** %10
%101 = getelementptr inbounds %struct.dirent, %struct.dirent* %100, i32 0, i32 1
%102 = load i8*, i8** %101
%103 = load %struct.dirent*, %struct.dirent** %10
%104 = getelementptr inbounds %struct.dirent, %struct.dirent* %103, i32 0, i32 1
%105 = load i8*, i8** %104
%106 = getelementptr inbounds %struct.stat, %struct.stat* %15, i32 0, i32 0
%107 = load i32, i32* %106
%108 = add nsw i32 %107, 1023
%109 = sdiv i32 %108, 1024
%110 = load %struct.dirent*, %struct.dirent** %10
%111 = getelementptr inbounds %struct.dirent, %struct.dirent* %110, i32 0, i32 1
%112 = load i8*, i8** %111
%113 = call i64 (i8*, i8*, ...) @sprintf(i8* %99, i8* getelementptr inbounds ([94 x i8], [94 x i8]* @.str.2, i64 0, i64 0), i8* %102, i8* %105, i32 %109, i8* %112)
%114 = load i64, i64* %9
%115 = add i64 %114, %113
store i64 %115, i64* %9
store i32 1, i32* %13
br label %116
116: ; preds = %96, %85
br label %117
117: ; preds = %116, %80
%118 = load i32, i32* %13
%119 = icmp ne i32 %118, 0
br i1 %119, label %136, label %120
120: ; preds = %117
%121 = getelementptr inbounds [81920 x i8], [81920 x i8]* %8, i64 0, i64 0
%122 = load i64, i64* %9
%123 = getelementptr inbounds i8, i8* %121, i64 %122
%124 = load %struct.dirent*, %struct.dirent** %10
%125 = getelementptr inbounds %struct.dirent, %struct.dirent* %124, i32 0, i32 1
%126 = load i8*, i8** %125
%127 = load %struct.dirent*, %struct.dirent** %10
%128 = getelementptr inbounds %struct.dirent, %struct.dirent* %127, i32 0, i32 1
%129 = load i8*, i8** %128
%130 = load %struct.dirent*, %struct.dirent** %10
%131 = getelementptr inbounds %struct.dirent, %struct.dirent* %130, i32 0, i32 1
%132 = load i8*, i8** %131
%133 = call i64 (i8*, i8*, ...) @sprintf(i8* %123, i8* getelementptr inbounds ([89 x i8], [89 x i8]* @.str.3, i64 0, i64 0), i8* %126, i8* %129, i8* %132)
%134 = load i64, i64* %9
%135 = add i64 %134, %133
store i64 %135, i64* %9
br label %136
136: ; preds = %120, %117
br label %54
137: ; preds = %79, %54
%138 = getelementptr inbounds [81920 x i8], [81920 x i8]* %8, i64 0, i64 0
%139 = load i64, i64* %9
%140 = getelementptr inbounds i8, i8* %138, i64 %139
%141 = call i64 (i8*, i8*, ...) @sprintf(i8* %140, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0))
%142 = load i64, i64* %9
%143 = add i64 %142, %141
store i64 %143, i64* %9
%144 = load i32, i32* %4
%145 = getelementptr inbounds [81920 x i8], [81920 x i8]* %8, i64 0, i64 0
%146 = load i64, i64* %9
%147 = call i64 @SockAPI_SendHttpResp(i32 %144, i32 200, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i64 0, i64 0), i32* null, i8* %145, i64 %146)
%148 = icmp eq i64 %147, 0
%149 = zext i1 %148 to i64
%150 = select i1 %148, i32 0, i32 -1
store i32 %150, i32* %3
br label %151
151: ; preds = %137, %25, %24
%152 = load i32, i32* %3
ret i32 %152
}

LLVM IR (-O2):
%struct.stat = type { i32 }
%struct.dirent = type { i32, i8* }
@.str = [18 x i8] c"get dir list fail\00"
@.str.1 = [60 x i8] c"<html><head><title>iOS Log list</title></head><body><table>\00"
@DT_DIR = global i32 0
@.str.2 = [94 x i8] c"<tr><td><a href=\22%s\22>%s</a></td><td>%u kb</td><td> <a href=\22%s&act=del\22>Delete</a></td></tr>\0A\00"
@.str.3 = [89 x i8] c"<tr><td><a href=\22%s\22>%s</a></td><td></td><td> <a href=\22%s&act=del\22>Delete</a></td></tr>\0A\00"
@.str.4 = [23 x i8] c"</table></body></html>\00"
@.str.5 = [3 x i8] c"OK\00"
@.str.6 = [10 x i8] c"text/html\00"
define i32 @parse_indexreq(i32 %0, i8* %1) {
%3 = alloca [512 x i8]
%4 = alloca [81920 x i8]
%5 = alloca %struct.stat
%6 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 0
%7 = getelementptr inbounds [81920 x i8], [81920 x i8]* %4, i64 0, i64 0
%8 = tail call i32* @opendir(i8* %1)
%9 = icmp eq i32* %8, null
br i1 %9, label %10, label %12
10: ; preds = %2
%11 = tail call i64 @SockAPI_SendHttpResp(i32 %0, i32 500, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* null, i32* null, i8* null, i64 0)
br label %87
12: ; preds = %2
%13 = tail call i8* @strlen(i8* %1)
%14 = ptrtoint i8* %13 to i64
%15 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 %14
%16 = trunc i64 %14 to i32
%17 = call i32 @memcpy(i8* %6, i8* %1, i32 %16)
%18 = getelementptr inbounds i8, i8* %15, i64 -1
%19 = load i8, i8* %18
%20 = icmp eq i8 %19, 47
br i1 %20, label %24, label %21
21: ; preds = %12
%22 = getelementptr inbounds i8, i8* %15, i64 1
store i8 47, i8* %15
%23 = add i64 %14, 1
br label %24
24: ; preds = %21, %12
%25 = phi i8* [ %22, %21 ], [ %15, %12 ]
%26 = phi i64 [ %23, %21 ], [ %14, %12 ]
%27 = sub i64 511, %26
%28 = call i64 (i8*, i8*, ...) @sprintf(i8* %7, i8* getelementptr inbounds ([60 x i8], [60 x i8]* @.str.1, i64 0, i64 0))
%29 = call %struct.dirent* @readdir(i32* %8)
%30 = icmp eq %struct.dirent* %29, null
br i1 %30, label %81, label %31
31: ; preds = %24
%32 = bitcast %struct.stat* %5 to i8*
%33 = getelementptr inbounds %struct.stat, %struct.stat* %5, i64 0, i32 0
br label %34
34: ; preds = %31, %77
%35 = phi %struct.dirent* [ %29, %31 ], [ %79, %77 ]
%36 = phi i64 [ %28, %31 ], [ %78, %77 ]
%37 = getelementptr inbounds %struct.dirent, %struct.dirent* %35, i64 0, i32 0
%38 = load i32, i32* %37
%39 = load i32, i32* @DT_DIR
%40 = and i32 %39, %38
%41 = icmp eq i32 %40, 0
br i1 %41, label %42, label %77
42: ; preds = %34
%43 = getelementptr inbounds %struct.dirent, %struct.dirent* %35, i64 0, i32 1
%44 = load i8*, i8** %43
%45 = call i8* @strlen(i8* %44)
%46 = ptrtoint i8* %45 to i64
%47 = trunc i64 %46 to i32
%48 = shl nsw i32 %47, 1
%49 = sext i32 %48 to i64
%50 = add i64 %36, -81821
%51 = add i64 %50, %49
%52 = icmp ult i64 %51, -81921
br i1 %52, label %53, label %54
53: ; preds = %42
br label %81
54: ; preds = %42
%55 = shl i64 %46, 32
%56 = ashr exact i64 %55, 32
%57 = icmp ult i64 %56, %27
br i1 %57, label %58, label %72
58: ; preds = %54
%59 = load i8*, i8** %43
%60 = add nsw i32 %47, 1
%61 = call i32 @memcpy(i8* %25, i8* %59, i32 %60)
%62 = call i64 @stat(i8* %6, %struct.stat* %5)
%63 = icmp eq i64 %62, 0
br i1 %63, label %64, label %72
64: ; preds = %58
%65 = getelementptr inbounds [81920 x i8], [81920 x i8]* %4, i64 0, i64 %36
%66 = load i8*, i8** %43
%67 = load i32, i32* %33
%68 = add nsw i32 %67, 1023
%69 = sdiv i32 %68, 1024
%70 = call i64 (i8*, i8*, ...) @sprintf(i8* %65, i8* getelementptr inbounds ([94 x i8], [94 x i8]* @.str.2, i64 0, i64 0), i8* %66, i8* %66, i32 %69, i8* %66)
%71 = add i64 %70, %36
br label %77
72: ; preds = %58, %54
%73 = getelementptr inbounds [81920 x i8], [81920 x i8]* %4, i64 0, i64 %36
%74 = load i8*, i8** %43
%75 = call i64 (i8*, i8*, ...) @sprintf(i8* %73, i8* getelementptr inbounds ([89 x i8], [89 x i8]* @.str.3, i64 0, i64 0), i8* %74, i8* %74, i8* %74)
%76 = add i64 %75, %36
br label %77
77: ; preds = %64, %72, %34
%78 = phi i64 [ %36, %34 ], [ %71, %64 ], [ %76, %72 ]
%79 = call %struct.dirent* @readdir(i32* %8)
%80 = icmp eq %struct.dirent* %79, null
br i1 %80, label %81, label %34
81: ; preds = %77, %24, %53
%82 = phi i64 [ %36, %53 ], [ %28, %24 ], [ %78, %77 ]
%83 = getelementptr inbounds [81920 x i8], [81920 x i8]* %4, i64 0, i64 %82
%84 = call i64 (i8*, i8*, ...) @sprintf(i8* %83, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.4, i64 0, i64 0))
%85 = add i64 %84, %82
%86 = call i64 @SockAPI_SendHttpResp(i32 %0, i32 200, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i64 0, i64 0), i32* null, i8* %7, i64 %85)
br label %87
87: ; preds = %10, %81
%88 = phi i64 [ %86, %81 ], [ %11, %10 ]
%89 = icmp ne i64 %88, 0
%90 = sext i1 %89 to i32
ret i32 %90
}