#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*/ memset(char *, char, int);
int /*<<< orphan*/ printf(char *, char *);
scalar_t__ recv(int, char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ strcmp(char *, char *);
char *strtok(char *, char *);
void readSock(int sock) {
  char buffer[522];
  memset(buffer, '\0', 522);
  if (recv(sock, buffer, 522, 0) > 0) {
    char *pch;
    pch = strtok(buffer, " ");
    if (!strcmp(pch, "NEW")) {
      printf("%s\n", buffer + 4);
    }
  }
}


x86 assembly (clang, -O0):
<readSock>:
push   %rbp
mov    %rsp,%rbp
sub    $0x220,%rsp
mov    %edi,-0x4(%rbp)
lea    -0x210(%rbp),%rdi
xor    %esi,%esi
mov    $0x20a,%edx
call   1050 <memset@plt>
mov    -0x4(%rbp),%edi
lea    -0x210(%rbp),%rsi
mov    $0x20a,%edx
xor    %ecx,%ecx
call   1030 <recv@plt>
cmp    $0x0,%rax
jle    11e3 <readSock+0x93>
lea    -0x210(%rbp),%rdi
lea    0xe61(%rip),%rsi
call   1070 <strtok@plt>
mov    %rax,-0x218(%rbp)
mov    -0x218(%rbp),%rdi
lea    0xe49(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%eax
jne    11de <readSock+0x8e>
lea    -0x210(%rbp),%rsi
add    $0x4,%rsi
lea    0xe2d(%rip),%rdi
call   1040 <printf@plt>
jmp    11e3 <readSock+0x93>
add    $0x220,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<readSock>:
push   %r14
push   %rbx
sub    $0x218,%rsp
mov    %edi,%ebx
mov    %rsp,%r14
mov    %r14,%rdi
xor    %esi,%esi
mov    $0x20a,%edx
call   1050 <memset@plt>
mov    %ebx,%edi
mov    %r14,%rsi
mov    $0x20a,%edx
xor    %ecx,%ecx
call   1030 <recv@plt>
test   %rax,%rax
jle    11b7 <readSock+0x67>
lea    0xe75(%rip),%rsi
mov    %rsp,%rdi
call   1070 <strtok@plt>
lea    0xe68(%rip),%rsi
mov    %rax,%rdi
call   1060 <strcmp@plt>
test   %eax,%eax
jne    11b7 <readSock+0x67>
lea    0x4(%rsp),%rsi
lea    0xe54(%rip),%rdi
call   1040 <printf@plt>
add    $0x218,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [2 x i8] c" \00"
@.str.1 = [4 x i8] c"NEW\00"
@.str.2 = [4 x i8] c"%s\0A\00"
define void @readSock(i32 %0) {
%2 = alloca i32
%3 = alloca [522 x i8]
%4 = alloca i8*
store i32 %0, i32* %2
%5 = getelementptr inbounds [522 x i8], [522 x i8]* %3, i64 0, i64 0
%6 = call i32 @memset(i8* %5, i8 signext 0, i32 522)
%7 = load i32, i32* %2
%8 = getelementptr inbounds [522 x i8], [522 x i8]* %3, i64 0, i64 0
%9 = call i64 @recv(i32 %7, i8* %8, i32 522, i32 0)
%10 = icmp sgt i64 %9, 0
br i1 %10, label %11, label %22
11: ; preds = %1
%12 = getelementptr inbounds [522 x i8], [522 x i8]* %3, i64 0, i64 0
%13 = call i8* @strtok(i8* %12, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i8* %13, i8** %4
%14 = load i8*, i8** %4
%15 = call i32 @strcmp(i8* %14, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%16 = icmp ne i32 %15, 0
br i1 %16, label %21, label %17
17: ; preds = %11
%18 = getelementptr inbounds [522 x i8], [522 x i8]* %3, i64 0, i64 0
%19 = getelementptr inbounds i8, i8* %18, i64 4
%20 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %19)
br label %21
21: ; preds = %17, %11
br label %22
22: ; preds = %21, %1
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c" \00"
@.str.1 = [4 x i8] c"NEW\00"
@.str.2 = [4 x i8] c"%s\0A\00"
define void @readSock(i32 %0) {
%2 = alloca [522 x i8]
%3 = getelementptr inbounds [522 x i8], [522 x i8]* %2, i64 0, i64 0
%4 = call i32 @memset(i8* %3, i8 signext 0, i32 522)
%5 = call i64 @recv(i32 %0, i8* %3, i32 522, i32 0)
%6 = icmp sgt i64 %5, 0
br i1 %6, label %7, label %14
7: ; preds = %1
%8 = call i8* @strtok(i8* %3, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%9 = call i32 @strcmp(i8* dereferenceable(1) %8, i8* dereferenceable(4) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%10 = icmp eq i32 %9, 0
br i1 %10, label %11, label %14
11: ; preds = %7
%12 = getelementptr inbounds [522 x i8], [522 x i8]* %2, i64 0, i64 4
%13 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %12)
br label %14
14: ; preds = %7, %11, %1
ret void
}