#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 *, ...);
int /*<<< orphan*/ set_camera_ctl(char *, int);
int /*<<< orphan*/ sprintf(char *, char *, unsigned int, ...);
int system(char *);
void init_camera(unsigned int w, unsigned int h, unsigned int fps) {
  int rc;
  char cmd[100];
  printf("Initialising camera to %ux%u @ %u fps\n", w, h, fps);
  sprintf(cmd, "v4l2-ctl --set-fmt-video=width=%u,height=%u,pixelformat=1", w,
          h);
  rc = system(cmd);
  printf("  Set frame size: %s\n", rc ? "Not ok" : "Ok");
  sprintf(cmd, "v4l2-ctl --set-parm=%u", fps);
  rc = system(cmd);
  printf("  Set frame rate: %s\n", rc ? "Not ok" : "Ok");
  set_camera_ctl("power_line_frequency", 1);
  set_camera_ctl("zoom_absolute", 100);
}


x86 assembly (clang, -O0):
<init_camera>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    -0x4(%rbp),%esi
mov    -0x8(%rbp),%edx
mov    -0xc(%rbp),%ecx
lea    0xe9c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x80(%rbp),%rdi
mov    -0x4(%rbp),%edx
mov    -0x8(%rbp),%ecx
lea    0xeab(%rip),%rsi
mov    $0x0,%al
call   1060 <sprintf@plt>
lea    -0x80(%rbp),%rdi
call   1030 <system@plt>
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%ecx
lea    0xee5(%rip),%rsi
lea    0xed7(%rip),%rax
cmp    $0x0,%ecx
cmovne %rax,%rsi
lea    0xeb3(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x80(%rbp),%rdi
mov    -0xc(%rbp),%edx
lea    0xebe(%rip),%rsi
mov    $0x0,%al
call   1060 <sprintf@plt>
lea    -0x80(%rbp),%rdi
call   1030 <system@plt>
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%ecx
lea    0xe9e(%rip),%rsi
lea    0xe90(%rip),%rax
cmp    $0x0,%ecx
cmovne %rax,%rsi
lea    0xea3(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xeab(%rip),%rdi
mov    $0x1,%esi
call   1050 <set_camera_ctl@plt>
lea    0xeaf(%rip),%rdi
mov    $0x64,%esi
call   1050 <set_camera_ctl@plt>
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<init_camera>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x68,%rsp
mov    %edx,%r15d
mov    %esi,%ebp
mov    %edi,%ebx
lea    0xea8(%rip),%rdi
mov    %ebx,%esi
mov    %ebp,%edx
mov    %r15d,%ecx
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xeba(%rip),%rsi
mov    %rsp,%r14
mov    %r14,%rdi
mov    %ebx,%edx
mov    %ebp,%ecx
xor    %eax,%eax
call   1060 <sprintf@plt>
mov    %r14,%rdi
call   1030 <system@plt>
test   %eax,%eax
lea    0xeef(%rip),%rbp
lea    0xee1(%rip),%rbx
mov    %rbx,%rsi
cmove  %rbp,%rsi
lea    0xebd(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xecf(%rip),%rsi
mov    %r14,%rdi
mov    %r15d,%edx
xor    %eax,%eax
call   1060 <sprintf@plt>
mov    %r14,%rdi
call   1030 <system@plt>
test   %eax,%eax
cmove  %rbp,%rbx
lea    0xec4(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xec9(%rip),%rdi
mov    $0x1,%esi
call   1050 <set_camera_ctl@plt>
lea    0xecd(%rip),%rdi
mov    $0x64,%esi
add    $0x68,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1050 <set_camera_ctl@plt>

LLVM IR (-O0):
@.str = [39 x i8] c"Initialising camera to %ux%u @ %u fps\0A\00"
@.str.1 = [58 x i8] c"v4l2-ctl --set-fmt-video=width=%u,height=%u,pixelformat=1\00"
@.str.2 = [22 x i8] c" Set frame size: %s\0A\00"
@.str.3 = [7 x i8] c"Not ok\00"
@.str.4 = [3 x i8] c"Ok\00"
@.str.5 = [23 x i8] c"v4l2-ctl --set-parm=%u\00"
@.str.6 = [22 x i8] c" Set frame rate: %s\0A\00"
@.str.7 = [21 x i8] c"power_line_frequency\00"
@.str.8 = [14 x i8] c"zoom_absolute\00"
define void @init_camera(i32 %0, i32 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca [100 x i8]
store i32 %0, i32* %4
store i32 %1, i32* %5
store i32 %2, i32* %6
%9 = load i32, i32* %4
%10 = load i32, i32* %5
%11 = load i32, i32* %6
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0), i32 %9, i32 %10, i32 %11)
%13 = getelementptr inbounds [100 x i8], [100 x i8]* %8, i64 0, i64 0
%14 = load i32, i32* %4
%15 = load i32, i32* %5
%16 = call i32 (i8*, i8*, i32, ...) @sprintf(i8* %13, i8* getelementptr inbounds ([58 x i8], [58 x i8]* @.str.1, i64 0, i64 0), i32 %14, i32 %15)
%17 = getelementptr inbounds [100 x i8], [100 x i8]* %8, i64 0, i64 0
%18 = call i32 @system(i8* %17)
store i32 %18, i32* %7
%19 = load i32, i32* %7
%20 = icmp ne i32 %19, 0
%21 = zext i1 %20 to i64
%22 = select i1 %20, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0)
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0), i8* %22)
%24 = getelementptr inbounds [100 x i8], [100 x i8]* %8, i64 0, i64 0
%25 = load i32, i32* %6
%26 = call i32 (i8*, i8*, i32, ...) @sprintf(i8* %24, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.5, i64 0, i64 0), i32 %25)
%27 = getelementptr inbounds [100 x i8], [100 x i8]* %8, i64 0, i64 0
%28 = call i32 @system(i8* %27)
store i32 %28, i32* %7
%29 = load i32, i32* %7
%30 = icmp ne i32 %29, 0
%31 = zext i1 %30 to i64
%32 = select i1 %30, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0)
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.6, i64 0, i64 0), i8* %32)
%34 = call i32 @set_camera_ctl(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.7, i64 0, i64 0), i32 1)
%35 = call i32 @set_camera_ctl(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.8, i64 0, i64 0), i32 100)
ret void
}

