#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*/ exit(int /*<<< orphan*/);
scalar_t__ fork();
int /*<<< orphan*/ harnessTlsServerAccept();
int /*<<< orphan*/ harnessTlsServerClose();
int /*<<< orphan*/ harnessTlsServerExpect(char *);
int /*<<< orphan*/ harnessTlsServerInitDefault();
int /*<<< orphan*/ harnessTlsServerReply(char *);
int /*<<< orphan*/ sleepMSec(int);
void testTlsServer(void) {
  if (fork() == 0) {
    harnessTlsServerInitDefault();
    harnessTlsServerAccept();
    harnessTlsServerExpect("some protocol info");
    harnessTlsServerReply("something:0\n");
    sleepMSec(100);
    harnessTlsServerReply("some ");
    sleepMSec(100);
    harnessTlsServerReply("contentAND MORE");
    sleepMSec(500);
    harnessTlsServerExpect("more protocol info");
    harnessTlsServerReply("0123456789AB");
    harnessTlsServerClose();
    harnessTlsServerAccept();
    harnessTlsServerReply("0123456789AB");
    harnessTlsServerClose();
    exit(0);
  }
}


x86 assembly (clang, -O0):
<testTlsServer>:
push   %rbp
mov    %rsp,%rbp
mov    $0x0,%al
call   10a0 <fork@plt>
cmp    $0x0,%rax
jne    1231 <testTlsServer+0xb1>
mov    $0x0,%al
call   1050 <harnessTlsServerInitDefault@plt>
mov    $0x0,%al
call   1040 <harnessTlsServerAccept@plt>
lea    0xe56(%rip),%rdi
call   1030 <harnessTlsServerExpect@plt>
lea    0xe5d(%rip),%rdi
call   1080 <harnessTlsServerReply@plt>
mov    $0x64,%edi
call   1060 <sleepMSec@plt>
lea    0xe54(%rip),%rdi
call   1080 <harnessTlsServerReply@plt>
mov    $0x64,%edi
call   1060 <sleepMSec@plt>
lea    0xe44(%rip),%rdi
call   1080 <harnessTlsServerReply@plt>
mov    $0x1f4,%edi
call   1060 <sleepMSec@plt>
lea    0xe3e(%rip),%rdi
call   1030 <harnessTlsServerExpect@plt>
lea    0xe45(%rip),%rdi
call   1080 <harnessTlsServerReply@plt>
mov    $0x0,%al
call   1070 <harnessTlsServerClose@plt>
mov    $0x0,%al
call   1040 <harnessTlsServerAccept@plt>
lea    0xe2b(%rip),%rdi
call   1080 <harnessTlsServerReply@plt>
mov    $0x0,%al
call   1070 <harnessTlsServerClose@plt>
xor    %edi,%edi
call   1090 <exit@plt>
pop    %rbp
ret

x86 assembly (clang, -O2):
<testTlsServer>:
push   %rbx
xor    %eax,%eax
call   10a0 <fork@plt>
test   %rax,%rax
je     118f <testTlsServer+0xf>
pop    %rbx
ret
xor    %eax,%eax
call   1050 <harnessTlsServerInitDefault@plt>
xor    %eax,%eax
call   1040 <harnessTlsServerAccept@plt>
lea    0xe5c(%rip),%rdi
call   1030 <harnessTlsServerExpect@plt>
lea    0xe63(%rip),%rdi
call   1080 <harnessTlsServerReply@plt>
mov    $0x64,%edi
call   1060 <sleepMSec@plt>
lea    0xe5a(%rip),%rdi
call   1080 <harnessTlsServerReply@plt>
mov    $0x64,%edi
call   1060 <sleepMSec@plt>
lea    0xe4a(%rip),%rdi
call   1080 <harnessTlsServerReply@plt>
mov    $0x1f4,%edi
call   1060 <sleepMSec@plt>
lea    0xe44(%rip),%rdi
call   1030 <harnessTlsServerExpect@plt>
lea    0xe4b(%rip),%rbx
mov    %rbx,%rdi
call   1080 <harnessTlsServerReply@plt>
xor    %eax,%eax
call   1070 <harnessTlsServerClose@plt>
xor    %eax,%eax
call   1040 <harnessTlsServerAccept@plt>
mov    %rbx,%rdi
call   1080 <harnessTlsServerReply@plt>
xor    %eax,%eax
call   1070 <harnessTlsServerClose@plt>
xor    %edi,%edi
call   1090 <exit@plt>

