#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 dirent {
  int dummy;
};
typedef int /*<<< orphan*/ save_file_list;
typedef int /*<<< orphan*/ DIR;

/* Variables and functions */
int O_CREAT;
int /*<<< orphan*/ O_RDONLY;
int O_TRUNC;
int O_WRONLY;
int S_IROTH;
int S_IRUSR;
int S_IWOTH;
int S_IWUSR;
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ free(char *);
size_t getfilesize_fd(int, int /*<<< orphan*/ *, int /*<<< orphan*/);
scalar_t__ malloc(int);
int open(char *, int, ...);
int /*<<< orphan*/ *opendir(char *);
int /*<<< orphan*/ printf(char *, char *);
size_t read(int, char *, int);
int /*<<< orphan*/ sprintf(char *, char *, ...);
size_t strlen(char *);
size_t write(int, char *, size_t);
void newbufferedpack_(char *devname, char *dirname) {
  int fdpackfile;
  fdpackfile = open(devname, O_WRONLY | O_CREAT | O_TRUNC,
                    S_IROTH | S_IWOTH | S_IRUSR | S_IWUSR);
  if (fdpackfile <= 0) {
    printf("*** ZVM Error open packfile (write)%s\n", devname);
    return;
  }
  char *indexpath;
  indexpath = dirname;
  DIR *dir;
  struct dirent *entry;
  dir = opendir(indexpath);
  char *newpath;
  char *save_file_list[] = {"mainindex.sps", "mainindex.spm", "mainindex.spa",
                            "mainindex.spk", "mainindex.spd", "mainindex.spp",
                            "mainindex.spe", "mainindex.spi", "mainindex.sph",
                            "zsphinx.conf"};
  int save_file_list_count = sizeof(save_file_list) / sizeof(char *);
  int i = 0;
  if (!dir)
    printf("*** ZVM Error open DIR %s\n", indexpath);
  int blocksize = 1024 * 64;
  char *buff = NULL;
  buff = (char *)malloc(blocksize);
  long deltabytes = 0;
  long mainbytes = 0;
  int filecount = 0;
  for (i = 0; i < save_file_list_count; i++) {
    {
      size_t size;
      size_t bread = 0;
      size_t bwrite;
      size_t bytecount;
      bytecount = 0;
      int fd;
      newpath =
          (char *)malloc(strlen(save_file_list[i]) + strlen(indexpath) + 2);
      sprintf(newpath, "%s/%s", indexpath, save_file_list[i]);
      fd = open(newpath, O_RDONLY);
      size = getfilesize_fd(fd, NULL, 0);
      char tempstr[strlen(newpath) + 12];
      sprintf(tempstr, "%10zu%s%10zu", strlen(newpath), newpath, size);
      bwrite = write(fdpackfile, tempstr, strlen(tempstr));
      if (size > 0) {
        while ((bread = read(fd, buff, blocksize)) > 0) {
          bytecount += bread;
          bwrite = write(fdpackfile, buff, bread);
        }
      } else
        bytecount = 0;
      close(fd);
      filecount++;
    }
  }
  free(buff);
  close(fdpackfile);
}


