#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 */
typedef int /*<<< orphan*/ uint8_t;
struct TYPE_2__ {
  int /*<<< orphan*/ s_addr;
};
struct sockaddr_in {
  TYPE_1__ sin_addr;
  int /*<<< orphan*/ sin_family;
};
struct packet {
  int dummy;
};
typedef int /*<<< orphan*/ ret;

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
int /*<<< orphan*/ *find_option(struct packet *, int /*<<< orphan*/);
int /*<<< orphan*/ memcpy(int /*<<< orphan*/ *, int /*<<< orphan*/ *, int);
int /*<<< orphan*/ memset(struct sockaddr_in *, int /*<<< orphan*/, int);
struct sockaddr_in parse_ip(uint8_t option, struct packet *pckt) {
  uint8_t *options = find_option(pckt, option);
  struct sockaddr_in ret;
  memset(&ret, 0, sizeof(ret));
  ret.sin_family = AF_INET;
  memcpy(&ret.sin_addr.s_addr, options, 4);
  ret.sin_addr.s_addr = ret.sin_addr.s_addr;
  return ret;
}


x86 assembly (clang, -O0):
<parse_ip>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0xc(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0xc(%rbp),%esi
call   1030 <find_option@plt>
mov    %rax,-0x20(%rbp)
lea    -0x8(%rbp),%rdi
xor    %esi,%esi
mov    $0x8,%edx
call   1040 <memset@plt>
mov    0x2e82(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
lea    -0x8(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    $0x4,%edx
call   1050 <memcpy@plt>
mov    -0x8(%rbp),%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_ip>:
push   %r14
push   %rbx
push   %rax
mov    %edi,%eax
mov    %rsi,%rdi
mov    %eax,%esi
call   1030 <find_option@plt>
mov    %rax,%rbx
mov    %rsp,%r14
mov    %r14,%rdi
xor    %esi,%esi
mov    $0x8,%edx
call   1040 <memset@plt>
mov    0x2e8c(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x4(%rsp)
mov    %r14,%rdi
mov    %rbx,%rsi
mov    $0x4,%edx
call   1050 <memcpy@plt>
mov    (%rsp),%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.packet = type { i32 }
%struct.sockaddr_in = type { %struct.TYPE_2__, i32 }
%struct.TYPE_2__ = type { i32 }
@AF_INET = global i32 0
define i64 @parse_ip(i32 %0, %struct.packet* %1) {
%3 = alloca %struct.sockaddr_in
%4 = alloca i32
%5 = alloca %struct.packet*
%6 = alloca i32*
store i32 %0, i32* %4
store %struct.packet* %1, %struct.packet** %5
%7 = load %struct.packet*, %struct.packet** %5
%8 = load i32, i32* %4
%9 = call i32* @find_option(%struct.packet* %7, i32 %8)
store i32* %9, i32** %6
%10 = call i32 @memset(%struct.sockaddr_in* %3, i32 0, i32 8)
%11 = load i32, i32* @AF_INET
%12 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i32 0, i32 1
store i32 %11, i32* %12
%13 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i32 0, i32 0
%14 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %13, i32 0, i32 0
%15 = load i32*, i32** %6
%16 = call i32 @memcpy(i32* %14, i32* %15, i32 4)
%17 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i32 0, i32 0
%18 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %17, i32 0, i32 0
%19 = load i32, i32* %18
%20 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %3, i32 0, i32 0
%21 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %20, i32 0, i32 0
store i32 %19, i32* %21
%22 = bitcast %struct.sockaddr_in* %3 to i64*
%23 = load i64, i64* %22
ret i64 %23
}

LLVM IR (-O2):
%struct.packet = type { i32 }
%struct.sockaddr_in = type { %struct.TYPE_2__, i32 }
%struct.TYPE_2__ = type { i32 }
@AF_INET = global i32 0
define i64 @parse_ip(i32 %0, %struct.packet* %1) {
%3 = alloca i64
%4 = bitcast i64* %3 to %struct.sockaddr_in*
%5 = tail call i32* @find_option(%struct.packet* %1, i32 %0)
%6 = call i32 @memset(%struct.sockaddr_in* %4, i32 0, i32 8)
%7 = load i32, i32* @AF_INET
%8 = getelementptr inbounds %struct.sockaddr_in, %struct.sockaddr_in* %4, i64 0, i32 1
store i32 %7, i32* %8
%9 = bitcast i64* %3 to i32*
%10 = call i32 @memcpy(i32* %9, i32* %5, i32 4)
%11 = load i64, i64* %3
ret i64 %11
}