#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 ssize_t;

/* Variables and functions */
int buf_read(int, char *);
int /*<<< orphan*/ free(char *);
char *malloc(size_t);
int /*<<< orphan*/ memcpy(char *, char *, size_t);
ssize_t smtp_recv_mail_data(int sockfd, char **buf_ptr, size_t *buf_size) {
  int rc, state;
  size_t n, buflen;
  char c, *ptr, *buf, *temp_buf;
  if (NULL == (buf = malloc(512 * sizeof(char))))
    return -1;
  state = 0;
  ptr = buf;
  buflen = 512;
  n = 0;
  for (;;) {
    if ((rc = buf_read(sockfd, &c)) == 1) {
      *ptr++ = c;
      if (4 == state) {
        if (c == '\n') {
          n -= 2;
          *(ptr - 3) = '\0';
          break;
        } else if (c == '\r')
          state = 1;
        else
          state = 0;
      } else if (3 == state) {
        if (c == '\r')
          state = 4;
        else if (c == '\r')
          state = 1;
        else
          state = 0;
      } else if (2 == state) {
        if (c == '.')
          state = 3;
        else if (c == '\r')
          state = 1;
        else
          state = 0;
      } else if (1 == state) {
        if (c == '\n')
          state = 2;
        else if (c == '\r')
          state = 1;
        else
          state = 0;
      } else if (c == '\r')
        state = 1;
    } else {
      *buf_ptr = NULL;
      *buf_size = 0;
      free(buf);
      if (rc == 1)
        return 0;
      else
        return -1;
    }
    ++n;
    if (n == buflen) {
      buflen *= 2;
      temp_buf = buf;
      if (NULL == (buf = malloc(buflen * sizeof(char)))) {
        free(temp_buf);
        return -1;
      }
      ptr = buf + n;
      memcpy(buf, temp_buf, n);
      free(temp_buf);
      temp_buf = NULL;
    }
  }
  *buf_ptr = buf;
  if (NULL != buf_size)
    *buf_size = buflen;
  return n;
}


