#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 EXIT_SUCCESS;
int /*<<< orphan*/ bzero(char *, int);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ strlen(char *);
int write(int, char *, int /*<<< orphan*/);
int send_message(int *sock, char *buffer) {
  int count = write(*sock, buffer, strlen(buffer));
  bzero(buffer, 100);
  if (count < 0) {
    perror("Sending message");
    return 6;
  }
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<send_message>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x2c(%rbp),%edi
mov    -0x28(%rbp),%rsi
mov    %eax,%edx
call   1030 <write@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%rdi
mov    $0x64,%esi
call   1060 <bzero@plt>
cmpl   $0x0,-0x1c(%rbp)
jge    11ab <send_message+0x6b>
lea    0xe66(%rip),%rdi
call   1050 <perror@plt>
movl   $0x6,-0x4(%rbp)
jmp    11b7 <send_message+0x77>
mov    0x2e2e(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<send_message>:
push   %rbp
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    (%rdi),%ebp
mov    %rsi,%rdi
call   1040 <strlen@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %eax,%edx
call   1030 <write@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
mov    $0x64,%esi
call   1060 <bzero@plt>
test   %ebp,%ebp
js     117f <send_message+0x3f>
mov    0x2e6a(%rip),%rax
mov    (%rax),%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret
lea    0xe7a(%rip),%rdi
call   1050 <perror@plt>
mov    $0x6,%eax
jmp    1178 <send_message+0x38>

LLVM IR (-O0):
@.str = [16 x i8] c"Sending message\00"
@EXIT_SUCCESS = global i32 0
define i32 @send_message(i32* %0, i8* %1) {
%3 = alloca i32
%4 = alloca i32*
%5 = alloca i8*
%6 = alloca i32
store i32* %0, i32** %4
store i8* %1, i8** %5
%7 = load i32*, i32** %4
%8 = load i32, i32* %7
%9 = load i8*, i8** %5
%10 = load i8*, i8** %5
%11 = call i32 @strlen(i8* %10)
%12 = call i32 @write(i32 %8, i8* %9, i32 %11)
store i32 %12, i32* %6
%13 = load i8*, i8** %5
%14 = call i32 @bzero(i8* %13, i32 100)
%15 = load i32, i32* %6
%16 = icmp slt i32 %15, 0
br i1 %16, label %17, label %19
17: ; preds = %2
%18 = call i32 @perror(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
store i32 6, i32* %3
br label %21
19: ; preds = %2
%20 = load i32, i32* @EXIT_SUCCESS
store i32 %20, i32* %3
br label %21
21: ; preds = %19, %17
%22 = load i32, i32* %3
ret i32 %22
}

LLVM IR (-O2):
@.str = [16 x i8] c"Sending message\00"
@EXIT_SUCCESS = global i32 0
define i32 @send_message(i32* nocapture %0, i8* %1) {
%3 = load i32, i32* %0
%4 = tail call i32 @strlen(i8* %1)
%5 = tail call i32 @write(i32 %3, i8* %1, i32 %4)
%6 = tail call i32 @bzero(i8* %1, i32 100)
%7 = icmp slt i32 %5, 0
br i1 %7, label %8, label %10
8: ; preds = %2
%9 = tail call i32 @perror(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
br label %12
10: ; preds = %2
%11 = load i32, i32* @EXIT_SUCCESS
br label %12
12: ; preds = %10, %8
%13 = phi i32 [ 6, %8 ], [ %11, %10 ]
ret i32 %13
}