#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*/ init_camera(struct camera *);
int /*<<< orphan*/ init_encoder(struct camera *);
int /*<<< orphan*/ init_file();
int /*<<< orphan*/ open_camera(struct camera *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ start_capturing(struct camera *);
void v4l2_init(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_encoder(cam);
  printf("init_encoder \n");
  init_file();
  printf("init_file \n");
}


x86 assembly (clang, -O0):
<v4l2_init>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <open_camera@plt>
lea    0xe84(%rip),%rdi
call   1050 <printf@plt>
mov    -0x8(%rbp),%rdi
call   1080 <init_camera@plt>
lea    0xe7d(%rip),%rdi
call   1050 <printf@plt>
mov    -0x8(%rbp),%rdi
call   1030 <start_capturing@plt>
lea    0xe76(%rip),%rdi
call   1050 <printf@plt>
mov    -0x8(%rbp),%rdi
call   1060 <init_encoder@plt>
lea    0xe73(%rip),%rdi
call   1050 <printf@plt>
mov    $0x0,%al
call   1070 <init_file@plt>
lea    0xe6f(%rip),%rdi
call   1050 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<v4l2_init>:
push   %rbx
mov    %rdi,%rbx
call   1050 <open_camera@plt>
lea    0xe90(%rip),%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
call   1080 <init_camera@plt>
lea    0xe89(%rip),%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
call   1040 <start_capturing@plt>
lea    0xe82(%rip),%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
call   1060 <init_encoder@plt>
lea    0xe7f(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   1070 <init_file@plt>
lea    0xe7a(%rip),%rdi
pop    %rbx
jmp    1030 <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 = [15 x i8] c"init_encoder \0A\00"
@.str.4 = [12 x i8] c"init_file \0A\00"
define void @v4l2_init(%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 = load %struct.camera*, %struct.camera** %2
%13 = call i32 @init_encoder(%struct.camera* %12)
%14 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0))
%15 = call i32 (...) @init_file()
%16 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
%struct.camera = type { i32 }
@str = [13 x i8] c"open_camera \00"
@str.5 = [13 x i8] c"init_camera \00"
@str.6 = [17 x i8] c"start_capturing \00"
@str.7 = [14 x i8] c"init_encoder \00"
@str.8 = [11 x i8] c"init_file \00"
define void @v4l2_init(%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.5, 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.6, i64 0, i64 0))
%8 = tail call i32 @init_encoder(%struct.camera* %0)
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str.7, i64 0, i64 0))
%10 = tail call i32 (...) @init_file()
%11 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @str.8, i64 0, i64 0))
ret void
}