#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 addrinfo {
  int /*<<< orphan*/ ai_addrlen;
  int /*<<< orphan*/ ai_addr;
  int /*<<< orphan*/ ai_protocol;
  int /*<<< orphan*/ ai_socktype;
  int /*<<< orphan*/ ai_family;
};
typedef int /*<<< orphan*/ hints;

/* Variables and functions */
int /*<<< orphan*/ AF_UNSPEC;
int /*<<< orphan*/ SOCK_STREAM;
int /*<<< orphan*/ connect(int, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ freeaddrinfo(struct addrinfo *);
int /*<<< orphan*/ getaddrinfo(char const *, char const *, struct addrinfo *,
                               struct addrinfo **);
int /*<<< orphan*/ memset(struct addrinfo *, int /*<<< orphan*/, int);
int /*<<< orphan*/ send(int, char const *, int /*<<< orphan*/,
                        int /*<<< orphan*/);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ start_main_loop(int);
int /*<<< orphan*/ strlen(char const *);
int main() {
  char const *host = "irc.freenode.net";
  char const *port = "8001";
  char const *nick = "NICK SeaB0t\r\n";
  char const *username = "USER SeaB0t nothing here :Real Name\r\n";
  char const *join = "JOIN #webelearningshit\r\n";
  int socker;
  struct addrinfo hints, *res;
  memset(&hints, 0, sizeof(hints));
  hints.ai_family = AF_UNSPEC;
  hints.ai_socktype = SOCK_STREAM;
  getaddrinfo(host, port, &hints, &res);
  socker = socket(res->ai_family, res->ai_socktype, res->ai_protocol);
  connect(socker, res->ai_addr, res->ai_addrlen);
  send(socker, nick, strlen(nick), 0);
  send(socker, username, strlen(username), 0);
  send(socker, join, strlen(join), 0);
  freeaddrinfo(res);
  start_main_loop(socker);
  return 1;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe67(%rip),%rax
mov    %rax,-0x10(%rbp)
lea    0xe6d(%rip),%rax
mov    %rax,-0x18(%rbp)
lea    0xe67(%rip),%rax
mov    %rax,-0x20(%rbp)
lea    0xe6a(%rip),%rax
mov    %rax,-0x28(%rbp)
lea    0xe85(%rip),%rax
mov    %rax,-0x30(%rbp)
lea    -0x48(%rbp),%rdi
xor    %esi,%esi
mov    $0x14,%edx
call   1050 <memset@plt>
mov    0x2e08(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x38(%rbp)
mov    0x2dec(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x3c(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
lea    -0x48(%rbp),%rdx
lea    -0x50(%rbp),%rcx
call   1080 <getaddrinfo@plt>
mov    -0x50(%rbp),%rax
mov    0x10(%rax),%edi
mov    -0x50(%rbp),%rax
mov    0xc(%rax),%esi
mov    -0x50(%rbp),%rax
mov    0x8(%rax),%edx
call   10a0 <socket@plt>
mov    %eax,-0x34(%rbp)
mov    -0x34(%rbp),%edi
mov    -0x50(%rbp),%rax
mov    0x4(%rax),%esi
mov    -0x50(%rbp),%rax
mov    (%rax),%edx
call   1070 <connect@plt>
mov    -0x34(%rbp),%eax
mov    %eax,-0x7c(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x78(%rbp)
mov    -0x20(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x7c(%rbp),%edi
mov    -0x78(%rbp),%rsi
mov    %eax,%edx
xor    %ecx,%ecx
call   1040 <send@plt>
mov    -0x34(%rbp),%eax
mov    %eax,-0x6c(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,-0x68(%rbp)
mov    -0x28(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x6c(%rbp),%edi
mov    -0x68(%rbp),%rsi
mov    %eax,%edx
xor    %ecx,%ecx
call   1040 <send@plt>
mov    -0x34(%rbp),%eax
mov    %eax,-0x5c(%rbp)
mov    -0x30(%rbp),%rax
mov    %rax,-0x58(%rbp)
mov    -0x30(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x5c(%rbp),%edi
mov    -0x58(%rbp),%rsi
mov    %eax,%edx
xor    %ecx,%ecx
call   1040 <send@plt>
mov    -0x50(%rbp),%rdi
call   1090 <freeaddrinfo@plt>
mov    -0x34(%rbp),%edi
call   1060 <start_main_loop@plt>
mov    $0x1,%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x28,%rsp
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x14,%edx
call   1050 <memset@plt>
mov    0x2e46(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x20(%rsp)
mov    0x2e29(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x1c(%rsp)
lea    0xe44(%rip),%rdi
lea    0xe4e(%rip),%rsi
lea    0x8(%rsp),%rcx
mov    %rbx,%rdx
call   1080 <getaddrinfo@plt>
mov    0x8(%rsp),%rax
mov    0x10(%rax),%edi
mov    0x8(%rax),%edx
mov    0xc(%rax),%esi
call   10a0 <socket@plt>
mov    %eax,%ebx
mov    0x8(%rsp),%rax
mov    (%rax),%edx
mov    0x4(%rax),%esi
mov    %ebx,%edi
call   1070 <connect@plt>
lea    0xe19(%rip),%r14
mov    %r14,%rdi
call   1030 <strlen@plt>
mov    %ebx,%edi
mov    %r14,%rsi
mov    %eax,%edx
xor    %ecx,%ecx
call   1040 <send@plt>
lea    0xe0a(%rip),%r14
mov    %r14,%rdi
call   1030 <strlen@plt>
mov    %ebx,%edi
mov    %r14,%rsi
mov    %eax,%edx
xor    %ecx,%ecx
call   1040 <send@plt>
lea    0xe13(%rip),%r14
mov    %r14,%rdi
call   1030 <strlen@plt>
mov    %ebx,%edi
mov    %r14,%rsi
mov    %eax,%edx
xor    %ecx,%ecx
call   1040 <send@plt>
mov    0x8(%rsp),%rdi
call   1090 <freeaddrinfo@plt>
mov    %ebx,%edi
call   1060 <start_main_loop@plt>
mov    $0x1,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.addrinfo = type { i32, i32, i32, i32, i32 }
@.str = [17 x i8] c"irc.freenode.net\00"
@.str.1 = [5 x i8] c"8001\00"
@.str.2 = [14 x i8] c"NICK SeaB0t\0D\0A\00"
@.str.3 = [38 x i8] c"USER SeaB0t nothing here :Real Name\0D\0A\00"
@.str.4 = [25 x i8] c"JOIN #webelearningshit\0D\0A\00"
@AF_UNSPEC = global i32 0
@SOCK_STREAM = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i32
%8 = alloca %struct.addrinfo
%9 = alloca %struct.addrinfo*
store i32 0, i32* %1
store i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8** %2
store i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i8** %3
store i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i8** %4
store i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.3, i64 0, i64 0), i8** %5
store i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.4, i64 0, i64 0), i8** %6
%10 = call i32 @memset(%struct.addrinfo* %8, i32 0, i32 20)
%11 = load i32, i32* @AF_UNSPEC
%12 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %8, i32 0, i32 4
store i32 %11, i32* %12
%13 = load i32, i32* @SOCK_STREAM
%14 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %8, i32 0, i32 3
store i32 %13, i32* %14
%15 = load i8*, i8** %2
%16 = load i8*, i8** %3
%17 = call i32 @getaddrinfo(i8* %15, i8* %16, %struct.addrinfo* %8, %struct.addrinfo** %9)
%18 = load %struct.addrinfo*, %struct.addrinfo** %9
%19 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %18, i32 0, i32 4
%20 = load i32, i32* %19
%21 = load %struct.addrinfo*, %struct.addrinfo** %9
%22 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %21, i32 0, i32 3
%23 = load i32, i32* %22
%24 = load %struct.addrinfo*, %struct.addrinfo** %9
%25 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %24, i32 0, i32 2
%26 = load i32, i32* %25
%27 = call i32 @socket(i32 %20, i32 %23, i32 %26)
store i32 %27, i32* %7
%28 = load i32, i32* %7
%29 = load %struct.addrinfo*, %struct.addrinfo** %9
%30 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %29, i32 0, i32 1
%31 = load i32, i32* %30
%32 = load %struct.addrinfo*, %struct.addrinfo** %9
%33 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %32, i32 0, i32 0
%34 = load i32, i32* %33
%35 = call i32 @connect(i32 %28, i32 %31, i32 %34)
%36 = load i32, i32* %7
%37 = load i8*, i8** %4
%38 = load i8*, i8** %4
%39 = call i32 @strlen(i8* %38)
%40 = call i32 @send(i32 %36, i8* %37, i32 %39, i32 0)
%41 = load i32, i32* %7
%42 = load i8*, i8** %5
%43 = load i8*, i8** %5
%44 = call i32 @strlen(i8* %43)
%45 = call i32 @send(i32 %41, i8* %42, i32 %44, i32 0)
%46 = load i32, i32* %7
%47 = load i8*, i8** %6
%48 = load i8*, i8** %6
%49 = call i32 @strlen(i8* %48)
%50 = call i32 @send(i32 %46, i8* %47, i32 %49, i32 0)
%51 = load %struct.addrinfo*, %struct.addrinfo** %9
%52 = call i32 @freeaddrinfo(%struct.addrinfo* %51)
%53 = load i32, i32* %7
%54 = call i32 @start_main_loop(i32 %53)
ret i32 1
}

LLVM IR (-O2):
%struct.addrinfo = type { i32, i32, i32, i32, i32 }
@.str = [17 x i8] c"irc.freenode.net\00"
@.str.1 = [5 x i8] c"8001\00"
@.str.2 = [14 x i8] c"NICK SeaB0t\0D\0A\00"
@.str.3 = [38 x i8] c"USER SeaB0t nothing here :Real Name\0D\0A\00"
@.str.4 = [25 x i8] c"JOIN #webelearningshit\0D\0A\00"
@AF_UNSPEC = global i32 0
@SOCK_STREAM = global i32 0
define i32 @main() {
%1 = alloca %struct.addrinfo
%2 = alloca %struct.addrinfo*
%3 = bitcast %struct.addrinfo* %1 to i8*
%4 = bitcast %struct.addrinfo** %2 to i8*
%5 = call i32 @memset(%struct.addrinfo* %1, i32 0, i32 20)
%6 = load i32, i32* @AF_UNSPEC
%7 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %1, i64 0, i32 4
store i32 %6, i32* %7
%8 = load i32, i32* @SOCK_STREAM
%9 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %1, i64 0, i32 3
store i32 %8, i32* %9
%10 = call i32 @getaddrinfo(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), %struct.addrinfo* %1, %struct.addrinfo** %2)
%11 = load %struct.addrinfo*, %struct.addrinfo** %2
%12 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %11, i64 0, i32 4
%13 = load i32, i32* %12
%14 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %11, i64 0, i32 3
%15 = load i32, i32* %14
%16 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %11, i64 0, i32 2
%17 = load i32, i32* %16
%18 = call i32 @socket(i32 %13, i32 %15, i32 %17)
%19 = load %struct.addrinfo*, %struct.addrinfo** %2
%20 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %19, i64 0, i32 1
%21 = load i32, i32* %20
%22 = getelementptr inbounds %struct.addrinfo, %struct.addrinfo* %19, i64 0, i32 0
%23 = load i32, i32* %22
%24 = call i32 @connect(i32 %18, i32 %21, i32 %23)
%25 = call i32 @strlen(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0))
%26 = call i32 @send(i32 %18, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i32 %25, i32 0)
%27 = call i32 @strlen(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.3, i64 0, i64 0))
%28 = call i32 @send(i32 %18, i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.3, i64 0, i64 0), i32 %27, i32 0)
%29 = call i32 @strlen(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.4, i64 0, i64 0))
%30 = call i32 @send(i32 %18, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.4, i64 0, i64 0), i32 %29, i32 0)
%31 = load %struct.addrinfo*, %struct.addrinfo** %2
%32 = call i32 @freeaddrinfo(%struct.addrinfo* %31)
%33 = call i32 @start_main_loop(i32 %18)
ret i32 1
}