#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_4__ TYPE_2__;
typedef struct TYPE_3__ TYPE_1__;

/* Type definitions */
struct iw_request_info {
  int dummy;
};
struct TYPE_3__ {
  int length;
};
struct TYPE_4__ {
  TYPE_1__ data;
};
struct iw_event {
  int len;
  TYPE_2__ u;
};

/* Variables and functions */
int IW_EV_LCP_PK_LEN;
int IW_EV_POINT_OFF;
int IW_EV_POINT_PK_LEN;
int iwe_stream_lcp_len(struct iw_request_info *);
int iwe_stream_point_len(struct iw_request_info *);
scalar_t__ likely(int);
int /*<<< orphan*/ memcpy(char *, char *, int);
char *iwe_stream_add_point(struct iw_request_info *info, char *stream,
                           char *ends, struct iw_event *iwe, char *extra) {
  int event_len = iwe_stream_point_len(info) + iwe->u.data.length;
  int point_len = iwe_stream_point_len(info);
  int lcp_len = iwe_stream_lcp_len(info);
  if (likely((stream + event_len) < ends)) {
    iwe->len = event_len;
    memcpy(stream, (char *)iwe, IW_EV_LCP_PK_LEN);
    memcpy(stream + lcp_len, ((char *)&iwe->u) + IW_EV_POINT_OFF,
           IW_EV_POINT_PK_LEN - IW_EV_LCP_PK_LEN);
    if (iwe->u.data.length && extra)
      memcpy(stream + point_len, extra, iwe->u.data.length);
    stream += event_len;
  }
  return stream;
}


