#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 */
struct msghdr {
  int dummy;
};
struct cmsghdr {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ memset(void *, int /*<<< orphan*/, size_t);
void init_hdrs(struct msghdr *mhp, struct cmsghdr *cmhp, char *bufp,
               size_t bufsize) {
  if (mhp != NULL)
    memset((void *)mhp, 0, sizeof(struct msghdr));
  if (cmhp != NULL)
    memset((void *)cmhp, 0, sizeof(struct cmsghdr));
  if (bufp != NULL)
    memset((void *)bufp, 0, bufsize);
}


x86 assembly (clang, -O0):
<init_hdrs>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
cmpq   $0x0,-0x8(%rbp)
je     1143 <init_hdrs+0x33>
mov    -0x8(%rbp),%rdi
xor    %esi,%esi
mov    $0x4,%edx
call   1030 <memset@plt>
cmpq   $0x0,-0x10(%rbp)
je     115e <init_hdrs+0x4e>
mov    -0x10(%rbp),%rdi
xor    %esi,%esi
mov    $0x4,%edx
call   1030 <memset@plt>
cmpq   $0x0,-0x18(%rbp)
je     1178 <init_hdrs+0x68>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rdx
xor    %esi,%esi
call   1030 <memset@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<init_hdrs>:
push   %r15
push   %r14
push   %rbx
mov    %rcx,%r14
mov    %rdx,%r15
mov    %rsi,%rbx
test   %rdi,%rdi
je     112f <init_hdrs+0x1f>
mov    $0x4,%edx
xor    %esi,%esi
call   1030 <memset@plt>
test   %rbx,%rbx
je     1143 <init_hdrs+0x33>
mov    $0x4,%edx
mov    %rbx,%rdi
xor    %esi,%esi
call   1030 <memset@plt>
test   %r15,%r15
je     115a <init_hdrs+0x4a>
mov    %r15,%rdi
xor    %esi,%esi
mov    %r14,%rdx
pop    %rbx
pop    %r14
pop    %r15
jmp    1030 <memset@plt>
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.msghdr = type { i32 }
%struct.cmsghdr = type { i32 }
define void @init_hdrs(%struct.msghdr* %0, %struct.cmsghdr* %1, i8* %2, i64 %3) {
%5 = alloca %struct.msghdr*
%6 = alloca %struct.cmsghdr*
%7 = alloca i8*
%8 = alloca i64
store %struct.msghdr* %0, %struct.msghdr** %5
store %struct.cmsghdr* %1, %struct.cmsghdr** %6
store i8* %2, i8** %7
store i64 %3, i64* %8
%9 = load %struct.msghdr*, %struct.msghdr** %5
%10 = icmp ne %struct.msghdr* %9, null
br i1 %10, label %11, label %15
11: ; preds = %4
%12 = load %struct.msghdr*, %struct.msghdr** %5
%13 = bitcast %struct.msghdr* %12 to i8*
%14 = call i32 @memset(i8* %13, i32 0, i64 4)
br label %15
15: ; preds = %11, %4
%16 = load %struct.cmsghdr*, %struct.cmsghdr** %6
%17 = icmp ne %struct.cmsghdr* %16, null
br i1 %17, label %18, label %22
18: ; preds = %15
%19 = load %struct.cmsghdr*, %struct.cmsghdr** %6
%20 = bitcast %struct.cmsghdr* %19 to i8*
%21 = call i32 @memset(i8* %20, i32 0, i64 4)
br label %22
22: ; preds = %18, %15
%23 = load i8*, i8** %7
%24 = icmp ne i8* %23, null
br i1 %24, label %25, label %29
25: ; preds = %22
%26 = load i8*, i8** %7
%27 = load i64, i64* %8
%28 = call i32 @memset(i8* %26, i32 0, i64 %27)
br label %29
29: ; preds = %25, %22
ret void
}

LLVM IR (-O2):
%struct.msghdr = type { i32 }
%struct.cmsghdr = type { i32 }
define void @init_hdrs(%struct.msghdr* %0, %struct.cmsghdr* %1, i8* %2, i64 %3) {
%5 = icmp eq %struct.msghdr* %0, null
br i1 %5, label %9, label %6
6: ; preds = %4
%7 = bitcast %struct.msghdr* %0 to i8*
%8 = tail call i32 @memset(i8* %7, i32 0, i64 4)
br label %9
9: ; preds = %6, %4
%10 = icmp eq %struct.cmsghdr* %1, null
br i1 %10, label %14, label %11
11: ; preds = %9
%12 = bitcast %struct.cmsghdr* %1 to i8*
%13 = tail call i32 @memset(i8* %12, i32 0, i64 4)
br label %14
14: ; preds = %11, %9
%15 = icmp eq i8* %2, null
br i1 %15, label %18, label %16
16: ; preds = %14
%17 = tail call i32 @memset(i8* %2, i32 0, i64 %3)
br label %18
18: ; preds = %16, %14
ret void
}