#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 camera {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ close_camera(struct camera *);
int /*<<< orphan*/ get_and_save_photo(struct camera *);
int /*<<< orphan*/ init_camera(struct camera *);
int /*<<< orphan*/ init_photo();
int /*<<< orphan*/ open_camera(struct camera *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ start_capturing(struct camera *);
int /*<<< orphan*/ stop_capturing(struct camera *);
int /*<<< orphan*/ uninit_camera(struct camera *);
void v4l2_capture(struct camera *cam) {
  open_camera(cam);
  printf("open_camera \n");
  init_camera(cam);
  printf("init_camera \n");
  start_capturing(cam);
  printf("start_capturing \n");
  init_photo();
  printf("init_photo \n");
  get_and_save_photo(cam);
  printf("get_and_save_photo \n");
  stop_capturing(cam);
  printf("stop_capturing \n");
  uninit_camera(cam);
  printf("uninit_camera \n");
  close_camera(cam);
  printf("close_camera \n");
}


x86 assembly (clang, -O0):
<v4l2_capture>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <open_camera@plt>
lea    0xe54(%rip),%rdi
call   1060 <printf@plt>
mov    -0x8(%rbp),%rdi
call   10a0 <init_camera@plt>
lea    0xe94(%rip),%rdi
call   1060 <printf@plt>
mov    -0x8(%rbp),%rdi
call   1040 <start_capturing@plt>
lea    0xe38(%rip),%rdi
call   1060 <printf@plt>
mov    $0x0,%al
call   10b0 <init_photo@plt>
lea    0xe37(%rip),%rdi
call   1060 <printf@plt>
mov    -0x8(%rbp),%rdi
call   1080 <get_and_save_photo@plt>
lea    0xe2f(%rip),%rdi
call   1060 <printf@plt>
mov    -0x8(%rbp),%rdi
call   1030 <stop_capturing@plt>
lea    0xe2f(%rip),%rdi
call   1060 <printf@plt>
mov    -0x8(%rbp),%rdi
call   1090 <uninit_camera@plt>
lea    0xe2b(%rip),%rdi
call   1060 <printf@plt>
mov    -0x8(%rbp),%rdi
call   1070 <close_camera@plt>
lea    0xe26(%rip),%rdi
call   1060 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<v4l2_capture>:
push   %rbx
mov    %rdi,%rbx
call   1060 <open_camera@plt>
lea    0xe60(%rip),%rdi
call   1040 <puts@plt>
mov    %rbx,%rdi
call   10a0 <init_camera@plt>
lea    0xe9c(%rip),%rdi
call   1040 <puts@plt>
mov    %rbx,%rdi
call   1050 <start_capturing@plt>
lea    0xe45(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
call   10b0 <init_photo@plt>
lea    0xe43(%rip),%rdi
call   1040 <puts@plt>
mov    %rbx,%rdi
call   1080 <get_and_save_photo@plt>
lea    0xe3b(%rip),%rdi
call   1040 <puts@plt>
mov    %rbx,%rdi
call   1030 <stop_capturing@plt>
lea    0xe3b(%rip),%rdi
call   1040 <puts@plt>
mov    %rbx,%rdi
call   1090 <uninit_camera@plt>
lea    0xe37(%rip),%rdi
call   1040 <puts@plt>
mov    %rbx,%rdi
call   1070 <close_camera@plt>
lea    0xe32(%rip),%rdi
pop    %rbx
jmp    1040 <puts@plt>

LLVM IR (-O0):
%struct.camera = type { i32 }
@.str = [14 x i8] c"open_camera \0A\00"
@.str.1 = [14 x i8] c"init_camera \0A\00"
@.str.2 = [18 x i8] c"start_capturing \0A\00"
@.str.3 = [13 x i8] c"init_photo \0A\00"
@.str.4 = [21 x i8] c"get_and_save_photo \0A\00"
@.str.5 = [17 x i8] c"stop_capturing \0A\00"
@.str.6 = [16 x i8] c"uninit_camera \0A\00"
@.str.7 = [15 x i8] c"close_camera \0A\00"
define void @v4l2_capture(%struct.camera* %0) {
%2 = alloca %struct.camera*
store %struct.camera* %0, %struct.camera** %2
%3 = load %struct.camera*, %struct.camera** %2
%4 = call i32 @open_camera(%struct.camera* %3)
%5 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
%6 = load %struct.camera*, %struct.camera** %2
%7 = call i32 @init_camera(%struct.camera* %6)
%8 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
%9 = load %struct.camera*, %struct.camera** %2
%10 = call i32 @start_capturing(%struct.camera* %9)
%11 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0))
%12 = call i32 (...) @init_photo()
%13 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.3, i64 0, i64 0))
%14 = load %struct.camera*, %struct.camera** %2
%15 = call i32 @get_and_save_photo(%struct.camera* %14)
%16 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i64 0, i64 0))
%17 = load %struct.camera*, %struct.camera** %2
%18 = call i32 @stop_capturing(%struct.camera* %17)
%19 = call i32 @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.5, i64 0, i64 0))
%20 = load %struct.camera*, %struct.camera** %2
%21 = call i32 @uninit_camera(%struct.camera* %20)
%22 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.6, i64 0, i64 0))
%23 = load %struct.camera*, %struct.camera** %2
%24 = call i32 @close_camera(%struct.camera* %23)
%25 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.7, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
%struct.camera = type { i32 }
@str = [13 x i8] c"open_camera \00"
@str.8 = [13 x i8] c"init_camera \00"
@str.9 = [17 x i8] c"start_capturing \00"
@str.10 = [12 x i8] c"init_photo \00"
@str.11 = [20 x i8] c"get_and_save_photo \00"
@str.12 = [16 x i8] c"stop_capturing \00"
@str.13 = [15 x i8] c"uninit_camera \00"
@str.14 = [14 x i8] c"close_camera \00"
define void @v4l2_capture(%struct.camera* %0) {
%2 = tail call i32 @open_camera(%struct.camera* %0)
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @str, i64 0, i64 0))
%4 = tail call i32 @init_camera(%struct.camera* %0)
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @str.8, i64 0, i64 0))
%6 = tail call i32 @start_capturing(%struct.camera* %0)
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str.9, i64 0, i64 0))
%8 = tail call i32 (...) @init_photo()
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str.10, i64 0, i64 0))
%10 = tail call i32 @get_and_save_photo(%struct.camera* %0)
%11 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str.11, i64 0, i64 0))
%12 = tail call i32 @stop_capturing(%struct.camera* %0)
%13 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str.12, i64 0, i64 0))
%14 = tail call i32 @uninit_camera(%struct.camera* %0)
%15 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str.13, i64 0, i64 0))
%16 = tail call i32 @close_camera(%struct.camera* %0)
%17 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str.14, i64 0, i64 0))
ret void
}