#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*/ error(char *);
int getusercount();
int /*<<< orphan*/ sprintf(char *, char *, int);
int /*<<< orphan*/ strcat(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int /*<<< orphan*/ strlen(char *);
int write(int, char *, int /*<<< orphan*/);
void sendusercount(int socket) {
  int n, loggedUsers;
  char userCount[8];
  char message[256];
  loggedUsers = getusercount();
  sprintf(userCount, "%d", loggedUsers);
  strcpy(message, userCount);
  strcat(message, " Users logged in.");
  n = write(socket, message, strlen(message));
  if (n < 0)
    error("ERROR in write");
}


x86 assembly (clang, -O0):
<sendusercount>:
push   %rbp
mov    %rsp,%rbp
sub    $0x130,%rsp
mov    %edi,-0x4(%rbp)
mov    $0x0,%al
call   1090 <getusercount@plt>
mov    %eax,-0xc(%rbp)
lea    -0x14(%rbp),%rdi
mov    -0xc(%rbp),%edx
lea    0xe6a(%rip),%rsi
call   1080 <sprintf@plt>
lea    -0x120(%rbp),%rdi
lea    -0x14(%rbp),%rsi
call   1030 <strcpy@plt>
lea    -0x120(%rbp),%rdi
lea    0xe4a(%rip),%rsi
call   1070 <strcat@plt>
mov    -0x4(%rbp),%eax
mov    %eax,-0x12c(%rbp)
lea    -0x120(%rbp),%rax
mov    %rax,-0x128(%rbp)
lea    -0x120(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0x12c(%rbp),%edi
mov    -0x128(%rbp),%rsi
mov    %eax,%edx
call   1040 <write@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jge    120e <sendusercount+0x9e>
lea    0xe0c(%rip),%rdi
call   1060 <error@plt>
add    $0x130,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sendusercount>:
push   %rbp
push   %r14
push   %rbx
sub    $0x110,%rsp
mov    %edi,%r14d
xor    %eax,%eax
call   1090 <getusercount@plt>
lea    0xe74(%rip),%rsi
lea    0x8(%rsp),%rbx
mov    %rbx,%rdi
mov    %eax,%edx
call   1080 <sprintf@plt>
lea    0x10(%rsp),%rbp
mov    %rbp,%rdi
mov    %rbx,%rsi
call   1030 <strcpy@plt>
lea    0xe51(%rip),%rsi
mov    %rbp,%rdi
call   1070 <strcat@plt>
mov    %rbp,%rdi
call   1050 <strlen@plt>
mov    %r14d,%edi
mov    %rbp,%rsi
mov    %eax,%edx
call   1040 <write@plt>
test   %eax,%eax
jns    11df <sendusercount+0x6f>
lea    0xe3b(%rip),%rdi
call   1060 <error@plt>
add    $0x110,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@.str.1 = [18 x i8] c" Users logged in.\00"
@.str.2 = [15 x i8] c"ERROR in write\00"
define void @sendusercount(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca [8 x i8]
%6 = alloca [256 x i8]
store i32 %0, i32* %2
%7 = call i32 (...) @getusercount()
store i32 %7, i32* %4
%8 = getelementptr inbounds [8 x i8], [8 x i8]* %5, i64 0, i64 0
%9 = load i32, i32* %4
%10 = call i32 @sprintf(i8* %8, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %9)
%11 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%12 = getelementptr inbounds [8 x i8], [8 x i8]* %5, i64 0, i64 0
%13 = call i32 @strcpy(i8* %11, i8* %12)
%14 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%15 = call i32 @strcat(i8* %14, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0))
%16 = load i32, i32* %2
%17 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%18 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%19 = call i32 @strlen(i8* %18)
%20 = call i32 @write(i32 %16, i8* %17, i32 %19)
store i32 %20, i32* %3
%21 = load i32, i32* %3
%22 = icmp slt i32 %21, 0
br i1 %22, label %23, label %25
23: ; preds = %1
%24 = call i32 @error(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0))
br label %25
25: ; preds = %23, %1
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@.str.1 = [18 x i8] c" Users logged in.\00"
@.str.2 = [15 x i8] c"ERROR in write\00"
define void @sendusercount(i32 %0) {
%2 = alloca [8 x i8]
%3 = alloca [256 x i8]
%4 = getelementptr inbounds [8 x i8], [8 x i8]* %2, i64 0, i64 0
%5 = getelementptr inbounds [256 x i8], [256 x i8]* %3, i64 0, i64 0
%6 = tail call i32 (...) @getusercount()
%7 = call i32 @sprintf(i8* %4, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %6)
%8 = call i32 @strcpy(i8* %5, i8* %4)
%9 = call i32 @strcat(i8* %5, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0))
%10 = call i32 @strlen(i8* %5)
%11 = call i32 @write(i32 %0, i8* %5, i32 %10)
%12 = icmp slt i32 %11, 0
br i1 %12, label %13, label %15
13: ; preds = %1
%14 = call i32 @error(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0))
br label %15
15: ; preds = %13, %1
ret void
}