#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 */
scalar_t__ strncmp(char const *, char *, int);
int newline_size(const char *array) {
  if (strncmp(array, "\r\n", 2) == 0 || strncmp(array, "\n\r", 2) == 0)
    return 2;
  else if (*array == '\r' || *array == '\n')
    return 1;
  return 0;
}


x86 assembly (clang, -O0):
<newline_size>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xed9(%rip),%rsi
mov    $0x2,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
je     115a <newline_size+0x4a>
mov    -0x10(%rbp),%rdi
lea    0xebd(%rip),%rsi
mov    $0x2,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    1166 <newline_size+0x56>
movl   $0x2,-0x4(%rbp)
jmp    119e <newline_size+0x8e>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0xd,%eax
je     1186 <newline_size+0x76>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0xa,%eax
jne    1192 <newline_size+0x82>
movl   $0x1,-0x4(%rbp)
jmp    119e <newline_size+0x8e>
jmp    1197 <newline_size+0x87>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<newline_size>:
push   %rbp
push   %rbx
push   %rax
mov    %rdi,%rbx
lea    0xee3(%rip),%rsi
mov    $0x2,%ebp
mov    $0x2,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     1160 <newline_size+0x50>
lea    0xecb(%rip),%rsi
mov    $0x2,%ebp
mov    %rbx,%rdi
mov    $0x2,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     1160 <newline_size+0x50>
mov    (%rbx),%al
cmp    $0xd,%al
sete   %cl
cmp    $0xa,%al
sete   %al
or     %cl,%al
movzbl %al,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"\0D\0A\00"
@.str.1 = [3 x i8] c"\0A\0D\00"
define i32 @newline_size(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
store i8* %0, i8** %3
%4 = load i8*, i8** %3
%5 = call i64 @strncmp(i8* %4, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 2)
%6 = icmp eq i64 %5, 0
br i1 %6, label %11, label %7
7: ; preds = %1
%8 = load i8*, i8** %3
%9 = call i64 @strncmp(i8* %8, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 2)
%10 = icmp eq i64 %9, 0
br i1 %10, label %11, label %12
11: ; preds = %7, %1
store i32 2, i32* %2
br label %25
12: ; preds = %7
%13 = load i8*, i8** %3
%14 = load i8, i8* %13
%15 = sext i8 %14 to i32
%16 = icmp eq i32 %15, 13
br i1 %16, label %22, label %17
17: ; preds = %12
%18 = load i8*, i8** %3
%19 = load i8, i8* %18
%20 = sext i8 %19 to i32
%21 = icmp eq i32 %20, 10
br i1 %21, label %22, label %23
22: ; preds = %17, %12
store i32 1, i32* %2
br label %25
23: ; preds = %17
br label %24
24: ; preds = %23
store i32 0, i32* %2
br label %25
25: ; preds = %24, %22, %11
%26 = load i32, i32* %2
ret i32 %26
}

LLVM IR (-O2):
@.str = [3 x i8] c"\0D\0A\00"
@.str.1 = [3 x i8] c"\0A\0D\00"
define i32 @newline_size(i8* %0) {
%2 = tail call i64 @strncmp(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 2)
%3 = icmp eq i64 %2, 0
br i1 %3, label %13, label %4
4: ; preds = %1
%5 = tail call i64 @strncmp(i8* %0, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 2)
%6 = icmp eq i64 %5, 0
br i1 %6, label %13, label %7
7: ; preds = %4
%8 = load i8, i8* %0
%9 = icmp eq i8 %8, 13
%10 = icmp eq i8 %8, 10
%11 = or i1 %9, %10
%12 = zext i1 %11 to i32
br label %13
13: ; preds = %7, %1, %4
%14 = phi i32 [ 2, %4 ], [ 2, %1 ], [ %12, %7 ]
ret i32 %14
}