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

/* 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 *clientp) {
  struct sockaddr_in *p = (struct sockaddr_in *)clientp;
  fprintf(stderr, "\t\tSERVER: %s %s ", msg1, msg2);
  if (clientp) {
    fprintf(stderr, "(%s:%d)", inet_ntoa(p->sin_addr), ntohs(p->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    -0x18(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    0x2e7d(%rip),%rax
mov    (%rax),%edi
mov    -0x8(%rbp),%rdx
mov    -0x10(%rbp),%rcx
lea    0xe8c(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
cmpq   $0x0,-0x18(%rbp)
je     11c4 <narrate+0x84>
mov    0x2e53(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x20(%rbp),%rax
mov    0x4(%rax),%edi
call   1030 <inet_ntoa@plt>
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rax
mov    (%rax),%edi
call   1060 <ntohs@plt>
mov    -0x2c(%rbp),%edi
mov    -0x28(%rbp),%rdx
mov    %eax,%ecx
lea    0xe54(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
mov    0x2e15(%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    0xe88(%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 = type { i32 }
%struct.sockaddr_in = type { i32, i32 }
@stderr = global i32 0
@.str = [17 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* %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca %struct.sockaddr*
%7 = alloca %struct.sockaddr_in*
store i8* %0, i8** %4
store i8* %1, i8** %5
store %struct.sockaddr* %2, %struct.sockaddr** %6
%8 = load %struct.sockaddr*, %struct.sockaddr** %6
%9 = bitcast %struct.sockaddr* %8 to %struct.sockaddr_in*
store %struct.sockaddr_in* %9, %struct.sockaddr_in** %7
%10 = load i32, i32* @stderr
%11 = load i8*, i8** %4
%12 = load i8*, i8** %5
%13 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %10, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8* %11, i8* %12)
%14 = load %struct.sockaddr*, %struct.sockaddr** %6
%15 = icmp ne %struct.sockaddr* %14, null
br i1 %15, label %16, label %27
16: ; preds = %3
%17 = load i32, i32* @stderr
%18 = load %struct.sockaddr_in*, %struct.sockaddr_in** %7
%19 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %18, i32 0, i32 1
%20 = load i32, i32* %19
%21 = call i8* @inet_ntoa(i32 %20)
%22 = load %struct.sockaddr_in*, %struct.sockaddr_in** %7
%23 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %22, i32 0, i32 0
%24 = load i32, i32* %23
%25 = call i32 @ntohs(i32 %24)
%26 = call i32 (i32, i8*, i8*, ...) @fprintf(i32 %17, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i8* %21, i32 %25)
br label %27
27: ; preds = %16, %3
%28 = load i32, i32* @stderr
%29 = call i32 @putc(i8 signext 10, i32 %28)
ret void
}

LLVM IR (-O2):
%struct.sockaddr = type { i32 }
@stderr = global i32 0
@.str = [17 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* %2) {
%4 = load i32, i32* @stderr
%5 = tail call i32 (i32, i8*, i8*, ...) @fprintf(i32 %4, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8* %0, i8* %1)
%6 = icmp eq %struct.sockaddr* %2, null
br i1 %6, label %16, label %7
7: ; preds = %3
%8 = load i32, i32* @stderr
%9 = getelementptr inbounds %struct.sockaddr, %struct.sockaddr* %2, i64 1, i32 0
%10 = load i32, i32* %9
%11 = tail call i8* @inet_ntoa(i32 %10)
%12 = getelementptr %struct.sockaddr, %struct.sockaddr* %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
}