#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 sockaddr_in {
  int /*<<< orphan*/ sin_port;
  int /*<<< orphan*/ sin_addr;
};

/* Variables and functions */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, ...);
char *inet_ntoa(int /*<<< orphan*/);
int ntohs(int /*<<< orphan*/);
int /*<<< orphan*/ putc(char, int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
void narrate(char *msg1, char *msg2, struct sockaddr_in *clientp) {
  fprintf(stderr, "\t\tSERVER: %s %s", msg1, msg2);
  if (clientp) {
    fprintf(stderr, "(%s:%d)", inet_ntoa(clientp->sin_addr),
            ntohs(clientp->sin_port));
  }
  putc('\n', stderr);
}


x86 assembly (clang, -O0):
<narrate>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    0x2e85(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
mov    -0x10(%rbp),%rcx
lea    0xe94(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
cmpq   $0x0,-0x18(%rbp)
je     11bc <narrate+0x7c>
mov    0x2e5b(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x24(%rbp)
mov    -0x18(%rbp),%rax
mov    0x4(%rax),%edi
call   1030 <inet_ntoa@plt>
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rax
mov    (%rax),%edi
call   1060 <ntohs@plt>
mov    -0x24(%rbp),%edi
mov    -0x20(%rbp),%rdx
mov    %eax,%ecx
lea    0xe5b(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    0x2e1d(%rip),%rax
mov    (%rax),%esi
mov    $0xa,%edi
call   1040 <putc@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<narrate>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdx,%rbx
mov    %rsi,%rcx
mov    %rdi,%rdx
mov    0x2e89(%rip),%r15
mov    (%r15),%edi
lea    0xe9f(%rip),%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
test   %rbx,%rbx
je     1198 <narrate+0x58>
mov    (%r15),%r14d
mov    0x4(%rbx),%edi
call   1030 <inet_ntoa@plt>
mov    %rax,%rbp
mov    (%rbx),%edi
call   1060 <ntohs@plt>
lea    0xe87(%rip),%rsi
mov    %r14d,%edi
mov    %rbp,%rdx
mov    %eax,%ecx
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    (%r15),%esi
mov    $0xa,%edi
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <putc@plt>

LLVM IR (-O0):
%struct.sockaddr_in = type { i32, i32 }
@stderr = global i32 0
@.str = [16 x i8] c"\09\09SERVER: %s %s\00"
@.str.1 = [8 x i8] c"(%s:%d)\00"
define void @narrate(i8* %0, i8* %1, %struct.sockaddr_in* %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca %struct.sockaddr_in*
store i8* %0, i8** %4
store i8* %1, i8** %5
store %struct.sockaddr_in* %2, %struct.sockaddr_in** %6
%7 = load i32, i32* @stderr
%8 = load i8*, i8** %4
%9 = load i8*, i8** %5
%10 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %7, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8* %8, i8* %9)
%11 = load %struct.sockaddr_in*, %struct.sockaddr_in** %6
%12 = icmp ne %struct.sockaddr_in* %11, null
br i1 %12, label %13, label %24
13: ; preds = %3
%14 = load i32, i32* @stderr
%15 = load %struct.sockaddr_in*, %struct.sockaddr_in** %6
%16 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %15, i32 0, i32 1
%17 = load i32, i32* %16
%18 = call i8* @inet_ntoa(i32 %17)
%19 = load %struct.sockaddr_in*, %struct.sockaddr_in** %6
%20 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %19, i32 0, i32 0
%21 = load i32, i32* %20
%22 = call i32 @ntohs(i32 %21)
%23 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %14, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i8* %18, i32 %22)
br label %24
24: ; preds = %13, %3
%25 = load i32, i32* @stderr
%26 = call i32 @putc(i8 signext 10, i32 %25)
ret void
}

LLVM IR (-O2):
%struct.sockaddr_in = type { i32, i32 }
@stderr = global i32 0
@.str = [16 x i8] c"\09\09SERVER: %s %s\00"
@.str.1 = [8 x i8] c"(%s:%d)\00"
define void @narrate(i8* %0, i8* %1, %struct.sockaddr_in* %2) {
%4 = load i32, i32* @stderr
%5 = tail call i32 (i32, i8*, i8*, ...) @fprintf(i32 %4, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8* %0, i8* %1)
%6 = icmp eq %struct.sockaddr_in* %2, null
br i1 %6, label %16, label %7
7: ; preds = %3
%8 = load i32, i32* @stderr
%9 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %2, i64 0, i32 1
%10 = load i32, i32* %9
%11 = tail call i8* @inet_ntoa(i32 %10)
%12 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %2, i64 0, i32 0
%13 = load i32, i32* %12
%14 = tail call i32 @ntohs(i32 %13)
%15 = tail call i32 (i32, i8*, i8*, ...) @fprintf(i32 %8, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i8* %11, i32 %14)
br label %16
16: ; preds = %7, %3
%17 = load i32, i32* @stderr
%18 = tail call i32 @putc(i8 signext 10, i32 %17)
ret void
}