x86 assembly (clang, -O0):
<newbufferedpack_>:
push   %rbp
mov    %rsp,%rbp
sub    $0x120,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
mov    0x2dca(%rip),%rax
mov    (%rax),%esi
mov    0x2e11(%rip),%rax
or     (%rax),%esi
mov    0x2e00(%rip),%rax
or     (%rax),%esi
mov    0x2dc7(%rip),%rax
mov    (%rax),%edx
mov    0x2d9e(%rip),%rax
or     (%rax),%edx
mov    0x2dad(%rip),%rax
or     (%rax),%edx
mov    0x2dbc(%rip),%rax
or     (%rax),%edx
mov    $0x0,%al
call   10d0 <open@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jg     123f <newbufferedpack_+0x7f>
mov    -0x8(%rbp),%rsi
lea    0xdcb(%rip),%rdi
call   1080 <printf@plt>
jmp    1528 <newbufferedpack_+0x368>
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
call   1060 <opendir@plt>
mov    %rax,-0x28(%rbp)
lea    -0x90(%rbp),%rdi
lea    0x2b2e(%rip),%rsi
mov    $0x50,%edx
call   10b0 <memcpy@plt>
movl   $0xa,-0x94(%rbp)
movl   $0x0,-0x98(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    129b <newbufferedpack_+0xdb>
mov    -0x20(%rbp),%rsi
lea    0xe1c(%rip),%rdi
call   1080 <printf@plt>
movl   $0x10000,-0x9c(%rbp)
movq   $0x0,-0xa8(%rbp)
mov    -0x9c(%rbp),%edi
call   10c0 <malloc@plt>
mov    %rax,-0xa8(%rbp)
movq   $0x0,-0xb0(%rbp)
movq   $0x0,-0xb8(%rbp)
movl   $0x0,-0xbc(%rbp)
movl   $0x0,-0x98(%rbp)
mov    -0x98(%rbp),%eax
cmp    -0x94(%rbp),%eax
jge    1514 <newbufferedpack_+0x354>
movq   $0x0,-0xd0(%rbp)
movq   $0x0,-0xe0(%rbp)
movslq -0x98(%rbp),%rax
mov    -0x90(%rbp,%rax,8),%rdi
ff
call   1070 <strlen@plt>
mov    %rax,-0x118(%rbp)
mov    -0x20(%rbp),%rdi
call   1070 <strlen@plt>
mov    %rax,%rcx
mov    -0x118(%rbp),%rax
mov    %ecx,%edx
mov    %eax,%ecx
mov    %ecx,%eax
mov    %edx,%ecx
lea    0x2(%rax,%rcx,1),%edi
call   10c0 <malloc@plt>
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rdi
mov    -0x20(%rbp),%rdx
movslq -0x98(%rbp),%rax
mov    -0x90(%rbp,%rax,8),%rcx
ff
lea    0xd58(%rip),%rsi
xor    %eax,%eax
mov    %eax,-0x108(%rbp)
mov    %al,-0x109(%rbp)
call   10e0 <sprintf@plt>
mov    -0x109(%rbp),%al
mov    -0x38(%rbp),%rdi
mov    0x2c3f(%rip),%rcx
mov    (%rcx),%esi
call   10d0 <open@plt>
mov    -0x108(%rbp),%edx
mov    %eax,-0xe4(%rbp)
mov    -0xe4(%rbp),%edi
mov    %edx,%esi
call   1040 <getfilesize_fd@plt>
mov    %rax,-0xc8(%rbp)
mov    -0x38(%rbp),%rdi
call   1070 <strlen@plt>
mov    %rax,%rdx
mov    %rdx,%rax
add    $0xc,%rax
mov    %rsp,%rcx
mov    %rcx,-0xf0(%rbp)
add    $0x1b,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x100(%rbp)
mov    %rcx,%rsp
mov    %rax,-0xf8(%rbp)
mov    -0x38(%rbp),%rdi
call   1070 <strlen@plt>
mov    -0x100(%rbp),%rdi
mov    %rax,%rdx
mov    -0x38(%rbp),%rcx
mov    -0xc8(%rbp),%r8
lea    0xcb2(%rip),%rsi
mov    $0x0,%al
call   10e0 <sprintf@plt>
mov    -0x100(%rbp),%rdi
mov    -0x14(%rbp),%eax
mov    %eax,-0x104(%rbp)
call   1070 <strlen@plt>
mov    -0x104(%rbp),%edi
mov    -0x100(%rbp),%rsi
mov    %rax,%rdx
call   1050 <write@plt>
mov    %rax,-0xd8(%rbp)
cmpq   $0x0,-0xc8(%rbp)
jbe    14d1 <newbufferedpack_+0x311>
jmp    146c <newbufferedpack_+0x2ac>
mov    -0xe4(%rbp),%edi
mov    -0xa8(%rbp),%rsi
mov    -0x9c(%rbp),%edx
call   10a0 <read@plt>
mov    %rax,-0xd0(%rbp)
cmp    $0x0,%rax
jbe    14cc <newbufferedpack_+0x30c>
mov    -0xd0(%rbp),%rax
add    -0xe0(%rbp),%rax
mov    %rax,-0xe0(%rbp)
mov    -0x14(%rbp),%edi
mov    -0xa8(%rbp),%rsi
mov    -0xd0(%rbp),%rdx
call   1050 <write@plt>
mov    %rax,-0xd8(%rbp)
jmp    146c <newbufferedpack_+0x2ac>
jmp    14dc <newbufferedpack_+0x31c>
movq   $0x0,-0xe0(%rbp)
mov    -0xe4(%rbp),%edi
call   1090 <close@plt>
mov    -0xbc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xbc(%rbp)
mov    -0xf0(%rbp),%rax
mov    %rax,%rsp
mov    -0x98(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x98(%rbp)
jmp    12ec <newbufferedpack_+0x12c>
mov    -0xa8(%rbp),%rdi
call   1030 <free@plt>
mov    -0x14(%rbp),%edi
call   1090 <close@plt>
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<newbufferedpack_>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    0x2de0(%rip),%rcx
mov    0x2e29(%rip),%rax
mov    (%rax),%eax
or     (%rcx),%eax
mov    0x2e16(%rip),%rcx
or     (%rcx),%eax
mov    0x2ddd(%rip),%rcx
mov    0x2db6(%rip),%rdx
mov    (%rdx),%edx
or     (%rcx),%edx
mov    0x2dc3(%rip),%rcx
or     (%rcx),%edx
mov    %rsi,%r14
mov    %rdi,%rbx
mov    0x2dcc(%rip),%rcx
or     (%rcx),%edx
mov    %eax,%esi
xor    %eax,%eax
call   10c0 <open@plt>
test   %eax,%eax
jle    1397 <newbufferedpack_+0x1e7>
mov    %eax,%r15d
mov    %r14,%rdi
call   1060 <opendir@plt>
test   %rax,%rax
jne    1236 <newbufferedpack_+0x86>
lea    0xe84(%rip),%rdi
mov    %r14,%rsi
call   1080 <printf@plt>
mov    %r14,-0x30(%rbp)
mov    $0x10000,%edi
call   10b0 <malloc@plt>
mov    %rax,%rbx
xor    %ecx,%ecx
jmp    126e <newbufferedpack_+0xbe>
nopl   0x0(%rax,%rax,1)
mov    %r12d,%edi
call   1090 <close@plt>
mov    -0x40(%rbp),%rsp
mov    -0x48(%rbp),%rcx
add    $0x1,%rcx
cmp    $0xa,%rcx
je     1379 <newbufferedpack_+0x1c9>
lea    0x2b1b(%rip),%rax
mov    %rcx,-0x48(%rbp)
mov    (%rax,%rcx,8),%r14
mov    %r14,%rdi
call   1070 <strlen@plt>
mov    %rax,%r13
mov    -0x30(%rbp),%r12
mov    %r12,%rdi
call   1070 <strlen@plt>
lea    (%rax,%r13,1),%edi
add    $0x2,%edi
call   10b0 <malloc@plt>
mov    %rax,%r13
mov    %rax,%rdi
lea    0xe20(%rip),%rsi
mov    %r12,%rdx
mov    %r14,%rcx
xor    %eax,%eax
call   10d0 <sprintf@plt>
mov    0x2d17(%rip),%rax
mov    (%rax),%esi
mov    %r13,%rdi
xor    %eax,%eax
call   10c0 <open@plt>
mov    %eax,%r12d
mov    %eax,%edi
xor    %esi,%esi
xor    %edx,%edx
call   1040 <getfilesize_fd@plt>
mov    %rax,-0x38(%rbp)
mov    %r13,%rdi
call   1070 <strlen@plt>
mov    %rsp,-0x40(%rbp)
add    $0x1b,%rax
and    $0xfffffffffffffff0,%rax
mov    %rsp,%r14
sub    %rax,%r14
mov    %r14,%rsp
mov    %r13,%rdi
call   1070 <strlen@plt>
mov    %r14,%rdi
lea    0xdc5(%rip),%rsi
mov    %rax,%rdx
mov    %r13,%rcx
mov    -0x38(%rbp),%r13
mov    %r13,%r8
xor    %eax,%eax
call   10d0 <sprintf@plt>
mov    %r14,%rdi
call   1070 <strlen@plt>
mov    %r15d,%edi
mov    %r14,%rsi
mov    %rax,%rdx
call   1050 <write@plt>
test   %r13,%r13
je     1250 <newbufferedpack_+0xa0>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %r12d,%edi
mov    %rbx,%rsi
mov    $0x10000,%edx
call   10a0 <read@plt>
test   %rax,%rax
je     1250 <newbufferedpack_+0xa0>
mov    %r15d,%edi
mov    %rbx,%rsi
mov    %rax,%rdx
call   1050 <write@plt>
jmp    1350 <newbufferedpack_+0x1a0>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %r15d,%edi
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1090 <close@plt>
lea    0xc62(%rip),%rdi
mov    %rbx,%rsi
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1080 <printf@plt>

LLVM IR (-O0):
%struct.dirent = type { i32 }
@O_WRONLY = global i32 0
@O_CREAT = global i32 0
@O_TRUNC = global i32 0
@S_IROTH = global i32 0
@S_IWOTH = global i32 0
@S_IRUSR = global i32 0
@S_IWUSR = global i32 0
@.str = [39 x i8] c"*** ZVM Error open packfile (write)%s\0A\00"
@.str.1 = [14 x i8] c"mainindex.sps\00"
@.str.2 = [14 x i8] c"mainindex.spm\00"
@.str.3 = [14 x i8] c"mainindex.spa\00"
@.str.4 = [14 x i8] c"mainindex.spk\00"
@.str.5 = [14 x i8] c"mainindex.spd\00"
@.str.6 = [14 x i8] c"mainindex.spp\00"
@.str.7 = [14 x i8] c"mainindex.spe\00"
@.str.8 = [14 x i8] c"mainindex.spi\00"
@.str.9 = [14 x i8] c"mainindex.sph\00"
@.str.10 = [13 x i8] c"zsphinx.conf\00"
@__const.newbufferedpack_.save_file_list = [10 x i8*] [i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i32 0, i32 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i32 0, i32 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i32 0, i32 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i32 0, i32 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.6, i32 0, i32 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.7, i32 0, i32 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.8, i32 0, i32 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.9, i32 0, i32 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.10, i32 0, i32 0)]
@.str.11 = [27 x i8] c"*** ZVM Error open DIR %s\0A\00"
@.str.12 = [6 x i8] c"%s/%s\00"
@O_RDONLY = global i32 0
@.str.13 = [13 x i8] c"%10zu%s%10zu\00"
define void @newbufferedpack_(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i32*
%8 = alloca %struct.dirent*
%9 = alloca i8*
%10 = alloca [10 x i8*]
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i8*
%15 = alloca i64
%16 = alloca i64
%17 = alloca i32
%18 = alloca i64
%19 = alloca i64
%20 = alloca i64
%21 = alloca i64
%22 = alloca i32
%23 = alloca i8*
%24 = alloca i64
store i8* %0, i8** %3
store i8* %1, i8** %4
%25 = load i8*, i8** %3
%26 = load i32, i32* @O_WRONLY
%27 = load i32, i32* @O_CREAT
%28 = or i32 %26, %27
%29 = load i32, i32* @O_TRUNC
%30 = or i32 %28, %29
%31 = load i32, i32* @S_IROTH
%32 = load i32, i32* @S_IWOTH
%33 = or i32 %31, %32
%34 = load i32, i32* @S_IRUSR
%35 = or i32 %33, %34
%36 = load i32, i32* @S_IWUSR
%37 = or i32 %35, %36
%38 = call i32 (i8*, i32, ...) @open(i8* %25, i32 %30, i32 %37)
store i32 %38, i32* %5
%39 = load i32, i32* %5
%40 = icmp sle i32 %39, 0
br i1 %40, label %41, label %44
41: ; preds = %2
%42 = load i8*, i8** %3
%43 = call i32 @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0), i8* %42)
br label %133
44: ; preds = %2
%45 = load i8*, i8** %4
store i8* %45, i8** %6
%46 = load i8*, i8** %6
%47 = call i32* @opendir(i8* %46)
store i32* %47, i32** %7
%48 = bitcast [10 x i8*]* %10 to i8*
store i32 10, i32* %11
store i32 0, i32* %12
%49 = load i32*, i32** %7
%50 = icmp ne i32* %49, null
br i1 %50, label %54, label %51
51: ; preds = %44
%52 = load i8*, i8** %6
%53 = call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.11, i64 0, i64 0), i8* %52)
br label %54
54: ; preds = %51, %44
store i32 65536, i32* %13
store i8* null, i8** %14
%55 = load i32, i32* %13
%56 = call i64 @malloc(i32 %55)
%57 = inttoptr i64 %56 to i8*
store i8* %57, i8** %14
store i64 0, i64* %15
store i64 0, i64* %16
store i32 0, i32* %17
store i32 0, i32* %12
br label %58
58: ; preds = %125, %54
%59 = load i32, i32* %12
%60 = load i32, i32* %11
%61 = icmp slt i32 %59, %60
br i1 %61, label %62, label %128
62: ; preds = %58
store i64 0, i64* %19
store i64 0, i64* %21
%63 = load i32, i32* %12
%64 = sext i32 %63 to i64
%65 = getelementptr inbounds [10 x i8*], [10 x i8*]* %10, i64 0, i64 %64
%66 = load i8*, i8** %65
%67 = call i64 @strlen(i8* %66)
%68 = load i8*, i8** %6
%69 = call i64 @strlen(i8* %68)
%70 = add i64 %67, %69
%71 = add i64 %70, 2
%72 = trunc i64 %71 to i32
%73 = call i64 @malloc(i32 %72)
%74 = inttoptr i64 %73 to i8*
store i8* %74, i8** %9
%75 = load i8*, i8** %9
%76 = load i8*, i8** %6
%77 = load i32, i32* %12
%78 = sext i32 %77 to i64
%79 = getelementptr inbounds [10 x i8*], [10 x i8*]* %10, i64 0, i64 %78
%80 = load i8*, i8** %79
%81 = call i32 (i8*, i8*, ...) @sprintf(i8* %75, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.12, i64 0, i64 0), i8* %76, i8* %80)
%82 = load i8*, i8** %9
%83 = load i32, i32* @O_RDONLY
%84 = call i32 (i8*, i32, ...) @open(i8* %82, i32 %83)
store i32 %84, i32* %22
%85 = load i32, i32* %22
%86 = call i64 @getfilesize_fd(i32 %85, i32* null, i32 0)
store i64 %86, i64* %18
%87 = load i8*, i8** %9
%88 = call i64 @strlen(i8* %87)
%89 = add i64 %88, 12
%90 = call i8* @llvm.stacksave()
store i8* %90, i8** %23
%91 = alloca i8, i64 %89
store i64 %89, i64* %24
%92 = load i8*, i8** %9
%93 = call i64 @strlen(i8* %92)
%94 = load i8*, i8** %9
%95 = load i64, i64* %18
%96 = call i32 (i8*, i8*, ...) @sprintf(i8* %91, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.13, i64 0, i64 0), i64 %93, i8* %94, i64 %95)
%97 = load i32, i32* %5
%98 = call i64 @strlen(i8* %91)
%99 = call i64 @write(i32 %97, i8* %91, i64 %98)
store i64 %99, i64* %20
%100 = load i64, i64* %18
%101 = icmp ugt i64 %100, 0
br i1 %101, label %102, label %118
102: ; preds = %62
br label %103
103: ; preds = %109, %102
%104 = load i32, i32* %22
%105 = load i8*, i8** %14
%106 = load i32, i32* %13
%107 = call i64 @read(i32 %104, i8* %105, i32 %106)
store i64 %107, i64* %19
%108 = icmp ugt i64 %107, 0
br i1 %108, label %109, label %117
109: ; preds = %103
%110 = load i64, i64* %19
%111 = load i64, i64* %21
%112 = add i64 %111, %110
store i64 %112, i64* %21
%113 = load i32, i32* %5
%114 = load i8*, i8** %14
%115 = load i64, i64* %19
%116 = call i64 @write(i32 %113, i8* %114, i64 %115)
store i64 %116, i64* %20
br label %103
117: ; preds = %103
br label %119
118: ; preds = %62
store i64 0, i64* %21
br label %119
119: ; preds = %118, %117
%120 = load i32, i32* %22
%121 = call i32 @close(i32 %120)
%122 = load i32, i32* %17
%123 = add nsw i32 %122, 1
store i32 %123, i32* %17
%124 = load i8*, i8** %23
br label %125
125: ; preds = %119
%126 = load i32, i32* %12
%127 = add nsw i32 %126, 1
store i32 %127, i32* %12
br label %58
128: ; preds = %58
%129 = load i8*, i8** %14
%130 = call i32 @free(i8* %129)
%131 = load i32, i32* %5
%132 = call i32 @close(i32 %131)
br label %133
133: ; preds = %128, %41
ret void
}

