#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 TYPE_3__ {
  int /*<<< orphan*/ priv;
};
struct TYPE_4__ {
  TYPE_1__ pix;
};
struct v4l2_format {
  unsigned int type;
  TYPE_2__ fmt;
};

/* Variables and functions */
scalar_t__ V4L2_BUF_TYPE_VIDEO_CAPTURE;
scalar_t__ V4L2_BUF_TYPE_VIDEO_OUTPUT;
int /*<<< orphan*/ V4L2_PIX_FMT_PRIV_MAGIC;
int /*<<< orphan*/ memset(struct v4l2_format *, int /*<<< orphan*/, int);
void v4l_format_init(struct v4l2_format *fmt, unsigned type) {
  memset(fmt, 0, sizeof(*fmt));
  fmt->type = type;
  if (fmt->type == V4L2_BUF_TYPE_VIDEO_CAPTURE ||
      fmt->type == V4L2_BUF_TYPE_VIDEO_OUTPUT)
    fmt->fmt.pix.priv = V4L2_PIX_FMT_PRIV_MAGIC;
}


x86 assembly (clang, -O0):
<v4l_format_init>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
xor    %esi,%esi
mov    $0x8,%edx
call   1030 <memset@plt>
mov    -0xc(%rbp),%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x8(%rbp),%rax
mov    (%rax),%eax
mov    0x2eab(%rip),%rcx
cmp    (%rcx),%rax
je     1164 <v4l_format_init+0x54>
mov    -0x8(%rbp),%rax
mov    (%rax),%eax
mov    0x2e85(%rip),%rcx
cmp    (%rcx),%rax
jne    1174 <v4l_format_init+0x64>
mov    0x2e6d(%rip),%rax
mov    (%rax),%ecx
mov    -0x8(%rbp),%rax
mov    %ecx,0x4(%rax)
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<v4l_format_init>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebp
mov    %rdi,%rbx
xor    %esi,%esi
mov    $0x8,%edx
call   1030 <memset@plt>
mov    %ebp,(%rbx)
mov    %ebp,%eax
mov    0x2ec1(%rip),%rcx
cmp    %rax,(%rcx)
je     1140 <v4l_format_init+0x30>
mov    0x2ea5(%rip),%rcx
cmp    %rax,(%rcx)
jne    114c <v4l_format_init+0x3c>
mov    0x2e91(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x4(%rbx)
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
%struct.v4l2_format = type { i32, %struct.TYPE_4__ }
%struct.TYPE_4__ = type { %struct.TYPE_3__ }
%struct.TYPE_3__ = type { i32 }
@V4L2_BUF_TYPE_VIDEO_CAPTURE = global i64 0
@V4L2_BUF_TYPE_VIDEO_OUTPUT = global i64 0
@V4L2_PIX_FMT_PRIV_MAGIC = global i32 0
define void @v4l_format_init(%struct.v4l2_format* %0, i32 %1) {
%3 = alloca %struct.v4l2_format*
%4 = alloca i32
store %struct.v4l2_format* %0, %struct.v4l2_format** %3
store i32 %1, i32* %4
%5 = load %struct.v4l2_format*, %struct.v4l2_format** %3
%6 = call i32 @memset(%struct.v4l2_format* %5, i32 0, i32 8)
%7 = load i32, i32* %4
%8 = load %struct.v4l2_format*, %struct.v4l2_format** %3
%9 = getelementptr inbounds %struct.v4l2_format, %struct.v4l2_format* %8, i32 0, i32 0
store i32 %7, i32* %9
%10 = load %struct.v4l2_format*, %struct.v4l2_format** %3
%11 = getelementptr inbounds %struct.v4l2_format, %struct.v4l2_format* %10, i32 0, i32 0
%12 = load i32, i32* %11
%13 = zext i32 %12 to i64
%14 = load i64, i64* @V4L2_BUF_TYPE_VIDEO_CAPTURE
%15 = icmp eq i64 %13, %14
br i1 %15, label %23, label %16
16: ; preds = %2
%17 = load %struct.v4l2_format*, %struct.v4l2_format** %3
%18 = getelementptr inbounds %struct.v4l2_format, %struct.v4l2_format* %17, i32 0, i32 0
%19 = load i32, i32* %18
%20 = zext i32 %19 to i64
%21 = load i64, i64* @V4L2_BUF_TYPE_VIDEO_OUTPUT
%22 = icmp eq i64 %20, %21
br i1 %22, label %23, label %29
23: ; preds = %16, %2
%24 = load i32, i32* @V4L2_PIX_FMT_PRIV_MAGIC
%25 = load %struct.v4l2_format*, %struct.v4l2_format** %3
%26 = getelementptr inbounds %struct.v4l2_format, %struct.v4l2_format* %25, i32 0, i32 1
%27 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %26, i32 0, i32 0
%28 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %27, i32 0, i32 0
store i32 %24, i32* %28
br label %29
29: ; preds = %23, %16
ret void
}

LLVM IR (-O2):
%struct.v4l2_format = type { i32, %struct.TYPE_4__ }
%struct.TYPE_4__ = type { %struct.TYPE_3__ }
%struct.TYPE_3__ = type { i32 }
@V4L2_BUF_TYPE_VIDEO_CAPTURE = global i64 0
@V4L2_BUF_TYPE_VIDEO_OUTPUT = global i64 0
@V4L2_PIX_FMT_PRIV_MAGIC = global i32 0
define void @v4l_format_init(%struct.v4l2_format* %0, i32 %1) {
%3 = tail call i32 @memset(%struct.v4l2_format* %0, i32 0, i32 8)
%4 = getelementptr inbounds %struct.v4l2_format, %struct.v4l2_format* %0, i64 0, i32 0
store i32 %1, i32* %4
%5 = zext i32 %1 to i64
%6 = load i64, i64* @V4L2_BUF_TYPE_VIDEO_CAPTURE
%7 = icmp eq i64 %6, %5
%8 = load i64, i64* @V4L2_BUF_TYPE_VIDEO_OUTPUT
%9 = icmp eq i64 %8, %5
%10 = select i1 %7, i1 true, i1 %9
br i1 %10, label %11, label %14
11: ; preds = %2
%12 = load i32, i32* @V4L2_PIX_FMT_PRIV_MAGIC
%13 = getelementptr inbounds %struct.v4l2_format, %struct.v4l2_format* %0, i64 0, i32 1, i32 0, i32 0
store i32 %12, i32* %13
br label %14
14: ; preds = %2, %11
ret void
}