#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*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ perror(char *);
int read(int, char *, int);
int /*<<< orphan*/ stderr;
char *strchr(char *, char);
int read_line(int fd, char *buff) {
  char *pch = NULL;
  int n = 0;
  memset(buff, 0, 10240);
  if ((n = read(fd, buff, 10240)) < 0)
    perror("server: read error");
  else if (n == 2 && *buff == '\r' && *(buff + 1) == '\n')
    n = 1;
  else
    buff[n - 1] = '\0';
  pch = strchr(buff, '/');
  if (pch != NULL) {
    fprintf(stderr, "You should not use '/'.\n");
    fflush(stderr);
    n = 1;
  }
  return n;
}


x86 assembly (clang, -O0):
<read_line>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x10(%rbp),%rdi
xor    %esi,%esi
mov    $0x2800,%edx
call   1040 <memset@plt>
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    $0x2800,%edx
call   1050 <read@plt>
mov    %eax,-0x1c(%rbp)
cmp    $0x0,%eax
jge    11bc <read_line+0x5c>
lea    0xe4e(%rip),%rdi
call   1080 <perror@plt>
jmp    1209 <read_line+0xa9>
cmpl   $0x2,-0x1c(%rbp)
jne    11f3 <read_line+0x93>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0xd,%eax
jne    11f3 <read_line+0x93>
mov    -0x10(%rbp),%rax
movsbl 0x1(%rax),%eax
cmp    $0xa,%eax
jne    11f3 <read_line+0x93>
movl   $0x1,-0x1c(%rbp)
jmp    1204 <read_line+0xa4>
mov    -0x10(%rbp),%rax
mov    -0x1c(%rbp),%ecx
sub    $0x1,%ecx
movslq %ecx,%rcx
movb   $0x0,(%rax,%rcx,1)
jmp    1209 <read_line+0xa9>
mov    -0x10(%rbp),%rdi
mov    $0x2f,%esi
call   1030 <strchr@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     1250 <read_line+0xf0>
mov    0x2db3(%rip),%rax
mov    (%rax),%edi
lea    0xddd(%rip),%rsi
call   1060 <fprintf@plt>
mov    0x2d9e(%rip),%rax
mov    (%rax),%edi
call   1070 <fflush@plt>
movl   $0x1,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<read_line>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%rbx
mov    %edi,%ebp
mov    %rsi,%rdi
xor    %esi,%esi
mov    $0x2800,%edx
call   1040 <memset@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    $0x2800,%edx
call   1050 <read@plt>
mov    %eax,%ebp
test   %eax,%eax
js     11ea <read_line+0x8a>
cmp    $0x2,%ebp
jne    11a3 <read_line+0x43>
cmpb   $0xd,(%rbx)
jne    11a3 <read_line+0x43>
mov    $0x1,%r14d
cmpb   $0xa,0x1(%rbx)
je     11ae <read_line+0x4e>
movslq %ebp,%rax
movb   $0x0,-0x1(%rax,%rbx,1)
mov    %ebp,%r14d
mov    %rbx,%rdi
mov    $0x2f,%esi
call   1030 <strchr@plt>
test   %rax,%rax
je     11e2 <read_line+0x82>
mov    0x2e19(%rip),%rbx
mov    (%rbx),%edi
lea    0xe43(%rip),%rsi
call   1060 <fprintf@plt>
mov    (%rbx),%edi
call   1070 <fflush@plt>
mov    $0x1,%r14d
mov    %r14d,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret
lea    0xe0f(%rip),%rdi
call   1080 <perror@plt>
jmp    11ab <read_line+0x4b>

