#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 */

/* Type definitions */
typedef int /*<<< orphan*/ u_int8_t;
typedef int /*<<< orphan*/ u_int32_t;
struct store_flow_complete {
  int dummy;
};
typedef int /*<<< orphan*/ buf;

/* Variables and functions */
int store_flow_serialise_masked(struct store_flow_complete *,
                                int /*<<< orphan*/, int /*<<< orphan*/ *, int,
                                int *, char *, int);
int store_put_buf(int, int /*<<< orphan*/ *, int, char *, int);
int store_put_flow(int fd, struct store_flow_complete *flow,
                   u_int32_t fieldmask, char *ebuf, int elen) {
  u_int8_t buf[1024];
  int len, r;
  if ((r = (store_flow_serialise_masked(flow, fieldmask, buf, sizeof(buf), &len,
                                        ebuf, elen))) != 0x00)
    return (r);
  return store_put_buf(fd, buf, len, ebuf, elen);
}


x86 assembly (clang, -O0):
<store_put_flow>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1040,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8d,-0x24(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
lea    -0x1030(%rbp),%rdx
mov    -0x20(%rbp),%r9
mov    -0x24(%rbp),%eax
mov    $0x1000,%ecx
lea    -0x1034(%rbp),%r8
mov    %eax,(%rsp)
call   1030 <store_flow_serialise_masked@plt>
mov    %eax,-0x1038(%rbp)
cmp    $0x0,%eax
je     1183 <store_put_flow+0x63>
mov    -0x1038(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11a3 <store_put_flow+0x83>
mov    -0x8(%rbp),%edi
lea    -0x1030(%rbp),%rsi
mov    -0x1034(%rbp),%edx
mov    -0x20(%rbp),%rcx
mov    -0x24(%rbp),%r8d
call   1040 <store_put_buf@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x1040,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<store_put_flow>:
push   %rbp
push   %r14
push   %rbx
sub    $0x1010,%rsp
mov    %r8d,%ebp
mov    %rcx,%rbx
mov    %edi,%r14d
mov    %r8d,(%rsp)
lea    0x10(%rsp),%rax
lea    0xc(%rsp),%r8
mov    %rsi,%rdi
mov    %edx,%esi
mov    %rax,%rdx
mov    $0x1000,%ecx
mov    %rbx,%r9
call   1030 <store_flow_serialise_masked@plt>
test   %eax,%eax
jne    1172 <store_put_flow+0x52>
mov    0xc(%rsp),%edx
lea    0x10(%rsp),%rsi
mov    %r14d,%edi
mov    %rbx,%rcx
mov    %ebp,%r8d
call   1040 <store_put_buf@plt>
add    $0x1010,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
%struct.store_flow_complete = type { i32 }
define i32 @store_put_flow(i32 %0, %struct.store_flow_complete* %1, i32 %2, i8* %3, i32 %4) {
%6 = alloca i32
%7 = alloca i32
%8 = alloca %struct.store_flow_complete*
%9 = alloca i32
%10 = alloca i8*
%11 = alloca i32
%12 = alloca [1024 x i32]
%13 = alloca i32
%14 = alloca i32
store i32 %0, i32* %7
store %struct.store_flow_complete* %1, %struct.store_flow_complete** %8
store i32 %2, i32* %9
store i8* %3, i8** %10
store i32 %4, i32* %11
%15 = load %struct.store_flow_complete*, %struct.store_flow_complete** %8
%16 = load i32, i32* %9
%17 = getelementptr inbounds [1024 x i32], [1024 x i32]* %12, i64 0, i64 0
%18 = load i8*, i8** %10
%19 = load i32, i32* %11
%20 = call i32 @store_flow_serialise_masked(%struct.store_flow_complete* %15, i32 %16, i32* %17, i32 4096, i32* %13, i8* %18, i32 %19)
store i32 %20, i32* %14
%21 = icmp ne i32 %20, 0
br i1 %21, label %22, label %24
22: ; preds = %5
%23 = load i32, i32* %14
store i32 %23, i32* %6
br label %31
24: ; preds = %5
%25 = load i32, i32* %7
%26 = getelementptr inbounds [1024 x i32], [1024 x i32]* %12, i64 0, i64 0
%27 = load i32, i32* %13
%28 = load i8*, i8** %10
%29 = load i32, i32* %11
%30 = call i32 @store_put_buf(i32 %25, i32* %26, i32 %27, i8* %28, i32 %29)
store i32 %30, i32* %6
br label %31
31: ; preds = %24, %22
%32 = load i32, i32* %6
ret i32 %32
}

LLVM IR (-O2):
%struct.store_flow_complete = type { i32 }
define i32 @store_put_flow(i32 %0, %struct.store_flow_complete* %1, i32 %2, i8* %3, i32 %4) {
%6 = alloca [1024 x i32]
%7 = alloca i32
%8 = bitcast [1024 x i32]* %6 to i8*
%9 = bitcast i32* %7 to i8*
%10 = getelementptr inbounds [1024 x i32], [1024 x i32]* %6, i64 0, i64 0
%11 = call i32 @store_flow_serialise_masked(%struct.store_flow_complete* %1, i32 %2, i32* %10, i32 4096, i32* %7, i8* %3, i32 %4)
%12 = icmp eq i32 %11, 0
br i1 %12, label %13, label %16
13: ; preds = %5
%14 = load i32, i32* %7
%15 = call i32 @store_put_buf(i32 %0, i32* %10, i32 %14, i8* %3, i32 %4)
br label %16
16: ; preds = %5, %13
%17 = phi i32 [ %15, %13 ], [ %11, %5 ]
ret i32 %17
}