#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 */
scalar_t__ fork();
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ wait(int /*<<< orphan*/ *);
int main() {
  pid_t pid = fork();
  if (pid >= 0) {
    if (pid == 0) {
      printf("%s\n", "Novo processo criado!");
    } else {
      printf("%s\n", "Novo processo criado!");
      wait(NULL);
    }
    return 0;
  } else {
    printf("%s\n", "Não pode criar o processo");
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1050 <fork@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jl     11a0 <main+0x70>
cmpq   $0x0,-0x10(%rbp)
jne    1178 <main+0x48>
lea    0xe99(%rip),%rdi
lea    0xe96(%rip),%rsi
call   1030 <printf@plt>
jmp    1194 <main+0x64>
lea    0xe81(%rip),%rdi
lea    0xe7e(%rip),%rsi
call   1030 <printf@plt>
xor    %eax,%eax
mov    %eax,%edi
call   1040 <wait@plt>
movl   $0x0,-0x4(%rbp)
jmp    11b3 <main+0x83>
lea    0xe59(%rip),%rdi
lea    0xe6c(%rip),%rsi
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
xor    %eax,%eax
call   1050 <fork@plt>
test   %rax,%rax
js     1161 <main+0x31>
mov    %rax,%rbx
lea    0xeb9(%rip),%rdi
lea    0xeb6(%rip),%rsi
call   1030 <printf@plt>
test   %rbx,%rbx
je     1174 <main+0x44>
xor    %edi,%edi
call   1040 <wait@plt>
jmp    1174 <main+0x44>
lea    0xe98(%rip),%rdi
lea    0xeab(%rip),%rsi
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%s\0A\00"
@.str.1 = [22 x i8] c"Novo processo criado!\00"
@.str.2 = [27 x i8] c"N\C3\A3o pode criar o processo\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i64
store i32 0, i32* %1
%3 = call i64 (...) @fork()
store i64 %3, i64* %2
%4 = load i64, i64* %2
%5 = icmp sge i64 %4, 0
br i1 %5, label %6, label %15
6: ; preds = %0
%7 = load i64, i64* %2
%8 = icmp eq i64 %7, 0
br i1 %8, label %9, label %11
9: ; preds = %6
%10 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0))
br label %14
11: ; preds = %6
%12 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0))
%13 = call i32 @wait(i32* null)
br label %14
14: ; preds = %11, %9
store i32 0, i32* %1
br label %17
15: ; preds = %0
%16 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0))
br label %17
17: ; preds = %14, %15
%18 = load i32, i32* %1
ret i32 %18
}

LLVM IR (-O2):
@.str = [4 x i8] c"%s\0A\00"
@.str.1 = [22 x i8] c"Novo processo criado!\00"
@.str.2 = [27 x i8] c"N\C3\A3o pode criar o processo\00"
define i32 @main() {
%1 = tail call i64 (...) @fork()
%2 = icmp sgt i64 %1, -1
br i1 %2, label %3, label %8
3: ; preds = %0
%4 = icmp eq i64 %1, 0
%5 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0))
br i1 %4, label %10, label %6
6: ; preds = %3
%7 = tail call i32 @wait(i32* null)
br label %10
8: ; preds = %0
%9 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0))
br label %10
10: ; preds = %3, %6, %8
ret i32 0
}