#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 *, int /*<<< orphan*/, int);
int recv(int, char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ strcat(char *, char *);
int strlen(char *);
int recvUntil(int sockfd, char *received, char delimiter) {
  char temp[53000];
  memset(temp, 0, 53000);
  memset(received, 0, 53000);
  while (recv(sockfd, temp, 53000, 0) != -1) {
    strcat(received, temp);
    if (temp[strlen(temp) - 1] == delimiter) {
      break;
    }
    memset(temp, 0, 53000);
  }
  return strlen(received);
}


x86 assembly (clang, -O0):
<recvUntil>:
push   %rbp
mov    %rsp,%rbp
sub    $0xcf20,%rsp
mov    %dl,%al
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %al,-0x11(%rbp)
lea    -0xcf20(%rbp),%rdi
xor    %esi,%esi
mov    $0xcf08,%edx
call   1050 <memset@plt>
mov    -0x10(%rbp),%rdi
xor    %esi,%esi
mov    $0xcf08,%edx
call   1050 <memset@plt>
mov    -0x4(%rbp),%edi
lea    -0xcf20(%rbp),%rsi
mov    $0xcf08,%edx
xor    %ecx,%ecx
call   1030 <recv@plt>
cmp    $0xffffffff,%eax
je     11eb <recvUntil+0xab>
mov    -0x10(%rbp),%rdi
lea    -0xcf20(%rbp),%rsi
call   1060 <strcat@plt>
lea    -0xcf20(%rbp),%rdi
call   1040 <strlen@plt>
sub    $0x1,%eax
cltq
movsbl -0xcf20(%rbp,%rax,1),%eax
ff
movsbl -0x11(%rbp),%ecx
cmp    %ecx,%eax
jne    11d3 <recvUntil+0x93>
jmp    11eb <recvUntil+0xab>
lea    -0xcf20(%rbp),%rdi
xor    %esi,%esi
mov    $0xcf08,%edx
call   1050 <memset@plt>
jmp    117a <recvUntil+0x3a>
mov    -0x10(%rbp),%rdi
call   1040 <strlen@plt>
add    $0xcf20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<recvUntil>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0xcf08,%rsp
mov    %edx,%r14d
mov    %rsi,%rbx
mov    %edi,%r15d
mov    %rsp,%rbp
mov    %rbp,%rdi
xor    %esi,%esi
mov    $0xcf08,%edx
call   1050 <memset@plt>
mov    %rbx,%rdi
nopl   0x0(%rax,%rax,1)
xor    %esi,%esi
mov    $0xcf08,%edx
call   1050 <memset@plt>
mov    %r15d,%edi
mov    %rbp,%rsi
mov    $0xcf08,%edx
xor    %ecx,%ecx
call   1030 <recv@plt>
cmp    $0xffffffff,%eax
je     11b4 <recvUntil+0x74>
mov    %rbx,%rdi
mov    %rbp,%rsi
call   1060 <strcat@plt>
mov    %rbp,%rdi
call   1040 <strlen@plt>
cltq
cmp    %r14b,-0x1(%rax,%rbp,1)
je     11b4 <recvUntil+0x74>
mov    %rbp,%rdi
jmp    1170 <recvUntil+0x30>
mov    %rbx,%rdi
call   1040 <strlen@plt>
add    $0xcf08,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @recvUntil(i32 %0, i8* %1, i8 signext %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8
%7 = alloca [53000 x i8]
store i32 %0, i32* %4
store i8* %1, i8** %5
store i8 %2, i8* %6
%8 = getelementptr inbounds [53000 x i8], [53000 x i8]* %7, i64 0, i64 0
%9 = call i32 @memset(i8* %8, i32 0, i32 53000)
%10 = load i8*, i8** %5
%11 = call i32 @memset(i8* %10, i32 0, i32 53000)
br label %12
12: ; preds = %32, %3
%13 = load i32, i32* %4
%14 = getelementptr inbounds [53000 x i8], [53000 x i8]* %7, i64 0, i64 0
%15 = call i32 @recv(i32 %13, i8* %14, i32 53000, i32 0)
%16 = icmp ne i32 %15, -1
br i1 %16, label %17, label %35
17: ; preds = %12
%18 = load i8*, i8** %5
%19 = getelementptr inbounds [53000 x i8], [53000 x i8]* %7, i64 0, i64 0
%20 = call i32 @strcat(i8* %18, i8* %19)
%21 = getelementptr inbounds [53000 x i8], [53000 x i8]* %7, i64 0, i64 0
%22 = call i32 @strlen(i8* %21)
%23 = sub nsw i32 %22, 1
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds [53000 x i8], [53000 x i8]* %7, i64 0, i64 %24
%26 = load i8, i8* %25
%27 = sext i8 %26 to i32
%28 = load i8, i8* %6
%29 = sext i8 %28 to i32
%30 = icmp eq i32 %27, %29
br i1 %30, label %31, label %32
31: ; preds = %17
br label %35
32: ; preds = %17
%33 = getelementptr inbounds [53000 x i8], [53000 x i8]* %7, i64 0, i64 0
%34 = call i32 @memset(i8* %33, i32 0, i32 53000)
br label %12
35: ; preds = %31, %12
%36 = load i8*, i8** %5
%37 = call i32 @strlen(i8* %36)
ret i32 %37
}

LLVM IR (-O2):
define i32 @recvUntil(i32 %0, i8* %1, i8 signext %2) {
%4 = alloca [53000 x i8]
%5 = getelementptr inbounds [53000 x i8], [53000 x i8]* %4, i64 0, i64 0
%6 = call i32 @memset(i8* %5, i32 0, i32 53000)
%7 = call i32 @memset(i8* %1, i32 0, i32 53000)
%8 = call i32 @recv(i32 %0, i8* %5, i32 53000, i32 0)
%9 = icmp eq i32 %8, -1
br i1 %9, label %22, label %10
10: ; preds = %3, %18
%11 = call i32 @strcat(i8* %1, i8* %5)
%12 = call i32 @strlen(i8* %5)
%13 = add nsw i32 %12, -1
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds [53000 x i8], [53000 x i8]* %4, i64 0, i64 %14
%16 = load i8, i8* %15
%17 = icmp eq i8 %16, %2
br i1 %17, label %22, label %18
18: ; preds = %10
%19 = call i32 @memset(i8* %5, i32 0, i32 53000)
%20 = call i32 @recv(i32 %0, i8* %5, i32 53000, i32 0)
%21 = icmp eq i32 %20, -1
br i1 %21, label %22, label %10
22: ; preds = %18, %10, %3
%23 = call i32 @strlen(i8* %1)
ret i32 %23
}