#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__ EINTR;
int /*<<< orphan*/ close(int);
scalar_t__ errno;
int /*<<< orphan*/ free(int *);
int /*<<< orphan*/ printf(char *, ...);
int read(int, char *, int);
char *strerror(scalar_t__);
void *deal_read(void *sockfd) {
  int *p;
  p = (int *)sockfd;
  int confd = *p;
  free(p);
  int n;
  char buff[2048] = {0};
  char *username;
again:
  while ((n = read(confd, buff, 2048)) > 0) {
    if (n <= 20) {
      printf("read error,receive date not enough\n");
      continue;
    }
    username = buff;
    int i;
    for (i = 0; i < 20; i++) {
      if (buff[i] == ' ') {
        buff[i] = '\0';
        break;
      }
    }
    char *p = buff + 20;
    printf("%s : %s\n", username, p);
  }
  if (n < 0 && errno == EINTR)
    goto again;
  else if (n < 0)
    printf("read error, %s\n", strerror(errno));
  close(confd);
  return NULL;
}


x86 assembly (clang, -O0):
<deal_read>:
push   %rbp
mov    %rsp,%rbp
sub    $0x840,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
lea    -0x820(%rbp),%rdi
xor    %esi,%esi
mov    $0x800,%edx
call   1050 <memset@plt>
jmp    11a1 <deal_read+0x41>
mov    -0x14(%rbp),%edi
lea    -0x820(%rbp),%rsi
mov    $0x800,%edx
call   1070 <read@plt>
mov    %eax,-0x18(%rbp)
cmp    $0x0,%eax
jle    127b <deal_read+0x11b>
cmpl   $0x14,-0x18(%rbp)
jg     11de <deal_read+0x7e>
lea    0xe2e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11a1 <deal_read+0x41>
lea    -0x820(%rbp),%rax
mov    %rax,-0x828(%rbp)
movl   $0x0,-0x82c(%rbp)
cmpl   $0x14,-0x82c(%rbp)
jge    1248 <deal_read+0xe8>
movslq -0x82c(%rbp),%rax
movsbl -0x820(%rbp,%rax,1),%eax
ff
cmp    $0x20,%eax
jne    122f <deal_read+0xcf>
movslq -0x82c(%rbp),%rax
movb   $0x0,-0x820(%rbp,%rax,1)
jmp    1248 <deal_read+0xe8>
jmp    1234 <deal_read+0xd4>
mov    -0x82c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x82c(%rbp)
jmp    11f6 <deal_read+0x96>
lea    -0x820(%rbp),%rax
add    $0x14,%rax
mov    %rax,-0x838(%rbp)
mov    -0x828(%rbp),%rsi
mov    -0x838(%rbp),%rdx
lea    0xdb5(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11a1 <deal_read+0x41>
cmpl   $0x0,-0x18(%rbp)
jge    12a4 <deal_read+0x144>
mov    0x2d54(%rip),%rax
mov    (%rax),%rax
mov    0x2d42(%rip),%rcx
cmp    (%rcx),%rax
jne    12a4 <deal_read+0x144>
jmp    119c <deal_read+0x3c>
cmpl   $0x0,-0x18(%rbp)
jge    12ce <deal_read+0x16e>
mov    0x2d2b(%rip),%rax
mov    (%rax),%rdi
call   1080 <strerror@plt>
mov    %rax,%rsi
lea    0xd66(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    12d3 <deal_read+0x173>
mov    -0x14(%rbp),%edi
call   1060 <close@plt>
xor    %eax,%eax
add    $0x840,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<deal_read>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x808,%rsp
mov    (%rdi),%ebx
call   1030 <free@plt>
mov    %rsp,%r14
mov    $0x800,%edx
mov    %r14,%rdi
xor    %esi,%esi
call   1060 <memset@plt>
lea    0x14(%rsp),%r15
lea    0xe73(%rip),%r12
lea    0xe53(%rip),%r13
mov    0x2e24(%rip),%rbp
jmp    11c8 <deal_read+0x58>
cs nopw 0x0(%rax,%rax,1)
mov    %r12,%rdi
call   1040 <puts@plt>
mov    %ebx,%edi
mov    %r14,%rsi
mov    $0x800,%edx
call   1080 <read@plt>
test   %eax,%eax
jle    1329 <deal_read+0x1b9>
cmp    $0x15,%eax
jb     11c0 <deal_read+0x50>
cmpb   $0x20,(%rsp)
jne    1200 <deal_read+0x90>
xor    %eax,%eax
jmp    1310 <deal_read+0x1a0>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    $0x1,%eax
cmpb   $0x20,0x1(%rsp)
je     1310 <deal_read+0x1a0>
mov    $0x2,%eax
cmpb   $0x20,0x2(%rsp)
je     1310 <deal_read+0x1a0>
mov    $0x3,%eax
cmpb   $0x20,0x3(%rsp)
je     1310 <deal_read+0x1a0>
mov    $0x4,%eax
cmpb   $0x20,0x4(%rsp)
je     1310 <deal_read+0x1a0>
mov    $0x5,%eax
cmpb   $0x20,0x5(%rsp)
je     1310 <deal_read+0x1a0>
mov    $0x6,%eax
cmpb   $0x20,0x6(%rsp)
je     1310 <deal_read+0x1a0>
mov    $0x7,%eax
cmpb   $0x20,0x7(%rsp)
je     1310 <deal_read+0x1a0>
mov    $0x8,%eax
cmpb   $0x20,0x8(%rsp)
je     1310 <deal_read+0x1a0>
mov    $0x9,%eax
cmpb   $0x20,0x9(%rsp)
je     1310 <deal_read+0x1a0>
mov    $0xa,%eax
cmpb   $0x20,0xa(%rsp)
je     1310 <deal_read+0x1a0>
mov    $0xb,%eax
cmpb   $0x20,0xb(%rsp)
je     1310 <deal_read+0x1a0>
mov    $0xc,%eax
cmpb   $0x20,0xc(%rsp)
je     1310 <deal_read+0x1a0>
mov    $0xd,%eax
cmpb   $0x20,0xd(%rsp)
je     1310 <deal_read+0x1a0>
mov    $0xe,%eax
cmpb   $0x20,0xe(%rsp)
je     1310 <deal_read+0x1a0>
mov    $0xf,%eax
cmpb   $0x20,0xf(%rsp)
je     1310 <deal_read+0x1a0>
mov    $0x10,%eax
cmpb   $0x20,0x10(%rsp)
je     1310 <deal_read+0x1a0>
mov    $0x11,%eax
cmpb   $0x20,0x11(%rsp)
je     1310 <deal_read+0x1a0>
mov    $0x12,%eax
cmpb   $0x20,0x12(%rsp)
je     1310 <deal_read+0x1a0>
mov    $0x13,%eax
cmpb   $0x20,0x13(%rsp)
jne    1314 <deal_read+0x1a4>
nopl   0x0(%rax,%rax,1)
movb   $0x0,(%rsp,%rax,1)
mov    %r13,%rdi
mov    %r14,%rsi
mov    %r15,%rdx
xor    %eax,%eax
call   1050 <printf@plt>
jmp    11c8 <deal_read+0x58>
test   %eax,%eax
jns    1357 <deal_read+0x1e7>
mov    0x2cac(%rip),%rax
mov    (%rax),%rdi
cmp    0x0(%rbp),%rdi
je     11c8 <deal_read+0x58>
call   1090 <strerror@plt>
lea    0xcbc(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %ebx,%edi
call   1070 <close@plt>
xor    %eax,%eax
add    $0x808,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [36 x i8] c"read error,receive date not enough\0A\00"
@.str.1 = [9 x i8] c"%s : %s\0A\00"
@errno = global i64 0
@EINTR = global i64 0
@.str.2 = [16 x i8] c"read error, %s\0A\00"
define i8* @deal_read(i8* %0) {
%2 = alloca i8*
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i32
%6 = alloca [2048 x i8]
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i8*
store i8* %0, i8** %2
%10 = load i8*, i8** %2
%11 = bitcast i8* %10 to i32*
store i32* %11, i32** %3
%12 = load i32*, i32** %3
%13 = load i32, i32* %12
store i32 %13, i32* %4
%14 = load i32*, i32** %3
%15 = call i32 @free(i32* %14)
%16 = bitcast [2048 x i8]* %6 to i8*
br label %17
17: ; preds = %61, %1
br label %18
18: ; preds = %48, %26, %17
%19 = load i32, i32* %4
%20 = getelementptr inbounds [2048 x i8], [2048 x i8]* %6, i64 0, i64 0
%21 = call i32 @read(i32 %19, i8* %20, i32 2048)
store i32 %21, i32* %5
%22 = icmp sgt i32 %21, 0
br i1 %22, label %23, label %54
23: ; preds = %18
%24 = load i32, i32* %5
%25 = icmp sle i32 %24, 20
br i1 %25, label %26, label %28
26: ; preds = %23
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str, i64 0, i64 0))
br label %18
28: ; preds = %23
%29 = getelementptr inbounds [2048 x i8], [2048 x i8]* %6, i64 0, i64 0
store i8* %29, i8** %7
store i32 0, i32* %8
br label %30
30: ; preds = %45, %28
%31 = load i32, i32* %8
%32 = icmp slt i32 %31, 20
br i1 %32, label %33, label %48
33: ; preds = %30
%34 = load i32, i32* %8
%35 = sext i32 %34 to i64
%36 = getelementptr inbounds [2048 x i8], [2048 x i8]* %6, i64 0, i64 %35
%37 = load i8, i8* %36
%38 = sext i8 %37 to i32
%39 = icmp eq i32 %38, 32
br i1 %39, label %40, label %44
40: ; preds = %33
%41 = load i32, i32* %8
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds [2048 x i8], [2048 x i8]* %6, i64 0, i64 %42
store i8 0, i8* %43
br label %48
44: ; preds = %33
br label %45
45: ; preds = %44
%46 = load i32, i32* %8
%47 = add nsw i32 %46, 1
store i32 %47, i32* %8
br label %30
48: ; preds = %40, %30
%49 = getelementptr inbounds [2048 x i8], [2048 x i8]* %6, i64 0, i64 0
%50 = getelementptr inbounds i8, i8* %49, i64 20
store i8* %50, i8** %9
%51 = load i8*, i8** %7
%52 = load i8*, i8** %9
%53 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8* %51, i8* %52)
br label %18
54: ; preds = %18
%55 = load i32, i32* %5
%56 = icmp slt i32 %55, 0
br i1 %56, label %57, label %62
57: ; preds = %54
%58 = load i64, i64* @errno
%59 = load i64, i64* @EINTR
%60 = icmp eq i64 %58, %59
br i1 %60, label %61, label %62
61: ; preds = %57
br label %17
62: ; preds = %57, %54
%63 = load i32, i32* %5
%64 = icmp slt i32 %63, 0
br i1 %64, label %65, label %69
65: ; preds = %62
%66 = load i64, i64* @errno
%67 = call i8* @strerror(i64 %66)
%68 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i8* %67)
br label %69
69: ; preds = %65, %62
br label %70
70: ; preds = %69
%71 = load i32, i32* %4
%72 = call i32 @close(i32 %71)
ret i8* null
}

