int str_echo(sockfd)
int sockfd;
{
  int n, testint;
  char line[1024];
  printf("sockfd = %d\n", sockfd);
  for (;;) {
    ;
    noprintf("%s: str_echo(): reading from sockfd %d\n",
             "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
             "2022-01-22/02-19-57/repos/anthony-kolesov/arc_ltp/refs/heads/"
             "master/testcases/kernel/sched/clisrv/pthserv.c",
             sockfd);
    n = readline(sockfd, line, 1024);
    printf("str_echo: n = %d\n", n);
    if (n == 0) {
      noprintf("%s: str_echo(): connection terminated\n",
               "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
               "outputs/2022-01-22/02-19-57/repos/anthony-kolesov/arc_ltp/refs/"
               "heads/master/testcases/kernel/sched/clisrv/pthserv.c");
      return 0;
    } else if (n < 0) {
      perror("str_echo: readline error");
      return (-1);
    }
    noprintf("%s: str_echo(): writing to sockfd = %d\n",
             "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
             "2022-01-22/02-19-57/repos/anthony-kolesov/arc_ltp/refs/heads/"
             "master/testcases/kernel/sched/clisrv/pthserv.c",
             sockfd);
    testint = writen(sockfd, line, n);
    ;
    if (testint != n) {
      perror("str_echo: writen error");
      return (-1);
    };
  }
}


