#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 */

/* Variables and functions */
int /*<<< orphan*/ printf(char *, char const *, int, char *);
int /*<<< orphan*/ sprintf(char *, char *, char const *, int);
int system(char *);
void set_camera_ctl(const char *ctl, int val) {
  int rc;
  char cmd[100];
  sprintf(cmd, "v4l2-ctl --set-ctrl=%s=%d", ctl, val);
  rc = system(cmd);
  printf("  Set camera ctrl (%s=%d): %s\n", ctl, val, rc ? "Not ok" : "Ok");
}


x86 assembly (clang, -O0):
<set_camera_ctl>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
lea    -0x80(%rbp),%rdi
mov    -0x8(%rbp),%rdx
mov    -0xc(%rbp),%ecx
lea    0xeac(%rip),%rsi
call   1050 <sprintf@plt>
lea    -0x80(%rbp),%rdi
call   1030 <system@plt>
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%rsi
mov    -0xc(%rbp),%edx
mov    -0x10(%rbp),%edi
lea    0xeca(%rip),%rcx
lea    0xebc(%rip),%rax
cmp    $0x0,%edi
cmovne %rax,%rcx
lea    0xe8f(%rip),%rdi
call   1040 <printf@plt>
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<set_camera_ctl>:
push   %rbp
push   %r14
push   %rbx
sub    $0x70,%rsp
mov    %esi,%ebp
mov    %rdi,%rbx
lea    0xebc(%rip),%rsi
mov    %rsp,%r14
mov    %r14,%rdi
mov    %rbx,%rdx
mov    %ebp,%ecx
call   1050 <sprintf@plt>
mov    %r14,%rdi
call   1030 <system@plt>
test   %eax,%eax
lea    0xedb(%rip),%rax
lea    0xecd(%rip),%rcx
cmove  %rax,%rcx
lea    0xea3(%rip),%rdi
mov    %rbx,%rsi
mov    %ebp,%edx
add    $0x70,%rsp
pop    %rbx
pop    %r14
pop    %rbp
jmp    1040 <printf@plt>

LLVM IR (-O0):
@.str = [26 x i8] c"v4l2-ctl --set-ctrl=%s=%d\00"
@.str.1 = [31 x i8] c" Set camera ctrl (%s=%d): %s\0A\00"
@.str.2 = [7 x i8] c"Not ok\00"
@.str.3 = [3 x i8] c"Ok\00"
define void @set_camera_ctl(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
%6 = alloca [100 x i8]
store i8* %0, i8** %3
store i32 %1, i32* %4
%7 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 0
%8 = load i8*, i8** %3
%9 = load i32, i32* %4
%10 = call i32 @sprintf(i8* %7, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i8* %8, i32 %9)
%11 = getelementptr inbounds [100 x i8], [100 x i8]* %6, i64 0, i64 0
%12 = call i32 @system(i8* %11)
store i32 %12, i32* %5
%13 = load i8*, i8** %3
%14 = load i32, i32* %4
%15 = load i32, i32* %5
%16 = icmp ne i32 %15, 0
%17 = zext i1 %16 to i64
%18 = select i1 %16, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0)
%19 = call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0), i8* %13, i32 %14, i8* %18)
ret void
}

LLVM IR (-O2):
@.str = [26 x i8] c"v4l2-ctl --set-ctrl=%s=%d\00"
@.str.1 = [31 x i8] c" Set camera ctrl (%s=%d): %s\0A\00"
@.str.2 = [7 x i8] c"Not ok\00"
@.str.3 = [3 x i8] c"Ok\00"
define void @set_camera_ctl(i8* %0, i32 %1) {
%3 = alloca [100 x i8]
%4 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%5 = call i32 @sprintf(i8* %4, i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i8* %0, i32 %1)
%6 = call i32 @system(i8* %4)
%7 = icmp eq i32 %6, 0
%8 = select i1 %7, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0)
%9 = tail call i32 @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.1, i64 0, i64 0), i8* %0, i32 %1, i8* %8)
ret void
}