#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 message {
  int dummy;
};
struct connection {
  int dummy;
};

/* Variables and functions */
struct message *connection_get_output_message(struct connection *);
int /*<<< orphan*/ connection_send(struct connection *, struct message *);
int /*<<< orphan*/ message_add_str(struct message *, char *, int);
int /*<<< orphan*/ message_begin(struct connection *, struct message *);
int /*<<< orphan*/ message_end(struct connection *, struct message *);
void send_hello(struct connection *conn) {
  struct message *msg;
  msg = connection_get_output_message(conn);
  message_begin(conn, msg);
  message_add_str(msg, "Hello World", 11);
  message_end(conn, msg);
  connection_send(conn, msg);
}


x86 assembly (clang, -O0):
<send_hello>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <connection_get_output_message@plt>
mov    %rax,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1050 <message_begin@plt>
mov    -0x10(%rbp),%rdi
lea    0xe7f(%rip),%rsi
mov    $0xb,%edx
call   1070 <message_add_str@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <message_end@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1060 <connection_send@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<send_hello>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
call   1040 <connection_get_output_message@plt>
mov    %rax,%rbx
mov    %r14,%rdi
mov    %rax,%rsi
call   1050 <message_begin@plt>
lea    0xe8f(%rip),%rsi
mov    %rbx,%rdi
mov    $0xb,%edx
call   1070 <message_add_str@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1030 <message_end@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1060 <connection_send@plt>

LLVM IR (-O0):
%struct.connection = type { i32 }
%struct.message = type { i32 }
@.str = [12 x i8] c"Hello World\00"
define void @send_hello(%struct.connection* %0) {
%2 = alloca %struct.connection*
%3 = alloca %struct.message*
store %struct.connection* %0, %struct.connection** %2
%4 = load %struct.connection*, %struct.connection** %2
%5 = call %struct.message* @connection_get_output_message(%struct.connection* %4)
store %struct.message* %5, %struct.message** %3
%6 = load %struct.connection*, %struct.connection** %2
%7 = load %struct.message*, %struct.message** %3
%8 = call i32 @message_begin(%struct.connection* %6, %struct.message* %7)
%9 = load %struct.message*, %struct.message** %3
%10 = call i32 @message_add_str(%struct.message* %9, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 11)
%11 = load %struct.connection*, %struct.connection** %2
%12 = load %struct.message*, %struct.message** %3
%13 = call i32 @message_end(%struct.connection* %11, %struct.message* %12)
%14 = load %struct.connection*, %struct.connection** %2
%15 = load %struct.message*, %struct.message** %3
%16 = call i32 @connection_send(%struct.connection* %14, %struct.message* %15)
ret void
}

LLVM IR (-O2):
%struct.connection = type { i32 }
%struct.message = type { i32 }
@.str = [12 x i8] c"Hello World\00"
define void @send_hello(%struct.connection* %0) {
%2 = tail call %struct.message* @connection_get_output_message(%struct.connection* %0)
%3 = tail call i32 @message_begin(%struct.connection* %0, %struct.message* %2)
%4 = tail call i32 @message_add_str(%struct.message* %2, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 11)
%5 = tail call i32 @message_end(%struct.connection* %0, %struct.message* %2)
%6 = tail call i32 @connection_send(%struct.connection* %0, %struct.message* %2)
ret void
}