#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*/ execlp(char *, char *, char *, char *, char *,
                          int /*<<< orphan*/ *);
scalar_t__ fork();
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ wait(int /*<<< orphan*/ *);
void criaprocesso(char caminho[40], char cmd[10], char parametro[30],
                  char parametro1[30], char prm[30]) {
  pid_t pid;
  pid = fork();
  if (pid < 0) {
    fprintf(stderr, "FALHA NO EXECUCAO DO FORK()");
    return;
  } else if (pid == 0) {
    execlp(caminho, cmd, parametro, parametro1, prm, NULL);
  } else {
    wait(NULL);
    printf("\n");
    return;
  }
}


x86 assembly (clang, -O0):
<criaprocesso>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    $0x0,%al
call   1070 <fork@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
jge    119c <criaprocesso+0x4c>
mov    0x2e57(%rip),%rax
mov    (%rax),%edi
lea    0xe6e(%rip),%rsi
call   1040 <fprintf@plt>
jmp    11e9 <criaprocesso+0x99>
cmpq   $0x0,-0x30(%rbp)
jne    11ca <criaprocesso+0x7a>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rcx
mov    -0x28(%rbp),%r8
xor    %eax,%eax
mov    %eax,%r9d
call   1050 <execlp@plt>
jmp    11e4 <criaprocesso+0x94>
xor    %eax,%eax
mov    %eax,%edi
call   1060 <wait@plt>
lea    0xe42(%rip),%rdi
call   1030 <printf@plt>
jmp    11e9 <criaprocesso+0x99>
jmp    11e9 <criaprocesso+0x99>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<criaprocesso>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %r8,%r14
mov    %rcx,%r15
mov    %rdx,%r12
mov    %rsi,%r13
mov    %rdi,%rbx
xor    %eax,%eax
call   1070 <fork@plt>
test   %rax,%rax
js     1190 <criaprocesso+0x40>
je     11ae <criaprocesso+0x5e>
xor    %edi,%edi
call   1060 <wait@plt>
mov    $0xa,%edi
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
jmp    1030 <putchar@plt>
mov    0x2e49(%rip),%rax
mov    (%rax),%edi
lea    0xe60(%rip),%rsi
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
jmp    1040 <fprintf@plt>
mov    %rbx,%rdi
mov    %r13,%rsi
mov    %r12,%rdx
mov    %r15,%rcx
mov    %r14,%r8
xor    %r9d,%r9d
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
jmp    1050 <execlp@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [28 x i8] c"FALHA NO EXECUCAO DO FORK()\00"
@.str.1 = [2 x i8] c"\0A\00"
define void @criaprocesso(i8* %0, i8* %1, i8* %2, i8* %3, i8* %4) {
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i64
store i8* %0, i8** %6
store i8* %1, i8** %7
store i8* %2, i8** %8
store i8* %3, i8** %9
store i8* %4, i8** %10
%12 = call i64 (...) @fork()
store i64 %12, i64* %11
%13 = load i64, i64* %11
%14 = icmp slt i64 %13, 0
br i1 %14, label %15, label %18
15: ; preds = %5
%16 = load i32, i32* @stderr
%17 = call i32 @fprintf(i32 %16, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0))
br label %32
18: ; preds = %5
%19 = load i64, i64* %11
%20 = icmp eq i64 %19, 0
br i1 %20, label %21, label %28
21: ; preds = %18
%22 = load i8*, i8** %6
%23 = load i8*, i8** %7
%24 = load i8*, i8** %8
%25 = load i8*, i8** %9
%26 = load i8*, i8** %10
%27 = call i32 @execlp(i8* %22, i8* %23, i8* %24, i8* %25, i8* %26, i32* null)
br label %31
28: ; preds = %18
%29 = call i32 @wait(i32* null)
%30 = call i32 @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %32
31: ; preds = %21
br label %32
32: ; preds = %15, %28, %31
ret void
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [28 x i8] c"FALHA NO EXECUCAO DO FORK()\00"
define void @criaprocesso(i8* %0, i8* %1, i8* %2, i8* %3, i8* %4) {
%6 = tail call i64 (...) @fork()
%7 = icmp slt i64 %6, 0
br i1 %7, label %8, label %11
8: ; preds = %5
%9 = load i32, i32* @stderr
%10 = tail call i32 @fprintf(i32 %9, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0))
br label %18
11: ; preds = %5
%12 = icmp eq i64 %6, 0
br i1 %12, label %13, label %15
13: ; preds = %11
%14 = tail call i32 @execlp(i8* %0, i8* %1, i8* %2, i8* %3, i8* %4, i32* null)
br label %18
15: ; preds = %11
%16 = tail call i32 @wait(i32* null)
%17 = tail call i32 @putchar(i32 10)
br label %18
18: ; preds = %13, %15, %8
ret void
}