#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_input {
  int index;
  char *name;
  int /*<<< orphan*/ status;
  int /*<<< orphan*/ tuner;
  int /*<<< orphan*/ audioset;
  int /*<<< orphan*/ type;
  int /*<<< orphan*/ std;
};

/* Variables and functions */
int /*<<< orphan*/ VIDIOC_ENUMINPUT;
int getpid();
scalar_t__ ioctl(int, int /*<<< orphan*/, struct v4l2_input *);
int /*<<< orphan*/ printf(char *, int, int, char *, int, int /*<<< orphan*/,
                          int /*<<< orphan*/, int /*<<< orphan*/,
                          int /*<<< orphan*/, int /*<<< orphan*/);
void __attribute__((unused)) v4l2_list_inputs(int videofd) {
  struct v4l2_input input;
  input.index = 0;
  while (ioctl(videofd, VIDIOC_ENUMINPUT, &input) == 0) {
    ({
      printf("\033[0;34m"
             "(%.5d) message: "
             "videofd %d: Found input '%s' w/ "
             "idx/std/type/audioset/tuner/status: %d/%.16llx/%d/%d/%d/%d"
             "\033[0m"
             "\n",
             getpid(), videofd, input.name, input.index, input.std, input.type,
             input.audioset, input.tuner, input.status);
    });
    ++input.index;
  }
}


x86 assembly (clang, -O0):
<v4l2_list_inputs>:
push   %rbp
mov    %rsp,%rbp
push   %rbx
sub    $0x58,%rsp
mov    %edi,-0xc(%rbp)
movl   $0x0,-0x38(%rbp)
mov    -0xc(%rbp),%edi
mov    0x2e9b(%rip),%rax
mov    (%rax),%esi
lea    -0x38(%rbp),%rdx
call   1050 <ioctl@plt>
cmp    $0x0,%rax
jne    11b6 <v4l2_list_inputs+0x86>
mov    $0x0,%al
call   1030 <getpid@plt>
mov    %eax,%esi
mov    -0xc(%rbp),%edx
mov    -0x30(%rbp),%rcx
mov    -0x38(%rbp),%r8d
mov    -0x18(%rbp),%r9d
mov    -0x1c(%rbp),%ebx
mov    -0x20(%rbp),%r11d
mov    -0x24(%rbp),%r10d
mov    -0x28(%rbp),%eax
lea    0xe71(%rip),%rdi
mov    %ebx,(%rsp)
mov    %r11d,0x8(%rsp)
mov    %r10d,0x10(%rsp)
mov    %eax,0x18(%rsp)
call   1040 <printf@plt>
mov    %eax,-0x3c(%rbp)
mov    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
jmp    1143 <v4l2_list_inputs+0x13>
add    $0x58,%rsp
pop    %rbx
pop    %rbp
ret

