#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 int pid_t;

/* Variables and functions */
int /*<<< orphan*/ EXIT_FAILURE;
int /*<<< orphan*/ execlp(char const *, char const *, char *,
                          int /*<<< orphan*/ *);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int fork();
int /*<<< orphan*/ perror(char *);
void cmusfm_spawn_server_process(const char *cmusfm) {
  pid_t pid;
  if ((pid = fork()) == -1) {
    perror("ERROR: Fork server");
    exit(EXIT_FAILURE);
  }
  if (pid == 0) {
    execlp(cmusfm, cmusfm, "server", NULL);
    perror("ERROR: Exec server");
    exit(EXIT_FAILURE);
  }
}


x86 assembly (clang, -O0):
<cmusfm_spawn_server_process>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    $0x0,%al
call   1060 <fork@plt>
mov    %eax,-0xc(%rbp)
cmp    $0xffffffff,%eax
jne    1179 <cmusfm_spawn_server_process+0x39>
lea    0xe9a(%rip),%rdi
call   1030 <perror@plt>
mov    0x2e6e(%rip),%rax
mov    (%rax),%edi
call   1040 <exit@plt>
cmpl   $0x0,-0xc(%rbp)
jne    11b5 <cmusfm_spawn_server_process+0x75>
mov    -0x8(%rbp),%rdi
mov    -0x8(%rbp),%rsi
lea    0xe8d(%rip),%rdx
xor    %eax,%eax
mov    %eax,%ecx
call   1050 <execlp@plt>
lea    0xe71(%rip),%rdi
call   1030 <perror@plt>
mov    0x2e32(%rip),%rax
mov    (%rax),%edi
call   1040 <exit@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cmusfm_spawn_server_process>:
push   %rbx
mov    %rdi,%rbx
xor    %eax,%eax
call   1060 <fork@plt>
test   %eax,%eax
je     1156 <cmusfm_spawn_server_process+0x16>
cmp    $0xffffffff,%eax
je     1173 <cmusfm_spawn_server_process+0x33>
pop    %rbx
ret
lea    0xec2(%rip),%rdx
mov    %rbx,%rdi
mov    %rbx,%rsi
xor    %ecx,%ecx
call   1050 <execlp@plt>
lea    0xea2(%rip),%rdi
jmp    117a <cmusfm_spawn_server_process+0x3a>
lea    0xe86(%rip),%rdi
call   1030 <perror@plt>
mov    0x2e5a(%rip),%rax
mov    (%rax),%edi
call   1040 <exit@plt>

LLVM IR (-O0):
@.str = [19 x i8] c"ERROR: Fork server\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [7 x i8] c"server\00"
@.str.2 = [19 x i8] c"ERROR: Exec server\00"
define void @cmusfm_spawn_server_process(i8* %0) {
%2 = alloca i8*
%3 = alloca i32
store i8* %0, i8** %2
%4 = call i32 (...) @fork()
store i32 %4, i32* %3
%5 = icmp eq i32 %4, -1
br i1 %5, label %6, label %10
6: ; preds = %1
%7 = call i32 @perror(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
%8 = load i32, i32* @EXIT_FAILURE
%9 = call i32 @exit(i32 %8)
unreachable
10: ; preds = %1
%11 = load i32, i32* %3
%12 = icmp eq i32 %11, 0
br i1 %12, label %13, label %20
13: ; preds = %10
%14 = load i8*, i8** %2
%15 = load i8*, i8** %2
%16 = call i32 @execlp(i8* %14, i8* %15, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32* null)
%17 = call i32 @perror(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0))
%18 = load i32, i32* @EXIT_FAILURE
%19 = call i32 @exit(i32 %18)
unreachable
20: ; preds = %10
ret void
}

LLVM IR (-O2):
@.str = [19 x i8] c"ERROR: Fork server\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [7 x i8] c"server\00"
@.str.2 = [19 x i8] c"ERROR: Exec server\00"
define void @cmusfm_spawn_server_process(i8* %0) {
%2 = tail call i32 (...) @fork()
switch i32 %2, label %12 [
i32 -1, label %3
i32 0, label %7
]
3: ; preds = %1
%4 = tail call i32 @perror(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0))
%5 = load i32, i32* @EXIT_FAILURE
%6 = tail call i32 @exit(i32 %5)
unreachable
7: ; preds = %1
%8 = tail call i32 @execlp(i8* %0, i8* %0, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32* null)
%9 = tail call i32 @perror(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0))
%10 = load i32, i32* @EXIT_FAILURE
%11 = tail call i32 @exit(i32 %10)
unreachable
12: ; preds = %1
ret void
}