x86 assembly (clang, -O0):
<iwe_stream_add_point>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    -0x8(%rbp),%rdi
call   1060 <iwe_stream_point_len@plt>
mov    -0x20(%rbp),%rcx
add    0x4(%rcx),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x8(%rbp),%rdi
call   1060 <iwe_stream_point_len@plt>
mov    %eax,-0x30(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <iwe_stream_lcp_len@plt>
mov    %eax,-0x34(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x2c(%rbp),%rcx
add    %rcx,%rax
cmp    -0x18(%rbp),%rax
setb   %al
and    $0x1,%al
movzbl %al,%edi
call   1050 <likely@plt>
cmp    $0x0,%rax
je     1248 <iwe_stream_add_point+0x108>
mov    -0x2c(%rbp),%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    0x2e23(%rip),%rax
mov    (%rax),%edx
call   1030 <memcpy@plt>
mov    -0x10(%rbp),%rdi
movslq -0x34(%rbp),%rax
add    %rax,%rdi
mov    -0x20(%rbp),%rsi
add    $0x4,%rsi
mov    0x2df2(%rip),%rax
movslq (%rax),%rax
add    %rax,%rsi
mov    0x2ddd(%rip),%rax
mov    (%rax),%edx
mov    0x2dec(%rip),%rax
sub    (%rax),%edx
call   1030 <memcpy@plt>
mov    -0x20(%rbp),%rax
cmpl   $0x0,0x4(%rax)
je     1237 <iwe_stream_add_point+0xf7>
cmpq   $0x0,-0x28(%rbp)
je     1237 <iwe_stream_add_point+0xf7>
mov    -0x10(%rbp),%rdi
movslq -0x30(%rbp),%rax
add    %rax,%rdi
mov    -0x28(%rbp),%rsi
mov    -0x20(%rbp),%rax
mov    0x4(%rax),%edx
call   1030 <memcpy@plt>
mov    -0x2c(%rbp),%ecx
mov    -0x10(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<iwe_stream_add_point>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %r8,0x10(%rsp)
mov    %rcx,%rbx
mov    %rdx,%r13
mov    %rsi,%r12
mov    %rdi,%rbp
call   1060 <iwe_stream_point_len@plt>
movslq 0x4(%rbx),%rcx
movslq %eax,%r14
add    %rcx,%r14
mov    %rbp,%rdi
call   1060 <iwe_stream_point_len@plt>
mov    %eax,0xc(%rsp)
mov    %rbp,%rdi
call   1040 <iwe_stream_lcp_len@plt>
mov    %eax,%ebp
lea    (%r12,%r14,1),%r15
xor    %edi,%edi
cmp    %r13,%r15
setb   %dil
call   1050 <likely@plt>
test   %rax,%rax
je     11fe <iwe_stream_add_point+0xbe>
lea    0x4(%rbx),%r13
mov    %r14d,(%rbx)
mov    0x2e3f(%rip),%r14
mov    (%r14),%edx
mov    %r12,%rdi
mov    %rbx,%rsi
call   1030 <memcpy@plt>
movslq %ebp,%rdi
add    %r12,%rdi
mov    0x2e14(%rip),%rax
movslq (%rax),%rsi
add    %r13,%rsi
mov    0x2dff(%rip),%rax
mov    (%rax),%edx
sub    (%r14),%edx
call   1030 <memcpy@plt>
mov    0x10(%rsp),%rsi
test   %rsi,%rsi
je     1201 <iwe_stream_add_point+0xc1>
mov    0x4(%rbx),%edx
test   %edx,%edx
je     1201 <iwe_stream_add_point+0xc1>
movslq 0xc(%rsp),%rax
add    %rax,%r12
mov    %r12,%rdi
call   1030 <memcpy@plt>
jmp    1201 <iwe_stream_add_point+0xc1>
mov    %r12,%r15
mov    %r15,%rax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.iw_request_info = type { i32 }
%struct.iw_event = type { i32, %struct.TYPE_4__ }
%struct.TYPE_4__ = type { %struct.TYPE_3__ }
%struct.TYPE_3__ = type { i32 }
@IW_EV_LCP_PK_LEN = global i32 0
@IW_EV_POINT_OFF = global i32 0
@IW_EV_POINT_PK_LEN = global i32 0
define i8* @iwe_stream_add_point(%struct.iw_request_info* %0, i8* %1, i8* %2, %struct.iw_event* %3, i8* %4) {
%6 = alloca %struct.iw_request_info*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca %struct.iw_event*
%10 = alloca i8*
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
store %struct.iw_request_info* %0, %struct.iw_request_info** %6
store i8* %1, i8** %7
store i8* %2, i8** %8
store %struct.iw_event* %3, %struct.iw_event** %9
store i8* %4, i8** %10
%14 = load %struct.iw_request_info*, %struct.iw_request_info** %6
%15 = call i32 @iwe_stream_point_len(%struct.iw_request_info* %14)
%16 = load %struct.iw_event*, %struct.iw_event** %9
%17 = getelementptr inbounds %struct.iw_event, %struct.iw_event* %16, i32 0, i32 1
%18 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %17, i32 0, i32 0
%19 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %18, i32 0, i32 0
%20 = load i32, i32* %19
%21 = add nsw i32 %15, %20
store i32 %21, i32* %11
%22 = load %struct.iw_request_info*, %struct.iw_request_info** %6
%23 = call i32 @iwe_stream_point_len(%struct.iw_request_info* %22)
store i32 %23, i32* %12
%24 = load %struct.iw_request_info*, %struct.iw_request_info** %6
%25 = call i32 @iwe_stream_lcp_len(%struct.iw_request_info* %24)
store i32 %25, i32* %13
%26 = load i8*, i8** %7
%27 = load i32, i32* %11
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds i8, i8* %26, i64 %28
%30 = load i8*, i8** %8
%31 = icmp ult i8* %29, %30
%32 = zext i1 %31 to i32
%33 = call i64 @likely(i32 %32)
%34 = icmp ne i64 %33, 0
br i1 %34, label %35, label %84
35: ; preds = %5
%36 = load i32, i32* %11
%37 = load %struct.iw_event*, %struct.iw_event** %9
%38 = getelementptr inbounds %struct.iw_event, %struct.iw_event* %37, i32 0, i32 0
store i32 %36, i32* %38
%39 = load i8*, i8** %7
%40 = load %struct.iw_event*, %struct.iw_event** %9
%41 = bitcast %struct.iw_event* %40 to i8*
%42 = load i32, i32* @IW_EV_LCP_PK_LEN
%43 = call i32 @memcpy(i8* %39, i8* %41, i32 %42)
%44 = load i8*, i8** %7
%45 = load i32, i32* %13
%46 = sext i32 %45 to i64
%47 = getelementptr inbounds i8, i8* %44, i64 %46
%48 = load %struct.iw_event*, %struct.iw_event** %9
%49 = getelementptr inbounds %struct.iw_event, %struct.iw_event* %48, i32 0, i32 1
%50 = bitcast %struct.TYPE_4__* %49 to i8*
%51 = load i32, i32* @IW_EV_POINT_OFF
%52 = sext i32 %51 to i64
%53 = getelementptr inbounds i8, i8* %50, i64 %52
%54 = load i32, i32* @IW_EV_POINT_PK_LEN
%55 = load i32, i32* @IW_EV_LCP_PK_LEN
%56 = sub nsw i32 %54, %55
%57 = call i32 @memcpy(i8* %47, i8* %53, i32 %56)
%58 = load %struct.iw_event*, %struct.iw_event** %9
%59 = getelementptr inbounds %struct.iw_event, %struct.iw_event* %58, i32 0, i32 1
%60 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %59, i32 0, i32 0
%61 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %60, i32 0, i32 0
%62 = load i32, i32* %61
%63 = icmp ne i32 %62, 0
br i1 %63, label %64, label %79
64: ; preds = %35
%65 = load i8*, i8** %10
%66 = icmp ne i8* %65, null
br i1 %66, label %67, label %79
67: ; preds = %64
%68 = load i8*, i8** %7
%69 = load i32, i32* %12
%70 = sext i32 %69 to i64
%71 = getelementptr inbounds i8, i8* %68, i64 %70
%72 = load i8*, i8** %10
%73 = load %struct.iw_event*, %struct.iw_event** %9
%74 = getelementptr inbounds %struct.iw_event, %struct.iw_event* %73, i32 0, i32 1
%75 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %74, i32 0, i32 0
%76 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %75, i32 0, i32 0
%77 = load i32, i32* %76
%78 = call i32 @memcpy(i8* %71, i8* %72, i32 %77)
br label %79
79: ; preds = %67, %64, %35
%80 = load i32, i32* %11
%81 = load i8*, i8** %7
%82 = sext i32 %80 to i64
%83 = getelementptr inbounds i8, i8* %81, i64 %82
store i8* %83, i8** %7
br label %84
84: ; preds = %79, %5
%85 = load i8*, i8** %7
ret i8* %85
}

LLVM IR (-O2):
%struct.iw_request_info = type { i32 }
%struct.iw_event = type { i32, %struct.TYPE_4__ }
%struct.TYPE_4__ = type { %struct.TYPE_3__ }
%struct.TYPE_3__ = type { i32 }
@IW_EV_LCP_PK_LEN = global i32 0
@IW_EV_POINT_OFF = global i32 0
@IW_EV_POINT_PK_LEN = global i32 0
define i8* @iwe_stream_add_point(%struct.iw_request_info* %0, i8* %1, i8* readnone %2, %struct.iw_event* %3, i8* %4) {
%6 = tail call i32 @iwe_stream_point_len(%struct.iw_request_info* %0)
%7 = getelementptr inbounds %struct.iw_event, %struct.iw_event* %3, i64 0, i32 1
%8 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %7, i64 0, i32 0, i32 0
%9 = load i32, i32* %8
%10 = add nsw i32 %9, %6
%11 = tail call i32 @iwe_stream_point_len(%struct.iw_request_info* %0)
%12 = tail call i32 @iwe_stream_lcp_len(%struct.iw_request_info* %0)
%13 = sext i32 %10 to i64
%14 = getelementptr inbounds i8, i8* %1, i64 %13
%15 = icmp ult i8* %14, %2
%16 = zext i1 %15 to i32
%17 = tail call i64 @likely(i32 %16)
%18 = icmp eq i64 %17, 0
br i1 %18, label %42, label %19
19: ; preds = %5
%20 = getelementptr inbounds %struct.iw_event, %struct.iw_event* %3, i64 0, i32 0
store i32 %10, i32* %20
%21 = bitcast %struct.iw_event* %3 to i8*
%22 = load i32, i32* @IW_EV_LCP_PK_LEN
%23 = tail call i32 @memcpy(i8* %1, i8* %21, i32 %22)
%24 = sext i32 %12 to i64
%25 = getelementptr inbounds i8, i8* %1, i64 %24
%26 = bitcast %struct.TYPE_4__* %7 to i8*
%27 = load i32, i32* @IW_EV_POINT_OFF
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds i8, i8* %26, i64 %28
%30 = load i32, i32* @IW_EV_POINT_PK_LEN
%31 = load i32, i32* @IW_EV_LCP_PK_LEN
%32 = sub nsw i32 %30, %31
%33 = tail call i32 @memcpy(i8* %25, i8* %29, i32 %32)
%34 = load i32, i32* %8
%35 = icmp ne i32 %34, 0
%36 = icmp ne i8* %4, null
%37 = and i1 %36, %35
br i1 %37, label %38, label %42
38: ; preds = %19
%39 = sext i32 %11 to i64
%40 = getelementptr inbounds i8, i8* %1, i64 %39
%41 = tail call i32 @memcpy(i8* %40, i8* %4, i32 %34)
br label %42
42: ; preds = %19, %38, %5
%43 = phi i8* [ %1, %5 ], [ %14, %38 ], [ %14, %19 ]
ret i8* %43
}