#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 */
int /*<<< orphan*/ text_is_valid_char(unsigned char const);
int text_is_binary(const unsigned char *text, size_t size) {
  size_t i;
  for (i = 0; i < size; ++i) {
    if (!text_is_valid_char(text[i]))
      return 1;
    if (text[i] == '\r' && text[i + 1] != '\n')
      return 1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<text_is_binary>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%rax
cmp    -0x18(%rbp),%rax
jae    11a9 <text_is_binary+0x99>
mov    -0x10(%rbp),%rax
mov    -0x20(%rbp),%rcx
movzbl (%rax,%rcx,1),%edi
call   1030 <text_is_valid_char@plt>
cmp    $0x0,%eax
jne    115c <text_is_binary+0x4c>
movl   $0x1,-0x4(%rbp)
jmp    11b0 <text_is_binary+0xa0>
mov    -0x10(%rbp),%rax
mov    -0x20(%rbp),%rcx
movzbl (%rax,%rcx,1),%eax
cmp    $0xd,%eax
jne    1193 <text_is_binary+0x83>
mov    -0x10(%rbp),%rax
mov    -0x20(%rbp),%rcx
movzbl 0x1(%rax,%rcx,1),%eax
cmp    $0xa,%eax
je     1193 <text_is_binary+0x83>
movl   $0x1,-0x4(%rbp)
jmp    11b0 <text_is_binary+0xa0>
jmp    1198 <text_is_binary+0x88>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    1128 <text_is_binary+0x18>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<text_is_binary>:
push   %r15
push   %r14
push   %rbx
test   %rsi,%rsi
je     115f <text_is_binary+0x4f>
mov    %rsi,%r14
mov    %rdi,%r15
xor    %ebx,%ebx
jmp    1139 <text_is_binary+0x29>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
add    $0x1,%rbx
cmp    %rbx,%r14
je     115f <text_is_binary+0x4f>
movzbl (%r15,%rbx,1),%edi
call   1030 <text_is_valid_char@plt>
mov    %eax,%ecx
mov    $0x1,%eax
test   %ecx,%ecx
je     1161 <text_is_binary+0x51>
cmpb   $0xd,(%r15,%rbx,1)
jne    1130 <text_is_binary+0x20>
cmpb   $0xa,0x1(%r15,%rbx,1)
je     1130 <text_is_binary+0x20>
jmp    1161 <text_is_binary+0x51>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i32 @text_is_binary(i8* %0, i64 %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i64
%6 = alloca i64
store i8* %0, i8** %4
store i64 %1, i64* %5
store i64 0, i64* %6
br label %7
7: ; preds = %36, %2
%8 = load i64, i64* %6
%9 = load i64, i64* %5
%10 = icmp ult i64 %8, %9
br i1 %10, label %11, label %39
11: ; preds = %7
%12 = load i8*, i8** %4
%13 = load i64, i64* %6
%14 = getelementptr inbounds i8, i8* %12, i64 %13
%15 = load i8, i8* %14
%16 = call i32 @text_is_valid_char(i8 zeroext %15)
%17 = icmp ne i32 %16, 0
br i1 %17, label %19, label %18
18: ; preds = %11
store i32 1, i32* %3
br label %40
19: ; preds = %11
%20 = load i8*, i8** %4
%21 = load i64, i64* %6
%22 = getelementptr inbounds i8, i8* %20, i64 %21
%23 = load i8, i8* %22
%24 = zext i8 %23 to i32
%25 = icmp eq i32 %24, 13
br i1 %25, label %26, label %35
26: ; preds = %19
%27 = load i8*, i8** %4
%28 = load i64, i64* %6
%29 = add i64 %28, 1
%30 = getelementptr inbounds i8, i8* %27, i64 %29
%31 = load i8, i8* %30
%32 = zext i8 %31 to i32
%33 = icmp ne i32 %32, 10
br i1 %33, label %34, label %35
34: ; preds = %26
store i32 1, i32* %3
br label %40
35: ; preds = %26, %19
br label %36
36: ; preds = %35
%37 = load i64, i64* %6
%38 = add i64 %37, 1
store i64 %38, i64* %6
br label %7
39: ; preds = %7
store i32 0, i32* %3
br label %40
40: ; preds = %39, %34, %18
%41 = load i32, i32* %3
ret i32 %41
}

LLVM IR (-O2):
define i32 @text_is_binary(i8* nocapture %0, i64 %1) {
%3 = icmp eq i64 %1, 0
br i1 %3, label %20, label %4
4: ; preds = %2, %18
%5 = phi i64 [ %13, %18 ], [ 0, %2 ]
%6 = getelementptr inbounds i8, i8* %0, i64 %5
%7 = load i8, i8* %6
%8 = tail call i32 @text_is_valid_char(i8 zeroext %7)
%9 = icmp eq i32 %8, 0
br i1 %9, label %20, label %10
10: ; preds = %4
%11 = load i8, i8* %6
%12 = icmp eq i8 %11, 13
%13 = add nuw i64 %5, 1
br i1 %12, label %14, label %18
14: ; preds = %10
%15 = getelementptr inbounds i8, i8* %0, i64 %13
%16 = load i8, i8* %15
%17 = icmp eq i8 %16, 10
br i1 %17, label %18, label %20
18: ; preds = %10, %14
%19 = icmp eq i64 %13, %1
br i1 %19, label %20, label %4
20: ; preds = %4, %14, %18, %2
%21 = phi i32 [ 0, %2 ], [ 0, %18 ], [ 1, %14 ], [ 1, %4 ]
ret i32 %21
}