LLVM IR (-O2):
@.str = [39 x i8] c"Initialising camera to %ux%u @ %u fps\0A\00"
@.str.1 = [58 x i8] c"v4l2-ctl --set-fmt-video=width=%u,height=%u,pixelformat=1\00"
@.str.2 = [22 x i8] c" Set frame size: %s\0A\00"
@.str.3 = [7 x i8] c"Not ok\00"
@.str.4 = [3 x i8] c"Ok\00"
@.str.5 = [23 x i8] c"v4l2-ctl --set-parm=%u\00"
@.str.6 = [22 x i8] c" Set frame rate: %s\0A\00"
@.str.7 = [21 x i8] c"power_line_frequency\00"
@.str.8 = [14 x i8] c"zoom_absolute\00"
define void @init_camera(i32 %0, i32 %1, i32 %2) {
%4 = alloca [100 x i8]
%5 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 0
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0), i32 %0, i32 %1, i32 %2)
%7 = call i32 (i8*, i8*, i32, ...) @sprintf(i8* %5, i8* dereferenceable(1) getelementptr inbounds ([58 x i8], [58 x i8]* @.str.1, i64 0, i64 0), i32 %0, i32 %1)
%8 = call i32 @system(i8* %5)
%9 = icmp eq i32 %8, 0
%10 = select i1 %9, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0)
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0), i8* %10)
%12 = call i32 (i8*, i8*, i32, ...) @sprintf(i8* %5, i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.5, i64 0, i64 0), i32 %2)
%13 = call i32 @system(i8* %5)
%14 = icmp eq i32 %13, 0
%15 = select i1 %14, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0)
%16 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.6, i64 0, i64 0), i8* %15)
%17 = tail call i32 @set_camera_ctl(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.7, i64 0, i64 0), i32 1)
%18 = tail call i32 @set_camera_ctl(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.8, i64 0, i64 0), i32 100)
ret void
}