#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*/ fprintf(int /*<<< orphan*/, char *, char *);
int recv(int, char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ stdout;
void recive(int sockfd, char *buffer) {
  *buffer = 0;
  char lastChar = *buffer;
  char secondLastChar = *buffer;
  char *begin_buffer = buffer;
  int begin_of_line = 1;
  while (!((lastChar == '\r' && secondLastChar == '.') ||
           (lastChar == '.' && secondLastChar == '\n'))) {
    int number = recv(sockfd, buffer, sizeof(char), 0);
    secondLastChar = lastChar;
    lastChar = *buffer;
    if (number == 1)
      buffer++;
  }
  buffer++;
  *buffer = 0;
  fprintf(stdout, "Server -> Client: %s\n", begin_buffer);
}


x86 assembly (clang, -O0):
<recive>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x10(%rbp),%rax
mov    (%rax),%al
mov    %al,-0x11(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%al
mov    %al,-0x12(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
movl   $0x1,-0x24(%rbp)
movsbl -0x11(%rbp),%eax
cmp    $0xd,%eax
jne    1176 <recive+0x56>
movsbl -0x12(%rbp),%ecx
mov    $0x1,%al
cmp    $0x2e,%ecx
mov    %al,-0x29(%rbp)
je     119b <recive+0x7b>
movsbl -0x11(%rbp),%ecx
xor    %eax,%eax
cmp    $0x2e,%ecx
mov    %al,-0x2a(%rbp)
jne    1195 <recive+0x75>
movsbl -0x12(%rbp),%eax
cmp    $0xa,%eax
sete   %al
mov    %al,-0x2a(%rbp)
mov    -0x2a(%rbp),%al
mov    %al,-0x29(%rbp)
mov    -0x29(%rbp),%al
xor    $0xff,%al
test   $0x1,%al
jne    11ad <recive+0x8d>
jmp    11ed <recive+0xcd>
mov    -0x4(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    $0x1,%edx
xor    %ecx,%ecx
call   1030 <recv@plt>
mov    %eax,-0x28(%rbp)
mov    -0x11(%rbp),%al
mov    %al,-0x12(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%al
mov    %al,-0x11(%rbp)
cmpl   $0x1,-0x28(%rbp)
jne    11e8 <recive+0xc8>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    1157 <recive+0x37>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movb   $0x0,(%rax)
mov    0x2dd9(%rip),%rax
mov    (%rax),%edi
mov    -0x20(%rbp),%rdx
lea    0xdec(%rip),%rsi
call   1040 <fprintf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<recive>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %edi,%r15d
movb   $0x0,(%rsi)
xor    %eax,%eax
mov    %rsi,%rbx
xor    %ebp,%ebp
nopw   0x0(%rax,%rax,1)
mov    %ebp,%ecx
mov    %eax,%ebp
cmp    $0xa,%cl
jne    114f <recive+0x2f>
cmp    $0x2e,%bpl
je     1181 <recive+0x61>
mov    %r15d,%edi
mov    %rbx,%rsi
mov    $0x1,%edx
xor    %ecx,%ecx
call   1030 <recv@plt>
xor    %ecx,%ecx
cmp    $0x1,%eax
sete   %cl
add    %rbx,%rcx
movzbl (%rbx),%eax
mov    %rcx,%rbx
cmp    $0x2e,%bpl
jne    1140 <recive+0x20>
mov    %rcx,%rbx
cmp    $0xd,%al
jne    1140 <recive+0x20>
jmp    1184 <recive+0x64>
mov    %rbx,%rcx
movb   $0x0,0x1(%rcx)
mov    0x2e51(%rip),%rax
mov    (%rax),%edi
lea    0xe68(%rip),%rsi
mov    %r14,%rdx
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <fprintf@plt>

LLVM IR (-O0):
@stdout = global i32 0
@.str = [22 x i8] c"Server -> Client: %s\0A\00"
define void @recive(i32 %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i8
%6 = alloca i8
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i32
store i32 %0, i32* %3
store i8* %1, i8** %4
%10 = load i8*, i8** %4
store i8 0, i8* %10
%11 = load i8*, i8** %4
%12 = load i8, i8* %11
store i8 %12, i8* %5
%13 = load i8*, i8** %4
%14 = load i8, i8* %13
store i8 %14, i8* %6
%15 = load i8*, i8** %4
store i8* %15, i8** %7
store i32 1, i32* %8
br label %16
16: ; preds = %49, %2
%17 = load i8, i8* %5
%18 = sext i8 %17 to i32
%19 = icmp eq i32 %18, 13
br i1 %19, label %20, label %24
20: ; preds = %16
%21 = load i8, i8* %6
%22 = sext i8 %21 to i32
%23 = icmp eq i32 %22, 46
br i1 %23, label %34, label %24
24: ; preds = %20, %16
%25 = load i8, i8* %5
%26 = sext i8 %25 to i32
%27 = icmp eq i32 %26, 46
br i1 %27, label %28, label %32
28: ; preds = %24
%29 = load i8, i8* %6
%30 = sext i8 %29 to i32
%31 = icmp eq i32 %30, 10
br label %32
32: ; preds = %28, %24
%33 = phi i1 [ false, %24 ], [ %31, %28 ]
br label %34
34: ; preds = %32, %20
%35 = phi i1 [ true, %20 ], [ %33, %32 ]
%36 = xor i1 %35, true
br i1 %36, label %37, label %50
37: ; preds = %34
%38 = load i32, i32* %3
%39 = load i8*, i8** %4
%40 = call i32 @recv(i32 %38, i8* %39, i32 1, i32 0)
store i32 %40, i32* %9
%41 = load i8, i8* %5
store i8 %41, i8* %6
%42 = load i8*, i8** %4
%43 = load i8, i8* %42
store i8 %43, i8* %5
%44 = load i32, i32* %9
%45 = icmp eq i32 %44, 1
br i1 %45, label %46, label %49
46: ; preds = %37
%47 = load i8*, i8** %4
%48 = getelementptr inbounds i8, i8* %47, i32 1
store i8* %48, i8** %4
br label %49
49: ; preds = %46, %37
br label %16
50: ; preds = %34
%51 = load i8*, i8** %4
%52 = getelementptr inbounds i8, i8* %51, i32 1
store i8* %52, i8** %4
%53 = load i8*, i8** %4
store i8 0, i8* %53
%54 = load i32, i32* @stdout
%55 = load i8*, i8** %7
%56 = call i32 @fprintf(i32 %54, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i8* %55)
ret void
}

LLVM IR (-O2):
@stdout = global i32 0
@.str = [22 x i8] c"Server -> Client: %s\0A\00"
define void @recive(i32 %0, i8* %1) {
store i8 0, i8* %1
br label %3
3: ; preds = %2, %10
%4 = phi i8* [ %1, %2 ], [ %15, %10 ]
%5 = phi i8 [ 0, %2 ], [ %12, %10 ]
%6 = phi i8 [ 0, %2 ], [ %5, %10 ]
%7 = icmp eq i8 %5, 46
%8 = icmp eq i8 %6, 10
%9 = and i1 %8, %7
br i1 %9, label %18, label %10
10: ; preds = %3
%11 = tail call i32 @recv(i32 %0, i8* %4, i32 1, i32 0)
%12 = load i8, i8* %4
%13 = icmp eq i32 %11, 1
%14 = zext i1 %13 to i64
%15 = getelementptr i8, i8* %4, i64 %14
%16 = icmp eq i8 %12, 13
%17 = and i1 %7, %16
br i1 %17, label %18, label %3
18: ; preds = %10, %3
%19 = phi i8* [ %15, %10 ], [ %4, %3 ]
%20 = getelementptr inbounds i8, i8* %19, i64 1
store i8 0, i8* %20
%21 = load i32, i32* @stdout
%22 = tail call i32 @fprintf(i32 %21, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i8* %1)
ret void
}