#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*/ STDOUT_FILENO;
int /*<<< orphan*/ err_sys(char *);
int recv(int, char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ write(int /*<<< orphan*/, char *, int);
void print_uptime(int sockfd) {
  int n;
  char buf[128];
  while ((n = recv(sockfd, buf, 128, 0)) > 0)
    write(STDOUT_FILENO, buf, n);
  if (n < 0)
    err_sys("recv error");
}


x86 assembly (clang, -O0):
<print_uptime>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%edi
lea    -0x90(%rbp),%rsi
mov    $0x80,%edx
xor    %ecx,%ecx
call   1030 <recv@plt>
mov    %eax,-0x8(%rbp)
cmp    $0x0,%eax
jle    117d <print_uptime+0x4d>
mov    0x2e89(%rip),%rax
mov    (%rax),%edi
lea    -0x90(%rbp),%rsi
mov    -0x8(%rbp),%edx
call   1050 <write@plt>
jmp    113e <print_uptime+0xe>
cmpl   $0x0,-0x8(%rbp)
jge    1193 <print_uptime+0x63>
lea    0xe72(%rip),%rdi
call   1040 <err_sys@plt>
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_uptime>:
push   %rbp
push   %r14
push   %rbx
sub    $0x80,%rsp
mov    %edi,%ebp
mov    %rsp,%rsi
mov    $0x80,%edx
xor    %ecx,%ecx
call   1030 <recv@plt>
test   %eax,%eax
jle    1182 <print_uptime+0x52>
mov    0x2e99(%rip),%r14
mov    %rsp,%rbx
nopw   0x0(%rax,%rax,1)
mov    (%r14),%edi
mov    %rbx,%rsi
mov    %eax,%edx
call   1050 <write@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    $0x80,%edx
xor    %ecx,%ecx
call   1030 <recv@plt>
test   %eax,%eax
jg     1160 <print_uptime+0x30>
test   %eax,%eax
jns    1192 <print_uptime+0x62>
lea    0xe73(%rip),%rdi
call   1040 <err_sys@plt>
add    $0x80,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@STDOUT_FILENO = global i32 0
@.str = [11 x i8] c"recv error\00"
define void @print_uptime(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca [128 x i8]
store i32 %0, i32* %2
br label %5
5: ; preds = %10, %1
%6 = load i32, i32* %2
%7 = getelementptr inbounds [128 x i8], [128 x i8]* %4, i64 0, i64 0
%8 = call i32 @recv(i32 %6, i8* %7, i32 128, i32 0)
store i32 %8, i32* %3
%9 = icmp sgt i32 %8, 0
br i1 %9, label %10, label %15
10: ; preds = %5
%11 = load i32, i32* @STDOUT_FILENO
%12 = getelementptr inbounds [128 x i8], [128 x i8]* %4, i64 0, i64 0
%13 = load i32, i32* %3
%14 = call i32 @write(i32 %11, i8* %12, i32 %13)
br label %5
15: ; preds = %5
%16 = load i32, i32* %3
%17 = icmp slt i32 %16, 0
br i1 %17, label %18, label %20
18: ; preds = %15
%19 = call i32 @err_sys(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
br label %20
20: ; preds = %18, %15
ret void
}

LLVM IR (-O2):
@STDOUT_FILENO = global i32 0
@.str = [11 x i8] c"recv error\00"
define void @print_uptime(i32 %0) {
%2 = alloca [128 x i8]
%3 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 0
%4 = call i32 @recv(i32 %0, i8* %3, i32 128, i32 0)
%5 = icmp sgt i32 %4, 0
br i1 %5, label %6, label %12
6: ; preds = %1, %6
%7 = phi i32 [ %10, %6 ], [ %4, %1 ]
%8 = load i32, i32* @STDOUT_FILENO
%9 = call i32 @write(i32 %8, i8* %3, i32 %7)
%10 = call i32 @recv(i32 %0, i8* %3, i32 128, i32 0)
%11 = icmp sgt i32 %10, 0
br i1 %11, label %6, label %12
12: ; preds = %6, %1
%13 = phi i32 [ %4, %1 ], [ %10, %6 ]
%14 = icmp slt i32 %13, 0
br i1 %14, label %15, label %17
15: ; preds = %12
%16 = call i32 @err_sys(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
br label %17
17: ; preds = %15, %12
ret void
}