#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*/ abort();
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ fputs(char *, int /*<<< orphan*/);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ stderr;
scalar_t__ strlen(char *);
scalar_t__ write(int, char *, scalar_t__);
void send_raw_msg(int socket, char *message) {
  fprintf(stderr, "Sending message: %s", message);
  if (write(socket, message, strlen(message)) != strlen(message)) {
    perror("write");
    fputs("Sending message failed!", stderr);
    abort();
  }
}


x86 assembly (clang, -O0):
<send_raw_msg>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    0x2e6a(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rdx
lea    0xe7d(%rip),%rsi
call   1070 <fprintf@plt>
mov    -0x4(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0x24(%rbp),%edi
mov    -0x20(%rbp),%rsi
mov    %rax,%rdx
call   1040 <write@plt>
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <strlen@plt>
mov    %rax,%rcx
mov    -0x18(%rbp),%rax
cmp    %rcx,%rax
je     11f3 <send_raw_msg+0x93>
lea    0xe42(%rip),%rdi
call   1080 <perror@plt>
mov    0x2e02(%rip),%rax
mov    (%rax),%esi
lea    0xe33(%rip),%rdi
call   1060 <fputs@plt>
mov    $0x0,%al
call   1030 <abort@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<send_raw_msg>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%rbx
mov    %edi,%ebp
mov    0x2e70(%rip),%r14
mov    (%r14),%edi
lea    0xe86(%rip),%rsi
mov    %rbx,%rdx
call   1070 <fprintf@plt>
mov    %rbx,%rdi
call   1050 <strlen@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %rax,%rdx
call   1040 <write@plt>
mov    %rax,%rbp
mov    %rbx,%rdi
call   1050 <strlen@plt>
cmp    %rax,%rbp
jne    11ac <send_raw_msg+0x4c>
pop    %rbx
pop    %r14
pop    %rbp
ret
lea    0xe61(%rip),%rdi
call   1080 <perror@plt>
mov    (%r14),%esi
lea    0xe58(%rip),%rdi
call   1060 <fputs@plt>
xor    %eax,%eax
call   1030 <abort@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [20 x i8] c"Sending message: %s\00"
@.str.1 = [6 x i8] c"write\00"
@.str.2 = [24 x i8] c"Sending message failed!\00"
define void @send_raw_msg(i32 %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
store i32 %0, i32* %3
store i8* %1, i8** %4
%5 = load i32, i32* @stderr
%6 = load i8*, i8** %4
%7 = call i32 @fprintf(i32 %5, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i8* %6)
%8 = load i32, i32* %3
%9 = load i8*, i8** %4
%10 = load i8*, i8** %4
%11 = call i64 @strlen(i8* %10)
%12 = call i64 @write(i32 %8, i8* %9, i64 %11)
%13 = load i8*, i8** %4
%14 = call i64 @strlen(i8* %13)
%15 = icmp ne i64 %12, %14
br i1 %15, label %16, label %21
16: ; preds = %2
%17 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%18 = load i32, i32* @stderr
%19 = call i32 @fputs(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0), i32 %18)
%20 = call i32 (...) @abort()
unreachable
21: ; preds = %2
ret void
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [20 x i8] c"Sending message: %s\00"
@.str.1 = [6 x i8] c"write\00"
@.str.2 = [24 x i8] c"Sending message failed!\00"
define void @send_raw_msg(i32 %0, i8* %1) {
%3 = load i32, i32* @stderr
%4 = tail call i32 @fprintf(i32 %3, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i8* %1)
%5 = tail call i64 @strlen(i8* dereferenceable(1) %1)
%6 = tail call i64 @write(i32 %0, i8* %1, i64 %5)
%7 = tail call i64 @strlen(i8* dereferenceable(1) %1)
%8 = icmp eq i64 %6, %7
br i1 %8, label %14, label %9
9: ; preds = %2
%10 = tail call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%11 = load i32, i32* @stderr
%12 = tail call i32 @fputs(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0), i32 %11)
%13 = tail call i32 (...) @abort()
unreachable
14: ; preds = %2
ret void
}