#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 /*<<< orphan*/ sin_port;
  TYPE_1__ sin_addr;
};
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, int, int, int, int,
                           int);
int htonl(int /*<<< orphan*/);
int htons(int /*<<< orphan*/);
void fprintaddr(FILE *file, struct sockaddr_in *addr) {
  fprintf(file, "%i.%i.%i.%i:%i", htonl(addr->sin_addr.s_addr) >> 24 & 0xff,
          htonl(addr->sin_addr.s_addr) >> 16 & 0xff,
          htonl(addr->sin_addr.s_addr) >> 8 & 0xff,
          htonl(addr->sin_addr.s_addr) >> 0 & 0xff, htons(addr->sin_port));
}


x86 assembly (clang, -O0):
<fprintaddr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rax
mov    0x4(%rax),%edi
call   1040 <htonl@plt>
sar    $0x18,%eax
and    $0xff,%eax
mov    %eax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    0x4(%rax),%edi
call   1040 <htonl@plt>
sar    $0x10,%eax
and    $0xff,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
mov    0x4(%rax),%edi
call   1040 <htonl@plt>
sar    $0x8,%eax
and    $0xff,%eax
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x4(%rax),%edi
call   1040 <htonl@plt>
sar    $0x0,%eax
and    $0xff,%eax
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%edi
call   1030 <htons@plt>
mov    -0x28(%rbp),%rdi
mov    -0x20(%rbp),%edx
mov    -0x1c(%rbp),%ecx
mov    -0x18(%rbp),%r8d
mov    -0x14(%rbp),%r9d
lea    0xe38(%rip),%rsi
mov    %eax,(%rsp)
call   1050 <fprintf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fprintaddr>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%r15
mov    0x4(%rsi),%edi
call   1040 <htonl@plt>
mov    %eax,%ebx
mov    %eax,%ecx
movzbl %bh,%edx
mov    %edx,%r13d
movzbl %bl,%r12d
shr    $0x18,%ebx
shr    $0x10,%ecx
movzbl %cl,%ebp
mov    (%r14),%edi
call   1030 <htons@plt>
mov    %eax,(%rsp)
lea    0xe8e(%rip),%rsi
mov    %r15,%rdi
mov    %ebx,%edx
mov    %ebp,%ecx
mov    %r13d,%r8d
mov    %r12d,%r9d
call   1050 <fprintf@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.sockaddr_in = type { i32, %struct.TYPE_2__ }
%struct.TYPE_2__ = type { i32 }
@.str = [15 x i8] c"%i.%i.%i.%i:%i\00"
define void @fprintaddr(i32* %0, %struct.sockaddr_in* %1) {
%3 = alloca i32*
%4 = alloca %struct.sockaddr_in*
store i32* %0, i32** %3
store %struct.sockaddr_in* %1, %struct.sockaddr_in** %4
%5 = load i32*, i32** %3
%6 = load %struct.sockaddr_in*, %struct.sockaddr_in** %4
%7 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %6, i32 0, i32 1
%8 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %7, i32 0, i32 0
%9 = load i32, i32* %8
%10 = call i32 @htonl(i32 %9)
%11 = ashr i32 %10, 24
%12 = and i32 %11, 255
%13 = load %struct.sockaddr_in*, %struct.sockaddr_in** %4
%14 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %13, i32 0, i32 1
%15 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %14, i32 0, i32 0
%16 = load i32, i32* %15
%17 = call i32 @htonl(i32 %16)
%18 = ashr i32 %17, 16
%19 = and i32 %18, 255
%20 = load %struct.sockaddr_in*, %struct.sockaddr_in** %4
%21 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %20, i32 0, i32 1
%22 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %21, i32 0, i32 0
%23 = load i32, i32* %22
%24 = call i32 @htonl(i32 %23)
%25 = ashr i32 %24, 8
%26 = and i32 %25, 255
%27 = load %struct.sockaddr_in*, %struct.sockaddr_in** %4
%28 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %27, i32 0, i32 1
%29 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %28, i32 0, i32 0
%30 = load i32, i32* %29
%31 = call i32 @htonl(i32 %30)
%32 = ashr i32 %31, 0
%33 = and i32 %32, 255
%34 = load %struct.sockaddr_in*, %struct.sockaddr_in** %4
%35 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %34, i32 0, i32 0
%36 = load i32, i32* %35
%37 = call i32 @htons(i32 %36)
%38 = call i32 @fprintf(i32* %5, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i32 %12, i32 %19, i32 %26, i32 %33, i32 %37)
ret void
}

LLVM IR (-O2):
%struct.sockaddr_in = type { i32, %struct.TYPE_2__ }
%struct.TYPE_2__ = type { i32 }
@.str = [15 x i8] c"%i.%i.%i.%i:%i\00"
define void @fprintaddr(i32* nocapture %0, %struct.sockaddr_in* nocapture %1) {
%3 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %1, i64 0, i32 1, i32 0
%4 = load i32, i32* %3
%5 = tail call i32 @htonl(i32 %4)
%6 = lshr i32 %5, 24
%7 = lshr i32 %5, 16
%8 = and i32 %7, 255
%9 = lshr i32 %5, 8
%10 = and i32 %9, 255
%11 = and i32 %5, 255
%12 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %1, i64 0, i32 0
%13 = load i32, i32* %12
%14 = tail call i32 @htons(i32 %13)
%15 = tail call i32 @fprintf(i32* %0, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i32 %6, i32 %8, i32 %10, i32 %11, i32 %14)
ret void
}