#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_in {
  int sin_port;
  int /*<<< orphan*/ sin_addr;
};

/* Variables and functions */
int FD_SETSIZE;
char *inet_ntoa(int /*<<< orphan*/);
int /*<<< orphan*/ send(int, char *, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ sprintf(char *, char *, char *, int);
int /*<<< orphan*/ strlen(char *);
void welcomeMessage(int servsockfd, int clisockfd,
                    struct sockaddr_in *cli_addr) {
  int fdptr;
  char message[1024];
  sprintf(message, "*** User '(no name)' entered from %s/%d. ***\n",
          inet_ntoa(cli_addr->sin_addr), cli_addr->sin_port);
  for (fdptr = 0; fdptr < FD_SETSIZE; fdptr++) {
    if (fdptr != servsockfd)
      send(fdptr, message, strlen(message), 0);
  }
}


x86 assembly (clang, -O0):
<welcomeMessage>:
push   %rbp
mov    %rsp,%rbp
sub    $0x440,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %rdx,-0x10(%rbp)
lea    -0x420(%rbp),%rax
mov    %rax,-0x428(%rbp)
mov    -0x10(%rbp),%rax
mov    0x4(%rax),%edi
call   1030 <inet_ntoa@plt>
mov    -0x428(%rbp),%rdi
mov    %rax,%rdx
mov    -0x10(%rbp),%rax
mov    (%rax),%ecx
lea    0xe7a(%rip),%rsi
call   1060 <sprintf@plt>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    0x2e44(%rip),%rcx
cmp    (%rcx),%eax
jge    11fc <welcomeMessage+0xbc>
mov    -0x14(%rbp),%eax
cmp    -0x4(%rbp),%eax
je     11e9 <welcomeMessage+0xa9>
mov    -0x14(%rbp),%eax
mov    %eax,-0x434(%rbp)
lea    -0x420(%rbp),%rax
mov    %rax,-0x430(%rbp)
lea    -0x420(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x434(%rbp),%edi
mov    -0x430(%rbp),%rsi
mov    %eax,%edx
xor    %ecx,%ecx
call   1050 <send@plt>
jmp    11ee <welcomeMessage+0xae>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    1192 <welcomeMessage+0x52>
add    $0x440,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<welcomeMessage>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x408,%rsp
mov    %rdx,%rbp
mov    %edi,%ebx
mov    0x4(%rdx),%edi
call   1030 <inet_ntoa@plt>
mov    0x0(%rbp),%ecx
lea    0xe9c(%rip),%rsi
mov    %rsp,%rdi
mov    %rax,%rdx
call   1060 <sprintf@plt>
mov    0x2e6a(%rip),%r15
mov    (%r15),%eax
test   %eax,%eax
jle    11b6 <welcomeMessage+0x76>
xor    %ebp,%ebp
mov    %rsp,%r14
jmp    1197 <welcomeMessage+0x57>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
add    $0x1,%ebp
cmp    %eax,%ebp
jge    11b6 <welcomeMessage+0x76>
cmp    %ebp,%ebx
je     1190 <welcomeMessage+0x50>
mov    %r14,%rdi
call   1040 <strlen@plt>
mov    %ebp,%edi
mov    %r14,%rsi
mov    %eax,%edx
xor    %ecx,%ecx
call   1050 <send@plt>
mov    (%r15),%eax
jmp    1190 <welcomeMessage+0x50>
add    $0x408,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.sockaddr_in = type { i32, i32 }
@.str = [46 x i8] c"*** User '(no name)' entered from %s/%d. ***\0A\00"
@FD_SETSIZE = global i32 0
define void @welcomeMessage(i32 %0, i32 %1, %struct.sockaddr_in* %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca %struct.sockaddr_in*
%7 = alloca i32
%8 = alloca [1024 x i8]
store i32 %0, i32* %4
store i32 %1, i32* %5
store %struct.sockaddr_in* %2, %struct.sockaddr_in** %6
%9 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%10 = load %struct.sockaddr_in*, %struct.sockaddr_in** %6
%11 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %10, i32 0, i32 1
%12 = load i32, i32* %11
%13 = call i8* @inet_ntoa(i32 %12)
%14 = load %struct.sockaddr_in*, %struct.sockaddr_in** %6
%15 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %14, i32 0, i32 0
%16 = load i32, i32* %15
%17 = call i32 @sprintf(i8* %9, i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str, i64 0, i64 0), i8* %13, i32 %16)
store i32 0, i32* %7
br label %18
18: ; preds = %33, %3
%19 = load i32, i32* %7
%20 = load i32, i32* @FD_SETSIZE
%21 = icmp slt i32 %19, %20
br i1 %21, label %22, label %36
22: ; preds = %18
%23 = load i32, i32* %7
%24 = load i32, i32* %4
%25 = icmp ne i32 %23, %24
br i1 %25, label %26, label %32
26: ; preds = %22
%27 = load i32, i32* %7
%28 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%29 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%30 = call i32 @strlen(i8* %29)
%31 = call i32 @send(i32 %27, i8* %28, i32 %30, i32 0)
br label %32
32: ; preds = %26, %22
br label %33
33: ; preds = %32
%34 = load i32, i32* %7
%35 = add nsw i32 %34, 1
store i32 %35, i32* %7
br label %18
36: ; preds = %18
ret void
}

LLVM IR (-O2):
%struct.sockaddr_in = type { i32, i32 }
@.str = [46 x i8] c"*** User '(no name)' entered from %s/%d. ***\0A\00"
@FD_SETSIZE = global i32 0
define void @welcomeMessage(i32 %0, i32 %1, %struct.sockaddr_in* nocapture %2) {
%4 = alloca [1024 x i8]
%5 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%6 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %2, i64 0, i32 1
%7 = load i32, i32* %6
%8 = tail call i8* @inet_ntoa(i32 %7)
%9 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %2, i64 0, i32 0
%10 = load i32, i32* %9
%11 = call i32 @sprintf(i8* %5, i8* dereferenceable(1) getelementptr inbounds ([46 x i8], [46 x i8]* @.str, i64 0, i64 0), i8* %8, i32 %10)
%12 = load i32, i32* @FD_SETSIZE
%13 = icmp sgt i32 %12, 0
br i1 %13, label %14, label %26
14: ; preds = %3, %22
%15 = phi i32 [ %23, %22 ], [ %12, %3 ]
%16 = phi i32 [ %24, %22 ], [ 0, %3 ]
%17 = icmp eq i32 %16, %0
br i1 %17, label %22, label %18
18: ; preds = %14
%19 = call i32 @strlen(i8* %5)
%20 = call i32 @send(i32 %16, i8* %5, i32 %19, i32 0)
%21 = load i32, i32* @FD_SETSIZE
br label %22
22: ; preds = %14, %18
%23 = phi i32 [ %15, %14 ], [ %21, %18 ]
%24 = add nuw nsw i32 %16, 1
%25 = icmp slt i32 %24, %23
br i1 %25, label %14, label %26
26: ; preds = %22, %3
ret void
}