#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*/ printf(char *, ...);
int recv(int, char *, int, int /*<<< orphan*/);
void display_result(int connection) {
  int received = 0;
  static char recv_buf[255 + 1];
  while ((received = recv(connection, recv_buf, 255, 0)) > 0) {
    recv_buf[received] = '\0';
    printf("%s", recv_buf);
  }
  printf("\n");
}


x86 assembly (clang, -O0):
<display_result>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
mov    -0x4(%rbp),%edi
lea    0x2f04(%rip),%rsi
mov    $0xff,%edx
xor    %ecx,%ecx
call   1030 <recv@plt>
mov    %eax,-0x8(%rbp)
cmp    $0x0,%eax
jle    117d <display_result+0x5d>
movslq -0x8(%rbp),%rcx
lea    0x2ee1(%rip),%rax
movb   $0x0,(%rax,%rcx,1)
lea    0xe96(%rip),%rdi
lea    0x2ecf(%rip),%rsi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    1132 <display_result+0x12>
lea    0xe7f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<display_result>:
push   %rbp
push   %r14
push   %rbx
mov    %edi,%ebp
lea    0x2f13(%rip),%rbx
mov    %rbx,%rsi
mov    $0xff,%edx
xor    %ecx,%ecx
call   1030 <recv@plt>
test   %eax,%eax
jle    1188 <display_result+0x58>
lea    0xea9(%rip),%r14
nopw   0x0(%rax,%rax,1)
mov    %eax,%eax
movb   $0x0,(%rax,%rbx,1)
mov    %r14,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    $0xff,%edx
xor    %ecx,%ecx
call   1030 <recv@plt>
test   %eax,%eax
jg     1160 <display_result+0x30>
mov    $0xa,%edi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1040 <putchar@plt>

LLVM IR (-O0):
@display_result.recv_buf = internal global [256 x i8] zeroinitializer
@.str = [3 x i8] c"%s\00"
@.str.1 = [2 x i8] c"\0A\00"
define void @display_result(i32 %0) {
%2 = alloca i32
%3 = alloca i32
store i32 %0, i32* %2
store i32 0, i32* %3
br label %4
4: ; preds = %8, %1
%5 = load i32, i32* %2
%6 = call i32 @recv(i32 %5, i8* getelementptr inbounds ([256 x i8], [256 x i8]* @display_result.recv_buf, i64 0, i64 0), i32 255, i32 0)
store i32 %6, i32* %3
%7 = icmp sgt i32 %6, 0
br i1 %7, label %8, label %13
8: ; preds = %4
%9 = load i32, i32* %3
%10 = sext i32 %9 to i64
%11 = getelementptr inbounds [256 x i8], [256 x i8]* @display_result.recv_buf, i64 0, i64 %10
store i8 0, i8* %11
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([256 x i8], [256 x i8]* @display_result.recv_buf, i64 0, i64 0))
br label %4
13: ; preds = %4
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@display_result.recv_buf = internal global [256 x i8] zeroinitializer
@.str = [3 x i8] c"%s\00"
define void @display_result(i32 %0) {
%2 = tail call i32 @recv(i32 %0, i8* getelementptr inbounds ([256 x i8], [256 x i8]* @display_result.recv_buf, i64 0, i64 0), i32 255, i32 0)
%3 = icmp sgt i32 %2, 0
br i1 %3, label %4, label %11
4: ; preds = %1, %4
%5 = phi i32 [ %9, %4 ], [ %2, %1 ]
%6 = zext i32 %5 to i64
%7 = getelementptr inbounds [256 x i8], [256 x i8]* @display_result.recv_buf, i64 0, i64 %6
store i8 0, i8* %7
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([256 x i8], [256 x i8]* @display_result.recv_buf, i64 0, i64 0))
%9 = tail call i32 @recv(i32 %0, i8* getelementptr inbounds ([256 x i8], [256 x i8]* @display_result.recv_buf, i64 0, i64 0), i32 255, i32 0)
%10 = icmp sgt i32 %9, 0
br i1 %10, label %4, label %11
11: ; preds = %4, %1
%12 = tail call i32 @putchar(i32 10)
ret void
}