#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 */
int /*<<< orphan*/ chmod(char *, int);
int descobre_comando(char *);
int /*<<< orphan*/ execve(char *, char **, char **);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ *fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ fork();
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int getpid();
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ sscanf(char *, char *, char *, char *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdin;
int /*<<< orphan*/ strcpy(char *, char *);
int strtol(char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ wait(int *);
int main(int argc, char **argv) {
  char comando[500], argumentos[500];
  char buffer[500];
  int cmd_id;
  int permissao_libera, permissao_protege;
  int status = 0;
  char *args[] = {"arg", NULL};
  char *env[] = {NULL};
  permissao_libera = strtol("777", 0, 8);
  permissao_protege = 0;
  printf("<%d>:$ ", getpid());
  while (fgets(buffer, 500, stdin) != NULL) {
    strcpy(comando, "");
    strcpy(argumentos, "");
    sscanf(buffer, " %[^ \n] %[^\n]", comando, argumentos);
    cmd_id = descobre_comando(comando);
    switch (cmd_id) {
    case 1:
      if (chmod(argumentos, permissao_protege) < 0)
        fprintf(stderr, "Deu errado.\n");
      else
        printf("Protegeu pra caramba o arquivo %s\n", argumentos);
      break;
    case 2:
      if (chmod(argumentos, permissao_libera) < 0)
        fprintf(stderr, "Deu errado.\n");
      else
        printf("Liberou geral o arquivo %s\n", argumentos);
      break;
    case 3:
      if (fork()) {
        wait(&status);
        printf("=> programa '%s' retornou com codigo %d\n", argumentos, status);
      } else {
        printf("Rodando %s com pid: %d\n", argumentos, getpid());
        execve(argumentos, args, env);
        printf("NAO ERA PRA PASSAR POR AQUI\nPASSE APENAS O ENDERECO DO "
               "PROGRAMA SEM PARAMETROS.\n");
        exit(-1);
      }
      break;
    case 4:
      if (fork()) {
        printf("\n");
      } else {
        printf("Rodando %s com pid: %d em background.\n", argumentos, getpid());
        execve(argumentos, args, env);
        exit(0);
      }
      break;
    case 5:
      exit(0);
      break;
    default:
      printf("Comando invalido\n");
      break;
    }
    printf("<%d>:$ ", getpid());
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x670,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x620(%rbp)
mov    0x2bf6(%rip),%rax
mov    %rax,-0x630(%rbp)
mov    0x2bf0(%rip),%rax
mov    %rax,-0x628(%rbp)
lea    -0x638(%rbp),%rdi
xor    %esi,%esi
mov    $0x8,%edx
call   1060 <memset@plt>
lea    0xddf(%rip),%rdi
xor    %esi,%esi
mov    $0x8,%edx
call   10a0 <strtol@plt>
mov    %eax,-0x618(%rbp)
movl   $0x0,-0x61c(%rbp)
mov    $0x0,%al
call   1040 <getpid@plt>
mov    %eax,%esi
lea    0xdb7(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x610(%rbp),%rdi
mov    0x2d6e(%rip),%rax
mov    (%rax),%edx
mov    $0x1f4,%esi
call   1070 <fgets@plt>
cmp    $0x0,%rax
je     1513 <main+0x333>
lea    0xe78(%rip),%rsi
mov    %rsi,-0x658(%rbp)
lea    -0x210(%rbp),%rdi
mov    %rdi,-0x648(%rbp)
call   1030 <strcpy@plt>
mov    -0x658(%rbp),%rsi
lea    -0x410(%rbp),%rdi
mov    %rdi,-0x650(%rbp)
call   1030 <strcpy@plt>
mov    -0x650(%rbp),%rcx
mov    -0x648(%rbp),%rdx
lea    0xd44(%rip),%rsi
lea    -0x610(%rbp),%rdi
call   10b0 <sscanf@plt>
mov    -0x648(%rbp),%rdi
call   10e0 <descobre_comando@plt>
mov    %eax,-0x614(%rbp)
mov    -0x614(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x640(%rbp)
sub    $0x4,%eax
ja     14e9 <main+0x309>
mov    -0x640(%rbp),%rax
lea    0xcd9(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    -0x410(%rbp),%rdi
mov    -0x61c(%rbp),%esi
call   10c0 <chmod@plt>
cmp    $0x0,%eax
jge    1365 <main+0x185>
mov    0x2c86(%rip),%rax
mov    (%rax),%edi
lea    0xcd7(%rip),%rsi
call   1090 <fprintf@plt>
jmp    137a <main+0x19a>
lea    -0x410(%rbp),%rsi
lea    0xccc(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    14f7 <main+0x317>
lea    -0x410(%rbp),%rdi
mov    -0x618(%rbp),%esi
call   10c0 <chmod@plt>
cmp    $0x0,%eax
jge    13b4 <main+0x1d4>
mov    0x2c37(%rip),%rax
mov    (%rax),%edi
lea    0xc88(%rip),%rsi
call   1090 <fprintf@plt>
jmp    13c9 <main+0x1e9>
lea    -0x410(%rbp),%rsi
lea    0xca0(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    14f7 <main+0x317>
mov    $0x0,%al
call   1100 <fork@plt>
cmp    $0x0,%eax
je     140a <main+0x22a>
lea    -0x620(%rbp),%rdi
call   10f0 <wait@plt>
lea    -0x410(%rbp),%rsi
mov    -0x620(%rbp),%edx
lea    0xc80(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    1468 <main+0x288>
lea    -0x410(%rbp),%rax
mov    %rax,-0x660(%rbp)
mov    $0x0,%al
call   1040 <getpid@plt>
mov    -0x660(%rbp),%rsi
mov    %eax,%edx
lea    0xc78(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x410(%rbp),%rdi
lea    -0x630(%rbp),%rsi
lea    -0x638(%rbp),%rdx
call   1080 <execve@plt>
lea    0xc68(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0xffffffff,%edi
call   10d0 <exit@plt>
jmp    14f7 <main+0x317>
mov    $0x0,%al
call   1100 <fork@plt>
cmp    $0x0,%eax
je     1490 <main+0x2b0>
lea    0xc8a(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    14dd <main+0x2fd>
lea    -0x410(%rbp),%rax
mov    %rax,-0x668(%rbp)
mov    $0x0,%al
call   1040 <getpid@plt>
mov    -0x668(%rbp),%rsi
mov    %eax,%edx
lea    0xc5b(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x410(%rbp),%rdi
lea    -0x630(%rbp),%rsi
lea    -0x638(%rbp),%rdx
call   1080 <execve@plt>
xor    %edi,%edi
call   10d0 <exit@plt>
jmp    14f7 <main+0x317>
xor    %edi,%edi
call   10d0 <exit@plt>
lea    0xc47(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0x0,%al
call   1040 <getpid@plt>
mov    %eax,%esi
lea    0xb15(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
jmp    126c <main+0x8c>
xor    %eax,%eax
add    $0x670,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x618,%rsp
movl   $0x0,(%rsp)
movaps 0x2bf1(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movq   $0x0,0x8(%rsp)
lea    0xdf4(%rip),%rdi
xor    %esi,%esi
mov    $0x8,%edx
call   10b0 <strtol@plt>
mov    %eax,0x4(%rsp)
xor    %eax,%eax
call   1060 <getpid@plt>
lea    0xdda(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1070 <printf@plt>
mov    0x2d96(%rip),%rax
mov    (%rax),%edx
lea    0x220(%rsp),%rdi
mov    $0x1f4,%esi
call   1080 <fgets@plt>
test   %rax,%rax
je     13be <main+0x1ce>
lea    0xe6f(%rip),%r15
lea    0x420(%rsp),%rbp
lea    0x20(%rsp),%rbx
lea    0x220(%rsp),%r13
lea    0xd8a(%rip),%r14
lea    0xd67(%rip),%r12
jmp    12d9 <main+0xe9>
lea    0xe94(%rip),%rdi
call   1050 <puts@plt>
xor    %eax,%eax
call   1060 <getpid@plt>
mov    %r14,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1070 <printf@plt>
mov    0x2d27(%rip),%rax
mov    (%rax),%edx
mov    %r13,%rdi
mov    $0x1f4,%esi
call   1080 <fgets@plt>
test   %rax,%rax
je     13be <main+0x1ce>
mov    %rbp,%rdi
mov    %r15,%rsi
call   1040 <strcpy@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1040 <strcpy@plt>
mov    %r13,%rdi
lea    0xd2b(%rip),%rsi
mov    %rbp,%rdx
mov    %rbx,%rcx
call   10c0 <sscanf@plt>
mov    %rbp,%rdi
call   10f0 <descobre_comando@plt>
add    $0xffffffff,%eax
cmp    $0x4,%eax
ja     129b <main+0xab>
movslq (%r12,%rax,4),%rax
add    %r12,%rax
jmp    *%rax
mov    %rbx,%rdi
xor    %esi,%esi
call   10d0 <chmod@plt>
test   %eax,%eax
js     13a4 <main+0x1b4>
lea    0xd0d(%rip),%rdi
jmp    134b <main+0x15b>
mov    %rbx,%rdi
mov    0x4(%rsp),%esi
call   10d0 <chmod@plt>
test   %eax,%eax
js     13a4 <main+0x1b4>
lea    0xd17(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1070 <printf@plt>
jmp    12a7 <main+0xb7>
xor    %eax,%eax
call   1110 <fork@plt>
test   %eax,%eax
je     13d2 <main+0x1e2>
mov    %rsp,%rdi
call   1100 <wait@plt>
mov    (%rsp),%edx
lea    0xd07(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1070 <printf@plt>
jmp    12a7 <main+0xb7>
xor    %eax,%eax
call   1110 <fork@plt>
test   %eax,%eax
je     1419 <main+0x229>
mov    $0xa,%edi
call   1030 <putchar@plt>
jmp    12a7 <main+0xb7>
mov    0x2c2d(%rip),%rax
mov    (%rax),%edi
lea    0xc7e(%rip),%rsi
call   10a0 <fprintf@plt>
jmp    12a7 <main+0xb7>
xor    %eax,%eax
add    $0x618,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
xor    %eax,%eax
call   1060 <getpid@plt>
lea    0xcc7(%rip),%rdi
lea    0x20(%rsp),%rbx
mov    %rbx,%rsi
mov    %eax,%edx
xor    %eax,%eax
call   1070 <printf@plt>
lea    0x10(%rsp),%rsi
lea    0x8(%rsp),%rdx
mov    %rbx,%rdi
call   1090 <execve@plt>
lea    0xcdc(%rip),%rdi
call   1050 <puts@plt>
mov    $0xffffffff,%edi
call   10e0 <exit@plt>
xor    %eax,%eax
call   1060 <getpid@plt>
lea    0xc98(%rip),%rdi
lea    0x20(%rsp),%rbx
mov    %rbx,%rsi
mov    %eax,%edx
xor    %eax,%eax
call   1070 <printf@plt>
lea    0x10(%rsp),%rsi
lea    0x8(%rsp),%rdx
mov    %rbx,%rdi
call   1090 <execve@plt>
xor    %edi,%edi
call   10e0 <exit@plt>

LLVM IR (-O0):
@.str = [4 x i8] c"arg\00"
@__const.main.args = [2 x i8*] [i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i32 0, i32 0), i8* null]
@.str.1 = [4 x i8] c"777\00"
@.str.2 = [8 x i8] c"<%d>:$ \00"
@stdin = global i32 0
@.str.3 = [1 x i8] zeroinitializer
@.str.4 = [14 x i8] c" %[^ \0A] %[^\0A]\00"
@stderr = global i32 0
@.str.5 = [13 x i8] c"Deu errado.\0A\00"
@.str.6 = [35 x i8] c"Protegeu pra caramba o arquivo %s\0A\00"
@.str.7 = [28 x i8] c"Liberou geral o arquivo %s\0A\00"
@.str.8 = [41 x i8] c"=> programa '%s' retornou com codigo %d\0A\00"
@.str.9 = [24 x i8] c"Rodando %s com pid: %d\0A\00"
@.str.10 = [81 x i8] c"NAO ERA PRA PASSAR POR AQUI\0APASSE APENAS O ENDERECO DO PROGRAMA SEM PARAMETROS.\0A\00"
@.str.11 = [2 x i8] c"\0A\00"
@.str.12 = [39 x i8] c"Rodando %s com pid: %d em background.\0A\00"
@.str.13 = [18 x i8] c"Comando invalido\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [500 x i8]
%7 = alloca [500 x i8]
%8 = alloca [500 x i8]
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca [2 x i8*]
%14 = alloca [1 x i8*]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %12
%15 = bitcast [2 x i8*]* %13 to i8*
%16 = bitcast [1 x i8*]* %14 to i8*
%17 = call i32 @strtol(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 0, i32 8)
store i32 %17, i32* %10
store i32 0, i32* %11
%18 = call i32 (...) @getpid()
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i32 %18)
br label %20
20: ; preds = %99, %2
%21 = getelementptr inbounds [500 x i8], [500 x i8]* %8, i64 0, i64 0
%22 = load i32, i32* @stdin
%23 = call i32* @fgets(i8* %21, i32 500, i32 %22)
%24 = icmp ne i32* %23, null
br i1 %24, label %25, label %102
25: ; preds = %20
%26 = getelementptr inbounds [500 x i8], [500 x i8]* %6, i64 0, i64 0
%27 = call i32 @strcpy(i8* %26, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.3, i64 0, i64 0))
%28 = getelementptr inbounds [500 x i8], [500 x i8]* %7, i64 0, i64 0
%29 = call i32 @strcpy(i8* %28, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.3, i64 0, i64 0))
%30 = getelementptr inbounds [500 x i8], [500 x i8]* %8, i64 0, i64 0
%31 = getelementptr inbounds [500 x i8], [500 x i8]* %6, i64 0, i64 0
%32 = getelementptr inbounds [500 x i8], [500 x i8]* %7, i64 0, i64 0
%33 = call i32 @sscanf(i8* %30, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0), i8* %31, i8* %32)
%34 = getelementptr inbounds [500 x i8], [500 x i8]* %6, i64 0, i64 0
%35 = call i32 @descobre_comando(i8* %34)
store i32 %35, i32* %9
%36 = load i32, i32* %9
switch i32 %36, label %97 [
i32 1, label %37
i32 2, label %49
i32 3, label %61
i32 4, label %80
i32 5, label %95
]
37: ; preds = %25
%38 = getelementptr inbounds [500 x i8], [500 x i8]* %7, i64 0, i64 0
%39 = load i32, i32* %11
%40 = call i32 @chmod(i8* %38, i32 %39)
%41 = icmp slt i32 %40, 0
br i1 %41, label %42, label %45
42: ; preds = %37
%43 = load i32, i32* @stderr
%44 = call i32 @fprintf(i32 %43, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0))
br label %48
45: ; preds = %37
%46 = getelementptr inbounds [500 x i8], [500 x i8]* %7, i64 0, i64 0
%47 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.6, i64 0, i64 0), i8* %46)
br label %48
48: ; preds = %45, %42
br label %99
49: ; preds = %25
%50 = getelementptr inbounds [500 x i8], [500 x i8]* %7, i64 0, i64 0
%51 = load i32, i32* %10
%52 = call i32 @chmod(i8* %50, i32 %51)
%53 = icmp slt i32 %52, 0
br i1 %53, label %54, label %57
54: ; preds = %49
%55 = load i32, i32* @stderr
%56 = call i32 @fprintf(i32 %55, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0))
br label %60
57: ; preds = %49
%58 = getelementptr inbounds [500 x i8], [500 x i8]* %7, i64 0, i64 0
%59 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.7, i64 0, i64 0), i8* %58)
br label %60
60: ; preds = %57, %54
br label %99
61: ; preds = %25
%62 = call i32 (...) @fork()
%63 = icmp ne i32 %62, 0
br i1 %63, label %64, label %69
64: ; preds = %61
%65 = call i32 @wait(i32* %12)
%66 = getelementptr inbounds [500 x i8], [500 x i8]* %7, i64 0, i64 0
%67 = load i32, i32* %12
%68 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.8, i64 0, i64 0), i8* %66, i32 %67)
br label %79
69: ; preds = %61
%70 = getelementptr inbounds [500 x i8], [500 x i8]* %7, i64 0, i64 0
%71 = call i32 (...) @getpid()
%72 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.9, i64 0, i64 0), i8* %70, i32 %71)
%73 = getelementptr inbounds [500 x i8], [500 x i8]* %7, i64 0, i64 0
%74 = getelementptr inbounds [2 x i8*], [2 x i8*]* %13, i64 0, i64 0
%75 = getelementptr inbounds [1 x i8*], [1 x i8*]* %14, i64 0, i64 0
%76 = call i32 @execve(i8* %73, i8** %74, i8** %75)
%77 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([81 x i8], [81 x i8]* @.str.10, i64 0, i64 0))
%78 = call i32 @exit(i32 -1)
unreachable
79: ; preds = %64
br label %99
80: ; preds = %25
%81 = call i32 (...) @fork()
%82 = icmp ne i32 %81, 0
br i1 %82, label %83, label %85
83: ; preds = %80
%84 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.11, i64 0, i64 0))
br label %94
85: ; preds = %80
%86 = getelementptr inbounds [500 x i8], [500 x i8]* %7, i64 0, i64 0
%87 = call i32 (...) @getpid()
%88 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.12, i64 0, i64 0), i8* %86, i32 %87)
%89 = getelementptr inbounds [500 x i8], [500 x i8]* %7, i64 0, i64 0
%90 = getelementptr inbounds [2 x i8*], [2 x i8*]* %13, i64 0, i64 0
%91 = getelementptr inbounds [1 x i8*], [1 x i8*]* %14, i64 0, i64 0
%92 = call i32 @execve(i8* %89, i8** %90, i8** %91)
%93 = call i32 @exit(i32 0)
unreachable
94: ; preds = %83
br label %99
95: ; preds = %25
%96 = call i32 @exit(i32 0)
unreachable
97: ; preds = %25
%98 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.13, i64 0, i64 0))
br label %99
99: ; preds = %97, %94, %79, %60, %48
%100 = call i32 (...) @getpid()
%101 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i32 %100)
br label %20
102: ; preds = %20
ret i32 0
}