x86 assembly (clang, -O0):
<smtp_recv_mail_data>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    $0x200,%edi
call   1060 <malloc@plt>
mov    %rax,%rcx
mov    %rcx,-0x48(%rbp)
xor    %eax,%eax
cmp    %rcx,%rax
jne    117b <smtp_recv_mail_data+0x3b>
movl   $0xffffffff,-0x4(%rbp)
jmp    1443 <smtp_recv_mail_data+0x303>
movl   $0x0,-0x20(%rbp)
mov    -0x48(%rbp),%rax
mov    %rax,-0x40(%rbp)
movq   $0x200,-0x30(%rbp)
movq   $0x0,-0x28(%rbp)
mov    -0x8(%rbp),%edi
lea    -0x31(%rbp),%rsi
call   1040 <buf_read@plt>
mov    %eax,-0x1c(%rbp)
cmp    $0x1,%eax
jne    1344 <smtp_recv_mail_data+0x204>
mov    -0x31(%rbp),%cl
mov    -0x40(%rbp),%rax
mov    %rax,%rdx
add    $0x1,%rdx
mov    %rdx,-0x40(%rbp)
mov    %cl,(%rax)
mov    $0x4,%eax
cmp    -0x20(%rbp),%eax
jne    1224 <smtp_recv_mail_data+0xe4>
movsbl -0x31(%rbp),%eax
cmp    $0xa,%eax
jne    11fa <smtp_recv_mail_data+0xba>
mov    -0x28(%rbp),%rax
sub    $0x2,%rax
mov    %rax,-0x28(%rbp)
mov    -0x40(%rbp),%rax
movb   $0x0,-0x3(%rax)
jmp    141a <smtp_recv_mail_data+0x2da>
movsbl -0x31(%rbp),%eax
cmp    $0xd,%eax
jne    1213 <smtp_recv_mail_data+0xd3>
movl   $0x1,-0x20(%rbp)
jmp    121a <smtp_recv_mail_data+0xda>
movl   $0x0,-0x20(%rbp)
jmp    121f <smtp_recv_mail_data+0xdf>
jmp    133f <smtp_recv_mail_data+0x1ff>
mov    $0x3,%eax
cmp    -0x20(%rbp),%eax
jne    1275 <smtp_recv_mail_data+0x135>
movsbl -0x31(%rbp),%eax
cmp    $0xd,%eax
jne    124b <smtp_recv_mail_data+0x10b>
movl   $0x4,-0x20(%rbp)
jmp    1270 <smtp_recv_mail_data+0x130>
movsbl -0x31(%rbp),%eax
cmp    $0xd,%eax
jne    1264 <smtp_recv_mail_data+0x124>
movl   $0x1,-0x20(%rbp)
jmp    126b <smtp_recv_mail_data+0x12b>
movl   $0x0,-0x20(%rbp)
jmp    1270 <smtp_recv_mail_data+0x130>
jmp    133a <smtp_recv_mail_data+0x1fa>
mov    $0x2,%eax
cmp    -0x20(%rbp),%eax
jne    12c6 <smtp_recv_mail_data+0x186>
movsbl -0x31(%rbp),%eax
cmp    $0x2e,%eax
jne    129c <smtp_recv_mail_data+0x15c>
movl   $0x3,-0x20(%rbp)
jmp    12c1 <smtp_recv_mail_data+0x181>
movsbl -0x31(%rbp),%eax
cmp    $0xd,%eax
jne    12b5 <smtp_recv_mail_data+0x175>
movl   $0x1,-0x20(%rbp)
jmp    12bc <smtp_recv_mail_data+0x17c>
movl   $0x0,-0x20(%rbp)
jmp    12c1 <smtp_recv_mail_data+0x181>
jmp    1335 <smtp_recv_mail_data+0x1f5>
mov    $0x1,%eax
cmp    -0x20(%rbp),%eax
jne    1317 <smtp_recv_mail_data+0x1d7>
movsbl -0x31(%rbp),%eax
cmp    $0xa,%eax
jne    12ed <smtp_recv_mail_data+0x1ad>
movl   $0x2,-0x20(%rbp)
jmp    1312 <smtp_recv_mail_data+0x1d2>
movsbl -0x31(%rbp),%eax
cmp    $0xd,%eax
jne    1306 <smtp_recv_mail_data+0x1c6>
movl   $0x1,-0x20(%rbp)
jmp    130d <smtp_recv_mail_data+0x1cd>
movl   $0x0,-0x20(%rbp)
jmp    1312 <smtp_recv_mail_data+0x1d2>
jmp    1330 <smtp_recv_mail_data+0x1f0>
movsbl -0x31(%rbp),%eax
cmp    $0xd,%eax
jne    132b <smtp_recv_mail_data+0x1eb>
movl   $0x1,-0x20(%rbp)
jmp    1330 <smtp_recv_mail_data+0x1f0>
jmp    1335 <smtp_recv_mail_data+0x1f5>
jmp    133a <smtp_recv_mail_data+0x1fa>
jmp    133f <smtp_recv_mail_data+0x1ff>
jmp    1385 <smtp_recv_mail_data+0x245>
mov    -0x10(%rbp),%rax
movq   $0x0,(%rax)
mov    -0x18(%rbp),%rax
movq   $0x0,(%rax)
mov    -0x48(%rbp),%rdi
call   1030 <free@plt>
cmpl   $0x1,-0x1c(%rbp)
jne    1379 <smtp_recv_mail_data+0x239>
movl   $0x0,-0x4(%rbp)
jmp    1443 <smtp_recv_mail_data+0x303>
movl   $0xffffffff,-0x4(%rbp)
jmp    1443 <smtp_recv_mail_data+0x303>
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
cmp    -0x30(%rbp),%rax
jne    1415 <smtp_recv_mail_data+0x2d5>
mov    -0x30(%rbp),%rax
shl    $0x1,%rax
mov    %rax,-0x30(%rbp)
mov    -0x48(%rbp),%rax
mov    %rax,-0x50(%rbp)
mov    -0x30(%rbp),%rdi
shl    $0x0,%rdi
call   1060 <malloc@plt>
mov    %rax,%rcx
mov    %rcx,-0x48(%rbp)
xor    %eax,%eax
cmp    %rcx,%rax
jne    13e7 <smtp_recv_mail_data+0x2a7>
mov    -0x50(%rbp),%rdi
call   1030 <free@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1443 <smtp_recv_mail_data+0x303>
mov    -0x48(%rbp),%rax
add    -0x28(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x48(%rbp),%rdi
mov    -0x50(%rbp),%rsi
mov    -0x28(%rbp),%rdx
call   1050 <memcpy@plt>
mov    -0x50(%rbp),%rdi
call   1030 <free@plt>
movq   $0x0,-0x50(%rbp)
jmp    119a <smtp_recv_mail_data+0x5a>
mov    -0x48(%rbp),%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
xor    %eax,%eax
cmp    -0x18(%rbp),%rax
je     143c <smtp_recv_mail_data+0x2fc>
mov    -0x30(%rbp),%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x28(%rbp),%rax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<smtp_recv_mail_data>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    %rdx,%r14
mov    %rsi,%rbp
mov    %edi,%ebx
mov    $0x200,%edi
call   1060 <malloc@plt>
mov    %rax,%r15
mov    $0xffffffff,%eax
test   %r15,%r15
je     131b <smtp_recv_mail_data+0x1db>
mov    %rbp,0x18(%rsp)
mov    %r14,0x20(%rsp)
lea    0x7(%rsp),%rsi
mov    %ebx,%edi
call   1040 <buf_read@plt>
cmp    $0x1,%eax
mov    %r15,0x8(%rsp)
jne    12f4 <smtp_recv_mail_data+0x1b4>
xor    %ebp,%ebp
mov    $0x200,%r12d
mov    %ebx,%eax
mov    $0xfffffffe,%ebx
mov    $0x1,%r13d
lea    0x7(%rsp),%r14
mov    %eax,0x10(%rsp)
mov    %r15,%rdx
mov    0x10(%rsp),%r15d
jmp    11e9 <smtp_recv_mail_data+0xa9>
nopl   (%rax)
add    $0x1,%rdx
mov    %rdx,0x28(%rsp)
mov    %r15d,%edi
mov    %r14,%rsi
call   1040 <buf_read@plt>
add    $0x1,%ebx
add    $0x1,%r13
cmp    $0x1,%eax
mov    0x28(%rsp),%rdx
jne    12f4 <smtp_recv_mail_data+0x1b4>
movzbl 0x7(%rsp),%eax
mov    %al,(%rdx)
lea    -0x1(%rbp),%eax
cmp    $0x3,%eax
ja     1230 <smtp_recv_mail_data+0xf0>
lea    0xe01(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movzbl 0x7(%rsp),%eax
xor    %ebp,%ebp
cmp    $0xd,%al
sete   %bpl
cmp    $0xa,%al
mov    $0x2,%eax
cmove  %eax,%ebp
jmp    1290 <smtp_recv_mail_data+0x150>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
cmpb   $0xd,0x7(%rsp)
mov    $0x1,%eax
cmove  %eax,%ebp
jmp    1290 <smtp_recv_mail_data+0x150>
nop
movzbl 0x7(%rsp),%eax
xor    %ebp,%ebp
cmp    $0xd,%al
sete   %bpl
cmp    $0x2e,%al
mov    $0x3,%eax
cmove  %eax,%ebp
jmp    1290 <smtp_recv_mail_data+0x150>
nopl   0x0(%rax)
xor    %ebp,%ebp
cmpb   $0xd,0x7(%rsp)
sete   %bpl
shl    $0x2,%ebp
jmp    1290 <smtp_recv_mail_data+0x150>
mov    $0x1,%ebp
movzbl 0x7(%rsp),%eax
cmp    $0xd,%al
je     1290 <smtp_recv_mail_data+0x150>
cmp    $0xa,%al
je     132a <smtp_recv_mail_data+0x1ea>
xor    %ebp,%ebp
nopl   0x0(%rax,%rax,1)
cmp    %r12,%r13
jne    11c0 <smtp_recv_mail_data+0x80>
mov    %rbp,0x30(%rsp)
mov    %ebx,0x14(%rsp)
lea    (%r12,%r12,1),%rbp
mov    %rbp,%rdi
call   1060 <malloc@plt>
test   %rax,%rax
je     130c <smtp_recv_mail_data+0x1cc>
mov    %rax,%rbx
add    %r12,%rax
mov    %rax,0x28(%rsp)
mov    %rbx,%rdi
mov    0x8(%rsp),%r15
mov    %r15,%rsi
mov    %r12,%rdx
call   1050 <memcpy@plt>
mov    %r15,%rdi
mov    0x10(%rsp),%r15d
call   1030 <free@plt>
mov    %rbp,%r12
mov    %rbx,0x8(%rsp)
mov    0x14(%rsp),%ebx
mov    0x30(%rsp),%rbp
jmp    11c9 <smtp_recv_mail_data+0x89>
mov    0x18(%rsp),%rax
movq   $0x0,(%rax)
mov    0x20(%rsp),%rax
movq   $0x0,(%rax)
mov    0x8(%rsp),%rdi
call   1030 <free@plt>
mov    $0xffffffff,%eax
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
movb   $0x0,-0x2(%rdx)
mov    0x18(%rsp),%rax
mov    0x8(%rsp),%rcx
mov    %rcx,(%rax)
mov    0x20(%rsp),%rax
test   %rax,%rax
je     1348 <smtp_recv_mail_data+0x208>
mov    %r12,(%rax)
mov    %ebx,%eax
jmp    131b <smtp_recv_mail_data+0x1db>

LLVM IR (-O0):
define i32 @smtp_recv_mail_data(i32 %0, i8** %1, i64* %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8**
%7 = alloca i64*
%8 = alloca i32
%9 = alloca i32
%10 = alloca i64
%11 = alloca i64
%12 = alloca i8
%13 = alloca i8*
%14 = alloca i8*
%15 = alloca i8*
store i32 %0, i32* %5
store i8** %1, i8*** %6
store i64* %2, i64** %7
%16 = call i8* @malloc(i64 512)
store i8* %16, i8** %14
%17 = icmp eq i8* null, %16
br i1 %17, label %18, label %19
18: ; preds = %3
store i32 -1, i32* %4
br label %154
19: ; preds = %3
store i32 0, i32* %9
%20 = load i8*, i8** %14
store i8* %20, i8** %13
store i64 512, i64* %11
store i64 0, i64* %10
br label %21
21: ; preds = %142, %19
%22 = load i32, i32* %5
%23 = call i32 @buf_read(i32 %22, i8* %12)
store i32 %23, i32* %8
%24 = icmp eq i32 %23, 1
br i1 %24, label %25, label %106
25: ; preds = %21
%26 = load i8, i8* %12
%27 = load i8*, i8** %13
%28 = getelementptr inbounds i8, i8* %27, i32 1
store i8* %28, i8** %13
store i8 %26, i8* %27
%29 = load i32, i32* %9
%30 = icmp eq i32 4, %29
br i1 %30, label %31, label %48
31: ; preds = %25
%32 = load i8, i8* %12
%33 = sext i8 %32 to i32
%34 = icmp eq i32 %33, 10
br i1 %34, label %35, label %40
35: ; preds = %31
%36 = load i64, i64* %10
%37 = sub i64 %36, 2
store i64 %37, i64* %10
%38 = load i8*, i8** %13
%39 = getelementptr inbounds i8, i8* %38, i64 -3
store i8 0, i8* %39
br label %143
40: ; preds = %31
%41 = load i8, i8* %12
%42 = sext i8 %41 to i32
%43 = icmp eq i32 %42, 13
br i1 %43, label %44, label %45
44: ; preds = %40
store i32 1, i32* %9
br label %46
45: ; preds = %40
store i32 0, i32* %9
br label %46
46: ; preds = %45, %44
br label %47
47: ; preds = %46
br label %105
48: ; preds = %25
%49 = load i32, i32* %9
%50 = icmp eq i32 3, %49
br i1 %50, label %51, label %64
51: ; preds = %48
%52 = load i8, i8* %12
%53 = sext i8 %52 to i32
%54 = icmp eq i32 %53, 13
br i1 %54, label %55, label %56
55: ; preds = %51
store i32 4, i32* %9
br label %63
56: ; preds = %51
%57 = load i8, i8* %12
%58 = sext i8 %57 to i32
%59 = icmp eq i32 %58, 13
br i1 %59, label %60, label %61
60: ; preds = %56
store i32 1, i32* %9
br label %62
61: ; preds = %56
store i32 0, i32* %9
br label %62
62: ; preds = %61, %60
br label %63
63: ; preds = %62, %55
br label %104
64: ; preds = %48
%65 = load i32, i32* %9
%66 = icmp eq i32 2, %65
br i1 %66, label %67, label %80
67: ; preds = %64
%68 = load i8, i8* %12
%69 = sext i8 %68 to i32
%70 = icmp eq i32 %69, 46
br i1 %70, label %71, label %72
71: ; preds = %67
store i32 3, i32* %9
br label %79
72: ; preds = %67
%73 = load i8, i8* %12
%74 = sext i8 %73 to i32
%75 = icmp eq i32 %74, 13
br i1 %75, label %76, label %77
76: ; preds = %72
store i32 1, i32* %9
br label %78
77: ; preds = %72
store i32 0, i32* %9
br label %78
78: ; preds = %77, %76
br label %79
79: ; preds = %78, %71
br label %103
80: ; preds = %64
%81 = load i32, i32* %9
%82 = icmp eq i32 1, %81
br i1 %82, label %83, label %96
83: ; preds = %80
%84 = load i8, i8* %12
%85 = sext i8 %84 to i32
%86 = icmp eq i32 %85, 10
br i1 %86, label %87, label %88
87: ; preds = %83
store i32 2, i32* %9
br label %95
88: ; preds = %83
%89 = load i8, i8* %12
%90 = sext i8 %89 to i32
%91 = icmp eq i32 %90, 13
br i1 %91, label %92, label %93
92: ; preds = %88
store i32 1, i32* %9
br label %94
93: ; preds = %88
store i32 0, i32* %9
br label %94
94: ; preds = %93, %92
br label %95
95: ; preds = %94, %87
br label %102
96: ; preds = %80
%97 = load i8, i8* %12
%98 = sext i8 %97 to i32
%99 = icmp eq i32 %98, 13
br i1 %99, label %100, label %101
100: ; preds = %96
store i32 1, i32* %9
br label %101
101: ; preds = %100, %96
br label %102
102: ; preds = %101, %95
br label %103
103: ; preds = %102, %79
br label %104
104: ; preds = %103, %63
br label %105
105: ; preds = %104, %47
br label %115
106: ; preds = %21
%107 = load i8**, i8*** %6
store i8* null, i8** %107
%108 = load i64*, i64** %7
store i64 0, i64* %108
%109 = load i8*, i8** %14
%110 = call i32 @free(i8* %109)
%111 = load i32, i32* %8
%112 = icmp eq i32 %111, 1
br i1 %112, label %113, label %114
113: ; preds = %106
store i32 0, i32* %4
br label %154
114: ; preds = %106
store i32 -1, i32* %4
br label %154
115: ; preds = %105
%116 = load i64, i64* %10
%117 = add i64 %116, 1
store i64 %117, i64* %10
%118 = load i64, i64* %10
%119 = load i64, i64* %11
%120 = icmp eq i64 %118, %119
br i1 %120, label %121, label %142
121: ; preds = %115
%122 = load i64, i64* %11
%123 = mul i64 %122, 2
store i64 %123, i64* %11
%124 = load i8*, i8** %14
store i8* %124, i8** %15
%125 = load i64, i64* %11
%126 = mul i64 %125, 1
%127 = call i8* @malloc(i64 %126)
store i8* %127, i8** %14
%128 = icmp eq i8* null, %127
br i1 %128, label %129, label %132
129: ; preds = %121
%130 = load i8*, i8** %15
%131 = call i32 @free(i8* %130)
store i32 -1, i32* %4
br label %154
132: ; preds = %121
%133 = load i8*, i8** %14
%134 = load i64, i64* %10
%135 = getelementptr inbounds i8, i8* %133, i64 %134
store i8* %135, i8** %13
%136 = load i8*, i8** %14
%137 = load i8*, i8** %15
%138 = load i64, i64* %10
%139 = call i32 @memcpy(i8* %136, i8* %137, i64 %138)
%140 = load i8*, i8** %15
%141 = call i32 @free(i8* %140)
store i8* null, i8** %15
br label %142
142: ; preds = %132, %115
br label %21
143: ; preds = %35
%144 = load i8*, i8** %14
%145 = load i8**, i8*** %6
store i8* %144, i8** %145
%146 = load i64*, i64** %7
%147 = icmp ne i64* null, %146
br i1 %147, label %148, label %151
148: ; preds = %143
%149 = load i64, i64* %11
%150 = load i64*, i64** %7
store i64 %149, i64* %150
br label %151
151: ; preds = %148, %143
%152 = load i64, i64* %10
%153 = trunc i64 %152 to i32
store i32 %153, i32* %4
br label %154
154: ; preds = %151, %129, %114, %113, %18
%155 = load i32, i32* %4
ret i32 %155
}

LLVM IR (-O2):
define i32 @smtp_recv_mail_data(i32 %0, i8** nocapture writeonly %1, i64* writeonly %2) {
%4 = alloca i8
%5 = tail call dereferenceable_or_null(512) i8* @malloc(i64 512)
%6 = icmp eq i8* %5, null
br i1 %6, label %71, label %7
7: ; preds = %3
%8 = call i32 @buf_read(i32 %0, i8* %4)
%9 = icmp eq i32 %8, 1
br i1 %9, label %10, label %44
10: ; preds = %7, %61
%11 = phi i8* [ %64, %61 ], [ %5, %7 ]
%12 = phi i8* [ %63, %61 ], [ %5, %7 ]
%13 = phi i64 [ %62, %61 ], [ 512, %7 ]
%14 = phi i64 [ %49, %61 ], [ 0, %7 ]
%15 = phi i32 [ %48, %61 ], [ 0, %7 ]
%16 = load i8, i8* %4
%17 = getelementptr inbounds i8, i8* %12, i64 1
store i8 %16, i8* %12
switch i32 %15, label %40 [
i32 4, label %18
i32 3, label %24
i32 2, label %28
i32 1, label %34
]
18: ; preds = %10
%19 = load i8, i8* %4
switch i8 %19, label %23 [
i8 10, label %20
i8 13, label %47
]
20: ; preds = %18
%21 = getelementptr inbounds i8, i8* %12, i64 -2
store i8 0, i8* %21
store i8* %11, i8** %1
%22 = icmp eq i64* %2, null
br i1 %22, label %68, label %67
23: ; preds = %18
br label %47
24: ; preds = %10
%25 = load i8, i8* %4
%26 = icmp eq i8 %25, 13
%27 = select i1 %26, i32 4, i32 0
br label %47
28: ; preds = %10
%29 = load i8, i8* %4
%30 = icmp eq i8 %29, 13
%31 = zext i1 %30 to i32
%32 = icmp eq i8 %29, 46
%33 = select i1 %32, i32 3, i32 %31
br label %47
34: ; preds = %10
%35 = load i8, i8* %4
%36 = icmp eq i8 %35, 13
%37 = zext i1 %36 to i32
%38 = icmp eq i8 %35, 10
%39 = select i1 %38, i32 2, i32 %37
br label %47
40: ; preds = %10
%41 = load i8, i8* %4
%42 = icmp eq i8 %41, 13
%43 = select i1 %42, i32 1, i32 %15
br label %47
44: ; preds = %61, %7
%45 = phi i8* [ %5, %7 ], [ %64, %61 ]
store i8* null, i8** %1
store i64 0, i64* %2
%46 = call i32 @free(i8* %45)
br label %71
47: ; preds = %24, %40, %34, %28, %18, %23
%48 = phi i32 [ 0, %23 ], [ 1, %18 ], [ %43, %40 ], [ %27, %24 ], [ %33, %28 ], [ %39, %34 ]
%49 = add i64 %14, 1
%50 = icmp eq i64 %49, %13
br i1 %50, label %51, label %61
51: ; preds = %47
%52 = shl i64 %13, 1
%53 = call i8* @malloc(i64 %52)
%54 = icmp eq i8* %53, null
br i1 %54, label %55, label %57
55: ; preds = %51
%56 = call i32 @free(i8* %11)
br label %71
57: ; preds = %51
%58 = getelementptr inbounds i8, i8* %53, i64 %13
%59 = call i32 @memcpy(i8* %53, i8* %11, i64 %13)
%60 = call i32 @free(i8* %11)
br label %61
61: ; preds = %57, %47
%62 = phi i64 [ %52, %57 ], [ %13, %47 ]
%63 = phi i8* [ %58, %57 ], [ %17, %47 ]
%64 = phi i8* [ %53, %57 ], [ %11, %47 ]
%65 = call i32 @buf_read(i32 %0, i8* %4)
%66 = icmp eq i32 %65, 1
br i1 %66, label %10, label %44
67: ; preds = %20
store i64 %13, i64* %2
br label %68
68: ; preds = %67, %20
%69 = trunc i64 %14 to i32
%70 = add i32 %69, -2
br label %71
71: ; preds = %3, %68, %55, %44
%72 = phi i32 [ %70, %68 ], [ -1, %55 ], [ -1, %44 ], [ -1, %3 ]
ret i32 %72
}