LLVM IR (-O0):
@.str = [19 x i8] c"server: read error\00"
@stderr = global i32 0
@.str.1 = [25 x i8] c"You should not use '/'.\0A\00"
define i32 @read_line(i32 %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
store i32 %0, i32* %3
store i8* %1, i8** %4
store i8* null, i8** %5
store i32 0, i32* %6
%7 = load i8*, i8** %4
%8 = call i32 @memset(i8* %7, i32 0, i32 10240)
%9 = load i32, i32* %3
%10 = load i8*, i8** %4
%11 = call i32 @read(i32 %9, i8* %10, i32 10240)
store i32 %11, i32* %6
%12 = icmp slt i32 %11, 0
br i1 %12, label %13, label %15
13: ; preds = %2
%14 = call i32 @perror(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
br label %37
15: ; preds = %2
%16 = load i32, i32* %6
%17 = icmp eq i32 %16, 2
br i1 %17, label %18, label %30
18: ; preds = %15
%19 = load i8*, i8** %4
%20 = load i8, i8* %19
%21 = sext i8 %20 to i32
%22 = icmp eq i32 %21, 13
br i1 %22, label %23, label %30
23: ; preds = %18
%24 = load i8*, i8** %4
%25 = getelementptr inbounds i8, i8* %24, i64 1
%26 = load i8, i8* %25
%27 = sext i8 %26 to i32
%28 = icmp eq i32 %27, 10
br i1 %28, label %29, label %30
29: ; preds = %23
store i32 1, i32* %6
br label %36
30: ; preds = %23, %18, %15
%31 = load i8*, i8** %4
%32 = load i32, i32* %6
%33 = sub nsw i32 %32, 1
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds i8, i8* %31, i64 %34
store i8 0, i8* %35
br label %36
36: ; preds = %30, %29
br label %37
37: ; preds = %36, %13
%38 = load i8*, i8** %4
%39 = call i8* @strchr(i8* %38, i8 signext 47)
store i8* %39, i8** %5
%40 = load i8*, i8** %5
%41 = icmp ne i8* %40, null
br i1 %41, label %42, label %47
42: ; preds = %37
%43 = load i32, i32* @stderr
%44 = call i32 @fprintf(i32 %43, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0))
%45 = load i32, i32* @stderr
%46 = call i32 @fflush(i32 %45)
store i32 1, i32* %6
br label %47
47: ; preds = %42, %37
%48 = load i32, i32* %6
ret i32 %48
}

LLVM IR (-O2):
@.str = [19 x i8] c"server: read error\00"
@stderr = global i32 0
@.str.1 = [25 x i8] c"You should not use '/'.\0A\00"
define i32 @read_line(i32 %0, i8* %1) {
%3 = tail call i32 @memset(i8* %1, i32 0, i32 10240)
%4 = tail call i32 @read(i32 %0, i8* %1, i32 10240)
%5 = icmp slt i32 %4, 0
br i1 %5, label %6, label %8
6: ; preds = %2
%7 = tail call i32 @perror(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
br label %21
8: ; preds = %2
%9 = icmp eq i32 %4, 2
br i1 %9, label %10, label %17
10: ; preds = %8
%11 = load i8, i8* %1
%12 = icmp eq i8 %11, 13
br i1 %12, label %13, label %17
13: ; preds = %10
%14 = getelementptr inbounds i8, i8* %1, i64 1
%15 = load i8, i8* %14
%16 = icmp eq i8 %15, 10
br i1 %16, label %21, label %17
17: ; preds = %13, %10, %8
%18 = add nsw i32 %4, -1
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds i8, i8* %1, i64 %19
store i8 0, i8* %20
br label %21
21: ; preds = %13, %17, %6
%22 = phi i32 [ %4, %6 ], [ %4, %17 ], [ 1, %13 ]
%23 = tail call i8* @strchr(i8* dereferenceable(1) %1, i8 signext 47)
%24 = icmp eq i8* %23, null
br i1 %24, label %30, label %25
25: ; preds = %21
%26 = load i32, i32* @stderr
%27 = tail call i32 @fprintf(i32 %26, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0))
%28 = load i32, i32* @stderr
%29 = tail call i32 @fflush(i32 %28)
br label %30
30: ; preds = %25, %21
%31 = phi i32 [ 1, %25 ], [ %22, %21 ]
ret i32 %31
}