#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*/ MSG_NOSIGNAL;
char *buildMsg(char *);
int /*<<< orphan*/ errno;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int send(int, char *, scalar_t__, int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
char *strerror(int /*<<< orphan*/);
scalar_t__ strlen(char *);
int sendMsg(int tracker_socket, char *msg) {
  char *data = buildMsg(msg);
  if (send(tracker_socket, data, strlen(msg) + 1, MSG_NOSIGNAL) == -1) {
    fprintf(stderr, "[Error %s] ", strerror(errno));
    fprintf(stderr,
            "Error communicating with socket. Please try again later.\n");
    return -1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<sendMsg>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1060 <buildMsg@plt>
mov    %rax,-0x18(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x24(%rbp),%edi
mov    -0x20(%rbp),%rsi
mov    %rax,%rdx
add    $0x1,%rdx
mov    0x2e38(%rip),%rax
mov    (%rax),%ecx
call   1040 <send@plt>
cmp    $0xffffffff,%eax
jne    11f9 <sendMsg+0xa9>
mov    0x2e31(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x28(%rbp)
mov    0x2e1d(%rip),%rax
mov    (%rax),%edi
call   1070 <strerror@plt>
mov    -0x28(%rbp),%edi
mov    %rax,%rdx
lea    0xe31(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    0x2e03(%rip),%rax
mov    (%rax),%edi
lea    0xe26(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1200 <sendMsg+0xb0>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sendMsg>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%rbx
mov    %edi,%r14d
mov    %rsi,%rdi
call   1060 <buildMsg@plt>
mov    %rax,%rbp
mov    %rbx,%rdi
call   1030 <strlen@plt>
lea    0x1(%rax),%rdx
mov    0x2e58(%rip),%rax
mov    (%rax),%ecx
mov    %r14d,%edi
mov    %rbp,%rsi
call   1040 <send@plt>
mov    %eax,%ecx
xor    %eax,%eax
cmp    $0xffffffff,%ecx
jne    11cf <sendMsg+0x7f>
mov    0x2e4b(%rip),%rbp
mov    0x0(%rbp),%ebx
mov    0x2e39(%rip),%rax
mov    (%rax),%edi
call   1070 <strerror@plt>
lea    0xe53(%rip),%rsi
mov    %ebx,%edi
mov    %rax,%rdx
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    0x0(%rbp),%edi
lea    0xe49(%rip),%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    $0xffffffff,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@MSG_NOSIGNAL = global i32 0
@stderr = global i32 0
@.str = [12 x i8] c"[Error %s] \00"
@errno = global i32 0
@.str.1 = [58 x i8] c"Error communicating with socket. Please try again later.\0A\00"
define i32 @sendMsg(i32 %0, i8* %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8*
store i32 %0, i32* %4
store i8* %1, i8** %5
%7 = load i8*, i8** %5
%8 = call i8* @buildMsg(i8* %7)
store i8* %8, i8** %6
%9 = load i32, i32* %4
%10 = load i8*, i8** %6
%11 = load i8*, i8** %5
%12 = call i64 @strlen(i8* %11)
%13 = add nsw i64 %12, 1
%14 = load i32, i32* @MSG_NOSIGNAL
%15 = call i32 @send(i32 %9, i8* %10, i64 %13, i32 %14)
%16 = icmp eq i32 %15, -1
br i1 %16, label %17, label %24
17: ; preds = %2
%18 = load i32, i32* @stderr
%19 = load i32, i32* @errno
%20 = call i8* @strerror(i32 %19)
%21 = call i32 (i32, i8*, ...) @fprintf(i32 %18, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* %20)
%22 = load i32, i32* @stderr
%23 = call i32 (i32, i8*, ...) @fprintf(i32 %22, i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str.1, i64 0, i64 0))
store i32 -1, i32* %3
br label %25
24: ; preds = %2
store i32 0, i32* %3
br label %25
25: ; preds = %24, %17
%26 = load i32, i32* %3
ret i32 %26
}

LLVM IR (-O2):
@MSG_NOSIGNAL = global i32 0
@stderr = global i32 0
@.str = [12 x i8] c"[Error %s] \00"
@errno = global i32 0
@.str.1 = [58 x i8] c"Error communicating with socket. Please try again later.\0A\00"
define i32 @sendMsg(i32 %0, i8* %1) {
%3 = tail call i8* @buildMsg(i8* %1)
%4 = tail call i64 @strlen(i8* dereferenceable(1) %1)
%5 = add nsw i64 %4, 1
%6 = load i32, i32* @MSG_NOSIGNAL
%7 = tail call i32 @send(i32 %0, i8* %3, i64 %5, i32 %6)
%8 = icmp eq i32 %7, -1
br i1 %8, label %9, label %16
9: ; preds = %2
%10 = load i32, i32* @stderr
%11 = load i32, i32* @errno
%12 = tail call i8* @strerror(i32 %11)
%13 = tail call i32 (i32, i8*, ...) @fprintf(i32 %10, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* %12)
%14 = load i32, i32* @stderr
%15 = tail call i32 (i32, i8*, ...) @fprintf(i32 %14, i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str.1, i64 0, i64 0))
br label %16
16: ; preds = %2, %9
%17 = phi i32 [ -1, %9 ], [ 0, %2 ]
ret i32 %17
}