x86 assembly (clang, -O0):
<str_echo>:
push   %rbp
mov    %rsp,%rbp
sub    $0x410,%rsp
mov    %edi,-0x8(%rbp)
mov    -0x8(%rbp),%esi
lea    0xfd9(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%edx
lea    0xe87(%rip),%rdi
lea    0xea8(%rip),%rsi
mov    $0x0,%al
call   1050 <noprintf@plt>
mov    -0x8(%rbp),%edi
lea    -0x410(%rbp),%rsi
mov    $0x400,%edx
mov    $0x0,%al
call   1040 <readline@plt>
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%esi
lea    0xf2a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cmpl   $0x0,-0xc(%rbp)
jne    11dc <str_echo+0x8c>
lea    0xf24(%rip),%rdi
lea    0xe5f(%rip),%rsi
mov    $0x0,%al
call   1050 <noprintf@plt>
movl   $0x0,-0x4(%rbp)
jmp    125f <str_echo+0x10f>
cmpl   $0x0,-0xc(%rbp)
jge    1200 <str_echo+0xb0>
lea    0xf20(%rip),%rdi
mov    $0x0,%al
call   1060 <perror@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    125f <str_echo+0x10f>
jmp    1205 <str_echo+0xb5>
mov    -0x8(%rbp),%edx
lea    0xf17(%rip),%rdi
lea    0xe12(%rip),%rsi
mov    $0x0,%al
call   1050 <noprintf@plt>
mov    -0x8(%rbp),%edi
lea    -0x410(%rbp),%rsi
mov    -0xc(%rbp),%edx
mov    $0x0,%al
call   1070 <writen@plt>
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
je     125a <str_echo+0x10a>
lea    0xf07(%rip),%rdi
mov    $0x0,%al
call   1060 <perror@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    125f <str_echo+0x10f>
jmp    116f <str_echo+0x1f>
mov    -0x4(%rbp),%eax
add    $0x410,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<str_echo>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x408,%rsp
mov    %edi,%ebx
lea    0xfd7(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xeae(%rip),%r15
mov    %rsp,%r12
lea    0xf50(%rip),%r13
lea    0xf9b(%rip),%rbp
nopl   0x0(%rax,%rax,1)
lea    0xe69(%rip),%rdi
mov    %r15,%rsi
mov    %ebx,%edx
xor    %eax,%eax
call   1050 <noprintf@plt>
mov    %ebx,%edi
mov    %r12,%rsi
mov    $0x400,%edx
xor    %eax,%eax
call   1040 <readline@plt>
mov    %eax,%r14d
mov    %r13,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1030 <printf@plt>
test   %r14d,%r14d
je     11f6 <str_echo+0xa6>
js     120f <str_echo+0xbf>
mov    %rbp,%rdi
mov    %r15,%rsi
mov    %ebx,%edx
xor    %eax,%eax
call   1050 <noprintf@plt>
mov    %ebx,%edi
mov    %r12,%rsi
mov    %r14d,%edx
xor    %eax,%eax
call   1070 <writen@plt>
cmp    %r14d,%eax
je     1190 <str_echo+0x40>
lea    0xf5a(%rip),%rdi
jmp    1216 <str_echo+0xc6>
lea    0xee9(%rip),%rdi
lea    0xe24(%rip),%rsi
xor    %ebx,%ebx
xor    %eax,%eax
call   1050 <noprintf@plt>
jmp    1222 <str_echo+0xd2>
lea    0xef7(%rip),%rdi
xor    %eax,%eax
call   1060 <perror@plt>
mov    $0xffffffff,%ebx
mov    %ebx,%eax
add    $0x408,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [13 x i8] c"sockfd = %d\0A\00"
@.str.1 = [40 x i8] c"%s: str_echo(): reading from sockfd %d\0A\00"
@.str.2 = [172 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/anthony-kolesov/arc_ltp/refs/heads/master/testcases/kernel/sched/clisrv/pthserv.c\00"
@.str.3 = [18 x i8] c"str_echo: n = %d\0A\00"
@.str.4 = [39 x i8] c"%s: str_echo(): connection terminated\0A\00"
@.str.5 = [25 x i8] c"str_echo: readline error\00"
@.str.6 = [40 x i8] c"%s: str_echo(): writing to sockfd = %d\0A\00"
@.str.7 = [23 x i8] c"str_echo: writen error\00"
define i32 @str_echo(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca [1024 x i8]
store i32 %0, i32* %3
%7 = load i32, i32* %3
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 %7)
br label %9
9: ; preds = %39, %1
%10 = load i32, i32* %3
%11 = call i32 (i8*, i8*, i32, ...) bitcast (i32 (...)* @noprintf to i32 (i8*, i8*, i32, ...)*)(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([172 x i8], [172 x i8]* @.str.2, i64 0, i64 0), i32 %10)
%12 = load i32, i32* %3
%13 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%14 = call i32 (i32, i8*, i32, ...) bitcast (i32 (...)* @readline to i32 (i32, i8*, i32, ...)*)(i32 %12, i8* %13, i32 1024)
store i32 %14, i32* %4
%15 = load i32, i32* %4
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0), i32 %15)
%17 = load i32, i32* %4
%18 = icmp eq i32 %17, 0
br i1 %18, label %19, label %21
19: ; preds = %9
%20 = call i32 (i8*, i8*, ...) bitcast (i32 (...)* @noprintf to i32 (i8*, i8*, ...)*)(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([172 x i8], [172 x i8]* @.str.2, i64 0, i64 0))
store i32 0, i32* %2
br label %40
21: ; preds = %9
%22 = load i32, i32* %4
%23 = icmp slt i32 %22, 0
br i1 %23, label %24, label %26
24: ; preds = %21
%25 = call i32 (i8*, ...) bitcast (i32 (...)* @perror to i32 (i8*, ...)*)(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.5, i64 0, i64 0))
store i32 -1, i32* %2
br label %40
26: ; preds = %21
br label %27
27: ; preds = %26
%28 = load i32, i32* %3
%29 = call i32 (i8*, i8*, i32, ...) bitcast (i32 (...)* @noprintf to i32 (i8*, i8*, i32, ...)*)(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([172 x i8], [172 x i8]* @.str.2, i64 0, i64 0), i32 %28)
%30 = load i32, i32* %3
%31 = getelementptr inbounds [1024 x i8], [1024 x i8]* %6, i64 0, i64 0
%32 = load i32, i32* %4
%33 = call i32 (i32, i8*, i32, ...) bitcast (i32 (...)* @writen to i32 (i32, i8*, i32, ...)*)(i32 %30, i8* %31, i32 %32)
store i32 %33, i32* %5
%34 = load i32, i32* %5
%35 = load i32, i32* %4
%36 = icmp ne i32 %34, %35
br i1 %36, label %37, label %39
37: ; preds = %27
%38 = call i32 (i8*, ...) bitcast (i32 (...)* @perror to i32 (i8*, ...)*)(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.7, i64 0, i64 0))
store i32 -1, i32* %2
br label %40
39: ; preds = %27
br label %9
40: ; preds = %37, %24, %19
%41 = load i32, i32* %2
ret i32 %41
}

