#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 */
struct sockaddr {
  int dummy;
};
typedef int /*<<< orphan*/ socklen_t;
typedef int /*<<< orphan*/ sendline;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
scalar_t__ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ sendto(int, char *, int, int /*<<< orphan*/,
                          struct sockaddr *, int /*<<< orphan*/);
void dg_cli(FILE *fp, int sockfd, struct sockaddr *sa, socklen_t len) {
  int n;
  char sendline[256 + 1] = {'\0'};
  char recvline[256 + 1] = {'\0'};
  while (fgets(sendline, sizeof(sendline), fp) < 0) {
    sendto(sockfd, sendline, sizeof(sendline), 0, sa, len);
  }
}


x86 assembly (clang, -O0):
<dg_cli>:
push   %rbp
mov    %rsp,%rbp
sub    $0x240,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
lea    -0x130(%rbp),%rdi
xor    %esi,%esi
mov    $0x101,%edx
call   1030 <memset@plt>
lea    -0x240(%rbp),%rdi
xor    %esi,%esi
mov    $0x101,%edx
call   1030 <memset@plt>
lea    -0x130(%rbp),%rdi
mov    -0x8(%rbp),%rdx
mov    $0x101,%esi
call   1050 <fgets@plt>
cmp    $0x0,%rax
jge    11b1 <dg_cli+0x81>
mov    -0xc(%rbp),%edi
lea    -0x130(%rbp),%rsi
mov    -0x18(%rbp),%r8
mov    -0x1c(%rbp),%r9d
mov    $0x101,%edx
xor    %ecx,%ecx
call   1040 <sendto@plt>
jmp    116f <dg_cli+0x3f>
add    $0x240,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dg_cli>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x110,%rsp
mov    %ecx,%r14d
mov    %rdx,%r15
mov    %esi,%r12d
mov    %rdi,%rbx
mov    %rsp,%rbp
mov    $0x101,%edx
mov    %rbp,%rdi
xor    %esi,%esi
call   1030 <memset@plt>
mov    %rbp,%rdi
mov    $0x101,%esi
mov    %rbx,%rdx
call   1050 <fgets@plt>
test   %rax,%rax
jns    11ad <dg_cli+0x7d>
mov    %rsp,%rbp
cs nopw 0x0(%rax,%rax,1)
nop
mov    %r12d,%edi
mov    %rbp,%rsi
mov    $0x101,%edx
xor    %ecx,%ecx
mov    %r15,%r8
mov    %r14d,%r9d
call   1040 <sendto@plt>
mov    %rbp,%rdi
mov    $0x101,%esi
mov    %rbx,%rdx
call   1050 <fgets@plt>
test   %rax,%rax
js     1180 <dg_cli+0x50>
add    $0x110,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.sockaddr = type { i32 }
define void @dg_cli(i32* %0, i32 %1, %struct.sockaddr* %2, i32 %3) {
%5 = alloca i32*
%6 = alloca i32
%7 = alloca %struct.sockaddr*
%8 = alloca i32
%9 = alloca i32
%10 = alloca [257 x i8]
%11 = alloca [257 x i8]
store i32* %0, i32** %5
store i32 %1, i32* %6
store %struct.sockaddr* %2, %struct.sockaddr** %7
store i32 %3, i32* %8
%12 = bitcast [257 x i8]* %10 to i8*
%13 = bitcast [257 x i8]* %11 to i8*
br label %14
14: ; preds = %19, %4
%15 = getelementptr inbounds [257 x i8], [257 x i8]* %10, i64 0, i64 0
%16 = load i32*, i32** %5
%17 = call i64 @fgets(i8* %15, i32 257, i32* %16)
%18 = icmp slt i64 %17, 0
br i1 %18, label %19, label %25
19: ; preds = %14
%20 = load i32, i32* %6
%21 = getelementptr inbounds [257 x i8], [257 x i8]* %10, i64 0, i64 0
%22 = load %struct.sockaddr*, %struct.sockaddr** %7
%23 = load i32, i32* %8
%24 = call i32 @sendto(i32 %20, i8* %21, i32 257, i32 0, %struct.sockaddr* %22, i32 %23)
br label %14
25: ; preds = %14
ret void
}

LLVM IR (-O2):
%struct.sockaddr = type { i32 }
define void @dg_cli(i32* nocapture %0, i32 %1, %struct.sockaddr* %2, i32 %3) {
%5 = alloca [257 x i8]
%6 = getelementptr inbounds [257 x i8], [257 x i8]* %5, i64 0, i64 0
%7 = call i64 @fgets(i8* %6, i32 257, i32* %0)
%8 = icmp slt i64 %7, 0
br i1 %8, label %9, label %13
9: ; preds = %4, %9
%10 = call i32 @sendto(i32 %1, i8* %6, i32 257, i32 0, %struct.sockaddr* %2, i32 %3)
%11 = call i64 @fgets(i8* %6, i32 257, i32* %0)
%12 = icmp slt i64 %11, 0
br i1 %12, label %9, label %13
13: ; preds = %9, %4
ret void
}