#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 */
typedef scalar_t__ pid_t;

/* Variables and functions */
int /*<<< orphan*/ EXIT_SUCCESS;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
scalar_t__ fork();
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ snprintf(char *, int, char *, char *);
int /*<<< orphan*/ system(char *);
int spawn(char *fname) {
  pid_t child_pid;
  char cmd[600];
  child_pid = fork();
  if (child_pid != 0)
    return child_pid;
  else {
    snprintf(cmd, 600, "omxplayer -b --no-osd -o both \"%s\"", fname);
    system(cmd);
    printf("\x1B[32m"
           "Play video done\n"
           "\033[0m");
    exit(EXIT_SUCCESS);
  }
}


x86 assembly (clang, -O0):
<spawn>:
push   %rbp
mov    %rsp,%rbp
sub    $0x270,%rsp
mov    %rdi,-0x8(%rbp)
mov    $0x0,%al
call   1070 <fork@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     1182 <spawn+0x32>
mov    -0x10(%rbp),%rax
add    $0x270,%rsp
pop    %rbp
ret
lea    -0x270(%rbp),%rdi
mov    -0x8(%rbp),%rcx
mov    $0x258,%esi
lea    0xe67(%rip),%rdx
call   1050 <snprintf@plt>
lea    -0x270(%rbp),%rdi
call   1030 <system@plt>
lea    0xe72(%rip),%rdi
call   1040 <printf@plt>
mov    0x2e23(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>

x86 assembly (clang, -O2):
<spawn>:
push   %r14
push   %rbx
sub    $0x258,%rsp
mov    %rdi,%rbx
xor    %eax,%eax
call   1070 <fork@plt>
test   %rax,%rax
je     1174 <spawn+0x24>
add    $0x258,%rsp
pop    %rbx
pop    %r14
ret
lea    0xe85(%rip),%rdx
mov    %rsp,%r14
mov    %r14,%rdi
mov    $0x258,%esi
mov    %rbx,%rcx
call   1050 <snprintf@plt>
mov    %r14,%rdi
call   1030 <system@plt>
lea    0xe86(%rip),%rdi
call   1040 <printf@plt>
mov    0x2e37(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@.str = [35 x i8] c"omxplayer -b --no-osd -o both \22%s\22\00"
@.str.1 = [26 x i8] c"\1B[32mPlay video done\0A\1B[0m\00"
@EXIT_SUCCESS = global i32 0
define i32 @spawn(i8* %0) {
%2 = alloca i8*
%3 = alloca i64
%4 = alloca [600 x i8]
store i8* %0, i8** %2
%5 = call i64 (...) @fork()
store i64 %5, i64* %3
%6 = load i64, i64* %3
%7 = icmp ne i64 %6, 0
br i1 %7, label %8, label %11
8: ; preds = %1
%9 = load i64, i64* %3
%10 = trunc i64 %9 to i32
ret i32 %10
11: ; preds = %1
%12 = getelementptr inbounds [600 x i8], [600 x i8]* %4, i64 0, i64 0
%13 = load i8*, i8** %2
%14 = call i32 @snprintf(i8* %12, i32 600, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0), i8* %13)
%15 = getelementptr inbounds [600 x i8], [600 x i8]* %4, i64 0, i64 0
%16 = call i32 @system(i8* %15)
%17 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0))
%18 = load i32, i32* @EXIT_SUCCESS
%19 = call i32 @exit(i32 %18)
unreachable
}

LLVM IR (-O2):
@.str = [35 x i8] c"omxplayer -b --no-osd -o both \22%s\22\00"
@.str.1 = [26 x i8] c"\1B[32mPlay video done\0A\1B[0m\00"
@EXIT_SUCCESS = global i32 0
define i32 @spawn(i8* %0) {
%2 = alloca [600 x i8]
%3 = getelementptr inbounds [600 x i8], [600 x i8]* %2, i64 0, i64 0
%4 = tail call i64 (...) @fork()
%5 = icmp eq i64 %4, 0
br i1 %5, label %8, label %6
6: ; preds = %1
%7 = trunc i64 %4 to i32
ret i32 %7
8: ; preds = %1
%9 = call i32 @snprintf(i8* %3, i32 600, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0), i8* %0)
%10 = call i32 @system(i8* %3)
%11 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0))
%12 = load i32, i32* @EXIT_SUCCESS
%13 = call i32 @exit(i32 %12)
unreachable
}