#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 */
typedef int /*<<< orphan*/ buf;

/* Variables and functions */
int /*<<< orphan*/ do_get(int, char *);
int /*<<< orphan*/ printf(char *, int, char *);
int read_line(int, char *, int);
char *strchr(char *, char);
scalar_t__ strcmp(char *, char *);
void get_client_data(int client_fd) {
  while (1) {
    char buf[128] = {'\0'};
    int size = read_line(client_fd, buf, sizeof(buf));
    printf("size:%d,read_line = %s", size, buf);
    if (size <= 2)
      break;
    char *p = strchr(buf, ' ');
    if (p) {
      *p++ = '\0';
      if (strcmp("GET", buf) == 0) {
        char *q = strchr(p, ' ');
        if (q) {
          *q = '\0';
          do_get(client_fd, p);
        }
      }
    }
  }
}


x86 assembly (clang, -O0):
<get_client_data>:
push   %rbp
mov    %rsp,%rbp
sub    $0xb0,%rsp
mov    %edi,-0x4(%rbp)
lea    -0x90(%rbp),%rdi
xor    %esi,%esi
mov    $0x80,%edx
call   1050 <memset@plt>
mov    -0x4(%rbp),%edi
lea    -0x90(%rbp),%rsi
mov    $0x80,%edx
call   1070 <read_line@plt>
mov    %eax,-0x94(%rbp)
mov    -0x94(%rbp),%esi
lea    -0x90(%rbp),%rdx
lea    0xe51(%rip),%rdi
call   1040 <printf@plt>
cmpl   $0x2,-0x94(%rbp)
jg     11c6 <get_client_data+0x66>
jmp    126f <get_client_data+0x10f>
lea    -0x90(%rbp),%rdi
mov    $0x20,%esi
call   1030 <strchr@plt>
mov    %rax,-0xa0(%rbp)
cmpq   $0x0,-0xa0(%rbp)
je     126a <get_client_data+0x10a>
mov    -0xa0(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0xa0(%rbp)
movb   $0x0,(%rax)
lea    -0x90(%rbp),%rsi
lea    0xe05(%rip),%rdi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
jne    1265 <get_client_data+0x105>
mov    -0xa0(%rbp),%rdi
mov    $0x20,%esi
call   1030 <strchr@plt>
mov    %rax,-0xa8(%rbp)
cmpq   $0x0,-0xa8(%rbp)
je     1260 <get_client_data+0x100>
mov    -0xa8(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x4(%rbp),%edi
mov    -0xa0(%rbp),%rsi
call   1080 <do_get@plt>
jmp    1265 <get_client_data+0x105>
jmp    126a <get_client_data+0x10a>
jmp    116e <get_client_data+0xe>
add    $0xb0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_client_data>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x80,%rsp
mov    %edi,%r12d
xorps  %xmm0,%xmm0
movaps %xmm0,0x70(%rsp)
movaps %xmm0,0x60(%rsp)
movaps %xmm0,0x50(%rsp)
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
movaps %xmm0,(%rsp)
mov    %rsp,%rbx
mov    %rbx,%rsi
mov    $0x80,%edx
call   1060 <read_line@plt>
mov    %eax,%ebp
lea    0xe5b(%rip),%rdi
mov    %eax,%esi
mov    %rbx,%rdx
call   1040 <printf@plt>
cmp    $0x3,%ebp
jge    11c4 <get_client_data+0x74>
add    $0x80,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %rsp,%rbx
lea    0xe32(%rip),%r14
lea    0xe42(%rip),%r15
jmp    122e <get_client_data+0xde>
nopw   0x0(%rax,%rax,1)
xorps  %xmm0,%xmm0
movaps %xmm0,0x70(%rsp)
movaps %xmm0,0x60(%rsp)
movaps %xmm0,0x50(%rsp)
movaps %xmm0,0x40(%rsp)
movaps %xmm0,0x30(%rsp)
movaps %xmm0,0x20(%rsp)
movaps %xmm0,0x10(%rsp)
movaps %xmm0,(%rsp)
mov    %r12d,%edi
mov    %rbx,%rsi
mov    $0x80,%edx
call   1060 <read_line@plt>
mov    %eax,%ebp
mov    %r14,%rdi
mov    %eax,%esi
mov    %rbx,%rdx
call   1040 <printf@plt>
cmp    $0x2,%ebp
jle    11b4 <get_client_data+0x64>
mov    %rbx,%rdi
mov    $0x20,%esi
call   1030 <strchr@plt>
test   %rax,%rax
je     11e0 <get_client_data+0x90>
mov    %rax,%rbp
movb   $0x0,(%rax)
mov    %r15,%rdi
mov    %rbx,%rsi
call   1050 <strcmp@plt>
test   %rax,%rax
jne    11e0 <get_client_data+0x90>
add    $0x1,%rbp
mov    %rbp,%rdi
mov    $0x20,%esi
call   1030 <strchr@plt>
test   %rax,%rax
je     11e0 <get_client_data+0x90>
movb   $0x0,(%rax)
mov    %r12d,%edi
mov    %rbp,%rsi
call   1070 <do_get@plt>
jmp    11e0 <get_client_data+0x90>

LLVM IR (-O0):
@.str = [23 x i8] c"size:%d,read_line = %s\00"
@.str.1 = [4 x i8] c"GET\00"
define void @get_client_data(i32 %0) {
%2 = alloca i32
%3 = alloca [128 x i8]
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8*
store i32 %0, i32* %2
br label %7
7: ; preds = %1, %41
%8 = bitcast [128 x i8]* %3 to i8*
%9 = load i32, i32* %2
%10 = getelementptr inbounds [128 x i8], [128 x i8]* %3, i64 0, i64 0
%11 = call i32 @read_line(i32 %9, i8* %10, i32 128)
store i32 %11, i32* %4
%12 = load i32, i32* %4
%13 = getelementptr inbounds [128 x i8], [128 x i8]* %3, i64 0, i64 0
%14 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i32 %12, i8* %13)
%15 = load i32, i32* %4
%16 = icmp sle i32 %15, 2
br i1 %16, label %17, label %18
17: ; preds = %7
br label %42
18: ; preds = %7
%19 = getelementptr inbounds [128 x i8], [128 x i8]* %3, i64 0, i64 0
%20 = call i8* @strchr(i8* %19, i8 signext 32)
store i8* %20, i8** %5
%21 = load i8*, i8** %5
%22 = icmp ne i8* %21, null
br i1 %22, label %23, label %41
23: ; preds = %18
%24 = load i8*, i8** %5
%25 = getelementptr inbounds i8, i8* %24, i32 1
store i8* %25, i8** %5
store i8 0, i8* %24
%26 = getelementptr inbounds [128 x i8], [128 x i8]* %3, i64 0, i64 0
%27 = call i64 @strcmp(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %26)
%28 = icmp eq i64 %27, 0
br i1 %28, label %29, label %40
29: ; preds = %23
%30 = load i8*, i8** %5
%31 = call i8* @strchr(i8* %30, i8 signext 32)
store i8* %31, i8** %6
%32 = load i8*, i8** %6
%33 = icmp ne i8* %32, null
br i1 %33, label %34, label %39
34: ; preds = %29
%35 = load i8*, i8** %6
store i8 0, i8* %35
%36 = load i32, i32* %2
%37 = load i8*, i8** %5
%38 = call i32 @do_get(i32 %36, i8* %37)
br label %39
39: ; preds = %34, %29
br label %40
40: ; preds = %39, %23
br label %41
41: ; preds = %40, %18
br label %7
42: ; preds = %17
ret void
}

LLVM IR (-O2):
@.str = [23 x i8] c"size:%d,read_line = %s\00"
@.str.1 = [4 x i8] c"GET\00"
define void @get_client_data(i32 %0) {
%2 = alloca [128 x i8]
%3 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 0
%4 = call i32 @read_line(i32 %0, i8* %3, i32 128)
%5 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i32 %4, i8* %3)
%6 = icmp slt i32 %4, 3
br i1 %6, label %23, label %7
7: ; preds = %1, %19
%8 = call i8* @strchr(i8* %3, i8 signext 32)
%9 = icmp eq i8* %8, null
br i1 %9, label %19, label %10
10: ; preds = %7
%11 = getelementptr inbounds i8, i8* %8, i64 1
store i8 0, i8* %8
%12 = call i64 @strcmp(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i8* %3)
%13 = icmp eq i64 %12, 0
br i1 %13, label %14, label %19
14: ; preds = %10
%15 = call i8* @strchr(i8* %11, i8 signext 32)
%16 = icmp eq i8* %15, null
br i1 %16, label %19, label %17
17: ; preds = %14
store i8 0, i8* %15
%18 = call i32 @do_get(i32 %0, i8* %11)
br label %19
19: ; preds = %7, %10, %17, %14
%20 = call i32 @read_line(i32 %0, i8* %3, i32 128)
%21 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0), i32 %20, i8* %3)
%22 = icmp slt i32 %20, 3
br i1 %22, label %23, label %7
23: ; preds = %19, %1
ret void
}