#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 s_addr;
};
struct sockaddr_in {
  int sin_port;
  TYPE_1__ sin_addr;
};
struct sockaddr {
  int dummy;
};

/* Variables and functions */
void get_address_bytes(int *addr_bytes, const struct sockaddr *addr) {
  struct sockaddr_in *inaddr = (struct sockaddr_in *)addr;
  addr_bytes[0] = inaddr->sin_addr.s_addr >> 0 & 0xFF;
  addr_bytes[1] = inaddr->sin_addr.s_addr >> 8 & 0xFF;
  addr_bytes[2] = inaddr->sin_addr.s_addr >> 16 & 0xFF;
  addr_bytes[3] = inaddr->sin_addr.s_addr >> 24 & 0xFF;
  addr_bytes[4] = inaddr->sin_port;
}


x86 assembly (clang, -O0):
<get_address_bytes>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    0x4(%rax),%ecx
sar    $0x0,%ecx
and    $0xff,%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x18(%rbp),%rax
mov    0x4(%rax),%ecx
sar    $0x8,%ecx
and    $0xff,%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,0x4(%rax)
mov    -0x18(%rbp),%rax
mov    0x4(%rax),%ecx
sar    $0x10,%ecx
and    $0xff,%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,0x8(%rax)
mov    -0x18(%rbp),%rax
mov    0x4(%rax),%ecx
sar    $0x18,%ecx
and    $0xff,%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,0xc(%rax)
mov    -0x18(%rbp),%rax
mov    (%rax),%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,0x10(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_address_bytes>:
movzbl 0x4(%rsi),%eax
mov    %eax,(%rdi)
movzbl 0x5(%rsi),%eax
mov    %eax,0x4(%rdi)
movzbl 0x6(%rsi),%eax
mov    %eax,0x8(%rdi)
movzbl 0x7(%rsi),%eax
mov    %eax,0xc(%rdi)
mov    (%rsi),%eax
mov    %eax,0x10(%rdi)
ret

LLVM IR (-O0):
%struct.sockaddr = type { i32 }
%struct.sockaddr_in = type { i32, %struct.TYPE_2__ }
%struct.TYPE_2__ = type { i32 }
define void @get_address_bytes(i32* %0, %struct.sockaddr* %1) {
%3 = alloca i32*
%4 = alloca %struct.sockaddr*
%5 = alloca %struct.sockaddr_in*
store i32* %0, i32** %3
store %struct.sockaddr* %1, %struct.sockaddr** %4
%6 = load %struct.sockaddr*, %struct.sockaddr** %4
%7 = bitcast %struct.sockaddr* %6 to %struct.sockaddr_in*
store %struct.sockaddr_in* %7, %struct.sockaddr_in** %5
%8 = load %struct.sockaddr_in*, %struct.sockaddr_in** %5
%9 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %8, i32 0, i32 1
%10 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %9, i32 0, i32 0
%11 = load i32, i32* %10
%12 = ashr i32 %11, 0
%13 = and i32 %12, 255
%14 = load i32*, i32** %3
%15 = getelementptr inbounds i32, i32* %14, i64 0
store i32 %13, i32* %15
%16 = load %struct.sockaddr_in*, %struct.sockaddr_in** %5
%17 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %16, i32 0, i32 1
%18 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %17, i32 0, i32 0
%19 = load i32, i32* %18
%20 = ashr i32 %19, 8
%21 = and i32 %20, 255
%22 = load i32*, i32** %3
%23 = getelementptr inbounds i32, i32* %22, i64 1
store i32 %21, i32* %23
%24 = load %struct.sockaddr_in*, %struct.sockaddr_in** %5
%25 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %24, i32 0, i32 1
%26 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %25, i32 0, i32 0
%27 = load i32, i32* %26
%28 = ashr i32 %27, 16
%29 = and i32 %28, 255
%30 = load i32*, i32** %3
%31 = getelementptr inbounds i32, i32* %30, i64 2
store i32 %29, i32* %31
%32 = load %struct.sockaddr_in*, %struct.sockaddr_in** %5
%33 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %32, i32 0, i32 1
%34 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %33, i32 0, i32 0
%35 = load i32, i32* %34
%36 = ashr i32 %35, 24
%37 = and i32 %36, 255
%38 = load i32*, i32** %3
%39 = getelementptr inbounds i32, i32* %38, i64 3
store i32 %37, i32* %39
%40 = load %struct.sockaddr_in*, %struct.sockaddr_in** %5
%41 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %40, i32 0, i32 0
%42 = load i32, i32* %41
%43 = load i32*, i32** %3
%44 = getelementptr inbounds i32, i32* %43, i64 4
store i32 %42, i32* %44
ret void
}

LLVM IR (-O2):
%struct.sockaddr = type { i32 }
define void @get_address_bytes(i32* nocapture writeonly %0, %struct.sockaddr* nocapture %1) {
%3 = getelementptr inbounds %struct.sockaddr, %struct.sockaddr* %1, i64 1, i32 0
%4 = load i32, i32* %3
%5 = and i32 %4, 255
store i32 %5, i32* %0
%6 = load i32, i32* %3
%7 = lshr i32 %6, 8
%8 = and i32 %7, 255
%9 = getelementptr inbounds i32, i32* %0, i64 1
store i32 %8, i32* %9
%10 = load i32, i32* %3
%11 = lshr i32 %10, 16
%12 = and i32 %11, 255
%13 = getelementptr inbounds i32, i32* %0, i64 2
store i32 %12, i32* %13
%14 = load i32, i32* %3
%15 = lshr i32 %14, 24
%16 = getelementptr inbounds i32, i32* %0, i64 3
store i32 %15, i32* %16
%17 = getelementptr %struct.sockaddr, %struct.sockaddr* %1, i64 0, i32 0
%18 = load i32, i32* %17
%19 = getelementptr inbounds i32, i32* %0, i64 4
store i32 %18, i32* %19
ret void
}