#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_2__ TYPE_1__;

/* Type definitions */
struct v4l2_ext_controls {
  size_t count;
  TYPE_1__ *controls;
};
typedef int /*<<< orphan*/ __u32;
typedef int /*<<< orphan*/ __s32;
struct TYPE_2__ {
  int /*<<< orphan*/ value;
  int /*<<< orphan*/ id;
};

/* Variables and functions */
void add_ctrl(struct v4l2_ext_controls *ctrls, __u32 id, __s32 value) {
  ctrls->controls[ctrls->count].id = id;
  ctrls->controls[ctrls->count].value = value;
  ctrls->count++;
}


x86 assembly (clang, -O0):
<add_ctrl>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    -0xc(%rbp),%edx
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%rax
mov    -0x8(%rbp),%rcx
mov    (%rcx),%rcx
mov    %edx,0x4(%rax,%rcx,8)
mov    -0x10(%rbp),%edx
mov    -0x8(%rbp),%rax
mov    0x8(%rax),%rax
mov    -0x8(%rbp),%rcx
mov    (%rcx),%rcx
mov    %edx,(%rax,%rcx,8)
mov    -0x8(%rbp),%rax
mov    (%rax),%rcx
add    $0x1,%rcx
mov    %rcx,(%rax)
pop    %rbp
ret

x86 assembly (clang, -O2):
<add_ctrl>:
mov    (%rdi),%rax
mov    0x8(%rdi),%rcx
mov    %esi,0x4(%rcx,%rax,8)
mov    %edx,(%rcx,%rax,8)
add    $0x1,%rax
mov    %rax,(%rdi)
ret

LLVM IR (-O0):
%struct.v4l2_ext_controls = type { i64, %struct.TYPE_2__* }
%struct.TYPE_2__ = type { i32, i32 }
define void @add_ctrl(%struct.v4l2_ext_controls* %0, i32 %1, i32 %2) {
%4 = alloca %struct.v4l2_ext_controls*
%5 = alloca i32
%6 = alloca i32
store %struct.v4l2_ext_controls* %0, %struct.v4l2_ext_controls** %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%7 = load i32, i32* %5
%8 = load %struct.v4l2_ext_controls*, %struct.v4l2_ext_controls** %4
%9 = getelementptr inbounds %struct.v4l2_ext_controls, %struct.v4l2_ext_controls* %8, i32 0, i32 1
%10 = load %struct.TYPE_2__*, %struct.TYPE_2__** %9
%11 = load %struct.v4l2_ext_controls*, %struct.v4l2_ext_controls** %4
%12 = getelementptr inbounds %struct.v4l2_ext_controls, %struct.v4l2_ext_controls* %11, i32 0, i32 0
%13 = load i64, i64* %12
%14 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %10, i64 %13
%15 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %14, i32 0, i32 1
store i32 %7, i32* %15
%16 = load i32, i32* %6
%17 = load %struct.v4l2_ext_controls*, %struct.v4l2_ext_controls** %4
%18 = getelementptr inbounds %struct.v4l2_ext_controls, %struct.v4l2_ext_controls* %17, i32 0, i32 1
%19 = load %struct.TYPE_2__*, %struct.TYPE_2__** %18
%20 = load %struct.v4l2_ext_controls*, %struct.v4l2_ext_controls** %4
%21 = getelementptr inbounds %struct.v4l2_ext_controls, %struct.v4l2_ext_controls* %20, i32 0, i32 0
%22 = load i64, i64* %21
%23 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %19, i64 %22
%24 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %23, i32 0, i32 0
store i32 %16, i32* %24
%25 = load %struct.v4l2_ext_controls*, %struct.v4l2_ext_controls** %4
%26 = getelementptr inbounds %struct.v4l2_ext_controls, %struct.v4l2_ext_controls* %25, i32 0, i32 0
%27 = load i64, i64* %26
%28 = add i64 %27, 1
store i64 %28, i64* %26
ret void
}

LLVM IR (-O2):
%struct.v4l2_ext_controls = type { i64, %struct.TYPE_2__* }
%struct.TYPE_2__ = type { i32, i32 }
define void @add_ctrl(%struct.v4l2_ext_controls* nocapture %0, i32 %1, i32 %2) {
%4 = getelementptr inbounds %struct.v4l2_ext_controls, %struct.v4l2_ext_controls* %0, i64 0, i32 1
%5 = load %struct.TYPE_2__*, %struct.TYPE_2__** %4
%6 = getelementptr inbounds %struct.v4l2_ext_controls, %struct.v4l2_ext_controls* %0, i64 0, i32 0
%7 = load i64, i64* %6
%8 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %5, i64 %7, i32 1
store i32 %1, i32* %8
%9 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %5, i64 %7, i32 0
store i32 %2, i32* %9
%10 = add i64 %7, 1
store i64 %10, i64* %6
ret void
}