#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 int /*<<< orphan*/ FILE;

/* Variables and functions */
int EOF;
int PATH_MAX;
int /*<<< orphan*/ SEEK_CUR;
int /*<<< orphan*/ assert(int);
int /*<<< orphan*/ exit(int);
scalar_t__ fclose(int /*<<< orphan*/ *);
int fgetc(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char const *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ fseek(int /*<<< orphan*/ *, int, int /*<<< orphan*/);
int fwrite(char *, int, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ isLikelyFilenameChar(int);
int replaceOneString(char *, int, char const *, int const, int const);
int /*<<< orphan*/ stderr;
int strlen(char const *);
void ReplaceStringsInOneFile(const char *file_name, const char *oldroot,
                             const char *newroot, const int old_oldroot_len) {
  FILE *file = NULL;
  char buffer[PATH_MAX * 2];
  const int newroot_len = strlen(newroot);
  const int oldroot_len = strlen(oldroot);
  int nmatched;
  int c;
  assert(old_oldroot_len < PATH_MAX);
  assert(NULL != file_name);
  assert(NULL != oldroot);
  assert(NULL != newroot);
  file = fopen(file_name, "rb+");
  if (NULL == file)
    do {
      fprintf(stderr, "Could not open file %s for update\n", file_name);
      fprintf(stderr, "Failed at line %d\n", 260);
      exit(1);
    } while (0);
  nmatched = 0;
  while (EOF != (c = fgetc(file))) {
    if (nmatched < oldroot_len) {
      if (c == oldroot[nmatched]) {
        buffer[nmatched++] = c;
      } else {
        fseek(file, -nmatched, SEEK_CUR);
        nmatched = 0;
      }
    } else {
      int nwrite;
      buffer[nmatched++] = c;
      if (!isLikelyFilenameChar(c)) {
        nwrite = replaceOneString(buffer, nmatched, newroot, newroot_len,
                                  oldroot_len);
        fseek(file, -nmatched, SEEK_CUR);
        if (nwrite != fwrite(buffer, 1, nwrite, file))
          do {
            fprintf(stderr, "Error writing to %s ?!\n", file_name);
            fprintf(stderr, "Failed at line %d\n", 294);
            exit(1);
          } while (0);
        nmatched = 0;
      }
    }
  }
  if (fclose(file))
    do {
      fprintf(stderr, "Error flushing to %s ?!\n", file_name);
      fprintf(stderr, "Failed at line %d\n", 303);
      exit(1);
    } while (0);
}


x86 assembly (clang, -O0):
<ReplaceStringsInOneFile>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
movq   $0x0,-0x28(%rbp)
mov    0x2e1a(%rip),%rax
mov    (%rax),%eax
add    %eax,%eax
mov    %rsp,%rcx
mov    %rcx,-0x30(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x58(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x38(%rbp)
mov    -0x18(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,-0x3c(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,-0x40(%rbp)
mov    -0x1c(%rbp),%eax
mov    0x2dd1(%rip),%rcx
cmp    (%rcx),%eax
setl   %al
and    $0x1,%al
movzbl %al,%edi
call   1070 <assert@plt>
xor    %eax,%eax
cmp    -0x8(%rbp),%rax
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1070 <assert@plt>
xor    %eax,%eax
cmp    -0x10(%rbp),%rax
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1070 <assert@plt>
xor    %eax,%eax
cmp    -0x18(%rbp),%rax
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1070 <assert@plt>
mov    -0x8(%rbp),%rdi
lea    0xd8e(%rip),%rsi
call   10b0 <fopen@plt>
mov    %rax,-0x28(%rbp)
xor    %eax,%eax
cmp    -0x28(%rbp),%rax
jne    12cd <ReplaceStringsInOneFile+0x11d>
jmp    128c <ReplaceStringsInOneFile+0xdc>
mov    0x2d35(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
lea    0xd64(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    0x2d1a(%rip),%rax
mov    (%rax),%edi
lea    0xd70(%rip),%rsi
mov    $0x104,%edx
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>
movl   $0x0,-0x44(%rbp)
mov    0x2cfd(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x5c(%rbp)
mov    -0x28(%rbp),%rdi
call   1060 <fgetc@plt>
mov    %eax,%ecx
mov    -0x5c(%rbp),%eax
mov    %ecx,-0x48(%rbp)
cmp    %ecx,%eax
je     1439 <ReplaceStringsInOneFile+0x289>
mov    -0x44(%rbp),%eax
cmp    -0x40(%rbp),%eax
jge    135e <ReplaceStringsInOneFile+0x1ae>
mov    -0x48(%rbp),%eax
mov    -0x10(%rbp),%rcx
movslq -0x44(%rbp),%rdx
movsbl (%rcx,%rdx,1),%ecx
cmp    %ecx,%eax
jne    133b <ReplaceStringsInOneFile+0x18b>
mov    -0x58(%rbp),%rax
mov    -0x48(%rbp),%ecx
mov    %cl,%dl
mov    -0x44(%rbp),%ecx
mov    %ecx,%esi
add    $0x1,%esi
mov    %esi,-0x44(%rbp)
movslq %ecx,%rcx
mov    %dl,(%rax,%rcx,1)
jmp    1359 <ReplaceStringsInOneFile+0x1a9>
mov    -0x28(%rbp),%rdi
xor    %esi,%esi
sub    -0x44(%rbp),%esi
mov    0x2c95(%rip),%rax
mov    (%rax),%edx
call   10a0 <fseek@plt>
movl   $0x0,-0x44(%rbp)
jmp    1434 <ReplaceStringsInOneFile+0x284>
mov    -0x58(%rbp),%rax
mov    -0x48(%rbp),%ecx
mov    %cl,%dl
mov    -0x44(%rbp),%ecx
mov    %ecx,%esi
add    $0x1,%esi
mov    %esi,-0x44(%rbp)
movslq %ecx,%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x48(%rbp),%edi
call   1030 <isLikelyFilenameChar@plt>
cmp    $0x0,%eax
jne    142f <ReplaceStringsInOneFile+0x27f>
mov    -0x58(%rbp),%rdi
mov    -0x44(%rbp),%esi
mov    -0x18(%rbp),%rdx
mov    -0x3c(%rbp),%ecx
mov    -0x40(%rbp),%r8d
call   1090 <replaceOneString@plt>
mov    %eax,-0x4c(%rbp)
mov    -0x28(%rbp),%rdi
xor    %esi,%esi
sub    -0x44(%rbp),%esi
mov    0x2c2d(%rip),%rax
mov    (%rax),%edx
call   10a0 <fseek@plt>
mov    -0x58(%rbp),%rdi
mov    -0x4c(%rbp),%eax
mov    %eax,-0x60(%rbp)
mov    -0x4c(%rbp),%edx
mov    -0x28(%rbp),%rcx
mov    $0x1,%esi
call   10d0 <fwrite@plt>
mov    %eax,%ecx
mov    -0x60(%rbp),%eax
cmp    %ecx,%eax
je     1428 <ReplaceStringsInOneFile+0x278>
jmp    13e7 <ReplaceStringsInOneFile+0x237>
mov    0x2bda(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
lea    0xc3f(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    0x2bbf(%rip),%rax
mov    (%rax),%edi
lea    0xc15(%rip),%rsi
mov    $0x126,%edx
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>
movl   $0x0,-0x44(%rbp)
jmp    1434 <ReplaceStringsInOneFile+0x284>
jmp    12d4 <ReplaceStringsInOneFile+0x124>
mov    -0x28(%rbp),%rdi
call   1040 <fclose@plt>
cmp    $0x0,%rax
je     1492 <ReplaceStringsInOneFile+0x2e2>
jmp    1451 <ReplaceStringsInOneFile+0x2a1>
mov    0x2b70(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
lea    0xbed(%rip),%rsi
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    0x2b55(%rip),%rax
mov    (%rax),%edi
lea    0xbab(%rip),%rsi
mov    $0x12f,%edx
mov    $0x0,%al
call   1080 <fprintf@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>
mov    -0x30(%rbp),%rax
mov    %rax,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ReplaceStringsInOneFile>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    %ecx,%r15d
mov    %rdx,%r13
mov    %rsi,%rbx
mov    %rdi,%r12
mov    0x2e1c(%rip),%r14
mov    (%r14),%eax
add    %eax,%eax
mov    %rsp,%rcx
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rcx
mov    %rcx,-0x40(%rbp)
mov    %rcx,%rsp
mov    %rdx,%rdi
call   1050 <strlen@plt>
mov    %eax,-0x44(%rbp)
mov    %rbx,%rdi
call   1050 <strlen@plt>
mov    %eax,-0x2c(%rbp)
xor    %edi,%edi
cmp    %r15d,(%r14)
setg   %dil
call   1070 <assert@plt>
xor    %edi,%edi
test   %r12,%r12
setne  %dil
call   1070 <assert@plt>
xor    %edi,%edi
mov    %rbx,-0x58(%rbp)
test   %rbx,%rbx
setne  %dil
call   1070 <assert@plt>
xor    %edi,%edi
mov    %r13,-0x50(%rbp)
test   %r13,%r13
setne  %dil
call   1070 <assert@plt>
lea    0xdb5(%rip),%rsi
mov    %r12,-0x38(%rbp)
mov    %r12,%rdi
call   10b0 <fopen@plt>
test   %rax,%rax
je     13a2 <ReplaceStringsInOneFile+0x1f2>
mov    %rax,%r13
mov    0x2d6e(%rip),%rax
mov    (%rax),%r14d
mov    %r13,%rdi
call   1060 <fgetc@plt>
cmp    %eax,%r14d
mov    -0x40(%rbp),%r14
jne    129e <ReplaceStringsInOneFile+0xee>
mov    %r13,%rdi
call   1040 <fclose@plt>
test   %rax,%rax
jne    13cd <ReplaceStringsInOneFile+0x21d>
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
xor    %r15d,%r15d
jmp    12e2 <ReplaceStringsInOneFile+0x132>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
neg    %r15d
mov    0x2d26(%rip),%rax
mov    (%rax),%edx
mov    %r13,%rdi
mov    %r15d,%esi
call   10a0 <fseek@plt>
xor    %r12d,%r12d
mov    0x2d07(%rip),%rax
mov    (%rax),%ebx
mov    %r13,%rdi
call   1060 <fgetc@plt>
mov    %r12d,%r15d
cmp    %eax,%ebx
je     127e <ReplaceStringsInOneFile+0xce>
movslq %r15d,%rcx
cmp    -0x2c(%rbp),%r15d
jge    1310 <ReplaceStringsInOneFile+0x160>
mov    -0x58(%rbp),%rdx
movsbl (%rdx,%rcx,1),%edx
cmp    %edx,%eax
jne    12b0 <ReplaceStringsInOneFile+0x100>
add    $0x1,%r15d
mov    %al,(%r14,%rcx,1)
mov    %r15d,%r12d
jmp    12ca <ReplaceStringsInOneFile+0x11a>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
lea    0x1(%rcx),%r12d
mov    %al,(%r14,%rcx,1)
mov    %eax,%edi
call   1030 <isLikelyFilenameChar@plt>
test   %eax,%eax
jne    12ca <ReplaceStringsInOneFile+0x11a>
mov    %r14,%rdi
mov    %r12d,%esi
mov    -0x50(%rbp),%rdx
mov    -0x44(%rbp),%ecx
mov    -0x2c(%rbp),%r8d
call   1090 <replaceOneString@plt>
mov    %eax,%r14d
not    %r15d
mov    0x2c9a(%rip),%rax
mov    (%rax),%edx
mov    %r13,%rdi
mov    %r15d,%esi
call   10a0 <fseek@plt>
mov    -0x40(%rbp),%rdi
mov    $0x1,%esi
mov    %r14d,%edx
mov    %r13,%rcx
call   10d0 <fwrite@plt>
xor    %r12d,%r12d
cmp    %eax,%r14d
mov    -0x40(%rbp),%r14
je     12ca <ReplaceStringsInOneFile+0x11a>
mov    0x2c4a(%rip),%rbx
mov    (%rbx),%edi
lea    0xcb3(%rip),%rsi
mov    -0x38(%rbp),%rdx
xor    %eax,%eax
call   1080 <fprintf@plt>
mov    (%rbx),%edi
lea    0xc8c(%rip),%rsi
mov    $0x126,%edx
jmp    13f6 <ReplaceStringsInOneFile+0x246>
mov    0x2c1f(%rip),%rbx
mov    (%rbx),%edi
lea    0xc52(%rip),%rsi
mov    -0x38(%rbp),%rdx
xor    %eax,%eax
call   1080 <fprintf@plt>
mov    (%rbx),%edi
lea    0xc61(%rip),%rsi
mov    $0x104,%edx
jmp    13f6 <ReplaceStringsInOneFile+0x246>
mov    0x2bf4(%rip),%rbx
mov    (%rbx),%edi
lea    0xc75(%rip),%rsi
mov    -0x38(%rbp),%rdx
xor    %eax,%eax
call   1080 <fprintf@plt>
mov    (%rbx),%edi
lea    0xc36(%rip),%rsi
mov    $0x12f,%edx
xor    %eax,%eax
call   1080 <fprintf@plt>
mov    $0x1,%edi
call   10c0 <exit@plt>

LLVM IR (-O0):
@PATH_MAX = global i32 0
@.str = [4 x i8] c"rb+\00"
@stderr = global i32 0
@.str.1 = [35 x i8] c"Could not open file %s for update\0A\00"
@.str.2 = [19 x i8] c"Failed at line %d\0A\00"
@EOF = global i32 0
@SEEK_CUR = global i32 0
@.str.3 = [24 x i8] c"Error writing to %s ?!\0A\00"
@.str.4 = [25 x i8] c"Error flushing to %s ?!\0A\00"
define void @ReplaceStringsInOneFile(i8* %0, i8* %1, i8* %2, i32 %3) {
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i32*
%10 = alloca i8*
%11 = alloca i64
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
store i8* %0, i8** %5
store i8* %1, i8** %6
store i8* %2, i8** %7
store i32 %3, i32* %8
store i32* null, i32** %9
%17 = load i32, i32* @PATH_MAX
%18 = mul nsw i32 %17, 2
%19 = zext i32 %18 to i64
%20 = call i8* @llvm.stacksave()
store i8* %20, i8** %10
%21 = alloca i8, i64 %19
store i64 %19, i64* %11
%22 = load i8*, i8** %7
%23 = call i32 @strlen(i8* %22)
store i32 %23, i32* %12
%24 = load i8*, i8** %6
%25 = call i32 @strlen(i8* %24)
store i32 %25, i32* %13
%26 = load i32, i32* %8
%27 = load i32, i32* @PATH_MAX
%28 = icmp slt i32 %26, %27
%29 = zext i1 %28 to i32
%30 = call i32 @assert(i32 %29)
%31 = load i8*, i8** %5
%32 = icmp ne i8* null, %31
%33 = zext i1 %32 to i32
%34 = call i32 @assert(i32 %33)
%35 = load i8*, i8** %6
%36 = icmp ne i8* null, %35
%37 = zext i1 %36 to i32
%38 = call i32 @assert(i32 %37)
%39 = load i8*, i8** %7
%40 = icmp ne i8* null, %39
%41 = zext i1 %40 to i32
%42 = call i32 @assert(i32 %41)
%43 = load i8*, i8** %5
%44 = call i32* @fopen(i8* %43, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
store i32* %44, i32** %9
%45 = load i32*, i32** %9
%46 = icmp eq i32* null, %45
br i1 %46, label %47, label %57
47: ; preds = %4
br label %48
48: ; preds = %47
%49 = load i32, i32* @stderr
%50 = load i8*, i8** %5
%51 = call i32 (i32, i8*, ...) @fprintf(i32 %49, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.1, i64 0, i64 0), i8* %50)
%52 = load i32, i32* @stderr
%53 = call i32 (i32, i8*, ...) @fprintf(i32 %52, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i32 260)
%54 = call i32 @exit(i32 1)
unreachable
55: ; No predecessors!
br label %56
56: ; preds = %55
br label %57
57: ; preds = %56, %4
store i32 0, i32* %14
br label %58
58: ; preds = %128, %57
%59 = load i32, i32* @EOF
%60 = load i32*, i32** %9
%61 = call i32 @fgetc(i32* %60)
store i32 %61, i32* %15
%62 = icmp ne i32 %59, %61
br i1 %62, label %63, label %129
63: ; preds = %58
%64 = load i32, i32* %14
%65 = load i32, i32* %13
%66 = icmp slt i32 %64, %65
br i1 %66, label %67, label %90
67: ; preds = %63
%68 = load i32, i32* %15
%69 = load i8*, i8** %6
%70 = load i32, i32* %14
%71 = sext i32 %70 to i64
%72 = getelementptr inbounds i8, i8* %69, i64 %71
%73 = load i8, i8* %72
%74 = sext i8 %73 to i32
%75 = icmp eq i32 %68, %74
br i1 %75, label %76, label %83
76: ; preds = %67
%77 = load i32, i32* %15
%78 = trunc i32 %77 to i8
%79 = load i32, i32* %14
%80 = add nsw i32 %79, 1
store i32 %80, i32* %14
%81 = sext i32 %79 to i64
%82 = getelementptr inbounds i8, i8* %21, i64 %81
store i8 %78, i8* %82
br label %89
83: ; preds = %67
%84 = load i32*, i32** %9
%85 = load i32, i32* %14
%86 = sub nsw i32 0, %85
%87 = load i32, i32* @SEEK_CUR
%88 = call i32 @fseek(i32* %84, i32 %86, i32 %87)
store i32 0, i32* %14
br label %89
89: ; preds = %83, %76
br label %128
90: ; preds = %63
%91 = load i32, i32* %15
%92 = trunc i32 %91 to i8
%93 = load i32, i32* %14
%94 = add nsw i32 %93, 1
store i32 %94, i32* %14
%95 = sext i32 %93 to i64
%96 = getelementptr inbounds i8, i8* %21, i64 %95
store i8 %92, i8* %96
%97 = load i32, i32* %15
%98 = call i32 @isLikelyFilenameChar(i32 %97)
%99 = icmp ne i32 %98, 0
br i1 %99, label %127, label %100
100: ; preds = %90
%101 = load i32, i32* %14
%102 = load i8*, i8** %7
%103 = load i32, i32* %12
%104 = load i32, i32* %13
%105 = call i32 @replaceOneString(i8* %21, i32 %101, i8* %102, i32 %103, i32 %104)
store i32 %105, i32* %16
%106 = load i32*, i32** %9
%107 = load i32, i32* %14
%108 = sub nsw i32 0, %107
%109 = load i32, i32* @SEEK_CUR
%110 = call i32 @fseek(i32* %106, i32 %108, i32 %109)
%111 = load i32, i32* %16
%112 = load i32, i32* %16
%113 = load i32*, i32** %9
%114 = call i32 @fwrite(i8* %21, i32 1, i32 %112, i32* %113)
%115 = icmp ne i32 %111, %114
br i1 %115, label %116, label %126
116: ; preds = %100
br label %117
117: ; preds = %116
%118 = load i32, i32* @stderr
%119 = load i8*, i8** %5
%120 = call i32 (i32, i8*, ...) @fprintf(i32 %118, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0), i8* %119)
%121 = load i32, i32* @stderr
%122 = call i32 (i32, i8*, ...) @fprintf(i32 %121, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i32 294)
%123 = call i32 @exit(i32 1)
unreachable
124: ; No predecessors!
br label %125
125: ; preds = %124
br label %126
126: ; preds = %125, %100
store i32 0, i32* %14
br label %127
127: ; preds = %126, %90
br label %128
128: ; preds = %127, %89
br label %58
129: ; preds = %58
%130 = load i32*, i32** %9
%131 = call i64 @fclose(i32* %130)
%132 = icmp ne i64 %131, 0
br i1 %132, label %133, label %143
133: ; preds = %129
br label %134
134: ; preds = %133
%135 = load i32, i32* @stderr
%136 = load i8*, i8** %5
%137 = call i32 (i32, i8*, ...) @fprintf(i32 %135, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.4, i64 0, i64 0), i8* %136)
%138 = load i32, i32* @stderr
%139 = call i32 (i32, i8*, ...) @fprintf(i32 %138, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i32 303)
%140 = call i32 @exit(i32 1)
unreachable
141: ; No predecessors!
br label %142
142: ; preds = %141
br label %143
143: ; preds = %142, %129
%144 = load i8*, i8** %10
ret void
}

LLVM IR (-O2):
@PATH_MAX = global i32 0
@.str = [4 x i8] c"rb+\00"
@stderr = global i32 0
@.str.1 = [35 x i8] c"Could not open file %s for update\0A\00"
@.str.2 = [19 x i8] c"Failed at line %d\0A\00"
@EOF = global i32 0
@SEEK_CUR = global i32 0
@.str.3 = [24 x i8] c"Error writing to %s ?!\0A\00"
@.str.4 = [25 x i8] c"Error flushing to %s ?!\0A\00"
define void @ReplaceStringsInOneFile(i8* %0, i8* %1, i8* %2, i32 %3) {
%5 = load i32, i32* @PATH_MAX
%6 = shl nsw i32 %5, 1
%7 = zext i32 %6 to i64
%8 = alloca i8, i64 %7
%9 = tail call i32 @strlen(i8* %2)
%10 = tail call i32 @strlen(i8* %1)
%11 = load i32, i32* @PATH_MAX
%12 = icmp sgt i32 %11, %3
%13 = zext i1 %12 to i32
%14 = tail call i32 @assert(i32 %13)
%15 = icmp ne i8* %0, null
%16 = zext i1 %15 to i32
%17 = tail call i32 @assert(i32 %16)
%18 = icmp ne i8* %1, null
%19 = zext i1 %18 to i32
%20 = tail call i32 @assert(i32 %19)
%21 = icmp ne i8* %2, null
%22 = zext i1 %21 to i32
%23 = tail call i32 @assert(i32 %22)
%24 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%25 = icmp eq i32* %24, null
br i1 %25, label %30, label %26
26: ; preds = %4
%27 = load i32, i32* @EOF
%28 = call i32 @fgetc(i32* %24)
%29 = icmp eq i32 %27, %28
br i1 %29, label %79, label %36
30: ; preds = %4
%31 = load i32, i32* @stderr
%32 = tail call i32 (i32, i8*, ...) @fprintf(i32 %31, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.1, i64 0, i64 0), i8* %0)
%33 = load i32, i32* @stderr
%34 = tail call i32 (i32, i8*, ...) @fprintf(i32 %33, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i32 260)
%35 = tail call i32 @exit(i32 1)
unreachable
36: ; preds = %26, %74
%37 = phi i32 [ %77, %74 ], [ %28, %26 ]
%38 = phi i32 [ %75, %74 ], [ 0, %26 ]
%39 = icmp slt i32 %38, %10
br i1 %39, label %40, label %54
40: ; preds = %36
%41 = sext i32 %38 to i64
%42 = getelementptr inbounds i8, i8* %1, i64 %41
%43 = load i8, i8* %42
%44 = sext i8 %43 to i32
%45 = icmp eq i32 %37, %44
br i1 %45, label %46, label %50
46: ; preds = %40
%47 = trunc i32 %37 to i8
%48 = add nsw i32 %38, 1
%49 = getelementptr inbounds i8, i8* %8, i64 %41
store i8 %47, i8* %49
br label %74
50: ; preds = %40
%51 = sub nsw i32 0, %38
%52 = load i32, i32* @SEEK_CUR
%53 = call i32 @fseek(i32* %24, i32 %51, i32 %52)
br label %74
54: ; preds = %36
%55 = trunc i32 %37 to i8
%56 = add nsw i32 %38, 1
%57 = sext i32 %38 to i64
%58 = getelementptr inbounds i8, i8* %8, i64 %57
store i8 %55, i8* %58
%59 = call i32 @isLikelyFilenameChar(i32 %37)
%60 = icmp eq i32 %59, 0
br i1 %60, label %61, label %74
61: ; preds = %54
%62 = call i32 @replaceOneString(i8* %8, i32 %56, i8* %2, i32 %9, i32 %10)
%63 = xor i32 %38, -1
%64 = load i32, i32* @SEEK_CUR
%65 = call i32 @fseek(i32* %24, i32 %63, i32 %64)
%66 = call i32 @fwrite(i8* %8, i32 1, i32 %62, i32* %24)
%67 = icmp eq i32 %62, %66
br i1 %67, label %74, label %68
68: ; preds = %61
%69 = load i32, i32* @stderr
%70 = call i32 (i32, i8*, ...) @fprintf(i32 %69, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0), i8* %0)
%71 = load i32, i32* @stderr
%72 = call i32 (i32, i8*, ...) @fprintf(i32 %71, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i32 294)
%73 = call i32 @exit(i32 1)
unreachable
74: ; preds = %54, %61, %46, %50
%75 = phi i32 [ %48, %46 ], [ 0, %50 ], [ %56, %54 ], [ 0, %61 ]
%76 = load i32, i32* @EOF
%77 = call i32 @fgetc(i32* %24)
%78 = icmp eq i32 %76, %77
br i1 %78, label %79, label %36
79: ; preds = %74, %26
%80 = call i64 @fclose(i32* %24)
%81 = icmp eq i64 %80, 0
br i1 %81, label %88, label %82
82: ; preds = %79
%83 = load i32, i32* @stderr
%84 = call i32 (i32, i8*, ...) @fprintf(i32 %83, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.4, i64 0, i64 0), i8* %0)
%85 = load i32, i32* @stderr
%86 = call i32 (i32, i8*, ...) @fprintf(i32 %85, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i32 303)
%87 = call i32 @exit(i32 1)
unreachable
88: ; preds = %79
ret void
}