#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*/ stderr;
extern void narrate(char *msg1, char *msg2, struct sockaddr_in *clientp) {
  fprintf(stderr, "SERVER: %s %s", msg1, msg2);
  if (clientp)
    fprintf(stderr, "(%s: %d)\n", inet_ntoa(clientp->sin_addr),
            ntohs(clientp->sin_port));
}


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    0x2e95(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
mov    -0x10(%rbp),%rcx
lea    0xea4(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
cmpq   $0x0,-0x18(%rbp)
je     11ac <narrate+0x7c>
mov    0x2e6b(%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   1050 <ntohs@plt>
mov    -0x24(%rbp),%edi
mov    -0x20(%rbp),%rdx
mov    %eax,%ecx
lea    0xe69(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<narrate>:
push   %rbp
push   %r14
push   %rbx
mov    %rdx,%rbx
mov    %rsi,%rcx
mov    %rdi,%rdx
mov    0x2e9c(%rip),%rbp
mov    0x0(%rbp),%edi
lea    0xeb2(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
test   %rbx,%rbx
je     118a <narrate+0x5a>
mov    0x0(%rbp),%r14d
mov    0x4(%rbx),%edi
call   1030 <inet_ntoa@plt>
mov    %rax,%rbp
mov    (%rbx),%edi
call   1050 <ntohs@plt>
lea    0xe97(%rip),%rsi
mov    %r14d,%edi
mov    %rbp,%rdx
mov    %eax,%ecx
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
jmp    1040 <fprintf@plt>
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
%struct.sockaddr_in = type { i32, i32 }
@stderr = global i32 0
@.str = [14 x i8] c"SERVER: %s %s\00"
@.str.1 = [10 x i8] c"(%s: %d)\0A\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 ([14 x i8], [14 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 ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8* %18, i32 %22)
br label %24
24: ; preds = %13, %3
ret void
}

LLVM IR (-O2):
%struct.sockaddr_in = type { i32, i32 }
@stderr = global i32 0
@.str = [14 x i8] c"SERVER: %s %s\00"
@.str.1 = [10 x i8] c"(%s: %d)\0A\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 ([14 x i8], [14 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 ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8* %11, i32 %14)
br label %16
16: ; preds = %7, %3
ret void
}