#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 */
char *calloc(int, int);
int /*<<< orphan*/ fill_array(char *, int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ free(char *);
size_t sanitize_crlf(char *, int);
int /*<<< orphan*/ stderr;
bool test_sanitizer() {
  fprintf(stderr, "CR at end of buffer: ");
  char *buffer = calloc(1, 16);
  fill_array(buffer, 16);
  buffer[16 - 1] = 0xd;
  size_t result_buffer_len;
  result_buffer_len = sanitize_crlf(buffer, 16);
  if (result_buffer_len == 16 || buffer[result_buffer_len - 1] != 0xa ||
      buffer[result_buffer_len - 2] != 0xd) {
    return false;
  }
  fprintf(stderr, "passed\n");
  fprintf(stderr, "CR at middle of buffer: ");
  free(buffer);
  buffer = calloc(1, 16);
  fill_array(buffer, 16);
  buffer[5] = 0xd;
  result_buffer_len = sanitize_crlf(buffer, 16);
  if (buffer[5] != 0xd || buffer[6] != 0xa || result_buffer_len != 16 + 1) {
    return false;
  }
  fprintf(stderr, "passed\n");
  fprintf(stderr, "LF at start of buffer: ");
  free(buffer);
  buffer = calloc(1, 16);
  fill_array(buffer, 16);
  buffer[0] = 0xa;
  result_buffer_len = sanitize_crlf(buffer, 16);
  if (result_buffer_len != 16 + 1 || buffer[0] != 0xd || buffer[1] != 0xa) {
    return false;
  }
  fprintf(stderr, "passed\n");
  fprintf(stderr, "CR at start of buffer, no LF: ");
  free(buffer);
  buffer = calloc(1, 16);
  fill_array(buffer, 16);
  buffer[0] = 0xd;
  result_buffer_len = sanitize_crlf(buffer, 16);
  if (buffer[0] != 0xd || buffer[1] != 0xa || result_buffer_len != 16 + 1) {
    return false;
  }
  fprintf(stderr, "passed\n");
  fprintf(stderr, "LF at middle of buffer, no CR before it: ");
  free(buffer);
  buffer = calloc(1, 16);
  fill_array(buffer, 16);
  buffer[5] = 0xa;
  result_buffer_len = sanitize_crlf(buffer, 16);
  if (buffer[5] != 0xd || buffer[6] != 0xa || result_buffer_len != 16 + 1) {
    return false;
  }
  fprintf(stderr, "passed\n");
  fprintf(stderr, "CRLF at middle of buffer: ");
  free(buffer);
  buffer = calloc(1, 16);
  fill_array(buffer, 16);
  buffer[6] = 0xd;
  buffer[7] = 0xa;
  result_buffer_len = sanitize_crlf(buffer, 16);
  if (buffer[6] != 0xd || buffer[7] != 0xa || buffer[8] != 0xd ||
      buffer[9] != 0xa) {
    return false;
  }
  fprintf(stderr, "passed\n");
  free(buffer);
  fprintf(stderr, "All CR/LF fixing Tests passed\n");
  return true;
}


x86 assembly (clang, -O0):
<test_sanitizer>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    0x2e81(%rip),%rax
mov    (%rax),%edi
lea    0xe98(%rip),%rsi
call   1050 <fprintf@plt>
mov    $0x1,%edi
mov    $0x10,%esi
call   1040 <calloc@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
mov    $0x10,%esi
call   1060 <fill_array@plt>
mov    -0x10(%rbp),%rax
movb   $0xd,0xf(%rax)
mov    -0x10(%rbp),%rdi
mov    $0x10,%esi
call   1070 <sanitize_crlf@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x10,-0x18(%rbp)
je     11e5 <test_sanitizer+0x95>
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%rcx
sub    $0x1,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0xa,%eax
jne    11e5 <test_sanitizer+0x95>
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%rcx
sub    $0x2,%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0xd,%eax
je     11f1 <test_sanitizer+0xa1>
movl   $0x0,-0x4(%rbp)
jmp    1589 <test_sanitizer+0x439>
mov    0x2de8(%rip),%rax
mov    (%rax),%edi
lea    0xec1(%rip),%rsi
call   1050 <fprintf@plt>
mov    0x2dd3(%rip),%rax
mov    (%rax),%edi
lea    0xe00(%rip),%rsi
call   1050 <fprintf@plt>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
mov    $0x1,%edi
mov    $0x10,%esi
call   1040 <calloc@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
mov    $0x10,%esi
call   1060 <fill_array@plt>
mov    -0x10(%rbp),%rax
movb   $0xd,0x5(%rax)
mov    -0x10(%rbp),%rdi
mov    $0x10,%esi
call   1070 <sanitize_crlf@plt>
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
movsbl 0x5(%rax),%eax
cmp    $0xd,%eax
jne    128c <test_sanitizer+0x13c>
mov    -0x10(%rbp),%rax
movsbl 0x6(%rax),%eax
cmp    $0xa,%eax
jne    128c <test_sanitizer+0x13c>
cmpq   $0x11,-0x18(%rbp)
je     1298 <test_sanitizer+0x148>
movl   $0x0,-0x4(%rbp)
jmp    1589 <test_sanitizer+0x439>
mov    0x2d41(%rip),%rax
mov    (%rax),%edi
lea    0xe1a(%rip),%rsi
call   1050 <fprintf@plt>
mov    0x2d2c(%rip),%rax
mov    (%rax),%edi
lea    0xd72(%rip),%rsi
call   1050 <fprintf@plt>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
mov    $0x1,%edi
mov    $0x10,%esi
call   1040 <calloc@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
mov    $0x10,%esi
call   1060 <fill_array@plt>
mov    -0x10(%rbp),%rax
movb   $0xa,(%rax)
mov    -0x10(%rbp),%rdi
mov    $0x10,%esi
call   1070 <sanitize_crlf@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x11,-0x18(%rbp)
jne    1331 <test_sanitizer+0x1e1>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0xd,%eax
jne    1331 <test_sanitizer+0x1e1>
mov    -0x10(%rbp),%rax
movsbl 0x1(%rax),%eax
cmp    $0xa,%eax
je     133d <test_sanitizer+0x1ed>
movl   $0x0,-0x4(%rbp)
jmp    1589 <test_sanitizer+0x439>
mov    0x2c9c(%rip),%rax
mov    (%rax),%edi
lea    0xd75(%rip),%rsi
call   1050 <fprintf@plt>
mov    0x2c87(%rip),%rax
mov    (%rax),%edi
lea    0xce5(%rip),%rsi
call   1050 <fprintf@plt>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
mov    $0x1,%edi
mov    $0x10,%esi
call   1040 <calloc@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
mov    $0x10,%esi
call   1060 <fill_array@plt>
mov    -0x10(%rbp),%rax
movb   $0xd,(%rax)
mov    -0x10(%rbp),%rdi
mov    $0x10,%esi
call   1070 <sanitize_crlf@plt>
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0xd,%eax
jne    13d6 <test_sanitizer+0x286>
mov    -0x10(%rbp),%rax
movsbl 0x1(%rax),%eax
cmp    $0xa,%eax
jne    13d6 <test_sanitizer+0x286>
cmpq   $0x11,-0x18(%rbp)
je     13e2 <test_sanitizer+0x292>
movl   $0x0,-0x4(%rbp)
jmp    1589 <test_sanitizer+0x439>
mov    0x2bf7(%rip),%rax
mov    (%rax),%edi
lea    0xcd0(%rip),%rsi
call   1050 <fprintf@plt>
mov    0x2be2(%rip),%rax
mov    (%rax),%edi
lea    0xc5f(%rip),%rsi
call   1050 <fprintf@plt>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
mov    $0x1,%edi
mov    $0x10,%esi
call   1040 <calloc@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
mov    $0x10,%esi
call   1060 <fill_array@plt>
mov    -0x10(%rbp),%rax
movb   $0xa,0x5(%rax)
mov    -0x10(%rbp),%rdi
mov    $0x10,%esi
call   1070 <sanitize_crlf@plt>
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
movsbl 0x5(%rax),%eax
cmp    $0xd,%eax
jne    147d <test_sanitizer+0x32d>
mov    -0x10(%rbp),%rax
movsbl 0x6(%rax),%eax
cmp    $0xa,%eax
jne    147d <test_sanitizer+0x32d>
cmpq   $0x11,-0x18(%rbp)
je     1489 <test_sanitizer+0x339>
movl   $0x0,-0x4(%rbp)
jmp    1589 <test_sanitizer+0x439>
mov    0x2b50(%rip),%rax
mov    (%rax),%edi
lea    0xc29(%rip),%rsi
call   1050 <fprintf@plt>
mov    0x2b3b(%rip),%rax
mov    (%rax),%edi
lea    0xbe2(%rip),%rsi
call   1050 <fprintf@plt>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
mov    $0x1,%edi
mov    $0x10,%esi
call   1040 <calloc@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
mov    $0x10,%esi
call   1060 <fill_array@plt>
mov    -0x10(%rbp),%rax
movb   $0xd,0x6(%rax)
mov    -0x10(%rbp),%rax
movb   $0xa,0x7(%rax)
mov    -0x10(%rbp),%rdi
mov    $0x10,%esi
call   1070 <sanitize_crlf@plt>
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
movsbl 0x6(%rax),%eax
cmp    $0xd,%eax
jne    1543 <test_sanitizer+0x3f3>
mov    -0x10(%rbp),%rax
movsbl 0x7(%rax),%eax
cmp    $0xa,%eax
jne    1543 <test_sanitizer+0x3f3>
mov    -0x10(%rbp),%rax
movsbl 0x8(%rax),%eax
cmp    $0xd,%eax
jne    1543 <test_sanitizer+0x3f3>
mov    -0x10(%rbp),%rax
movsbl 0x9(%rax),%eax
cmp    $0xa,%eax
je     154f <test_sanitizer+0x3ff>
movl   $0x0,-0x4(%rbp)
jmp    1589 <test_sanitizer+0x439>
mov    0x2a8a(%rip),%rax
mov    (%rax),%edi
lea    0xb63(%rip),%rsi
call   1050 <fprintf@plt>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
mov    0x2a6c(%rip),%rax
mov    (%rax),%edi
lea    0xb2e(%rip),%rsi
call   1050 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_sanitizer>:
push   %rbp
push   %r14
push   %rbx
mov    0x2e85(%rip),%r14
mov    (%r14),%edi
lea    0xe9b(%rip),%rsi
call   1050 <fprintf@plt>
mov    $0x1,%edi
mov    $0x10,%esi
call   1040 <calloc@plt>
mov    %rax,%rbx
mov    %rax,%rdi
mov    $0x10,%esi
call   1060 <fill_array@plt>
movb   $0xd,0xf(%rbx)
mov    %rbx,%rdi
mov    $0x10,%esi
call   1070 <sanitize_crlf@plt>
xor    %ebp,%ebp
cmp    $0x10,%rax
je     1423 <test_sanitizer+0x2d3>
cmpb   $0xa,-0x1(%rax,%rbx,1)
jne    1423 <test_sanitizer+0x2d3>
cmpb   $0xd,-0x2(%rax,%rbx,1)
jne    1423 <test_sanitizer+0x2d3>
mov    (%r14),%edi
lea    0xefc(%rip),%rsi
call   1050 <fprintf@plt>
mov    (%r14),%edi
lea    0xe41(%rip),%rsi
call   1050 <fprintf@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    $0x1,%edi
mov    $0x10,%esi
call   1040 <calloc@plt>
mov    %rax,%rbx
mov    %rax,%rdi
mov    $0x10,%esi
call   1060 <fill_array@plt>
movb   $0xd,0x5(%rbx)
mov    %rbx,%rdi
mov    $0x10,%esi
call   1070 <sanitize_crlf@plt>
cmpb   $0xd,0x5(%rbx)
jne    1423 <test_sanitizer+0x2d3>
cmpb   $0xa,0x6(%rbx)
jne    1423 <test_sanitizer+0x2d3>
cmp    $0x11,%rax
jne    1423 <test_sanitizer+0x2d3>
mov    (%r14),%edi
lea    0xe88(%rip),%rsi
call   1050 <fprintf@plt>
mov    (%r14),%edi
lea    0xde6(%rip),%rsi
call   1050 <fprintf@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    $0x1,%edi
mov    $0x10,%esi
call   1040 <calloc@plt>
mov    %rax,%rbx
mov    %rax,%rdi
mov    $0x10,%esi
call   1060 <fill_array@plt>
movb   $0xa,(%rbx)
mov    %rbx,%rdi
mov    $0x10,%esi
call   1070 <sanitize_crlf@plt>
cmp    $0x11,%rax
jne    1423 <test_sanitizer+0x2d3>
cmpb   $0xd,(%rbx)
jne    1423 <test_sanitizer+0x2d3>
cmpb   $0xa,0x1(%rbx)
jne    1423 <test_sanitizer+0x2d3>
mov    (%r14),%edi
lea    0xe16(%rip),%rsi
call   1050 <fprintf@plt>
mov    (%r14),%edi
lea    0xd8c(%rip),%rsi
call   1050 <fprintf@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    $0x1,%edi
mov    $0x10,%esi
call   1040 <calloc@plt>
mov    %rax,%rbx
mov    %rax,%rdi
mov    $0x10,%esi
call   1060 <fill_array@plt>
movb   $0xd,(%rbx)
mov    %rbx,%rdi
mov    $0x10,%esi
call   1070 <sanitize_crlf@plt>
cmpb   $0xd,(%rbx)
jne    1423 <test_sanitizer+0x2d3>
cmpb   $0xa,0x1(%rbx)
jne    1423 <test_sanitizer+0x2d3>
cmp    $0x11,%rax
jne    1423 <test_sanitizer+0x2d3>
mov    (%r14),%edi
lea    0xda4(%rip),%rsi
call   1050 <fprintf@plt>
mov    (%r14),%edi
lea    0xd39(%rip),%rsi
call   1050 <fprintf@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    $0x1,%edi
mov    $0x10,%esi
call   1040 <calloc@plt>
mov    %rax,%rbx
mov    %rax,%rdi
mov    $0x10,%esi
call   1060 <fill_array@plt>
movb   $0xa,0x5(%rbx)
mov    %rbx,%rdi
mov    $0x10,%esi
call   1070 <sanitize_crlf@plt>
cmpb   $0xd,0x5(%rbx)
jne    1423 <test_sanitizer+0x2d3>
cmpb   $0xa,0x6(%rbx)
jne    1423 <test_sanitizer+0x2d3>
cmp    $0x11,%rax
jne    1423 <test_sanitizer+0x2d3>
mov    (%r14),%edi
lea    0xd30(%rip),%rsi
call   1050 <fprintf@plt>
mov    (%r14),%edi
lea    0xcef(%rip),%rsi
call   1050 <fprintf@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    $0x1,%edi
mov    $0x10,%esi
call   1040 <calloc@plt>
mov    %rax,%rbx
mov    %rax,%rdi
mov    $0x10,%esi
call   1060 <fill_array@plt>
movw   $0xa0d,0x6(%rbx)
mov    %rbx,%rdi
mov    $0x10,%esi
call   1070 <sanitize_crlf@plt>
cmpb   $0xd,0x6(%rbx)
jne    1423 <test_sanitizer+0x2d3>
cmpb   $0xa,0x7(%rbx)
jne    1423 <test_sanitizer+0x2d3>
cmpb   $0xd,0x8(%rbx)
jne    1423 <test_sanitizer+0x2d3>
cmpb   $0xa,0x9(%rbx)
jne    1423 <test_sanitizer+0x2d3>
mov    (%r14),%edi
lea    0xcc0(%rip),%rsi
call   1050 <fprintf@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    (%r14),%edi
lea    0xc92(%rip),%rsi
call   1050 <fprintf@plt>
mov    $0x1,%ebp
mov    %ebp,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [22 x i8] c"CR at end of buffer: \00"
@.str.1 = [8 x i8] c"passed\0A\00"
@.str.2 = [25 x i8] c"CR at middle of buffer: \00"
@.str.3 = [24 x i8] c"LF at start of buffer: \00"
@.str.4 = [31 x i8] c"CR at start of buffer, no LF: \00"
@.str.5 = [42 x i8] c"LF at middle of buffer, no CR before it: \00"
@.str.6 = [27 x i8] c"CRLF at middle of buffer: \00"
@.str.7 = [31 x i8] c"All CR/LF fixing Tests passed\0A\00"
define i32 @test_sanitizer() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca i64
%4 = load i32, i32* @stderr
%5 = call i32 @fprintf(i32 %4, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
%6 = call i8* @calloc(i32 1, i32 16)
store i8* %6, i8** %2
%7 = load i8*, i8** %2
%8 = call i32 @fill_array(i8* %7, i32 16)
%9 = load i8*, i8** %2
%10 = getelementptr inbounds i8, i8* %9, i64 15
store i8 13, i8* %10
%11 = load i8*, i8** %2
%12 = call i64 @sanitize_crlf(i8* %11, i32 16)
store i64 %12, i64* %3
%13 = load i64, i64* %3
%14 = icmp eq i64 %13, 16
br i1 %14, label %31, label %15
15: ; preds = %0
%16 = load i8*, i8** %2
%17 = load i64, i64* %3
%18 = sub i64 %17, 1
%19 = getelementptr inbounds i8, i8* %16, i64 %18
%20 = load i8, i8* %19
%21 = sext i8 %20 to i32
%22 = icmp ne i32 %21, 10
br i1 %22, label %31, label %23
23: ; preds = %15
%24 = load i8*, i8** %2
%25 = load i64, i64* %3
%26 = sub i64 %25, 2
%27 = getelementptr inbounds i8, i8* %24, i64 %26
%28 = load i8, i8* %27
%29 = sext i8 %28 to i32
%30 = icmp ne i32 %29, 13
br i1 %30, label %31, label %32
31: ; preds = %23, %15, %0
store i32 0, i32* %1
br label %195
32: ; preds = %23
%33 = load i32, i32* @stderr
%34 = call i32 @fprintf(i32 %33, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%35 = load i32, i32* @stderr
%36 = call i32 @fprintf(i32 %35, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0))
%37 = load i8*, i8** %2
%38 = call i32 @free(i8* %37)
%39 = call i8* @calloc(i32 1, i32 16)
store i8* %39, i8** %2
%40 = load i8*, i8** %2
%41 = call i32 @fill_array(i8* %40, i32 16)
%42 = load i8*, i8** %2
%43 = getelementptr inbounds i8, i8* %42, i64 5
store i8 13, i8* %43
%44 = load i8*, i8** %2
%45 = call i64 @sanitize_crlf(i8* %44, i32 16)
store i64 %45, i64* %3
%46 = load i8*, i8** %2
%47 = getelementptr inbounds i8, i8* %46, i64 5
%48 = load i8, i8* %47
%49 = sext i8 %48 to i32
%50 = icmp ne i32 %49, 13
br i1 %50, label %60, label %51
51: ; preds = %32
%52 = load i8*, i8** %2
%53 = getelementptr inbounds i8, i8* %52, i64 6
%54 = load i8, i8* %53
%55 = sext i8 %54 to i32
%56 = icmp ne i32 %55, 10
br i1 %56, label %60, label %57
57: ; preds = %51
%58 = load i64, i64* %3
%59 = icmp ne i64 %58, 17
br i1 %59, label %60, label %61
60: ; preds = %57, %51, %32
store i32 0, i32* %1
br label %195
61: ; preds = %57
%62 = load i32, i32* @stderr
%63 = call i32 @fprintf(i32 %62, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%64 = load i32, i32* @stderr
%65 = call i32 @fprintf(i32 %64, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0))
%66 = load i8*, i8** %2
%67 = call i32 @free(i8* %66)
%68 = call i8* @calloc(i32 1, i32 16)
store i8* %68, i8** %2
%69 = load i8*, i8** %2
%70 = call i32 @fill_array(i8* %69, i32 16)
%71 = load i8*, i8** %2
%72 = getelementptr inbounds i8, i8* %71, i64 0
store i8 10, i8* %72
%73 = load i8*, i8** %2
%74 = call i64 @sanitize_crlf(i8* %73, i32 16)
store i64 %74, i64* %3
%75 = load i64, i64* %3
%76 = icmp ne i64 %75, 17
br i1 %76, label %89, label %77
77: ; preds = %61
%78 = load i8*, i8** %2
%79 = getelementptr inbounds i8, i8* %78, i64 0
%80 = load i8, i8* %79
%81 = sext i8 %80 to i32
%82 = icmp ne i32 %81, 13
br i1 %82, label %89, label %83
83: ; preds = %77
%84 = load i8*, i8** %2
%85 = getelementptr inbounds i8, i8* %84, i64 1
%86 = load i8, i8* %85
%87 = sext i8 %86 to i32
%88 = icmp ne i32 %87, 10
br i1 %88, label %89, label %90
89: ; preds = %83, %77, %61
store i32 0, i32* %1
br label %195
90: ; preds = %83
%91 = load i32, i32* @stderr
%92 = call i32 @fprintf(i32 %91, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%93 = load i32, i32* @stderr
%94 = call i32 @fprintf(i32 %93, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.4, i64 0, i64 0))
%95 = load i8*, i8** %2
%96 = call i32 @free(i8* %95)
%97 = call i8* @calloc(i32 1, i32 16)
store i8* %97, i8** %2
%98 = load i8*, i8** %2
%99 = call i32 @fill_array(i8* %98, i32 16)
%100 = load i8*, i8** %2
%101 = getelementptr inbounds i8, i8* %100, i64 0
store i8 13, i8* %101
%102 = load i8*, i8** %2
%103 = call i64 @sanitize_crlf(i8* %102, i32 16)
store i64 %103, i64* %3
%104 = load i8*, i8** %2
%105 = getelementptr inbounds i8, i8* %104, i64 0
%106 = load i8, i8* %105
%107 = sext i8 %106 to i32
%108 = icmp ne i32 %107, 13
br i1 %108, label %118, label %109
109: ; preds = %90
%110 = load i8*, i8** %2
%111 = getelementptr inbounds i8, i8* %110, i64 1
%112 = load i8, i8* %111
%113 = sext i8 %112 to i32
%114 = icmp ne i32 %113, 10
br i1 %114, label %118, label %115
115: ; preds = %109
%116 = load i64, i64* %3
%117 = icmp ne i64 %116, 17
br i1 %117, label %118, label %119
118: ; preds = %115, %109, %90
store i32 0, i32* %1
br label %195
119: ; preds = %115
%120 = load i32, i32* @stderr
%121 = call i32 @fprintf(i32 %120, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%122 = load i32, i32* @stderr
%123 = call i32 @fprintf(i32 %122, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.5, i64 0, i64 0))
%124 = load i8*, i8** %2
%125 = call i32 @free(i8* %124)
%126 = call i8* @calloc(i32 1, i32 16)
store i8* %126, i8** %2
%127 = load i8*, i8** %2
%128 = call i32 @fill_array(i8* %127, i32 16)
%129 = load i8*, i8** %2
%130 = getelementptr inbounds i8, i8* %129, i64 5
store i8 10, i8* %130
%131 = load i8*, i8** %2
%132 = call i64 @sanitize_crlf(i8* %131, i32 16)
store i64 %132, i64* %3
%133 = load i8*, i8** %2
%134 = getelementptr inbounds i8, i8* %133, i64 5
%135 = load i8, i8* %134
%136 = sext i8 %135 to i32
%137 = icmp ne i32 %136, 13
br i1 %137, label %147, label %138
138: ; preds = %119
%139 = load i8*, i8** %2
%140 = getelementptr inbounds i8, i8* %139, i64 6
%141 = load i8, i8* %140
%142 = sext i8 %141 to i32
%143 = icmp ne i32 %142, 10
br i1 %143, label %147, label %144
144: ; preds = %138
%145 = load i64, i64* %3
%146 = icmp ne i64 %145, 17
br i1 %146, label %147, label %148
147: ; preds = %144, %138, %119
store i32 0, i32* %1
br label %195
148: ; preds = %144
%149 = load i32, i32* @stderr
%150 = call i32 @fprintf(i32 %149, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%151 = load i32, i32* @stderr
%152 = call i32 @fprintf(i32 %151, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.6, i64 0, i64 0))
%153 = load i8*, i8** %2
%154 = call i32 @free(i8* %153)
%155 = call i8* @calloc(i32 1, i32 16)
store i8* %155, i8** %2
%156 = load i8*, i8** %2
%157 = call i32 @fill_array(i8* %156, i32 16)
%158 = load i8*, i8** %2
%159 = getelementptr inbounds i8, i8* %158, i64 6
store i8 13, i8* %159
%160 = load i8*, i8** %2
%161 = getelementptr inbounds i8, i8* %160, i64 7
store i8 10, i8* %161
%162 = load i8*, i8** %2
%163 = call i64 @sanitize_crlf(i8* %162, i32 16)
store i64 %163, i64* %3
%164 = load i8*, i8** %2
%165 = getelementptr inbounds i8, i8* %164, i64 6
%166 = load i8, i8* %165
%167 = sext i8 %166 to i32
%168 = icmp ne i32 %167, 13
br i1 %168, label %187, label %169
169: ; preds = %148
%170 = load i8*, i8** %2
%171 = getelementptr inbounds i8, i8* %170, i64 7
%172 = load i8, i8* %171
%173 = sext i8 %172 to i32
%174 = icmp ne i32 %173, 10
br i1 %174, label %187, label %175
175: ; preds = %169
%176 = load i8*, i8** %2
%177 = getelementptr inbounds i8, i8* %176, i64 8
%178 = load i8, i8* %177
%179 = sext i8 %178 to i32
%180 = icmp ne i32 %179, 13
br i1 %180, label %187, label %181
181: ; preds = %175
%182 = load i8*, i8** %2
%183 = getelementptr inbounds i8, i8* %182, i64 9
%184 = load i8, i8* %183
%185 = sext i8 %184 to i32
%186 = icmp ne i32 %185, 10
br i1 %186, label %187, label %188
187: ; preds = %181, %175, %169, %148
store i32 0, i32* %1
br label %195
188: ; preds = %181
%189 = load i32, i32* @stderr
%190 = call i32 @fprintf(i32 %189, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%191 = load i8*, i8** %2
%192 = call i32 @free(i8* %191)
%193 = load i32, i32* @stderr
%194 = call i32 @fprintf(i32 %193, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.7, i64 0, i64 0))
store i32 1, i32* %1
br label %195
195: ; preds = %188, %187, %147, %118, %89, %60, %31
%196 = load i32, i32* %1
ret i32 %196
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [22 x i8] c"CR at end of buffer: \00"
@.str.1 = [8 x i8] c"passed\0A\00"
@.str.2 = [25 x i8] c"CR at middle of buffer: \00"
@.str.3 = [24 x i8] c"LF at start of buffer: \00"
@.str.4 = [31 x i8] c"CR at start of buffer, no LF: \00"
@.str.5 = [42 x i8] c"LF at middle of buffer, no CR before it: \00"
@.str.6 = [27 x i8] c"CRLF at middle of buffer: \00"
@.str.7 = [31 x i8] c"All CR/LF fixing Tests passed\0A\00"
define i32 @test_sanitizer() {
%1 = load i32, i32* @stderr
%2 = tail call i32 @fprintf(i32 %1, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
%3 = tail call dereferenceable_or_null(16) i8* @calloc(i32 1, i32 16)
%4 = tail call i32 @fill_array(i8* %3, i32 16)
%5 = getelementptr inbounds i8, i8* %3, i64 15
store i8 13, i8* %5
%6 = tail call i64 @sanitize_crlf(i8* %3, i32 16)
%7 = icmp eq i64 %6, 16
br i1 %7, label %118, label %8
8: ; preds = %0
%9 = add i64 %6, -1
%10 = getelementptr inbounds i8, i8* %3, i64 %9
%11 = load i8, i8* %10
%12 = icmp eq i8 %11, 10
br i1 %12, label %13, label %118
13: ; preds = %8
%14 = add i64 %6, -2
%15 = getelementptr inbounds i8, i8* %3, i64 %14
%16 = load i8, i8* %15
%17 = icmp eq i8 %16, 13
br i1 %17, label %18, label %118
18: ; preds = %13
%19 = load i32, i32* @stderr
%20 = tail call i32 @fprintf(i32 %19, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%21 = load i32, i32* @stderr
%22 = tail call i32 @fprintf(i32 %21, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.2, i64 0, i64 0))
%23 = tail call i32 @free(i8* %3)
%24 = tail call dereferenceable_or_null(16) i8* @calloc(i32 1, i32 16)
%25 = tail call i32 @fill_array(i8* %24, i32 16)
%26 = getelementptr inbounds i8, i8* %24, i64 5
store i8 13, i8* %26
%27 = tail call i64 @sanitize_crlf(i8* %24, i32 16)
%28 = load i8, i8* %26
%29 = icmp eq i8 %28, 13
br i1 %29, label %30, label %118
30: ; preds = %18
%31 = getelementptr inbounds i8, i8* %24, i64 6
%32 = load i8, i8* %31
%33 = icmp ne i8 %32, 10
%34 = icmp ne i64 %27, 17
%35 = select i1 %33, i1 true, i1 %34
br i1 %35, label %118, label %36
36: ; preds = %30
%37 = load i32, i32* @stderr
%38 = tail call i32 @fprintf(i32 %37, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%39 = load i32, i32* @stderr
%40 = tail call i32 @fprintf(i32 %39, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0))
%41 = tail call i32 @free(i8* %24)
%42 = tail call dereferenceable_or_null(16) i8* @calloc(i32 1, i32 16)
%43 = tail call i32 @fill_array(i8* %42, i32 16)
store i8 10, i8* %42
%44 = tail call i64 @sanitize_crlf(i8* %42, i32 16)
%45 = icmp eq i64 %44, 17
br i1 %45, label %46, label %118
46: ; preds = %36
%47 = load i8, i8* %42
%48 = icmp eq i8 %47, 13
br i1 %48, label %49, label %118
49: ; preds = %46
%50 = getelementptr inbounds i8, i8* %42, i64 1
%51 = load i8, i8* %50
%52 = icmp eq i8 %51, 10
br i1 %52, label %53, label %118
53: ; preds = %49
%54 = load i32, i32* @stderr
%55 = tail call i32 @fprintf(i32 %54, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%56 = load i32, i32* @stderr
%57 = tail call i32 @fprintf(i32 %56, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.4, i64 0, i64 0))
%58 = tail call i32 @free(i8* %42)
%59 = tail call dereferenceable_or_null(16) i8* @calloc(i32 1, i32 16)
%60 = tail call i32 @fill_array(i8* %59, i32 16)
store i8 13, i8* %59
%61 = tail call i64 @sanitize_crlf(i8* %59, i32 16)
%62 = load i8, i8* %59
%63 = icmp eq i8 %62, 13
br i1 %63, label %64, label %118
64: ; preds = %53
%65 = getelementptr inbounds i8, i8* %59, i64 1
%66 = load i8, i8* %65
%67 = icmp ne i8 %66, 10
%68 = icmp ne i64 %61, 17
%69 = select i1 %67, i1 true, i1 %68
br i1 %69, label %118, label %70
70: ; preds = %64
%71 = load i32, i32* @stderr
%72 = tail call i32 @fprintf(i32 %71, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%73 = load i32, i32* @stderr
%74 = tail call i32 @fprintf(i32 %73, i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.5, i64 0, i64 0))
%75 = tail call i32 @free(i8* %59)
%76 = tail call dereferenceable_or_null(16) i8* @calloc(i32 1, i32 16)
%77 = tail call i32 @fill_array(i8* %76, i32 16)
%78 = getelementptr inbounds i8, i8* %76, i64 5
store i8 10, i8* %78
%79 = tail call i64 @sanitize_crlf(i8* %76, i32 16)
%80 = load i8, i8* %78
%81 = icmp eq i8 %80, 13
br i1 %81, label %82, label %118
82: ; preds = %70
%83 = getelementptr inbounds i8, i8* %76, i64 6
%84 = load i8, i8* %83
%85 = icmp ne i8 %84, 10
%86 = icmp ne i64 %79, 17
%87 = select i1 %85, i1 true, i1 %86
br i1 %87, label %118, label %88
88: ; preds = %82
%89 = load i32, i32* @stderr
%90 = tail call i32 @fprintf(i32 %89, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%91 = load i32, i32* @stderr
%92 = tail call i32 @fprintf(i32 %91, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.6, i64 0, i64 0))
%93 = tail call i32 @free(i8* %76)
%94 = tail call dereferenceable_or_null(16) i8* @calloc(i32 1, i32 16)
%95 = tail call i32 @fill_array(i8* %94, i32 16)
%96 = getelementptr inbounds i8, i8* %94, i64 6
store i8 13, i8* %96
%97 = getelementptr inbounds i8, i8* %94, i64 7
store i8 10, i8* %97
%98 = tail call i64 @sanitize_crlf(i8* %94, i32 16)
%99 = load i8, i8* %96
%100 = icmp eq i8 %99, 13
br i1 %100, label %101, label %118
101: ; preds = %88
%102 = load i8, i8* %97
%103 = icmp eq i8 %102, 10
br i1 %103, label %104, label %118
104: ; preds = %101
%105 = getelementptr inbounds i8, i8* %94, i64 8
%106 = load i8, i8* %105
%107 = icmp eq i8 %106, 13
br i1 %107, label %108, label %118
108: ; preds = %104
%109 = getelementptr inbounds i8, i8* %94, i64 9
%110 = load i8, i8* %109
%111 = icmp eq i8 %110, 10
br i1 %111, label %112, label %118
112: ; preds = %108
%113 = load i32, i32* @stderr
%114 = tail call i32 @fprintf(i32 %113, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%115 = tail call i32 @free(i8* %94)
%116 = load i32, i32* @stderr
%117 = tail call i32 @fprintf(i32 %116, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.7, i64 0, i64 0))
br label %118
118: ; preds = %88, %101, %104, %108, %70, %82, %53, %64, %36, %46, %49, %18, %30, %0, %8, %13, %112
%119 = phi i32 [ 1, %112 ], [ 0, %13 ], [ 0, %8 ], [ 0, %0 ], [ 0, %30 ], [ 0, %18 ], [ 0, %49 ], [ 0, %46 ], [ 0, %36 ], [ 0, %64 ], [ 0, %53 ], [ 0, %82 ], [ 0, %70 ], [ 0, %108 ], [ 0, %104 ], [ 0, %101 ], [ 0, %88 ]
ret i32 %119
}