#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 */
struct svc_req {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ execlp(char *, int /*<<< orphan*/ *);
int fork();
int /*<<< orphan*/ system(char *);
int /*<<< orphan*/ wait(int /*<<< orphan*/);
int *ejecutartarea_1_svc(int *opcion, struct svc_req *req) {
  static int toReturn = 0;
  int op = *opcion;
  if (op == 1) {
    int p_hijo = fork();
    if (p_hijo >= 0)
      if (p_hijo == 0)
        execlp("tarea", NULL);
      else
        wait(0);
    else {
      toReturn = -1;
      return &(toReturn);
    }
  } else
    system("./tarea");
  return &toReturn;
}


x86 assembly (clang, -O0):
<ejecutartarea_1_svc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x1c(%rbp)
cmpl   $0x1,-0x1c(%rbp)
jne    11c1 <ejecutartarea_1_svc+0x81>
mov    $0x0,%al
call   1060 <fork@plt>
mov    %eax,-0x20(%rbp)
cmpl   $0x0,-0x20(%rbp)
jl     11a2 <ejecutartarea_1_svc+0x62>
cmpl   $0x0,-0x20(%rbp)
jne    1196 <ejecutartarea_1_svc+0x56>
lea    0xe7a(%rip),%rdi
xor    %eax,%eax
mov    %eax,%esi
call   1040 <execlp@plt>
jmp    119d <ejecutartarea_1_svc+0x5d>
xor    %edi,%edi
call   1050 <wait@plt>
jmp    11bc <ejecutartarea_1_svc+0x7c>
movl   $0xffffffff,0x2e98(%rip)
ff ff ff
lea    0x2e91(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    11d8 <ejecutartarea_1_svc+0x98>
jmp    11cd <ejecutartarea_1_svc+0x8d>
lea    0xe38(%rip),%rdi
call   1030 <system@plt>
lea    0x2e70(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ejecutartarea_1_svc>:
push   %rax
cmpl   $0x1,(%rdi)
jne    115c <ejecutartarea_1_svc+0x1c>
xor    %eax,%eax
call   1060 <fork@plt>
test   %eax,%eax
js     116a <ejecutartarea_1_svc+0x2a>
je     1176 <ejecutartarea_1_svc+0x36>
xor    %edi,%edi
call   1050 <wait@plt>
jmp    1184 <ejecutartarea_1_svc+0x44>
lea    0xe9d(%rip),%rdi
call   1030 <system@plt>
jmp    1184 <ejecutartarea_1_svc+0x44>
movl   $0xffffffff,0x2ed0(%rip)
ff ff ff
jmp    1184 <ejecutartarea_1_svc+0x44>
lea    0xe85(%rip),%rdi
xor    %esi,%esi
call   1040 <execlp@plt>
lea    0x2eb9(%rip),%rax
pop    %rcx
ret

LLVM IR (-O0):
%struct.svc_req = type { i32 }
@ejecutartarea_1_svc.toReturn = internal global i32 0
@.str = [6 x i8] c"tarea\00"
@.str.1 = [8 x i8] c"./tarea\00"
define i32* @ejecutartarea_1_svc(i32* %0, %struct.svc_req* %1) {
%3 = alloca i32*
%4 = alloca i32*
%5 = alloca %struct.svc_req*
%6 = alloca i32
%7 = alloca i32
store i32* %0, i32** %4
store %struct.svc_req* %1, %struct.svc_req** %5
%8 = load i32*, i32** %4
%9 = load i32, i32* %8
store i32 %9, i32* %6
%10 = load i32, i32* %6
%11 = icmp eq i32 %10, 1
br i1 %11, label %12, label %26
12: ; preds = %2
%13 = call i32 (...) @fork()
store i32 %13, i32* %7
%14 = load i32, i32* %7
%15 = icmp sge i32 %14, 0
br i1 %15, label %16, label %24
16: ; preds = %12
%17 = load i32, i32* %7
%18 = icmp eq i32 %17, 0
br i1 %18, label %19, label %21
19: ; preds = %16
%20 = call i32 @execlp(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32* null)
br label %23
21: ; preds = %16
%22 = call i32 @wait(i32 0)
br label %23
23: ; preds = %21, %19
br label %25
24: ; preds = %12
store i32 -1, i32* @ejecutartarea_1_svc.toReturn
store i32* @ejecutartarea_1_svc.toReturn, i32** %3
br label %29
25: ; preds = %23
br label %28
26: ; preds = %2
%27 = call i32 @system(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
br label %28
28: ; preds = %26, %25
store i32* @ejecutartarea_1_svc.toReturn, i32** %3
br label %29
29: ; preds = %28, %24
%30 = load i32*, i32** %3
ret i32* %30
}

LLVM IR (-O2):
%struct.svc_req = type { i32 }
@ejecutartarea_1_svc.toReturn = internal global i32 0
@.str = [6 x i8] c"tarea\00"
@.str.1 = [8 x i8] c"./tarea\00"
define i32* @ejecutartarea_1_svc(i32* nocapture %0, %struct.svc_req* nocapture readnone %1) {
%3 = load i32, i32* %0
%4 = icmp eq i32 %3, 1
br i1 %4, label %5, label %15
5: ; preds = %2
%6 = tail call i32 (...) @fork()
%7 = icmp sgt i32 %6, -1
br i1 %7, label %8, label %14
8: ; preds = %5
%9 = icmp eq i32 %6, 0
br i1 %9, label %10, label %12
10: ; preds = %8
%11 = tail call i32 @execlp(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32* null)
br label %17
12: ; preds = %8
%13 = tail call i32 @wait(i32 0)
br label %17
14: ; preds = %5
store i32 -1, i32* @ejecutartarea_1_svc.toReturn
br label %17
15: ; preds = %2
%16 = tail call i32 @system(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
br label %17
17: ; preds = %14, %10, %12, %15
ret i32* @ejecutartarea_1_svc.toReturn
}