LLVM IR (-O2):
%struct.dirent = type { i32 }
@O_WRONLY = global i32 0
@O_CREAT = global i32 0
@O_TRUNC = global i32 0
@S_IROTH = global i32 0
@S_IWOTH = global i32 0
@S_IRUSR = global i32 0
@S_IWUSR = global i32 0
@.str = [39 x i8] c"*** ZVM Error open packfile (write)%s\0A\00"
@.str.1 = [14 x i8] c"mainindex.sps\00"
@.str.2 = [14 x i8] c"mainindex.spm\00"
@.str.3 = [14 x i8] c"mainindex.spa\00"
@.str.4 = [14 x i8] c"mainindex.spk\00"
@.str.5 = [14 x i8] c"mainindex.spd\00"
@.str.6 = [14 x i8] c"mainindex.spp\00"
@.str.7 = [14 x i8] c"mainindex.spe\00"
@.str.8 = [14 x i8] c"mainindex.spi\00"
@.str.9 = [14 x i8] c"mainindex.sph\00"
@.str.10 = [13 x i8] c"zsphinx.conf\00"
@__const.newbufferedpack_.save_file_list = [10 x i8*] [i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i32 0, i32 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i32 0, i32 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i32 0, i32 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i32 0, i32 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.6, i32 0, i32 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.7, i32 0, i32 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.8, i32 0, i32 0), i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.9, i32 0, i32 0), i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.10, i32 0, i32 0)]
@.str.11 = [27 x i8] c"*** ZVM Error open DIR %s\0A\00"
@.str.12 = [6 x i8] c"%s/%s\00"
@O_RDONLY = global i32 0
@.str.13 = [13 x i8] c"%10zu%s%10zu\00"
define void @newbufferedpack_(i8* %0, i8* %1) {
%3 = load i32, i32* @O_WRONLY
%4 = load i32, i32* @O_CREAT
%5 = or i32 %4, %3
%6 = load i32, i32* @O_TRUNC
%7 = or i32 %5, %6
%8 = load i32, i32* @S_IROTH
%9 = load i32, i32* @S_IWOTH
%10 = or i32 %9, %8
%11 = load i32, i32* @S_IRUSR
%12 = or i32 %10, %11
%13 = load i32, i32* @S_IWUSR
%14 = or i32 %12, %13
%15 = tail call i32 (i8*, i32, ...) @open(i8* %0, i32 %7, i32 %14)
%16 = icmp slt i32 %15, 1
br i1 %16, label %17, label %19
17: ; preds = %2
%18 = tail call i32 @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0), i8* %0)
br label %66
19: ; preds = %2
%20 = tail call i32* @opendir(i8* %1)
%21 = icmp eq i32* %20, null
br i1 %21, label %22, label %24
22: ; preds = %19
%23 = tail call i32 @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.11, i64 0, i64 0), i8* %1)
br label %24
24: ; preds = %22, %19
%25 = tail call i64 @malloc(i32 65536)
%26 = inttoptr i64 %25 to i8*
br label %27
27: ; preds = %24, %59
%28 = phi i64 [ 0, %24 ], [ %61, %59 ]
%29 = getelementptr inbounds [10 x i8*], [10 x i8*]* @__const.newbufferedpack_.save_file_list, i64 0, i64 %28
%30 = load i8*, i8** %29
%31 = tail call i64 @strlen(i8* dereferenceable(1) %30)
%32 = tail call i64 @strlen(i8* dereferenceable(1) %1)
%33 = add i64 %32, %31
%34 = trunc i64 %33 to i32
%35 = add i32 %34, 2
%36 = tail call i64 @malloc(i32 %35)
%37 = inttoptr i64 %36 to i8*
%38 = tail call i32 (i8*, i8*, ...) @sprintf(i8* dereferenceable(1) %37, i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.12, i64 0, i64 0), i8* %1, i8* %30)
%39 = load i32, i32* @O_RDONLY
%40 = tail call i32 (i8*, i32, ...) @open(i8* %37, i32 %39)
%41 = tail call i64 @getfilesize_fd(i32 %40, i32* null, i32 0)
%42 = tail call i64 @strlen(i8* dereferenceable(1) %37)
%43 = add i64 %42, 12
%44 = tail call i8* @llvm.stacksave()
%45 = alloca i8, i64 %43
%46 = tail call i64 @strlen(i8* dereferenceable(1) %37)
%47 = call i32 (i8*, i8*, ...) @sprintf(i8* %45, i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.13, i64 0, i64 0), i64 %46, i8* %37, i64 %41)
%48 = call i64 @strlen(i8* %45)
%49 = call i64 @write(i32 %15, i8* %45, i64 %48)
%50 = icmp eq i64 %41, 0
br i1 %50, label %59, label %51
51: ; preds = %27
%52 = tail call i64 @read(i32 %40, i8* %26, i32 65536)
%53 = icmp eq i64 %52, 0
br i1 %53, label %59, label %54
54: ; preds = %51, %54
%55 = phi i64 [ %57, %54 ], [ %52, %51 ]
%56 = tail call i64 @write(i32 %15, i8* %26, i64 %55)
%57 = tail call i64 @read(i32 %40, i8* %26, i32 65536)
%58 = icmp eq i64 %57, 0
br i1 %58, label %59, label %54
59: ; preds = %54, %51, %27
%60 = tail call i32 @close(i32 %40)
tail call void @llvm.stackrestore(i8* %44)
%61 = add nuw nsw i64 %28, 1
%62 = icmp eq i64 %61, 10
br i1 %62, label %63, label %27
63: ; preds = %59
%64 = tail call i32 @free(i8* %26)
%65 = tail call i32 @close(i32 %15)
br label %66
66: ; preds = %63, %17
ret void
}