#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 v4l2_capability {
  int capabilities;
  scalar_t__ card;
};
struct option {
  char *member_0;
  char member_3;
  int /*<<< orphan*/ *member_2;
  int /*<<< orphan*/ member_1;
};

/* Variables and functions */
int /*<<< orphan*/ O_RDONLY;
int V4L2_CAP_AUDIO;
int V4L2_CAP_RADIO;
int V4L2_CAP_TUNER;
int V4L2_CAP_VIDEO_CAPTURE;
int V4L2_CAP_VIDEO_OUTPUT;
int V4L2_CAP_VIDEO_OVERLAY;
int /*<<< orphan*/ VIDIOC_QUERYCAP;
int /*<<< orphan*/ close(int);
int getopt_long(int, char **, char *, struct option const *,
                int /*<<< orphan*/ *);
scalar_t__ ioctl(int, int /*<<< orphan*/, struct v4l2_capability *);
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
#define no_argument 128
int open(char *, int /*<<< orphan*/);
size_t optind;
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ strcat(char *, char *);
int /*<<< orphan*/ vdev_property_add(char *, char *);
int /*<<< orphan*/ vdev_property_free_all();
int /*<<< orphan*/ vdev_property_print();
int main(int argc, char *argv[]) {
  static const struct option options[] = {{"help", no_argument, NULL, 'h'}, {}};
  int fd = 0;
  char *device;
  struct v4l2_capability v2cap;
  char cap_str[4097];
  memset(cap_str, 0, 4097);
  for (;;) {
    int option;
    option = getopt_long(argc, argv, "h", options, NULL);
    if (option == -1) {
      break;
    }
    switch (option) {
    case 'h':
      printf("%s [-h,--help] <device file>\n\n"
             "Video4Linux device identification.\n\n"
             "  -h  Print this message\n",
             argv[0]);
      return 0;
    default:
      return 1;
    }
  }
  device = argv[optind];
  if (device == NULL) {
    return 2;
  }
  fd = open(device, O_RDONLY);
  if (fd < 0) {
    return 3;
  }
  if (ioctl(fd, VIDIOC_QUERYCAP, &v2cap) == 0) {
    vdev_property_add("VDEV_V4L_VERSION", "2");
    vdev_property_add("VDEV_V4L_PRODUCT", (char *)v2cap.card);
    strcat(cap_str, ":");
    if ((v2cap.capabilities & V4L2_CAP_VIDEO_CAPTURE) > 0) {
      strcat(cap_str, "capture:");
    }
    if ((v2cap.capabilities & V4L2_CAP_VIDEO_OUTPUT) > 0) {
      strcat(cap_str, "video_output:");
    }
    if ((v2cap.capabilities & V4L2_CAP_VIDEO_OVERLAY) > 0) {
      strcat(cap_str, "video_overlay:");
    }
    if ((v2cap.capabilities & V4L2_CAP_AUDIO) > 0) {
      strcat(cap_str, "audio:");
    }
    if ((v2cap.capabilities & V4L2_CAP_TUNER) > 0) {
      strcat(cap_str, "tuner:");
    }
    if ((v2cap.capabilities & V4L2_CAP_RADIO) > 0) {
      strcat(cap_str, "radio:");
    }
    vdev_property_add("VDEV_V4L_CAPABILITIES", cap_str);
  }
  close(fd);
  vdev_property_print();
  vdev_property_free_all();
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1050,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
lea    -0x1040(%rbp),%rdi
xor    %esi,%esi
mov    $0x1001,%edx
call   1070 <memset@plt>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xe24(%rip),%rdx
lea    0x2ba8(%rip),%rcx
xor    %eax,%eax
mov    %eax,%r8d
call   1040 <getopt_long@plt>
mov    %eax,-0x1044(%rbp)
cmpl   $0xffffffff,-0x1044(%rbp)
jne    120a <main+0x6a>
jmp    1249 <main+0xa9>
mov    -0x1044(%rbp),%eax
sub    $0x68,%eax
jne    123d <main+0x9d>
jmp    121e <main+0x7e>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xddb(%rip),%rdi
call   1060 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1416 <main+0x276>
movl   $0x1,-0x4(%rbp)
jmp    1416 <main+0x276>
mov    -0x10(%rbp),%rax
mov    0x2d64(%rip),%rcx
mov    (%rcx),%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    1276 <main+0xd6>
movl   $0x2,-0x4(%rbp)
jmp    1416 <main+0x276>
mov    -0x20(%rbp),%rdi
mov    0x2d4f(%rip),%rax
mov    (%rax),%esi
call   10b0 <open@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jge    12a1 <main+0x101>
movl   $0x3,-0x4(%rbp)
jmp    1416 <main+0x276>
mov    -0x14(%rbp),%edi
mov    0x2ce5(%rip),%rax
mov    (%rax),%esi
lea    -0x30(%rbp),%rdx
call   1080 <ioctl@plt>
cmp    $0x0,%rax
jne    13f9 <main+0x259>
lea    0xd9c(%rip),%rdi
lea    0xda6(%rip),%rsi
call   1030 <vdev_property_add@plt>
mov    -0x28(%rbp),%rsi
lea    0xd98(%rip),%rdi
call   1030 <vdev_property_add@plt>
lea    -0x1040(%rbp),%rdi
lea    0xd9d(%rip),%rsi
call   10c0 <strcat@plt>
mov    -0x30(%rbp),%eax
mov    0x2cd8(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
jle    131e <main+0x17e>
lea    -0x1040(%rbp),%rdi
lea    0xd6e(%rip),%rsi
call   10c0 <strcat@plt>
mov    -0x30(%rbp),%eax
mov    0x2ca0(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
jle    1346 <main+0x1a6>
lea    -0x1040(%rbp),%rdi
lea    0xd4f(%rip),%rsi
call   10c0 <strcat@plt>
mov    -0x30(%rbp),%eax
mov    0x2c58(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
jle    136e <main+0x1ce>
lea    -0x1040(%rbp),%rdi
lea    0xd35(%rip),%rsi
call   10c0 <strcat@plt>
mov    -0x30(%rbp),%eax
mov    0x2c28(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
jle    1396 <main+0x1f6>
lea    -0x1040(%rbp),%rdi
lea    0xd1c(%rip),%rsi
call   10c0 <strcat@plt>
mov    -0x30(%rbp),%eax
mov    0x2c20(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
jle    13be <main+0x21e>
lea    -0x1040(%rbp),%rdi
lea    0xcfb(%rip),%rsi
call   10c0 <strcat@plt>
mov    -0x30(%rbp),%eax
mov    0x2c18(%rip),%rcx
and    (%rcx),%eax
cmp    $0x0,%eax
jle    13e6 <main+0x246>
lea    -0x1040(%rbp),%rdi
lea    0xcda(%rip),%rsi
call   10c0 <strcat@plt>
lea    -0x1040(%rbp),%rsi
lea    0xcce(%rip),%rdi
call   1030 <vdev_property_add@plt>
mov    -0x14(%rbp),%edi
call   1090 <close@plt>
mov    $0x0,%al
call   1050 <vdev_property_print@plt>
mov    $0x0,%al
call   10a0 <vdev_property_free_all@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x1050,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
sub    $0x1018,%rsp
mov    %rsi,%rbx
mov    %edi,%ebp
lea    0x10(%rsp),%rdi
xor    %esi,%esi
mov    $0x1001,%edx
call   1070 <memset@plt>
lea    0xe3f(%rip),%rdx
lea    0x2bc3(%rip),%rcx
mov    %ebp,%edi
mov    %rbx,%rsi
xor    %r8d,%r8d
call   1040 <getopt_long@plt>
cmp    $0xffffffff,%eax
je     1203 <main+0x63>
mov    $0x1,%ebp
cmp    $0x68,%eax
jne    1373 <main+0x1d3>
mov    (%rbx),%rsi
lea    0xe10(%rip),%rdi
call   1060 <printf@plt>
xor    %ebp,%ebp
jmp    1373 <main+0x1d3>
mov    0x2dae(%rip),%rax
mov    (%rax),%rax
mov    (%rbx,%rax,8),%rdi
test   %rdi,%rdi
je     1367 <main+0x1c7>
mov    0x2daf(%rip),%rax
mov    (%rax),%esi
call   10b0 <open@plt>
test   %eax,%eax
js     136e <main+0x1ce>
mov    %eax,%ebx
mov    0x2d57(%rip),%rax
mov    (%rax),%esi
mov    %rsp,%rdx
mov    %ebx,%edi
call   1080 <ioctl@plt>
test   %rax,%rax
jne    134e <main+0x1ae>
lea    0xe0e(%rip),%rdi
lea    0xe18(%rip),%rsi
call   1030 <vdev_property_add@plt>
mov    0x8(%rsp),%rsi
lea    0xe09(%rip),%rdi
call   1030 <vdev_property_add@plt>
lea    0xe15(%rip),%rsi
lea    0x10(%rsp),%rdi
call   10c0 <strcat@plt>
mov    (%rsp),%eax
mov    0x2d4b(%rip),%rcx
test   %eax,(%rcx)
jle    12a5 <main+0x105>
lea    0xdef(%rip),%rsi
lea    0x10(%rsp),%rdi
call   10c0 <strcat@plt>
mov    (%rsp),%eax
mov    0x2d1c(%rip),%rcx
test   %eax,(%rcx)
jle    12c4 <main+0x124>
lea    0xdd9(%rip),%rsi
lea    0x10(%rsp),%rdi
call   10c0 <strcat@plt>
mov    (%rsp),%eax
mov    0x2cdd(%rip),%rcx
test   %eax,(%rcx)
jle    12e3 <main+0x143>
lea    0xdc8(%rip),%rsi
lea    0x10(%rsp),%rdi
call   10c0 <strcat@plt>
mov    (%rsp),%eax
mov    0x2cb6(%rip),%rcx
test   %eax,(%rcx)
jle    1302 <main+0x162>
lea    0xdb8(%rip),%rsi
lea    0x10(%rsp),%rdi
call   10c0 <strcat@plt>
mov    (%rsp),%eax
mov    0x2cb7(%rip),%rcx
test   %eax,(%rcx)
jle    1321 <main+0x181>
lea    0xda0(%rip),%rsi
lea    0x10(%rsp),%rdi
call   10c0 <strcat@plt>
mov    (%rsp),%eax
mov    0x2cb8(%rip),%rcx
test   %eax,(%rcx)
jle    133d <main+0x19d>
lea    0xd88(%rip),%rsi
lea    0x10(%rsp),%rdi
call   10c0 <strcat@plt>
lea    0xd7e(%rip),%rdi
lea    0x10(%rsp),%rsi
call   1030 <vdev_property_add@plt>
mov    %ebx,%edi
call   1090 <close@plt>
xor    %ebp,%ebp
xor    %eax,%eax
call   1050 <vdev_property_print@plt>
xor    %eax,%eax
call   10a0 <vdev_property_free_all@plt>
jmp    1373 <main+0x1d3>
mov    $0x2,%ebp
jmp    1373 <main+0x1d3>
mov    $0x3,%ebp
mov    %ebp,%eax
add    $0x1018,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
%struct.option = type { i8*, i8, i32*, i32 }
%struct.v4l2_capability = type { i32, i64 }
@main.options = internal constant [2 x %struct.option] [%struct.option { i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i32 0, i32 0), i8 -128, i32* null, i32 104 }, %struct.option zeroinitializer]
@.str = [5 x i8] c"help\00"
@.str.1 = [2 x i8] c"h\00"
@.str.2 = [92 x i8] c"%s [-h,--help] <device file>\0A\0AVideo4Linux device identification.\0A\0A -h Print this message\0A\00"
@optind = global i64 0
@O_RDONLY = global i32 0
@VIDIOC_QUERYCAP = global i32 0
@.str.3 = [17 x i8] c"VDEV_V4L_VERSION\00"
@.str.4 = [2 x i8] c"2\00"
@.str.5 = [17 x i8] c"VDEV_V4L_PRODUCT\00"
@.str.6 = [2 x i8] c":\00"
@V4L2_CAP_VIDEO_CAPTURE = global i32 0
@.str.7 = [9 x i8] c"capture:\00"
@V4L2_CAP_VIDEO_OUTPUT = global i32 0
@.str.8 = [14 x i8] c"video_output:\00"
@V4L2_CAP_VIDEO_OVERLAY = global i32 0
@.str.9 = [15 x i8] c"video_overlay:\00"
@V4L2_CAP_AUDIO = global i32 0
@.str.10 = [7 x i8] c"audio:\00"
@V4L2_CAP_TUNER = global i32 0
@.str.11 = [7 x i8] c"tuner:\00"
@V4L2_CAP_RADIO = global i32 0
@.str.12 = [7 x i8] c"radio:\00"
@.str.13 = [22 x i8] c"VDEV_V4L_CAPABILITIES\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i8*
%8 = alloca %struct.v4l2_capability
%9 = alloca [4097 x i8]
%10 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %6
%11 = getelementptr inbounds [4097 x i8], [4097 x i8]* %9, i64 0, i64 0
%12 = call i32 @memset(i8* %11, i32 0, i32 4097)
br label %13
13: ; preds = %2
%14 = load i32, i32* %4
%15 = load i8**, i8*** %5
%16 = call i32 @getopt_long(i32 %14, i8** %15, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), %struct.option* getelementptr inbounds ([2 x %struct.option], [2 x %struct.option]* @main.options, i64 0, i64 0), i32* null)
store i32 %16, i32* %10
%17 = load i32, i32* %10
%18 = icmp eq i32 %17, -1
br i1 %18, label %19, label %20
19: ; preds = %13
br label %28
20: ; preds = %13
%21 = load i32, i32* %10
switch i32 %21, label %27 [
i32 104, label %22
]
22: ; preds = %20
%23 = load i8**, i8*** %5
%24 = getelementptr inbounds i8*, i8** %23, i64 0
%25 = load i8*, i8** %24
%26 = call i32 @printf(i8* getelementptr inbounds ([92 x i8], [92 x i8]* @.str.2, i64 0, i64 0), i8* %25)
store i32 0, i32* %3
br label %117
27: ; preds = %20
store i32 1, i32* %3
br label %117
28: ; preds = %19
%29 = load i8**, i8*** %5
%30 = load i64, i64* @optind
%31 = getelementptr inbounds i8*, i8** %29, i64 %30
%32 = load i8*, i8** %31
store i8* %32, i8** %7
%33 = load i8*, i8** %7
%34 = icmp eq i8* %33, null
br i1 %34, label %35, label %36
35: ; preds = %28
store i32 2, i32* %3
br label %117
36: ; preds = %28
%37 = load i8*, i8** %7
%38 = load i32, i32* @O_RDONLY
%39 = call i32 @open(i8* %37, i32 %38)
store i32 %39, i32* %6
%40 = load i32, i32* %6
%41 = icmp slt i32 %40, 0
br i1 %41, label %42, label %43
42: ; preds = %36
store i32 3, i32* %3
br label %117
43: ; preds = %36
%44 = load i32, i32* %6
%45 = load i32, i32* @VIDIOC_QUERYCAP
%46 = call i64 @ioctl(i32 %44, i32 %45, %struct.v4l2_capability* %8)
%47 = icmp eq i64 %46, 0
br i1 %47, label %48, label %112
48: ; preds = %43
%49 = call i32 @vdev_property_add(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%50 = getelementptr inbounds %struct.v4l2_capability, %struct.v4l2_capability* %8, i32 0, i32 1
%51 = load i64, i64* %50
%52 = inttoptr i64 %51 to i8*
%53 = call i32 @vdev_property_add(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.5, i64 0, i64 0), i8* %52)
%54 = getelementptr inbounds [4097 x i8], [4097 x i8]* %9, i64 0, i64 0
%55 = call i32 @strcat(i8* %54, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
%56 = getelementptr inbounds %struct.v4l2_capability, %struct.v4l2_capability* %8, i32 0, i32 0
%57 = load i32, i32* %56
%58 = load i32, i32* @V4L2_CAP_VIDEO_CAPTURE
%59 = and i32 %57, %58
%60 = icmp sgt i32 %59, 0
br i1 %60, label %61, label %64
61: ; preds = %48
%62 = getelementptr inbounds [4097 x i8], [4097 x i8]* %9, i64 0, i64 0
%63 = call i32 @strcat(i8* %62, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.7, i64 0, i64 0))
br label %64
64: ; preds = %61, %48
%65 = getelementptr inbounds %struct.v4l2_capability, %struct.v4l2_capability* %8, i32 0, i32 0
%66 = load i32, i32* %65
%67 = load i32, i32* @V4L2_CAP_VIDEO_OUTPUT
%68 = and i32 %66, %67
%69 = icmp sgt i32 %68, 0
br i1 %69, label %70, label %73
70: ; preds = %64
%71 = getelementptr inbounds [4097 x i8], [4097 x i8]* %9, i64 0, i64 0
%72 = call i32 @strcat(i8* %71, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.8, i64 0, i64 0))
br label %73
73: ; preds = %70, %64
%74 = getelementptr inbounds %struct.v4l2_capability, %struct.v4l2_capability* %8, i32 0, i32 0
%75 = load i32, i32* %74
%76 = load i32, i32* @V4L2_CAP_VIDEO_OVERLAY
%77 = and i32 %75, %76
%78 = icmp sgt i32 %77, 0
br i1 %78, label %79, label %82
79: ; preds = %73
%80 = getelementptr inbounds [4097 x i8], [4097 x i8]* %9, i64 0, i64 0
%81 = call i32 @strcat(i8* %80, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.9, i64 0, i64 0))
br label %82
82: ; preds = %79, %73
%83 = getelementptr inbounds %struct.v4l2_capability, %struct.v4l2_capability* %8, i32 0, i32 0
%84 = load i32, i32* %83
%85 = load i32, i32* @V4L2_CAP_AUDIO
%86 = and i32 %84, %85
%87 = icmp sgt i32 %86, 0
br i1 %87, label %88, label %91
88: ; preds = %82
%89 = getelementptr inbounds [4097 x i8], [4097 x i8]* %9, i64 0, i64 0
%90 = call i32 @strcat(i8* %89, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.10, i64 0, i64 0))
br label %91
91: ; preds = %88, %82
%92 = getelementptr inbounds %struct.v4l2_capability, %struct.v4l2_capability* %8, i32 0, i32 0
%93 = load i32, i32* %92
%94 = load i32, i32* @V4L2_CAP_TUNER
%95 = and i32 %93, %94
%96 = icmp sgt i32 %95, 0
br i1 %96, label %97, label %100
97: ; preds = %91
%98 = getelementptr inbounds [4097 x i8], [4097 x i8]* %9, i64 0, i64 0
%99 = call i32 @strcat(i8* %98, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.11, i64 0, i64 0))
br label %100
100: ; preds = %97, %91
%101 = getelementptr inbounds %struct.v4l2_capability, %struct.v4l2_capability* %8, i32 0, i32 0
%102 = load i32, i32* %101
%103 = load i32, i32* @V4L2_CAP_RADIO
%104 = and i32 %102, %103
%105 = icmp sgt i32 %104, 0
br i1 %105, label %106, label %109
106: ; preds = %100
%107 = getelementptr inbounds [4097 x i8], [4097 x i8]* %9, i64 0, i64 0
%108 = call i32 @strcat(i8* %107, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.12, i64 0, i64 0))
br label %109
109: ; preds = %106, %100
%110 = getelementptr inbounds [4097 x i8], [4097 x i8]* %9, i64 0, i64 0
%111 = call i32 @vdev_property_add(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.13, i64 0, i64 0), i8* %110)
br label %112
112: ; preds = %109, %43
%113 = load i32, i32* %6
%114 = call i32 @close(i32 %113)
%115 = call i32 (...) @vdev_property_print()
%116 = call i32 (...) @vdev_property_free_all()
store i32 0, i32* %3
br label %117
117: ; preds = %112, %42, %35, %27, %22
%118 = load i32, i32* %3
ret i32 %118
}