LLVM IR (-O2):
@.str = [4 x i8] c"arg\00"
@__const.main.args = [2 x i8*] [i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i32 0, i32 0), i8* null]
@.str.1 = [4 x i8] c"777\00"
@.str.2 = [8 x i8] c"<%d>:$ \00"
@stdin = global i32 0
@.str.3 = [1 x i8] zeroinitializer
@.str.4 = [14 x i8] c" %[^ \0A] %[^\0A]\00"
@stderr = global i32 0
@.str.5 = [13 x i8] c"Deu errado.\0A\00"
@.str.6 = [35 x i8] c"Protegeu pra caramba o arquivo %s\0A\00"
@.str.7 = [28 x i8] c"Liberou geral o arquivo %s\0A\00"
@.str.8 = [41 x i8] c"=> programa '%s' retornou com codigo %d\0A\00"
@.str.9 = [24 x i8] c"Rodando %s com pid: %d\0A\00"
@.str.12 = [39 x i8] c"Rodando %s com pid: %d em background.\0A\00"
@str = [80 x i8] c"NAO ERA PRA PASSAR POR AQUI\0APASSE APENAS O ENDERECO DO PROGRAMA SEM PARAMETROS.\00"
@str.14 = [17 x i8] c"Comando invalido\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [500 x i8]
%4 = alloca [500 x i8]
%5 = alloca [500 x i8]
%6 = alloca i32
%7 = alloca [2 x i8*]
%8 = alloca [1 x i8*]
%9 = getelementptr inbounds [500 x i8], [500 x i8]* %3, i64 0, i64 0
%10 = getelementptr inbounds [500 x i8], [500 x i8]* %4, i64 0, i64 0
%11 = getelementptr inbounds [500 x i8], [500 x i8]* %5, i64 0, i64 0
%12 = bitcast i32* %6 to i8*
store i32 0, i32* %6
%13 = bitcast [2 x i8*]* %7 to i8*
%14 = bitcast [1 x i8*]* %8 to i8*
%15 = bitcast [1 x i8*]* %8 to i64*
store i64 0, i64* %15
%16 = tail call i32 @strtol(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 0, i32 8)
%17 = tail call i32 (...) @getpid()
%18 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i32 %17)
%19 = load i32, i32* @stdin
%20 = call i32* @fgets(i8* %11, i32 500, i32 %19)
%21 = icmp eq i32* %20, null
br i1 %21, label %80, label %22
22: ; preds = %2, %74
%23 = call i32 @strcpy(i8* %9, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.3, i64 0, i64 0))
%24 = call i32 @strcpy(i8* %10, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.3, i64 0, i64 0))
%25 = call i32 @sscanf(i8* %11, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.4, i64 0, i64 0), i8* %9, i8* %10)
%26 = call i32 @descobre_comando(i8* %9)
switch i32 %26, label %72 [
i32 1, label %27
i32 2, label %35
i32 3, label %43
i32 4, label %58
i32 5, label %70
]
27: ; preds = %22
%28 = call i32 @chmod(i8* %10, i32 0)
%29 = icmp slt i32 %28, 0
br i1 %29, label %30, label %33
30: ; preds = %27
%31 = load i32, i32* @stderr
%32 = call i32 @fprintf(i32 %31, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0))
br label %74
33: ; preds = %27
%34 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str.6, i64 0, i64 0), i8* %10)
br label %74
35: ; preds = %22
%36 = call i32 @chmod(i8* %10, i32 %16)
%37 = icmp slt i32 %36, 0
br i1 %37, label %38, label %41
38: ; preds = %35
%39 = load i32, i32* @stderr
%40 = call i32 @fprintf(i32 %39, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0))
br label %74
41: ; preds = %35
%42 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.7, i64 0, i64 0), i8* %10)
br label %74
43: ; preds = %22
%44 = call i32 (...) @fork()
%45 = icmp eq i32 %44, 0
br i1 %45, label %50, label %46
46: ; preds = %43
%47 = call i32 @wait(i32* %6)
%48 = load i32, i32* %6
%49 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @.str.8, i64 0, i64 0), i8* %10, i32 %48)
br label %74
50: ; preds = %43
%51 = call i32 (...) @getpid()
%52 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.9, i64 0, i64 0), i8* %10, i32 %51)
%53 = getelementptr inbounds [2 x i8*], [2 x i8*]* %7, i64 0, i64 0
%54 = getelementptr inbounds [1 x i8*], [1 x i8*]* %8, i64 0, i64 0
%55 = call i32 @execve(i8* %10, i8** %53, i8** %54)
%56 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([80 x i8], [80 x i8]* @str, i64 0, i64 0))
%57 = call i32 @exit(i32 -1)
unreachable
58: ; preds = %22
%59 = call i32 (...) @fork()
%60 = icmp eq i32 %59, 0
br i1 %60, label %63, label %61
61: ; preds = %58
%62 = call i32 @putchar(i32 10)
br label %74
63: ; preds = %58
%64 = call i32 (...) @getpid()
%65 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @.str.12, i64 0, i64 0), i8* %10, i32 %64)
%66 = getelementptr inbounds [2 x i8*], [2 x i8*]* %7, i64 0, i64 0
%67 = getelementptr inbounds [1 x i8*], [1 x i8*]* %8, i64 0, i64 0
%68 = call i32 @execve(i8* %10, i8** %66, i8** %67)
%69 = call i32 @exit(i32 0)
unreachable
70: ; preds = %22
%71 = call i32 @exit(i32 0)
unreachable
72: ; preds = %22
%73 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str.14, i64 0, i64 0))
br label %74
74: ; preds = %38, %41, %30, %33, %72, %61, %46
%75 = call i32 (...) @getpid()
%76 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i32 %75)
%77 = load i32, i32* @stdin
%78 = call i32* @fgets(i8* %11, i32 500, i32 %77)
%79 = icmp eq i32* %78, null
br i1 %79, label %80, label %22
80: ; preds = %74, %2
ret i32 0
}