struct operation *demarshal_msg(int sockfd) {
  char curr_char;
  int count = 0;
  int i;
  char *msg = malloc(1024);
  struct operation *marshal_msg;
  int *status = malloc(sizeof(int));
  recv(sockfd, &curr_char, 1, 0);
  if (curr_char == 'E') {
    printf("END\n");
    exit(0);
  } else {
    msg[count] = curr_char;
    count++;
    i = 0;
    for (i = 0; i < 3; i++) {
      while (1) {
        recv(sockfd, &curr_char, 1, 0);
        msg[count] = curr_char;
        count++;
        if (curr_char == ' ') {
          break;
        }
      }
    }
    while (1) {
      recv(sockfd, &curr_char, 1, 0);
      if (curr_char == '\r') {
        msg[count] = curr_char;
        count++;
        recv(sockfd, &curr_char, 1, 0);
        if (curr_char == '\n') {
          msg[count] = curr_char;
          count++;
          break;
        }
      } else {
        msg[count] = curr_char;
      }
      count++;
    }
  }
  gwkv_demarshal_client(msg, &marshal_msg, status);
  free(status);
  free(msg);
  return marshal_msg;
}


x86 assembly (clang, -O0):
<demarshal_msg>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x0,-0xc(%rbp)
mov    $0x400,%edi
call   1060 <malloc@plt>
mov    %rax,-0x18(%rbp)
mov    $0x4,%edi
call   1060 <malloc@plt>
mov    %rax,-0x28(%rbp)
mov    -0x4(%rbp),%edi
lea    -0x5(%rbp),%rsi
mov    $0x1,%edx
xor    %ecx,%ecx
mov    $0x0,%al
call   1040 <recv@plt>
movsbl -0x5(%rbp),%eax
cmp    $0x45,%eax
jne    11c5 <demarshal_msg+0x65>
lea    0xe49(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
xor    %edi,%edi
call   1080 <exit@plt>
mov    -0x5(%rbp),%dl
mov    -0x18(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
movl   $0x0,-0x10(%rbp)
cmpl   $0x3,-0x10(%rbp)
jge    124f <demarshal_msg+0xef>
jmp    11f9 <demarshal_msg+0x99>
mov    -0x4(%rbp),%edi
lea    -0x5(%rbp),%rsi
mov    $0x1,%edx
xor    %ecx,%ecx
mov    $0x0,%al
call   1040 <recv@plt>
mov    -0x5(%rbp),%dl
mov    -0x18(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
movsbl -0x5(%rbp),%eax
cmp    $0x20,%eax
jne    1237 <demarshal_msg+0xd7>
jmp    123c <demarshal_msg+0xdc>
jmp    11f9 <demarshal_msg+0x99>
jmp    1241 <demarshal_msg+0xe1>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    11ea <demarshal_msg+0x8a>
jmp    1254 <demarshal_msg+0xf4>
mov    -0x4(%rbp),%edi
lea    -0x5(%rbp),%rsi
mov    $0x1,%edx
xor    %ecx,%ecx
mov    $0x0,%al
call   1040 <recv@plt>
movsbl -0x5(%rbp),%eax
cmp    $0xd,%eax
jne    12d0 <demarshal_msg+0x170>
mov    -0x5(%rbp),%dl
mov    -0x18(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
mov    -0x4(%rbp),%edi
lea    -0x5(%rbp),%rsi
mov    $0x1,%edx
xor    %ecx,%ecx
mov    $0x0,%al
call   1040 <recv@plt>
movsbl -0x5(%rbp),%eax
cmp    $0xa,%eax
jne    12cb <demarshal_msg+0x16b>
mov    -0x5(%rbp),%dl
mov    -0x18(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    12ec <demarshal_msg+0x18c>
jmp    12de <demarshal_msg+0x17e>
mov    -0x5(%rbp),%dl
mov    -0x18(%rbp),%rax
movslq -0xc(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1254 <demarshal_msg+0xf4>
jmp    12f1 <demarshal_msg+0x191>
mov    -0x18(%rbp),%rdi
mov    -0x28(%rbp),%rdx
lea    -0x20(%rbp),%rsi
mov    $0x0,%al
call   1070 <gwkv_demarshal_client@plt>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
mov    -0x20(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<demarshal_msg>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %edi,%r13d
mov    $0x400,%edi
call   1060 <malloc@plt>
mov    %rax,%r15
mov    $0x4,%edi
call   1060 <malloc@plt>
mov    %rax,%rbx
lea    0x7(%rsp),%rsi
mov    %r13d,%edi
mov    $0x1,%edx
xor    %ecx,%ecx
xor    %eax,%eax
call   1040 <recv@plt>
mov    0x7(%rsp),%al
cmp    $0x45,%al
je     1308 <demarshal_msg+0x1a8>
mov    %rbx,0x8(%rsp)
mov    %al,(%r15)
mov    $0x1,%ebx
lea    0x7(%rsp),%r12
nop
mov    %r13d,%edi
mov    %r12,%rsi
mov    $0x1,%edx
xor    %ecx,%ecx
xor    %eax,%eax
call   1040 <recv@plt>
movzbl 0x7(%rsp),%eax
mov    %al,(%r15,%rbx,1)
add    $0x1,%rbx
cmp    $0x20,%al
jne    11c0 <demarshal_msg+0x60>
movslq %ebx,%rbp
add    %r15,%rbp
lea    0x7(%rsp),%r12
xor    %r14d,%r14d
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %r13d,%edi
mov    %r12,%rsi
mov    $0x1,%edx
xor    %ecx,%ecx
xor    %eax,%eax
call   1040 <recv@plt>
movzbl 0x7(%rsp),%eax
mov    %al,0x0(%rbp,%r14,1)
add    $0x1,%r14
cmp    $0x20,%al
jne    1200 <demarshal_msg+0xa0>
add    %r14,%rbx
movslq %ebx,%rax
mov    %r15,%rbp
add    %rax,%rbp
lea    0x7(%rsp),%r12
nopw   0x0(%rax,%rax,1)
mov    %r13d,%edi
mov    %r12,%rsi
mov    $0x1,%edx
xor    %ecx,%ecx
xor    %eax,%eax
call   1040 <recv@plt>
movzbl 0x7(%rsp),%eax
mov    %al,0x0(%rbp)
add    $0x1,%ebx
add    $0x1,%rbp
cmp    $0x20,%al
jne    1240 <demarshal_msg+0xe0>
lea    0x7(%rsp),%r12
mov    0x8(%rsp),%r14
jmp    1287 <demarshal_msg+0x127>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %al,(%r15,%rbp,1)
add    $0x1,%ebx
mov    %r13d,%edi
mov    %r12,%rsi
mov    $0x1,%edx
xor    %ecx,%ecx
xor    %eax,%eax
call   1040 <recv@plt>
movzbl 0x7(%rsp),%eax
movslq %ebx,%rbp
cmp    $0xd,%al
jne    1280 <demarshal_msg+0x120>
movb   $0xd,(%r15,%rbp,1)
add    $0x1,%rbp
mov    %r13d,%edi
mov    %r12,%rsi
mov    $0x1,%edx
xor    %ecx,%ecx
xor    %eax,%eax
call   1040 <recv@plt>
cmpb   $0xa,0x7(%rsp)
mov    %ebp,%ebx
jne    1284 <demarshal_msg+0x124>
movb   $0xa,(%r15,%rbp,1)
lea    0x10(%rsp),%rsi
mov    %r15,%rdi
mov    %r14,%rdx
xor    %eax,%eax
call   1070 <gwkv_demarshal_client@plt>
mov    %r14,%rdi
call   1030 <free@plt>
mov    %r15,%rdi
call   1030 <free@plt>
mov    0x10(%rsp),%rax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xcf1(%rip),%rdi
call   1050 <puts@plt>
xor    %edi,%edi
call   1080 <exit@plt>

LLVM IR (-O0):
%struct.operation = type opaque
@.str = [5 x i8] c"END\0A\00"
define %struct.operation* @demarshal_msg(i32 %0) {
%2 = alloca i32
%3 = alloca i8
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8*
%7 = alloca %struct.operation*
%8 = alloca i32*
store i32 %0, i32* %2
store i32 0, i32* %4
%9 = call i8* @malloc(i64 1024)
store i8* %9, i8** %6
%10 = call i8* @malloc(i64 4)
%11 = bitcast i8* %10 to i32*
store i32* %11, i32** %8
%12 = load i32, i32* %2
%13 = call i32 (i32, i8*, i32, i32, ...) bitcast (i32 (...)* @recv to i32 (i32, i8*, i32, i32, ...)*)(i32 %12, i8* %3, i32 1, i32 0)
%14 = load i8, i8* %3
%15 = sext i8 %14 to i32
%16 = icmp eq i32 %15, 69
br i1 %16, label %17, label %19
17: ; preds = %1
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
unreachable
19: ; preds = %1
%20 = load i8, i8* %3
%21 = load i8*, i8** %6
%22 = load i32, i32* %4
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds i8, i8* %21, i64 %23
store i8 %20, i8* %24
%25 = load i32, i32* %4
%26 = add nsw i32 %25, 1
store i32 %26, i32* %4
store i32 0, i32* %5
store i32 0, i32* %5
br label %27
27: ; preds = %47, %19
%28 = load i32, i32* %5
%29 = icmp slt i32 %28, 3
br i1 %29, label %30, label %50
30: ; preds = %27
br label %31
31: ; preds = %30, %45
%32 = load i32, i32* %2
%33 = call i32 (i32, i8*, i32, i32, ...) bitcast (i32 (...)* @recv to i32 (i32, i8*, i32, i32, ...)*)(i32 %32, i8* %3, i32 1, i32 0)
%34 = load i8, i8* %3
%35 = load i8*, i8** %6
%36 = load i32, i32* %4
%37 = sext i32 %36 to i64
%38 = getelementptr inbounds i8, i8* %35, i64 %37
store i8 %34, i8* %38
%39 = load i32, i32* %4
%40 = add nsw i32 %39, 1
store i32 %40, i32* %4
%41 = load i8, i8* %3
%42 = sext i8 %41 to i32
%43 = icmp eq i32 %42, 32
br i1 %43, label %44, label %45
44: ; preds = %31
br label %46
45: ; preds = %31
br label %31
46: ; preds = %44
br label %47
47: ; preds = %46
%48 = load i32, i32* %5
%49 = add nsw i32 %48, 1
store i32 %49, i32* %5
br label %27
50: ; preds = %27
br label %51
51: ; preds = %50, %85
%52 = load i32, i32* %2
%53 = call i32 (i32, i8*, i32, i32, ...) bitcast (i32 (...)* @recv to i32 (i32, i8*, i32, i32, ...)*)(i32 %52, i8* %3, i32 1, i32 0)
%54 = load i8, i8* %3
%55 = sext i8 %54 to i32
%56 = icmp eq i32 %55, 13
br i1 %56, label %57, label %79
57: ; preds = %51
%58 = load i8, i8* %3
%59 = load i8*, i8** %6
%60 = load i32, i32* %4
%61 = sext i32 %60 to i64
%62 = getelementptr inbounds i8, i8* %59, i64 %61
store i8 %58, i8* %62
%63 = load i32, i32* %4
%64 = add nsw i32 %63, 1
store i32 %64, i32* %4
%65 = load i32, i32* %2
%66 = call i32 (i32, i8*, i32, i32, ...) bitcast (i32 (...)* @recv to i32 (i32, i8*, i32, i32, ...)*)(i32 %65, i8* %3, i32 1, i32 0)
%67 = load i8, i8* %3
%68 = sext i8 %67 to i32
%69 = icmp eq i32 %68, 10
br i1 %69, label %70, label %78
70: ; preds = %57
%71 = load i8, i8* %3
%72 = load i8*, i8** %6
%73 = load i32, i32* %4
%74 = sext i32 %73 to i64
%75 = getelementptr inbounds i8, i8* %72, i64 %74
store i8 %71, i8* %75
%76 = load i32, i32* %4
%77 = add nsw i32 %76, 1
store i32 %77, i32* %4
br label %88
78: ; preds = %57
br label %85
79: ; preds = %51
%80 = load i8, i8* %3
%81 = load i8*, i8** %6
%82 = load i32, i32* %4
%83 = sext i32 %82 to i64
%84 = getelementptr inbounds i8, i8* %81, i64 %83
store i8 %80, i8* %84
br label %85
85: ; preds = %79, %78
%86 = load i32, i32* %4
%87 = add nsw i32 %86, 1
store i32 %87, i32* %4
br label %51
88: ; preds = %70
br label %89
89: ; preds = %88
%90 = load i8*, i8** %6
%91 = load i32*, i32** %8
%92 = call i32 (i8*, %struct.operation**, i32*, ...) bitcast (i32 (...)* @gwkv_demarshal_client to i32 (i8*, %struct.operation**, i32*, ...)*)(i8* %90, %struct.operation** %7, i32* %91)
%93 = load i32*, i32** %8
%94 = bitcast i32* %93 to i8*
%95 = load i8*, i8** %6
%96 = load %struct.operation*, %struct.operation** %7
ret %struct.operation* %96
}

LLVM IR (-O2):
%struct.operation = type opaque
@str = [4 x i8] c"END\00"
define %struct.operation* @demarshal_msg(i32 %0) {
%2 = alloca i8
%3 = alloca %struct.operation*
%4 = tail call dereferenceable_or_null(1024) i8* @malloc(i64 1024)
%5 = bitcast %struct.operation** %3 to i8*
%6 = tail call dereferenceable_or_null(4) i8* @malloc(i64 4)
%7 = call i32 (i32, i8*, i32, i32, ...) bitcast (i32 (...)* @recv to i32 (i32, i8*, i32, i32, ...)*)(i32 %0, i8* %2, i32 1, i32 0)
%8 = load i8, i8* %2
%9 = icmp eq i8 %8, 69
br i1 %9, label %10, label %12
10: ; preds = %1
%11 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @str, i64 0, i64 0))
unreachable
12: ; preds = %1
store i8 %8, i8* %4
br label %13
13: ; preds = %12, %13
%14 = phi i64 [ 1, %12 ], [ %18, %13 ]
%15 = call i32 (i32, i8*, i32, i32, ...) bitcast (i32 (...)* @recv to i32 (i32, i8*, i32, i32, ...)*)(i32 %0, i8* %2, i32 1, i32 0)
%16 = load i8, i8* %2
%17 = getelementptr inbounds i8, i8* %4, i64 %14
store i8 %16, i8* %17
%18 = add i64 %14, 1
%19 = icmp eq i8 %16, 32
br i1 %19, label %20, label %13
20: ; preds = %13
%21 = shl i64 %18, 32
%22 = ashr exact i64 %21, 32
br label %23
23: ; preds = %23, %20
%24 = phi i64 [ %22, %20 ], [ %28, %23 ]
%25 = call i32 (i32, i8*, i32, i32, ...) bitcast (i32 (...)* @recv to i32 (i32, i8*, i32, i32, ...)*)(i32 %0, i8* %2, i32 1, i32 0)
%26 = load i8, i8* %2
%27 = getelementptr inbounds i8, i8* %4, i64 %24
store i8 %26, i8* %27
%28 = add i64 %24, 1
%29 = icmp eq i8 %26, 32
br i1 %29, label %30, label %23
30: ; preds = %23
%31 = shl i64 %28, 32
%32 = ashr exact i64 %31, 32
br label %33
33: ; preds = %33, %30
%34 = phi i64 [ %32, %30 ], [ %38, %33 ]
%35 = call i32 (i32, i8*, i32, i32, ...) bitcast (i32 (...)* @recv to i32 (i32, i8*, i32, i32, ...)*)(i32 %0, i8* %2, i32 1, i32 0)
%36 = load i8, i8* %2
%37 = getelementptr inbounds i8, i8* %4, i64 %34
store i8 %36, i8* %37
%38 = add i64 %34, 1
%39 = icmp eq i8 %36, 32
br i1 %39, label %40, label %33
40: ; preds = %33
%41 = trunc i64 %38 to i32
br label %42
42: ; preds = %40, %61
%43 = phi i32 [ %63, %61 ], [ %41, %40 ]
%44 = call i32 (i32, i8*, i32, i32, ...) bitcast (i32 (...)* @recv to i32 (i32, i8*, i32, i32, ...)*)(i32 %0, i8* %2, i32 1, i32 0)
%45 = load i8, i8* %2
%46 = icmp eq i8 %45, 13
%47 = sext i32 %43 to i64
%48 = getelementptr inbounds i8, i8* %4, i64 %47
br i1 %46, label %49, label %60
49: ; preds = %42
store i8 13, i8* %48
%50 = add nsw i32 %43, 1
%51 = call i32 (i32, i8*, i32, i32, ...) bitcast (i32 (...)* @recv to i32 (i32, i8*, i32, i32, ...)*)(i32 %0, i8* %2, i32 1, i32 0)
%52 = load i8, i8* %2
%53 = icmp eq i8 %52, 10
br i1 %53, label %54, label %61
54: ; preds = %49
%55 = bitcast i8* %6 to i32*
%56 = sext i32 %50 to i64
%57 = getelementptr inbounds i8, i8* %4, i64 %56
store i8 10, i8* %57
%58 = call i32 (i8*, %struct.operation**, i32*, ...) bitcast (i32 (...)* @gwkv_demarshal_client to i32 (i8*, %struct.operation**, i32*, ...)*)(i8* %4, %struct.operation** %3, i32* %55)
%59 = load %struct.operation*, %struct.operation** %3
ret %struct.operation* %59
60: ; preds = %42
store i8 %45, i8* %48
br label %61
61: ; preds = %49, %60
%62 = phi i32 [ %50, %49 ], [ %43, %60 ]
%63 = add nsw i32 %62, 1
br label %42
}