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

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
int /*<<< orphan*/ htonl(int);
int /*<<< orphan*/ htons(int);
struct sockaddr_in com2n(int a1, int a2, int a3, int a4, int p1, int p2) {
  struct sockaddr_in ret;
  ret.sin_addr.s_addr = htonl(a4 + (a3 << 8) + (a2 << 16) + (a1 << 24));
  ret.sin_port = htons((p1 << 8) + p2);
  ret.sin_family = AF_INET;
  return (ret);
}


x86 assembly (clang, -O0):
<com2n>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x14(%rbp)
mov    %esi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    %ecx,-0x20(%rbp)
mov    %r8d,-0x24(%rbp)
mov    %r9d,-0x28(%rbp)
mov    -0x20(%rbp),%edi
mov    -0x1c(%rbp),%eax
shl    $0x8,%eax
add    %eax,%edi
mov    -0x18(%rbp),%eax
shl    $0x10,%eax
add    %eax,%edi
mov    -0x14(%rbp),%eax
shl    $0x18,%eax
add    %eax,%edi
call   1040 <htonl@plt>
mov    %eax,-0x8(%rbp)
mov    -0x24(%rbp),%edi
shl    $0x8,%edi
mov    -0x28(%rbp),%eax
add    %eax,%edi
call   1030 <htons@plt>
mov    %eax,-0xc(%rbp)
mov    0x2e6f(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x30(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rax
mov    -0x30(%rbp),%edx
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<com2n>:
push   %rbp
push   %r14
push   %rbx
mov    %r9d,%r14d
mov    %r8d,%ebp
shl    $0x8,%edx
shl    $0x10,%esi
shl    $0x18,%edi
add    %esi,%edi
add    %ecx,%edi
add    %edx,%edi
call   1040 <htonl@plt>
mov    %eax,%ebx
shl    $0x8,%ebp
add    %r14d,%ebp
mov    %ebp,%edi
call   1030 <htons@plt>
mov    0x2e94(%rip),%rcx
mov    (%rcx),%ecx
shl    $0x20,%rax
or     %rcx,%rax
mov    %ebx,%edx
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
%struct.sockaddr_in = type { i32, i32, %struct.TYPE_2__ }
%struct.TYPE_2__ = type { i32 }
@AF_INET = global i32 0
define { i64, i32 } @com2n(i32 %0, i32 %1, i32 %2, i32 %3, i32 %4, i32 %5) {
%7 = alloca %struct.sockaddr_in
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca { i64, i32 }
store i32 %0, i32* %8
store i32 %1, i32* %9
store i32 %2, i32* %10
store i32 %3, i32* %11
store i32 %4, i32* %12
store i32 %5, i32* %13
%15 = load i32, i32* %11
%16 = load i32, i32* %10
%17 = shl i32 %16, 8
%18 = add nsw i32 %15, %17
%19 = load i32, i32* %9
%20 = shl i32 %19, 16
%21 = add nsw i32 %18, %20
%22 = load i32, i32* %8
%23 = shl i32 %22, 24
%24 = add nsw i32 %21, %23
%25 = call i32 @htonl(i32 %24)
%26 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %7, i32 0, i32 2
%27 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %26, i32 0, i32 0
store i32 %25, i32* %27
%28 = load i32, i32* %12
%29 = shl i32 %28, 8
%30 = load i32, i32* %13
%31 = add nsw i32 %29, %30
%32 = call i32 @htons(i32 %31)
%33 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %7, i32 0, i32 1
store i32 %32, i32* %33
%34 = load i32, i32* @AF_INET
%35 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %7, i32 0, i32 0
store i32 %34, i32* %35
%36 = bitcast { i64, i32 }* %14 to i8*
%37 = bitcast %struct.sockaddr_in* %7 to i8*
%38 = load { i64, i32 }, { i64, i32 }* %14
ret { i64, i32 } %38
}

LLVM IR (-O2):
@AF_INET = global i32 0
define { i64, i32 } @com2n(i32 %0, i32 %1, i32 %2, i32 %3, i32 %4, i32 %5) {
%7 = shl i32 %2, 8
%8 = shl i32 %1, 16
%9 = shl i32 %0, 24
%10 = add i32 %8, %9
%11 = add i32 %10, %3
%12 = add i32 %11, %7
%13 = tail call i32 @htonl(i32 %12)
%14 = shl i32 %4, 8
%15 = add nsw i32 %14, %5
%16 = tail call i32 @htons(i32 %15)
%17 = load i32, i32* @AF_INET
%18 = zext i32 %16 to i64
%19 = shl nuw i64 %18, 32
%20 = zext i32 %17 to i64
%21 = or i64 %19, %20
%22 = insertvalue { i64, i32 } poison, i64 %21, 0
%23 = insertvalue { i64, i32 } %22, i32 %13, 1
ret { i64, i32 } %23
}