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

/* Variables and functions */
int BUFSIZ;
int /*<<< orphan*/ fputc(char, int /*<<< orphan*/ *);
int /*<<< orphan*/ fwrite(char *, int, int, int /*<<< orphan*/ *);
void filtered_write(char *wbuffer, int wlen, FILE *wstream) {
  static char lastchar, savedchar;
  char *chkptr, *dest_end, *dest_ch, *nxtptr, *w_end;
  int destlen;
  char destbuf[BUFSIZ];
  if (wbuffer == NULL) {
    if (savedchar != '\0') {
      if (savedchar == '\r')
        savedchar = '\n';
      fputc(savedchar, wstream);
      lastchar = savedchar;
      savedchar = '\0';
    }
    if (lastchar != '\0' && lastchar != '\n')
      fputc('\n', wstream);
    lastchar = '\0';
    return;
  }
  dest_ch = &destbuf[0];
  dest_end = dest_ch + sizeof(destbuf);
  chkptr = wbuffer;
  w_end = wbuffer + wlen;
  lastchar = '\0';
  if (savedchar != '\0') {
    chkptr = &savedchar;
    nxtptr = wbuffer;
  } else
    nxtptr = chkptr + 1;
  while (chkptr < w_end) {
    if (nxtptr < w_end) {
      if ((*chkptr == '\r' && *nxtptr == '\n') ||
          (*chkptr == '\n' && *nxtptr == '\r')) {
        *dest_ch++ = '\n';
        nxtptr++;
        goto check_next;
      }
    } else {
      savedchar = '\0';
      if (*chkptr == '\r' || *chkptr == '\n') {
        savedchar = *chkptr;
        break;
      }
    }
    if (*chkptr == '\r')
      *dest_ch++ = '\n';
    else
      *dest_ch++ = *chkptr;
  check_next:
    chkptr = nxtptr;
    nxtptr = chkptr + 1;
    if (dest_ch >= dest_end) {
      destlen = dest_ch - &destbuf[0];
      fwrite(destbuf, 1, destlen, wstream);
      lastchar = destbuf[destlen - 1];
      dest_ch = &destbuf[0];
    }
  }
  destlen = dest_ch - &destbuf[0];
  if (destlen > 0) {
    fwrite(destbuf, 1, destlen, wstream);
    lastchar = destbuf[destlen - 1];
  }
}


