#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*/ bzero(char *, int);
int /*<<< orphan*/ error(char *);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ strcpy(char *, char const *);
int /*<<< orphan*/ strlen(char *);
int write(int, char *, int /*<<< orphan*/);
void write_irc(char buffer[], int sockfd, const char *msg) {
  int n;
  bzero(buffer, 1024);
  strcpy(buffer, msg);
  n = write(sockfd, buffer, strlen(buffer));
  printf("%s", buffer);
  if (n < 0)
    error("ERROR writing to socket");
}


x86 assembly (clang, -O0):
<write_irc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
mov    $0x400,%esi
call   1080 <bzero@plt>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0xc(%rbp),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <strlen@plt>
mov    -0x2c(%rbp),%edi
mov    -0x28(%rbp),%rsi
mov    %eax,%edx
call   1040 <write@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x8(%rbp),%rsi
lea    0xe3f(%rip),%rdi
call   1060 <printf@plt>
cmpl   $0x0,-0x1c(%rbp)
jge    11dc <write_irc+0x7c>
lea    0xe2c(%rip),%rdi
call   1070 <error@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<write_irc>:
push   %rbp
push   %r14
push   %rbx
mov    %rdx,%rbx
mov    %esi,%r14d
mov    %rdi,%rbp
mov    $0x400,%esi
call   1080 <bzero@plt>
mov    %rbp,%rdi
mov    %rbx,%rsi
call   1030 <strcpy@plt>
mov    %rbp,%rdi
call   1050 <strlen@plt>
mov    %r14d,%edi
mov    %rbp,%rsi
mov    %eax,%edx
call   1040 <write@plt>
mov    %eax,%ebx
lea    0xe60(%rip),%rdi
mov    %rbp,%rsi
call   1060 <printf@plt>
test   %ebx,%ebx
js     11b1 <write_irc+0x51>
pop    %rbx
pop    %r14
pop    %rbp
ret
lea    0xe4b(%rip),%rdi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1070 <error@plt>

LLVM IR (-O0):
@.str = [3 x i8] c"%s\00"
@.str.1 = [24 x i8] c"ERROR writing to socket\00"
define void @write_irc(i8* %0, i32 %1, i8* %2) {
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i32
store i8* %0, i8** %4
store i32 %1, i32* %5
store i8* %2, i8** %6
%8 = load i8*, i8** %4
%9 = call i32 @bzero(i8* %8, i32 1024)
%10 = load i8*, i8** %4
%11 = load i8*, i8** %6
%12 = call i32 @strcpy(i8* %10, i8* %11)
%13 = load i32, i32* %5
%14 = load i8*, i8** %4
%15 = load i8*, i8** %4
%16 = call i32 @strlen(i8* %15)
%17 = call i32 @write(i32 %13, i8* %14, i32 %16)
store i32 %17, i32* %7
%18 = load i8*, i8** %4
%19 = call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %18)
%20 = load i32, i32* %7
%21 = icmp slt i32 %20, 0
br i1 %21, label %22, label %24
22: ; preds = %3
%23 = call i32 @error(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0))
br label %24
24: ; preds = %22, %3
ret void
}

LLVM IR (-O2):
@.str = [3 x i8] c"%s\00"
@.str.1 = [24 x i8] c"ERROR writing to socket\00"
define void @write_irc(i8* %0, i32 %1, i8* %2) {
%4 = tail call i32 @bzero(i8* %0, i32 1024)
%5 = tail call i32 @strcpy(i8* %0, i8* %2)
%6 = tail call i32 @strlen(i8* %0)
%7 = tail call i32 @write(i32 %1, i8* %0, i32 %6)
%8 = tail call i32 @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %0)
%9 = icmp slt i32 %7, 0
br i1 %9, label %10, label %12
10: ; preds = %3
%11 = tail call i32 @error(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0))
br label %12
12: ; preds = %10, %3
ret void
}