LLVM IR (-O2):
@.str.1 = [9 x i8] c"%s : %s\0A\00"
@errno = global i64 0
@EINTR = global i64 0
@.str.2 = [16 x i8] c"read error, %s\0A\00"
@str = [35 x i8] c"read error,receive date not enough\00"
define noalias i8* @deal_read(i8* nocapture %0) {
%2 = alloca [2048 x i8]
%3 = bitcast i8* %0 to i32*
%4 = load i32, i32* %3
%5 = tail call i32 @free(i32* %3)
%6 = getelementptr inbounds [2048 x i8], [2048 x i8]* %2, i64 0, i64 0
%7 = getelementptr inbounds [2048 x i8], [2048 x i8]* %2, i64 0, i64 20
%8 = getelementptr inbounds [2048 x i8], [2048 x i8]* %2, i64 0, i64 1
%9 = getelementptr inbounds [2048 x i8], [2048 x i8]* %2, i64 0, i64 2
%10 = getelementptr inbounds [2048 x i8], [2048 x i8]* %2, i64 0, i64 3
%11 = getelementptr inbounds [2048 x i8], [2048 x i8]* %2, i64 0, i64 4
%12 = getelementptr inbounds [2048 x i8], [2048 x i8]* %2, i64 0, i64 5
%13 = getelementptr inbounds [2048 x i8], [2048 x i8]* %2, i64 0, i64 6
%14 = getelementptr inbounds [2048 x i8], [2048 x i8]* %2, i64 0, i64 7
%15 = getelementptr inbounds [2048 x i8], [2048 x i8]* %2, i64 0, i64 8
%16 = getelementptr inbounds [2048 x i8], [2048 x i8]* %2, i64 0, i64 9
%17 = getelementptr inbounds [2048 x i8], [2048 x i8]* %2, i64 0, i64 10
%18 = getelementptr inbounds [2048 x i8], [2048 x i8]* %2, i64 0, i64 11
%19 = getelementptr inbounds [2048 x i8], [2048 x i8]* %2, i64 0, i64 12
%20 = getelementptr inbounds [2048 x i8], [2048 x i8]* %2, i64 0, i64 13
%21 = getelementptr inbounds [2048 x i8], [2048 x i8]* %2, i64 0, i64 14
%22 = getelementptr inbounds [2048 x i8], [2048 x i8]* %2, i64 0, i64 15
%23 = getelementptr inbounds [2048 x i8], [2048 x i8]* %2, i64 0, i64 16
%24 = getelementptr inbounds [2048 x i8], [2048 x i8]* %2, i64 0, i64 17
%25 = getelementptr inbounds [2048 x i8], [2048 x i8]* %2, i64 0, i64 18
%26 = getelementptr inbounds [2048 x i8], [2048 x i8]* %2, i64 0, i64 19
br label %27
27: ; preds = %106, %1
%28 = call i32 @read(i32 %4, i8* %6, i32 2048)
%29 = icmp sgt i32 %28, 0
br i1 %29, label %30, label %103
30: ; preds = %27, %38
%31 = phi i32 [ %39, %38 ], [ %28, %27 ]
%32 = icmp ult i32 %31, 21
br i1 %32, label %36, label %33
33: ; preds = %30
%34 = load i8, i8* %6
%35 = icmp eq i8 %34, 32
br i1 %35, label %41, label %44
36: ; preds = %30
%37 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @str, i64 0, i64 0))
br label %38
38: ; preds = %36, %101
%39 = call i32 @read(i32 %4, i8* %6, i32 2048)
%40 = icmp sgt i32 %39, 0
br i1 %40, label %30, label %103
41: ; preds = %98, %95, %92, %89, %86, %83, %80, %77, %74, %71, %68, %65, %62, %59, %56, %53, %50, %47, %44, %33
%42 = phi i64 [ 0, %33 ], [ 1, %44 ], [ 2, %47 ], [ 3, %50 ], [ 4, %53 ], [ 5, %56 ], [ 6, %59 ], [ 7, %62 ], [ 8, %65 ], [ 9, %68 ], [ 10, %71 ], [ 11, %74 ], [ 12, %77 ], [ 13, %80 ], [ 14, %83 ], [ 15, %86 ], [ 16, %89 ], [ 17, %92 ], [ 18, %95 ], [ 19, %98 ]
%43 = getelementptr inbounds [2048 x i8], [2048 x i8]* %2, i64 0, i64 %42
store i8 0, i8* %43
br label %101
44: ; preds = %33
%45 = load i8, i8* %8
%46 = icmp eq i8 %45, 32
br i1 %46, label %41, label %47
47: ; preds = %44
%48 = load i8, i8* %9
%49 = icmp eq i8 %48, 32
br i1 %49, label %41, label %50
50: ; preds = %47
%51 = load i8, i8* %10
%52 = icmp eq i8 %51, 32
br i1 %52, label %41, label %53
53: ; preds = %50
%54 = load i8, i8* %11
%55 = icmp eq i8 %54, 32
br i1 %55, label %41, label %56
56: ; preds = %53
%57 = load i8, i8* %12
%58 = icmp eq i8 %57, 32
br i1 %58, label %41, label %59
59: ; preds = %56
%60 = load i8, i8* %13
%61 = icmp eq i8 %60, 32
br i1 %61, label %41, label %62
62: ; preds = %59
%63 = load i8, i8* %14
%64 = icmp eq i8 %63, 32
br i1 %64, label %41, label %65
65: ; preds = %62
%66 = load i8, i8* %15
%67 = icmp eq i8 %66, 32
br i1 %67, label %41, label %68
68: ; preds = %65
%69 = load i8, i8* %16
%70 = icmp eq i8 %69, 32
br i1 %70, label %41, label %71
71: ; preds = %68
%72 = load i8, i8* %17
%73 = icmp eq i8 %72, 32
br i1 %73, label %41, label %74
74: ; preds = %71
%75 = load i8, i8* %18
%76 = icmp eq i8 %75, 32
br i1 %76, label %41, label %77
77: ; preds = %74
%78 = load i8, i8* %19
%79 = icmp eq i8 %78, 32
br i1 %79, label %41, label %80
80: ; preds = %77
%81 = load i8, i8* %20
%82 = icmp eq i8 %81, 32
br i1 %82, label %41, label %83
83: ; preds = %80
%84 = load i8, i8* %21
%85 = icmp eq i8 %84, 32
br i1 %85, label %41, label %86
86: ; preds = %83
%87 = load i8, i8* %22
%88 = icmp eq i8 %87, 32
br i1 %88, label %41, label %89
89: ; preds = %86
%90 = load i8, i8* %23
%91 = icmp eq i8 %90, 32
br i1 %91, label %41, label %92
92: ; preds = %89
%93 = load i8, i8* %24
%94 = icmp eq i8 %93, 32
br i1 %94, label %41, label %95
95: ; preds = %92
%96 = load i8, i8* %25
%97 = icmp eq i8 %96, 32
br i1 %97, label %41, label %98
98: ; preds = %95
%99 = load i8, i8* %26
%100 = icmp eq i8 %99, 32
br i1 %100, label %41, label %101
101: ; preds = %98, %41
%102 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i8* %6, i8* %7)
br label %38
103: ; preds = %38, %27
%104 = phi i32 [ %28, %27 ], [ %39, %38 ]
%105 = icmp slt i32 %104, 0
br i1 %105, label %106, label %113
106: ; preds = %103
%107 = load i64, i64* @errno
%108 = load i64, i64* @EINTR
%109 = icmp eq i64 %107, %108
br i1 %109, label %27, label %110
110: ; preds = %106
%111 = call i8* @strerror(i64 %107)
%112 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.2, i64 0, i64 0), i8* %111)
br label %113
113: ; preds = %103, %110
%114 = call i32 @close(i32 %4)
ret i8* null
}