#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 */
typedef struct TYPE_2__ TYPE_1__;

/* Type definitions */
struct TYPE_2__ {
  int /*<<< orphan*/ s_addr;
};
struct sockaddr_in {
  int sin_family;
  scalar_t__ sin_port;
  TYPE_1__ sin_addr;
};
typedef int /*<<< orphan*/ fromip;

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
int INET_ADDRSTRLEN;
char *inet_ntop(int /*<<< orphan*/, int /*<<< orphan*/ *, char *, int);
int ntohs(unsigned short);
int /*<<< orphan*/ printf(char *, ...);
void printsin(struct sockaddr_in *sin, char *m1, char *m2) {
  char fromip[INET_ADDRSTRLEN];
  printf("%s %s:\n", m1, m2);
  printf("  family %d, addr %s, port %d\n", sin->sin_family,
         inet_ntop(AF_INET, &(sin->sin_addr.s_addr), fromip, sizeof(fromip)),
         ntohs((unsigned short)(sin->sin_port)));
}


x86 assembly (clang, -O0):
<printsin>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    0x2e8d(%rip),%rax
mov    (%rax),%eax
mov    %rax,-0x40(%rbp)
mov    %rsp,%rcx
mov    %rcx,-0x20(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x48(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
lea    0xe7d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x48(%rbp),%rdx
mov    -0x40(%rbp),%rax
mov    -0x8(%rbp),%rcx
mov    (%rcx),%ecx
mov    %ecx,-0x34(%rbp)
mov    0x2e46(%rip),%rcx
mov    (%rcx),%edi
mov    -0x8(%rbp),%rsi
add    $0x10,%rsi
mov    %eax,%ecx
call   1030 <inet_ntop@plt>
mov    %rax,-0x30(%rbp)
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%rax
movzwl %ax,%edi
call   1050 <ntohs@plt>
mov    -0x34(%rbp),%esi
mov    -0x30(%rbp),%rdx
mov    %eax,%ecx
lea    0xe31(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x20(%rbp),%rax
mov    %rax,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printsin>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %rdi,%r15
mov    0x2e93(%rip),%rax
mov    (%rax),%r14d
mov    %rsp,%rbx
mov    %r14,%rax
add    $0xf,%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rbx
mov    %rbx,%rsp
lea    0xe9d(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    (%r15),%r12d
mov    0x2e74(%rip),%rax
mov    (%rax),%edi
lea    0x10(%r15),%rsi
mov    %rbx,%rdx
mov    %r14d,%ecx
call   1030 <inet_ntop@plt>
mov    %rax,%rbx
movzwl 0x8(%r15),%edi
call   1050 <ntohs@plt>
lea    0xe6f(%rip),%rdi
mov    %r12d,%esi
mov    %rbx,%rdx
mov    %eax,%ecx
xor    %eax,%eax
call   1040 <printf@plt>
lea    -0x20(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.sockaddr_in = type { i32, i64, %struct.TYPE_2__ }
%struct.TYPE_2__ = type { i32 }
@INET_ADDRSTRLEN = global i32 0
@.str = [8 x i8] c"%s %s:\0A\00"
@.str.1 = [31 x i8] c" family %d, addr %s, port %d\0A\00"
@AF_INET = global i32 0
define void @printsin(%struct.sockaddr_in* %0, i8* %1, i8* %2) {
%4 = alloca %struct.sockaddr_in*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i64
store %struct.sockaddr_in* %0, %struct.sockaddr_in** %4
store i8* %1, i8** %5
store i8* %2, i8** %6
%9 = load i32, i32* @INET_ADDRSTRLEN
%10 = zext i32 %9 to i64
%11 = call i8* @llvm.stacksave()
store i8* %11, i8** %7
%12 = alloca i8, i64 %10
store i64 %10, i64* %8
%13 = load i8*, i8** %5
%14 = load i8*, i8** %6
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* %13, i8* %14)
%16 = load %struct.sockaddr_in*, %struct.sockaddr_in** %4
%17 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %16, i32 0, i32 0
%18 = load i32, i32* %17
%19 = load i32, i32* @AF_INET
%20 = load %struct.sockaddr_in*, %struct.sockaddr_in** %4
%21 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %20, i32 0, i32 2
%22 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %21, i32 0, i32 0
%23 = trunc i64 %10 to i32
%24 = call i8* @inet_ntop(i32 %19, i32* %22, i8* %12, i32 %23)
%25 = load %struct.sockaddr_in*, %struct.sockaddr_in** %4
%26 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %25, i32 0, i32 1
%27 = load i64, i64* %26
%28 = trunc i64 %27 to i16
%29 = call i32 @ntohs(i16 zeroext %28)
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0), i32 %18, i8* %24, i32 %29)
%31 = load i8*, i8** %7
ret void
}

LLVM IR (-O2):
%struct.sockaddr_in = type { i32, i64, %struct.TYPE_2__ }
%struct.TYPE_2__ = type { i32 }
@INET_ADDRSTRLEN = global i32 0
@.str = [8 x i8] c"%s %s:\0A\00"
@.str.1 = [31 x i8] c" family %d, addr %s, port %d\0A\00"
@AF_INET = global i32 0
define void @printsin(%struct.sockaddr_in* %0, i8* %1, i8* %2) {
%4 = load i32, i32* @INET_ADDRSTRLEN
%5 = zext i32 %4 to i64
%6 = alloca i8, i64 %5
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i8* %1, i8* %2)
%8 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %0, i64 0, i32 0
%9 = load i32, i32* %8
%10 = load i32, i32* @AF_INET
%11 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %0, i64 0, i32 2, i32 0
%12 = call i8* @inet_ntop(i32 %10, i32* %11, i8* %6, i32 %4)
%13 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %0, i64 0, i32 1
%14 = load i64, i64* %13
%15 = trunc i64 %14 to i16
%16 = call i32 @ntohs(i16 zeroext %15)
%17 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0), i32 %9, i8* %12, i32 %16)
ret void
}