x86 assembly (clang, -O2):
<v4l2_list_inputs>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %edi,%r13d
movl   $0x0,(%rsp)
mov    0x2e99(%rip),%r12
mov    (%r12),%esi
mov    %rsp,%rdx
call   1050 <ioctl@plt>
test   %rax,%rax
jne    11c6 <v4l2_list_inputs+0x96>
lea    0xe99(%rip),%r14
mov    %rsp,%r15
nopw   0x0(%rax,%rax,1)
xor    %eax,%eax
call   1030 <getpid@plt>
mov    0x8(%rsp),%rcx
mov    (%rsp),%r8d
mov    0x20(%rsp),%r9d
mov    0x1c(%rsp),%r10d
mov    0x18(%rsp),%r11d
mov    0x14(%rsp),%ebx
mov    0x10(%rsp),%ebp
mov    %r14,%rdi
mov    %eax,%esi
mov    %r13d,%edx
push   %rbp
push   %rbx
push   %r11
push   %r10
call   1040 <printf@plt>
add    $0x20,%rsp
addl   $0x1,(%rsp)
mov    (%r12),%esi
mov    %r13d,%edi
mov    %r15,%rdx
call   1050 <ioctl@plt>
test   %rax,%rax
je     1170 <v4l2_list_inputs+0x40>
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.v4l2_input = type { i32, i8*, i32, i32, i32, i32, i32 }
@VIDIOC_ENUMINPUT = global i32 0
@.str = [119 x i8] c"\1B[0;34m(%.5d) message: videofd %d: Found input '%s' w/ idx/std/type/audioset/tuner/status: %d/%.16llx/%d/%d/%d/%d\1B[0m\0A\00"
define void @v4l2_list_inputs(i32 %0) {
%2 = alloca i32
%3 = alloca %struct.v4l2_input
%4 = alloca i32
store i32 %0, i32* %2
%5 = getelementptr inbounds %struct.v4l2_input, %struct.v4l2_input* %3, i32 0, i32 0
store i32 0, i32* %5
br label %6
6: ; preds = %11, %1
%7 = load i32, i32* %2
%8 = load i32, i32* @VIDIOC_ENUMINPUT
%9 = call i64 @ioctl(i32 %7, i32 %8, %struct.v4l2_input* %3)
%10 = icmp eq i64 %9, 0
br i1 %10, label %11, label %33
11: ; preds = %6
%12 = call i32 (...) @getpid()
%13 = load i32, i32* %2
%14 = getelementptr inbounds %struct.v4l2_input, %struct.v4l2_input* %3, i32 0, i32 1
%15 = load i8*, i8** %14
%16 = getelementptr inbounds %struct.v4l2_input, %struct.v4l2_input* %3, i32 0, i32 0
%17 = load i32, i32* %16
%18 = getelementptr inbounds %struct.v4l2_input, %struct.v4l2_input* %3, i32 0, i32 6
%19 = load i32, i32* %18
%20 = getelementptr inbounds %struct.v4l2_input, %struct.v4l2_input* %3, i32 0, i32 5
%21 = load i32, i32* %20
%22 = getelementptr inbounds %struct.v4l2_input, %struct.v4l2_input* %3, i32 0, i32 4
%23 = load i32, i32* %22
%24 = getelementptr inbounds %struct.v4l2_input, %struct.v4l2_input* %3, i32 0, i32 3
%25 = load i32, i32* %24
%26 = getelementptr inbounds %struct.v4l2_input, %struct.v4l2_input* %3, i32 0, i32 2
%27 = load i32, i32* %26
%28 = call i32 @printf(i8* getelementptr inbounds ([119 x i8], [119 x i8]* @.str, i64 0, i64 0), i32 %12, i32 %13, i8* %15, i32 %17, i32 %19, i32 %21, i32 %23, i32 %25, i32 %27)
store i32 %28, i32* %4
%29 = load i32, i32* %4
%30 = getelementptr inbounds %struct.v4l2_input, %struct.v4l2_input* %3, i32 0, i32 0
%31 = load i32, i32* %30
%32 = add nsw i32 %31, 1
store i32 %32, i32* %30
br label %6
33: ; preds = %6
ret void
}

LLVM IR (-O2):
%struct.v4l2_input = type { i32, i8*, i32, i32, i32, i32, i32 }
@VIDIOC_ENUMINPUT = global i32 0
@.str = [119 x i8] c"\1B[0;34m(%.5d) message: videofd %d: Found input '%s' w/ idx/std/type/audioset/tuner/status: %d/%.16llx/%d/%d/%d/%d\1B[0m\0A\00"
define void @v4l2_list_inputs(i32 %0) {
%2 = alloca %struct.v4l2_input
%3 = bitcast %struct.v4l2_input* %2 to i8*
%4 = getelementptr inbounds %struct.v4l2_input, %struct.v4l2_input* %2, i64 0, i32 0
store i32 0, i32* %4
%5 = load i32, i32* @VIDIOC_ENUMINPUT
%6 = call i64 @ioctl(i32 %0, i32 %5, %struct.v4l2_input* %2)
%7 = icmp eq i64 %6, 0
br i1 %7, label %8, label %30
8: ; preds = %1
%9 = getelementptr inbounds %struct.v4l2_input, %struct.v4l2_input* %2, i64 0, i32 1
%10 = getelementptr inbounds %struct.v4l2_input, %struct.v4l2_input* %2, i64 0, i32 6
%11 = getelementptr inbounds %struct.v4l2_input, %struct.v4l2_input* %2, i64 0, i32 5
%12 = getelementptr inbounds %struct.v4l2_input, %struct.v4l2_input* %2, i64 0, i32 4
%13 = getelementptr inbounds %struct.v4l2_input, %struct.v4l2_input* %2, i64 0, i32 3
%14 = getelementptr inbounds %struct.v4l2_input, %struct.v4l2_input* %2, i64 0, i32 2
br label %15
15: ; preds = %8, %15
%16 = call i32 (...) @getpid()
%17 = load i8*, i8** %9
%18 = load i32, i32* %4
%19 = load i32, i32* %10
%20 = load i32, i32* %11
%21 = load i32, i32* %12
%22 = load i32, i32* %13
%23 = load i32, i32* %14
%24 = call i32 @printf(i8* getelementptr inbounds ([119 x i8], [119 x i8]* @.str, i64 0, i64 0), i32 %16, i32 %0, i8* %17, i32 %18, i32 %19, i32 %20, i32 %21, i32 %22, i32 %23)
%25 = load i32, i32* %4
%26 = add nsw i32 %25, 1
store i32 %26, i32* %4
%27 = load i32, i32* @VIDIOC_ENUMINPUT
%28 = call i64 @ioctl(i32 %0, i32 %27, %struct.v4l2_input* %2)
%29 = icmp eq i64 %28, 0
br i1 %29, label %15, label %30
30: ; preds = %15, %1
ret void
}