#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 */

/* Variables and functions */
scalar_t__ fork();
int getpid();
int /*<<< orphan*/ printf(char *, ...);
int setpriority_ep(int, int);
int /*<<< orphan*/ sleep(int);
int main(int argc, char **argv) {
  int pidPai;
  pidPai = getpid();
  if (fork()) {
    printf("PID do pai: %d\n", pidPai);
    sleep(60);
  } else {
    printf("Filho vai tentar mudar a prioridade do pai\n");
    printf("Resultado da syscall: %d\n", setpriority_ep(pidPai, 1));
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x0,%al
call   1030 <getpid@plt>
mov    %eax,-0x14(%rbp)
mov    $0x0,%al
call   1070 <fork@plt>
cmp    $0x0,%rax
je     11a1 <main+0x51>
mov    -0x14(%rbp),%esi
lea    0xe75(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x3c,%edi
call   1060 <sleep@plt>
jmp    11cc <main+0x7c>
lea    0xe68(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x14(%rbp),%edi
mov    $0x1,%esi
call   1050 <setpriority_ep@plt>
mov    %eax,%esi
lea    0xe77(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
xor    %eax,%eax
call   1040 <getpid@plt>
mov    %eax,%ebx
xor    %eax,%eax
call   1080 <fork@plt>
test   %rax,%rax
je     1192 <main+0x32>
lea    0xe83(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0x3c,%edi
call   1070 <sleep@plt>
jmp    11ba <main+0x5a>
lea    0xe91(%rip),%rdi
call   1030 <puts@plt>
mov    %ebx,%edi
mov    $0x1,%esi
call   1060 <setpriority_ep@plt>
lea    0xe5f(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [16 x i8] c"PID do pai: %d\0A\00"
@.str.1 = [44 x i8] c"Filho vai tentar mudar a prioridade do pai\0A\00"
@.str.2 = [26 x i8] c"Resultado da syscall: %d\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = call i32 (...) @getpid()
store i32 %7, i32* %6
%8 = call i64 (...) @fork()
%9 = icmp ne i64 %8, 0
br i1 %9, label %10, label %14
10: ; preds = %2
%11 = load i32, i32* %6
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i32 %11)
%13 = call i32 @sleep(i32 60)
br label %19
14: ; preds = %2
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.1, i64 0, i64 0))
%16 = load i32, i32* %6
%17 = call i32 @setpriority_ep(i32 %16, i32 1)
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0), i32 %17)
br label %19
19: ; preds = %14, %10
ret i32 0
}

LLVM IR (-O2):
@.str = [16 x i8] c"PID do pai: %d\0A\00"
@.str.2 = [26 x i8] c"Resultado da syscall: %d\0A\00"
@str = [43 x i8] c"Filho vai tentar mudar a prioridade do pai\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i32 (...) @getpid()
%4 = tail call i64 (...) @fork()
%5 = icmp eq i64 %4, 0
br i1 %5, label %9, label %6
6: ; preds = %2
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i32 %3)
%8 = tail call i32 @sleep(i32 60)
br label %13
9: ; preds = %2
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @str, i64 0, i64 0))
%11 = tail call i32 @setpriority_ep(i32 %3, i32 1)
%12 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.2, i64 0, i64 0), i32 %11)
br label %13
13: ; preds = %9, %6
ret i32 0
}