LLVM IR (-O2):
@.str = [13 x i8] c"sockfd = %d\0A\00"
@.str.1 = [40 x i8] c"%s: str_echo(): reading from sockfd %d\0A\00"
@.str.2 = [172 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/anthony-kolesov/arc_ltp/refs/heads/master/testcases/kernel/sched/clisrv/pthserv.c\00"
@.str.3 = [18 x i8] c"str_echo: n = %d\0A\00"
@.str.4 = [39 x i8] c"%s: str_echo(): connection terminated\0A\00"
@.str.5 = [25 x i8] c"str_echo: readline error\00"
@.str.6 = [40 x i8] c"%s: str_echo(): writing to sockfd = %d\0A\00"
@.str.7 = [23 x i8] c"str_echo: writen error\00"
define i32 @str_echo(i32 %0) {
%2 = alloca [1024 x i8]
%3 = getelementptr inbounds [1024 x i8], [1024 x i8]* %2, i64 0, i64 0
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 %0)
br label %5
5: ; preds = %16, %1
%6 = call i32 (i8*, i8*, i32, ...) bitcast (i32 (...)* @noprintf to i32 (i8*, i8*, i32, ...)*)(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([172 x i8], [172 x i8]* @.str.2, i64 0, i64 0), i32 %0)
%7 = call i32 (i32, i8*, i32, ...) bitcast (i32 (...)* @readline to i32 (i32, i8*, i32, ...)*)(i32 %0, i8* %3, i32 1024)
%8 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0), i32 %7)
%9 = icmp eq i32 %7, 0
br i1 %9, label %10, label %12
10: ; preds = %5
%11 = call i32 (i8*, i8*, ...) bitcast (i32 (...)* @noprintf to i32 (i8*, i8*, ...)*)(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([172 x i8], [172 x i8]* @.str.2, i64 0, i64 0))
br label %22
12: ; preds = %5
%13 = icmp slt i32 %7, 0
br i1 %13, label %14, label %16
14: ; preds = %12
%15 = call i32 (i8*, ...) bitcast (i32 (...)* @perror to i32 (i8*, ...)*)(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.5, i64 0, i64 0))
br label %22
16: ; preds = %12
%17 = call i32 (i8*, i8*, i32, ...) bitcast (i32 (...)* @noprintf to i32 (i8*, i8*, i32, ...)*)(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.6, i64 0, i64 0), i8* getelementptr inbounds ([172 x i8], [172 x i8]* @.str.2, i64 0, i64 0), i32 %0)
%18 = call i32 (i32, i8*, i32, ...) bitcast (i32 (...)* @writen to i32 (i32, i8*, i32, ...)*)(i32 %0, i8* %3, i32 %7)
%19 = icmp eq i32 %18, %7
br i1 %19, label %5, label %20
20: ; preds = %16
%21 = call i32 (i8*, ...) bitcast (i32 (...)* @perror to i32 (i8*, ...)*)(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.7, i64 0, i64 0))
br label %22
22: ; preds = %20, %14, %10
%23 = phi i32 [ 0, %10 ], [ -1, %14 ], [ -1, %20 ]
ret i32 %23
}