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

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


x86 assembly (clang, -O0):
<v4l2_list_outputs>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %edi,-0x4(%rbp)
movl   $0x0,-0x28(%rbp)
mov    -0x4(%rbp),%edi
mov    0x2e9c(%rip),%rax
mov    (%rax),%esi
lea    -0x28(%rbp),%rdx
call   1050 <ioctl@plt>
cmp    $0x0,%rax
jne    11ae <v4l2_list_outputs+0x7e>
mov    $0x0,%al
call   1030 <getpid@plt>
mov    %eax,%esi
mov    -0x4(%rbp),%edx
mov    -0x20(%rbp),%rcx
mov    -0x28(%rbp),%r8d
mov    -0xc(%rbp),%r9d
mov    -0x10(%rbp),%r11d
mov    -0x14(%rbp),%r10d
mov    -0x18(%rbp),%eax
lea    0xe75(%rip),%rdi
mov    %r11d,(%rsp)
mov    %r10d,0x8(%rsp)
mov    %eax,0x10(%rsp)
call   1040 <printf@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    1142 <v4l2_list_outputs+0x12>
add    $0x50,%rsp
pop    %rbp
ret

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

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

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