x86 assembly (clang, -O0):
<filtered_write>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    0x2ea6(%rip),%rax
mov    (%rax),%eax
mov    %rax,-0x70(%rbp)
mov    %rsp,%rcx
mov    %rcx,-0x50(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x68(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x58(%rbp)
cmpq   $0x0,-0x8(%rbp)
jne    11fb <filtered_write+0xdb>
movsbl 0x2ec0(%rip),%eax
cmp    $0x0,%eax
je     11ba <filtered_write+0x9a>
movsbl 0x2eb0(%rip),%eax
cmp    $0xd,%eax
jne    1195 <filtered_write+0x75>
movb   $0xa,0x2ea0(%rip)
mov    0x2e9a(%rip),%al
mov    -0x18(%rbp),%rsi
movsbl %al,%edi
call   1030 <fputc@plt>
mov    0x2e88(%rip),%al
mov    %al,0x2e81(%rip)
movb   $0x0,0x2e7b(%rip)
movsbl 0x2e73(%rip),%eax
cmp    $0x0,%eax
je     11e8 <filtered_write+0xc8>
movsbl 0x2e63(%rip),%eax
cmp    $0xa,%eax
je     11e8 <filtered_write+0xc8>
mov    -0x18(%rbp),%rsi
mov    $0xa,%edi
call   1030 <fputc@plt>
movb   $0x0,0x2e45(%rip)
movl   $0x1,-0x5c(%rbp)
jmp    1414 <filtered_write+0x2f4>
mov    -0x70(%rbp),%rax
mov    -0x68(%rbp),%rcx
mov    %rcx,-0x30(%rbp)
add    -0x30(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rax
movslq -0xc(%rbp),%rcx
add    %rcx,%rax
mov    %rax,-0x40(%rbp)
movb   $0x0,0x2e07(%rip)
movsbl 0x2e01(%rip),%eax
cmp    $0x0,%eax
je     1255 <filtered_write+0x135>
lea    0x2df1(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x38(%rbp)
jmp    1261 <filtered_write+0x141>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x38(%rbp)
jmp    1266 <filtered_write+0x146>
mov    -0x20(%rbp),%rax
cmp    -0x40(%rbp),%rax
jae    13ca <filtered_write+0x2aa>
mov    -0x38(%rbp),%rax
cmp    -0x40(%rbp),%rax
jae    12ea <filtered_write+0x1ca>
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0xd,%eax
jne    12a2 <filtered_write+0x182>
mov    -0x38(%rbp),%rax
movsbl (%rax),%eax
cmp    $0xa,%eax
je     12c2 <filtered_write+0x1a2>
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0xa,%eax
jne    12e5 <filtered_write+0x1c5>
mov    -0x38(%rbp),%rax
movsbl (%rax),%eax
cmp    $0xd,%eax
jne    12e5 <filtered_write+0x1c5>
mov    -0x30(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x30(%rbp)
movb   $0xa,(%rax)
mov    -0x38(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x38(%rbp)
jmp    136a <filtered_write+0x24a>
jmp    1327 <filtered_write+0x207>
movb   $0x0,0x2d44(%rip)
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0xd,%eax
je     1311 <filtered_write+0x1f1>
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0xa,%eax
jne    1322 <filtered_write+0x202>
mov    -0x20(%rbp),%rax
mov    (%rax),%al
mov    %al,0x2d18(%rip)
jmp    13ca <filtered_write+0x2aa>
jmp    1327 <filtered_write+0x207>
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0xd,%eax
jne    134e <filtered_write+0x22e>
mov    -0x30(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x30(%rbp)
movb   $0xa,(%rax)
jmp    1365 <filtered_write+0x245>
mov    -0x20(%rbp),%rax
mov    (%rax),%cl
mov    -0x30(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x30(%rbp)
mov    %cl,(%rax)
jmp    136a <filtered_write+0x24a>
mov    -0x38(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x38(%rbp)
mov    -0x30(%rbp),%rax
cmp    -0x28(%rbp),%rax
jb     13c5 <filtered_write+0x2a5>
mov    -0x68(%rbp),%rdi
mov    -0x30(%rbp),%rax
sub    %rdi,%rax
mov    %eax,-0x44(%rbp)
mov    -0x44(%rbp),%edx
mov    -0x18(%rbp),%rcx
mov    $0x1,%esi
call   1040 <fwrite@plt>
mov    -0x68(%rbp),%rax
mov    -0x44(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,1),%cl
mov    %cl,0x2c73(%rip)
mov    %rax,-0x30(%rbp)
jmp    1266 <filtered_write+0x146>
mov    -0x68(%rbp),%rcx
mov    -0x30(%rbp),%rax
sub    %rcx,%rax
mov    %eax,-0x44(%rbp)
cmpl   $0x0,-0x44(%rbp)
jle    140d <filtered_write+0x2ed>
mov    -0x68(%rbp),%rdi
mov    -0x44(%rbp),%edx
mov    -0x18(%rbp),%rcx
mov    $0x1,%esi
call   1040 <fwrite@plt>
mov    -0x68(%rbp),%rax
mov    -0x44(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,1),%al
mov    %al,0x2c27(%rip)
movl   $0x0,-0x5c(%rbp)
mov    -0x50(%rbp),%rax
mov    %rax,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<filtered_write>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdx,-0x30(%rbp)
mov    0x2ea7(%rip),%rax
mov    (%rax),%r13d
mov    %rsp,%r15
lea    0xf(%r13),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r15
mov    %r15,%rsp
test   %rdi,%rdi
je     1236 <filtered_write+0x116>
mov    %rdi,%r12
movslq %esi,%r14
add    %rdi,%r14
movb   $0x0,0x2ece(%rip)
mov    0x2ec9(%rip),%cl
lea    0x2ec2(%rip),%rax
test   %cl,%cl
cmove  %rdi,%rax
cmp    %r14,%rax
jae    126e <filtered_write+0x14e>
add    %r15,%r13
cmp    $0x1,%cl
adc    $0x0,%r12
mov    %r15,%rbx
jmp    11b4 <filtered_write+0x94>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %r12,%rax
lea    0x1(%r12),%rcx
cmp    %r14,%r12
mov    %rcx,%r12
jae    1279 <filtered_write+0x159>
cmp    %r14,%r12
jae    11d0 <filtered_write+0xb0>
movzbl (%rax),%eax
cmp    $0xa,%al
je     1224 <filtered_write+0x104>
cmp    $0xd,%al
jne    11ea <filtered_write+0xca>
cmpb   $0xa,(%r12)
je     122d <filtered_write+0x10d>
movb   $0xa,(%rbx)
jmp    11ec <filtered_write+0xcc>
movb   $0x0,0x2e5e(%rip)
movzbl (%rax),%eax
cmp    $0xd,%al
je     1273 <filtered_write+0x153>
cmp    $0xa,%al
je     1273 <filtered_write+0x153>
mov    %al,(%rbx)
add    $0x1,%rbx
cmp    %r13,%rbx
jb     11a0 <filtered_write+0x80>
sub    %r15d,%ebx
mov    %r15,%rdi
mov    $0x1,%esi
mov    %ebx,%edx
mov    -0x30(%rbp),%rcx
call   1040 <fwrite@plt>
add    $0xffffffff,%ebx
movslq %ebx,%rax
movzbl (%r15,%rax,1),%eax
mov    %al,0x2e18(%rip)
mov    %r15,%rbx
jmp    11a0 <filtered_write+0x80>
mov    $0xa,%al
cmpb   $0xd,(%r12)
jne    11ea <filtered_write+0xca>
movb   $0xa,(%rbx)
add    $0x1,%r12
jmp    11ec <filtered_write+0xcc>
mov    0x2df9(%rip),%al
test   %al,%al
je     129c <filtered_write+0x17c>
cmp    $0xd,%al
jne    124d <filtered_write+0x12d>
movb   $0xa,0x2dea(%rip)
mov    $0xa,%al
movsbl %al,%edi
mov    -0x30(%rbp),%rsi
call   1030 <fputc@plt>
mov    0x2dd6(%rip),%cl
mov    %cl,0x2dcf(%rip)
movb   $0x0,0x2dc9(%rip)
jmp    12a2 <filtered_write+0x182>
mov    %r15,%rbx
jmp    1279 <filtered_write+0x159>
mov    %al,0x2dbc(%rip)
sub    %r15,%rbx
test   %ebx,%ebx
jle    12c3 <filtered_write+0x1a3>
mov    %r15,%rdi
mov    $0x1,%esi
mov    %ebx,%edx
mov    -0x30(%rbp),%rcx
call   1040 <fwrite@plt>
add    $0xffffffff,%ebx
mov    (%r15,%rbx,1),%al
jmp    12bd <filtered_write+0x19d>
mov    0x2d92(%rip),%cl
xor    %eax,%eax
test   %cl,%cl
je     12bd <filtered_write+0x19d>
cmp    $0xa,%cl
je     12bd <filtered_write+0x19d>
mov    $0xa,%edi
mov    -0x30(%rbp),%rsi
call   1030 <fputc@plt>
xor    %eax,%eax
mov    %al,0x2d71(%rip)
lea    -0x28(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@filtered_write.lastchar = internal global i8 0
@filtered_write.savedchar = internal global i8 0
@BUFSIZ = global i32 0
define void @filtered_write(i8* %0, i32 %1, i32* %2) {
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i32*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i8*
%12 = alloca i32
%13 = alloca i8*
%14 = alloca i64
%15 = alloca i32
store i8* %0, i8** %4
store i32 %1, i32* %5
store i32* %2, i32** %6
%16 = load i32, i32* @BUFSIZ
%17 = zext i32 %16 to i64
%18 = call i8* @llvm.stacksave()
store i8* %18, i8** %13
%19 = alloca i8, i64 %17
store i64 %17, i64* %14
%20 = load i8*, i8** %4
%21 = icmp eq i8* %20, null
br i1 %21, label %22, label %48
22: ; preds = %3
%23 = load i8, i8* @filtered_write.savedchar
%24 = sext i8 %23 to i32
%25 = icmp ne i32 %24, 0
br i1 %25, label %26, label %36
26: ; preds = %22
%27 = load i8, i8* @filtered_write.savedchar
%28 = sext i8 %27 to i32
%29 = icmp eq i32 %28, 13
br i1 %29, label %30, label %31
30: ; preds = %26
store i8 10, i8* @filtered_write.savedchar
br label %31
31: ; preds = %30, %26
%32 = load i8, i8* @filtered_write.savedchar
%33 = load i32*, i32** %6
%34 = call i32 @fputc(i8 signext %32, i32* %33)
%35 = load i8, i8* @filtered_write.savedchar
store i8 %35, i8* @filtered_write.lastchar
store i8 0, i8* @filtered_write.savedchar
br label %36
36: ; preds = %31, %22
%37 = load i8, i8* @filtered_write.lastchar
%38 = sext i8 %37 to i32
%39 = icmp ne i32 %38, 0
br i1 %39, label %40, label %47
40: ; preds = %36
%41 = load i8, i8* @filtered_write.lastchar
%42 = sext i8 %41 to i32
%43 = icmp ne i32 %42, 10
br i1 %43, label %44, label %47
44: ; preds = %40
%45 = load i32*, i32** %6
%46 = call i32 @fputc(i8 signext 10, i32* %45)
br label %47
47: ; preds = %44, %40, %36
store i8 0, i8* @filtered_write.lastchar
store i32 1, i32* %15
br label %171
48: ; preds = %3
%49 = getelementptr inbounds i8, i8* %19, i64 0
store i8* %49, i8** %9
%50 = load i8*, i8** %9
%51 = getelementptr inbounds i8, i8* %50, i64 %17
store i8* %51, i8** %8
%52 = load i8*, i8** %4
store i8* %52, i8** %7
%53 = load i8*, i8** %4
%54 = load i32, i32* %5
%55 = sext i32 %54 to i64
%56 = getelementptr inbounds i8, i8* %53, i64 %55
store i8* %56, i8** %11
store i8 0, i8* @filtered_write.lastchar
%57 = load i8, i8* @filtered_write.savedchar
%58 = sext i8 %57 to i32
%59 = icmp ne i32 %58, 0
br i1 %59, label %60, label %62
60: ; preds = %48
store i8* @filtered_write.savedchar, i8** %7
%61 = load i8*, i8** %4
store i8* %61, i8** %10
br label %65
62: ; preds = %48
%63 = load i8*, i8** %7
%64 = getelementptr inbounds i8, i8* %63, i64 1
store i8* %64, i8** %10
br label %65
65: ; preds = %62, %60
br label %66
66: ; preds = %151, %65
%67 = load i8*, i8** %7
%68 = load i8*, i8** %11
%69 = icmp ult i8* %67, %68
br i1 %69, label %70, label %152
70: ; preds = %66
%71 = load i8*, i8** %10
%72 = load i8*, i8** %11
%73 = icmp ult i8* %71, %72
br i1 %73, label %74, label %100
74: ; preds = %70
%75 = load i8*, i8** %7
%76 = load i8, i8* %75
%77 = sext i8 %76 to i32
%78 = icmp eq i32 %77, 13
br i1 %78, label %79, label %84
79: ; preds = %74
%80 = load i8*, i8** %10
%81 = load i8, i8* %80
%82 = sext i8 %81 to i32
%83 = icmp eq i32 %82, 10
br i1 %83, label %94, label %84
84: ; preds = %79, %74
%85 = load i8*, i8** %7
%86 = load i8, i8* %85
%87 = sext i8 %86 to i32
%88 = icmp eq i32 %87, 10
br i1 %88, label %89, label %99
89: ; preds = %84
%90 = load i8*, i8** %10
%91 = load i8, i8* %90
%92 = sext i8 %91 to i32
%93 = icmp eq i32 %92, 13
br i1 %93, label %94, label %99
94: ; preds = %89, %79
%95 = load i8*, i8** %9
%96 = getelementptr inbounds i8, i8* %95, i32 1
store i8* %96, i8** %9
store i8 10, i8* %95
%97 = load i8*, i8** %10
%98 = getelementptr inbounds i8, i8* %97, i32 1
store i8* %98, i8** %10
br label %128
99: ; preds = %89, %84
br label %114
100: ; preds = %70
store i8 0, i8* @filtered_write.savedchar
%101 = load i8*, i8** %7
%102 = load i8, i8* %101
%103 = sext i8 %102 to i32
%104 = icmp eq i32 %103, 13
br i1 %104, label %110, label %105
105: ; preds = %100
%106 = load i8*, i8** %7
%107 = load i8, i8* %106
%108 = sext i8 %107 to i32
%109 = icmp eq i32 %108, 10
br i1 %109, label %110, label %113
110: ; preds = %105, %100
%111 = load i8*, i8** %7
%112 = load i8, i8* %111
store i8 %112, i8* @filtered_write.savedchar
br label %152
113: ; preds = %105
br label %114
114: ; preds = %113, %99
%115 = load i8*, i8** %7
%116 = load i8, i8* %115
%117 = sext i8 %116 to i32
%118 = icmp eq i32 %117, 13
br i1 %118, label %119, label %122
119: ; preds = %114
%120 = load i8*, i8** %9
%121 = getelementptr inbounds i8, i8* %120, i32 1
store i8* %121, i8** %9
store i8 10, i8* %120
br label %127
122: ; preds = %114
%123 = load i8*, i8** %7
%124 = load i8, i8* %123
%125 = load i8*, i8** %9
%126 = getelementptr inbounds i8, i8* %125, i32 1
store i8* %126, i8** %9
store i8 %124, i8* %125
br label %127
127: ; preds = %122, %119
br label %128
128: ; preds = %127, %94
%129 = load i8*, i8** %10
store i8* %129, i8** %7
%130 = load i8*, i8** %7
%131 = getelementptr inbounds i8, i8* %130, i64 1
store i8* %131, i8** %10
%132 = load i8*, i8** %9
%133 = load i8*, i8** %8
%134 = icmp uge i8* %132, %133
br i1 %134, label %135, label %151
135: ; preds = %128
%136 = load i8*, i8** %9
%137 = getelementptr inbounds i8, i8* %19, i64 0
%138 = ptrtoint i8* %136 to i64
%139 = ptrtoint i8* %137 to i64
%140 = sub i64 %138, %139
%141 = trunc i64 %140 to i32
store i32 %141, i32* %12
%142 = load i32, i32* %12
%143 = load i32*, i32** %6
%144 = call i32 @fwrite(i8* %19, i32 1, i32 %142, i32* %143)
%145 = load i32, i32* %12
%146 = sub nsw i32 %145, 1
%147 = sext i32 %146 to i64
%148 = getelementptr inbounds i8, i8* %19, i64 %147
%149 = load i8, i8* %148
store i8 %149, i8* @filtered_write.lastchar
%150 = getelementptr inbounds i8, i8* %19, i64 0
store i8* %150, i8** %9
br label %151
151: ; preds = %135, %128
br label %66
152: ; preds = %110, %66
%153 = load i8*, i8** %9
%154 = getelementptr inbounds i8, i8* %19, i64 0
%155 = ptrtoint i8* %153 to i64
%156 = ptrtoint i8* %154 to i64
%157 = sub i64 %155, %156
%158 = trunc i64 %157 to i32
store i32 %158, i32* %12
%159 = load i32, i32* %12
%160 = icmp sgt i32 %159, 0
br i1 %160, label %161, label %170
161: ; preds = %152
%162 = load i32, i32* %12
%163 = load i32*, i32** %6
%164 = call i32 @fwrite(i8* %19, i32 1, i32 %162, i32* %163)
%165 = load i32, i32* %12
%166 = sub nsw i32 %165, 1
%167 = sext i32 %166 to i64
%168 = getelementptr inbounds i8, i8* %19, i64 %167
%169 = load i8, i8* %168
store i8 %169, i8* @filtered_write.lastchar
br label %170
170: ; preds = %161, %152
store i32 0, i32* %15
br label %171
171: ; preds = %170, %47
%172 = load i8*, i8** %13
%173 = load i32, i32* %15
switch i32 %173, label %175 [
i32 0, label %174
i32 1, label %174
]
174: ; preds = %171, %171
ret void
175: ; preds = %171
unreachable
}

LLVM IR (-O2):
@filtered_write.lastchar = internal unnamed_addr global i8 0
@filtered_write.savedchar = internal global i8 0
@BUFSIZ = global i32 0
define void @filtered_write(i8* %0, i32 %1, i32* nocapture %2) {
%4 = load i32, i32* @BUFSIZ
%5 = zext i32 %4 to i64
%6 = alloca i8, i64 %5
%7 = icmp eq i8* %0, null
br i1 %7, label %8, label %21
8: ; preds = %3
%9 = load i8, i8* @filtered_write.savedchar
switch i8 %9, label %11 [
i8 0, label %15
i8 13, label %10
]
10: ; preds = %8
store i8 10, i8* @filtered_write.savedchar
br label %11
11: ; preds = %8, %10
%12 = phi i8 [ %9, %8 ], [ 10, %10 ]
%13 = tail call i32 @fputc(i8 signext %12, i32* %2)
%14 = load i8, i8* @filtered_write.savedchar
store i8 %14, i8* @filtered_write.lastchar
store i8 0, i8* @filtered_write.savedchar
br label %17
15: ; preds = %8
%16 = load i8, i8* @filtered_write.lastchar
br label %17
17: ; preds = %15, %11
%18 = phi i8 [ %16, %15 ], [ %14, %11 ]
switch i8 %18, label %19 [
i8 10, label %87
i8 0, label %87
]
19: ; preds = %17
%20 = tail call i32 @fputc(i8 signext 10, i32* %2)
br label %87
21: ; preds = %3
%22 = getelementptr inbounds i8, i8* %6, i64 %5
%23 = sext i32 %1 to i64
%24 = getelementptr inbounds i8, i8* %0, i64 %23
store i8 0, i8* @filtered_write.lastchar
%25 = load i8, i8* @filtered_write.savedchar
%26 = icmp eq i8 %25, 0
%27 = select i1 %26, i8* %0, i8* @filtered_write.savedchar
%28 = icmp ult i8* %27, %24
br i1 %28, label %31, label %29
29: ; preds = %21
%30 = ptrtoint i8* %6 to i64
br label %74
31: ; preds = %21
%32 = zext i1 %26 to i64
%33 = getelementptr i8, i8* %0, i64 %32
%34 = ptrtoint i8* %6 to i64
br label %35
35: ; preds = %31, %71
%36 = phi i8* [ %27, %31 ], [ %57, %71 ]
%37 = phi i8* [ %6, %31 ], [ %72, %71 ]
%38 = phi i8* [ %33, %31 ], [ %59, %71 ]
%39 = icmp ult i8* %38, %24
br i1 %39, label %40, label %50
40: ; preds = %35
%41 = load i8, i8* %36
switch i8 %41, label %54 [
i8 13, label %42
i8 10, label %45
]
42: ; preds = %40
%43 = load i8, i8* %38
%44 = icmp eq i8 %43, 10
br i1 %44, label %48, label %53
45: ; preds = %40
%46 = load i8, i8* %38
%47 = icmp eq i8 %46, 13
br i1 %47, label %48, label %54
48: ; preds = %45, %42
store i8 10, i8* %37
%49 = getelementptr inbounds i8, i8* %38, i64 1
br label %56
50: ; preds = %35
store i8 0, i8* @filtered_write.savedchar
%51 = load i8, i8* %36
switch i8 %51, label %54 [
i8 13, label %52
i8 10, label %52
]
52: ; preds = %50, %50
store i8 %51, i8* @filtered_write.savedchar
br label %74
53: ; preds = %42
store i8 10, i8* %37
br label %56
54: ; preds = %50, %45, %40
%55 = phi i8 [ %41, %40 ], [ 10, %45 ], [ %51, %50 ]
store i8 %55, i8* %37
br label %56
56: ; preds = %53, %54, %48
%57 = phi i8* [ %49, %48 ], [ %38, %53 ], [ %38, %54 ]
%58 = getelementptr inbounds i8, i8* %37, i64 1
%59 = getelementptr inbounds i8, i8* %57, i64 1
%60 = icmp ult i8* %58, %22
br i1 %60, label %71, label %61
61: ; preds = %56
%62 = ptrtoint i8* %58 to i64
%63 = sub i64 %62, %34
%64 = trunc i64 %63 to i32
%65 = call i32 @fwrite(i8* %6, i32 1, i32 %64, i32* %2)
%66 = shl i64 %63, 32
%67 = add i64 %66, -4294967296
%68 = ashr exact i64 %67, 32
%69 = getelementptr inbounds i8, i8* %6, i64 %68
%70 = load i8, i8* %69
store i8 %70, i8* @filtered_write.lastchar
br label %71
71: ; preds = %61, %56
%72 = phi i8* [ %6, %61 ], [ %58, %56 ]
%73 = icmp ult i8* %57, %24
br i1 %73, label %35, label %74
74: ; preds = %71, %29, %52
%75 = phi i64 [ %30, %29 ], [ %34, %52 ], [ %34, %71 ]
%76 = phi i8* [ %6, %29 ], [ %37, %52 ], [ %72, %71 ]
%77 = ptrtoint i8* %76 to i64
%78 = sub i64 %77, %75
%79 = trunc i64 %78 to i32
%80 = icmp sgt i32 %79, 0
br i1 %80, label %81, label %89
81: ; preds = %74
%82 = call i32 @fwrite(i8* %6, i32 1, i32 %79, i32* %2)
%83 = add i64 %78, 4294967295
%84 = and i64 %83, 4294967295
%85 = getelementptr inbounds i8, i8* %6, i64 %84
%86 = load i8, i8* %85
br label %87
87: ; preds = %19, %17, %17, %81
%88 = phi i8 [ %86, %81 ], [ 0, %17 ], [ 0, %17 ], [ 0, %19 ]
store i8 %88, i8* @filtered_write.lastchar
br label %89
89: ; preds = %87, %74
ret void
}