LLVM IR (-O0):
@.str = [19 x i8] c"some protocol info\00"
@.str.1 = [13 x i8] c"something:0\0A\00"
@.str.2 = [6 x i8] c"some \00"
@.str.3 = [16 x i8] c"contentAND MORE\00"
@.str.4 = [19 x i8] c"more protocol info\00"
@.str.5 = [13 x i8] c"0123456789AB\00"
define void @testTlsServer() {
%1 = call i64 (...) @fork()
%2 = icmp eq i64 %1, 0
br i1 %2, label %3, label %20
3: ; preds = %0
%4 = call i32 (...) @harnessTlsServerInitDefault()
%5 = call i32 (...) @harnessTlsServerAccept()
%6 = call i32 @harnessTlsServerExpect(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
%7 = call i32 @harnessTlsServerReply(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0))
%8 = call i32 @sleepMSec(i32 100)
%9 = call i32 @harnessTlsServerReply(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%10 = call i32 @sleepMSec(i32 100)
%11 = call i32 @harnessTlsServerReply(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0))
%12 = call i32 @sleepMSec(i32 500)
%13 = call i32 @harnessTlsServerExpect(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0))
%14 = call i32 @harnessTlsServerReply(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0))
%15 = call i32 (...) @harnessTlsServerClose()
%16 = call i32 (...) @harnessTlsServerAccept()
%17 = call i32 @harnessTlsServerReply(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0))
%18 = call i32 (...) @harnessTlsServerClose()
%19 = call i32 @exit(i32 0)
unreachable
20: ; preds = %0
ret void
}

LLVM IR (-O2):
@.str = [19 x i8] c"some protocol info\00"
@.str.1 = [13 x i8] c"something:0\0A\00"
@.str.2 = [6 x i8] c"some \00"
@.str.3 = [16 x i8] c"contentAND MORE\00"
@.str.4 = [19 x i8] c"more protocol info\00"
@.str.5 = [13 x i8] c"0123456789AB\00"
define void @testTlsServer() {
%1 = tail call i64 (...) @fork()
%2 = icmp eq i64 %1, 0
br i1 %2, label %3, label %20
3: ; preds = %0
%4 = tail call i32 (...) @harnessTlsServerInitDefault()
%5 = tail call i32 (...) @harnessTlsServerAccept()
%6 = tail call i32 @harnessTlsServerExpect(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
%7 = tail call i32 @harnessTlsServerReply(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0))
%8 = tail call i32 @sleepMSec(i32 100)
%9 = tail call i32 @harnessTlsServerReply(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.2, i64 0, i64 0))
%10 = tail call i32 @sleepMSec(i32 100)
%11 = tail call i32 @harnessTlsServerReply(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.3, i64 0, i64 0))
%12 = tail call i32 @sleepMSec(i32 500)
%13 = tail call i32 @harnessTlsServerExpect(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0))
%14 = tail call i32 @harnessTlsServerReply(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0))
%15 = tail call i32 (...) @harnessTlsServerClose()
%16 = tail call i32 (...) @harnessTlsServerAccept()
%17 = tail call i32 @harnessTlsServerReply(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0))
%18 = tail call i32 (...) @harnessTlsServerClose()
%19 = tail call i32 @exit(i32 0)
unreachable
20: ; preds = %0
ret void
}