LLVM IR (-O2):
%struct.option = type { i8*, i8, i32*, i32 }
%struct.v4l2_capability = type { i32, i64 }
@main.options = internal constant [2 x %struct.option] [%struct.option { i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i32 0, i32 0), i8 -128, i32* null, i32 104 }, %struct.option zeroinitializer]
@.str = [5 x i8] c"help\00"
@.str.1 = [2 x i8] c"h\00"
@.str.2 = [92 x i8] c"%s [-h,--help] <device file>\0A\0AVideo4Linux device identification.\0A\0A -h Print this message\0A\00"
@optind = global i64 0
@O_RDONLY = global i32 0
@VIDIOC_QUERYCAP = global i32 0
@.str.3 = [17 x i8] c"VDEV_V4L_VERSION\00"
@.str.4 = [2 x i8] c"2\00"
@.str.5 = [17 x i8] c"VDEV_V4L_PRODUCT\00"
@.str.6 = [2 x i8] c":\00"
@V4L2_CAP_VIDEO_CAPTURE = global i32 0
@.str.7 = [9 x i8] c"capture:\00"
@V4L2_CAP_VIDEO_OUTPUT = global i32 0
@.str.8 = [14 x i8] c"video_output:\00"
@V4L2_CAP_VIDEO_OVERLAY = global i32 0
@.str.9 = [15 x i8] c"video_overlay:\00"
@V4L2_CAP_AUDIO = global i32 0
@.str.10 = [7 x i8] c"audio:\00"
@V4L2_CAP_TUNER = global i32 0
@.str.11 = [7 x i8] c"tuner:\00"
@V4L2_CAP_RADIO = global i32 0
@.str.12 = [7 x i8] c"radio:\00"
@.str.13 = [22 x i8] c"VDEV_V4L_CAPABILITIES\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca %struct.v4l2_capability
%4 = alloca [4097 x i8]
%5 = bitcast %struct.v4l2_capability* %3 to i8*
%6 = getelementptr inbounds [4097 x i8], [4097 x i8]* %4, i64 0, i64 0
%7 = call i32 @memset(i8* %6, i32 0, i32 4097)
%8 = call i32 @getopt_long(i32 %0, i8** %1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), %struct.option* getelementptr inbounds ([2 x %struct.option], [2 x %struct.option]* @main.options, i64 0, i64 0), i32* null)
switch i32 %8, label %85 [
i32 -1, label %12
i32 104, label %9
]
9: ; preds = %2
%10 = load i8*, i8** %1
%11 = call i32 @printf(i8* getelementptr inbounds ([92 x i8], [92 x i8]* @.str.2, i64 0, i64 0), i8* %10)
br label %85
12: ; preds = %2
%13 = load i64, i64* @optind
%14 = getelementptr inbounds i8*, i8** %1, i64 %13
%15 = load i8*, i8** %14
%16 = icmp eq i8* %15, null
br i1 %16, label %85, label %17
17: ; preds = %12
%18 = load i32, i32* @O_RDONLY
%19 = call i32 @open(i8* %15, i32 %18)
%20 = icmp slt i32 %19, 0
br i1 %20, label %85, label %21
21: ; preds = %17
%22 = load i32, i32* @VIDIOC_QUERYCAP
%23 = call i64 @ioctl(i32 %19, i32 %22, %struct.v4l2_capability* %3)
%24 = icmp eq i64 %23, 0
br i1 %24, label %25, label %81
25: ; preds = %21
%26 = call i32 @vdev_property_add(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%27 = getelementptr inbounds %struct.v4l2_capability, %struct.v4l2_capability* %3, i64 0, i32 1
%28 = load i64, i64* %27
%29 = inttoptr i64 %28 to i8*
%30 = call i32 @vdev_property_add(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.5, i64 0, i64 0), i8* %29)
%31 = call i32 @strcat(i8* %6, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0))
%32 = getelementptr inbounds %struct.v4l2_capability, %struct.v4l2_capability* %3, i64 0, i32 0
%33 = load i32, i32* %32
%34 = load i32, i32* @V4L2_CAP_VIDEO_CAPTURE
%35 = and i32 %34, %33
%36 = icmp sgt i32 %35, 0
br i1 %36, label %37, label %40
37: ; preds = %25
%38 = call i32 @strcat(i8* %6, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.7, i64 0, i64 0))
%39 = load i32, i32* %32
br label %40
40: ; preds = %37, %25
%41 = phi i32 [ %39, %37 ], [ %33, %25 ]
%42 = load i32, i32* @V4L2_CAP_VIDEO_OUTPUT
%43 = and i32 %42, %41
%44 = icmp sgt i32 %43, 0
br i1 %44, label %45, label %48
45: ; preds = %40
%46 = call i32 @strcat(i8* %6, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.8, i64 0, i64 0))
%47 = load i32, i32* %32
br label %48
48: ; preds = %45, %40
%49 = phi i32 [ %47, %45 ], [ %41, %40 ]
%50 = load i32, i32* @V4L2_CAP_VIDEO_OVERLAY
%51 = and i32 %50, %49
%52 = icmp sgt i32 %51, 0
br i1 %52, label %53, label %56
53: ; preds = %48
%54 = call i32 @strcat(i8* %6, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.9, i64 0, i64 0))
%55 = load i32, i32* %32
br label %56
56: ; preds = %53, %48
%57 = phi i32 [ %55, %53 ], [ %49, %48 ]
%58 = load i32, i32* @V4L2_CAP_AUDIO
%59 = and i32 %58, %57
%60 = icmp sgt i32 %59, 0
br i1 %60, label %61, label %64
61: ; preds = %56
%62 = call i32 @strcat(i8* %6, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.10, i64 0, i64 0))
%63 = load i32, i32* %32
br label %64
64: ; preds = %61, %56
%65 = phi i32 [ %63, %61 ], [ %57, %56 ]
%66 = load i32, i32* @V4L2_CAP_TUNER
%67 = and i32 %66, %65
%68 = icmp sgt i32 %67, 0
br i1 %68, label %69, label %72
69: ; preds = %64
%70 = call i32 @strcat(i8* %6, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.11, i64 0, i64 0))
%71 = load i32, i32* %32
br label %72
72: ; preds = %69, %64
%73 = phi i32 [ %71, %69 ], [ %65, %64 ]
%74 = load i32, i32* @V4L2_CAP_RADIO
%75 = and i32 %74, %73
%76 = icmp sgt i32 %75, 0
br i1 %76, label %77, label %79
77: ; preds = %72
%78 = call i32 @strcat(i8* %6, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.12, i64 0, i64 0))
br label %79
79: ; preds = %77, %72
%80 = call i32 @vdev_property_add(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.13, i64 0, i64 0), i8* %6)
br label %81
81: ; preds = %79, %21
%82 = call i32 @close(i32 %19)
%83 = call i32 (...) @vdev_property_print()
%84 = call i32 (...) @vdev_property_free_all()
br label %85
85: ; preds = %2, %9, %17, %12, %81
%86 = phi i32 [ 0, %81 ], [ 2, %12 ], [ 3, %17 ], [ 0, %9 ], [ 1, %2 ]
ret i32 %86
}