#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*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
int /*<<< orphan*/ strcat(char *, char *);
int system(char *);
int removeArquivo(void) {
  int ag_num, ret;
  char comando[20] = "rm -f ";
  printf("Deseja remover qual agenda? (1,2,3,4=todas)\nOpcao__");
  scanf("%d", &ag_num);
  switch (ag_num) {
  case 1: {
    strcat(comando, "file1.dat");
    ret = system(comando);
    printf("comando = %s\n", comando);
  } break;
  case 2: {
    strcat(comando, "file2.dat");
    ret = system(comando);
    printf("comando = %s\n", comando);
  } break;
  case 3: {
    strcat(comando, "file3.dat");
    ret = system(comando);
    printf("comando = %s\n", comando);
  } break;
  case 4: {
    ret = system("rm -f *.dat");
    printf("comando = rm -f *.dat\n");
  }
  default: {
  }
  }
  if (ret == -1)
    return 0;
  return 1;
}


x86 assembly (clang, -O0):
<removeArquivo>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movaps 0xec1(%rip),%xmm0
movaps %xmm0,-0x20(%rbp)
movl   $0x0,-0x10(%rbp)
lea    0xec3(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xee9(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1050 <scanf@plt>
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,%ecx
mov    %rcx,-0x28(%rbp)
sub    $0x3,%eax
ja     1257 <removeArquivo+0x117>
mov    -0x28(%rbp),%rax
lea    0xe68(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    -0x20(%rbp),%rdi
lea    0xeaf(%rip),%rsi
call   1060 <strcat@plt>
lea    -0x20(%rbp),%rdi
call   1030 <system@plt>
mov    %eax,-0xc(%rbp)
lea    -0x20(%rbp),%rsi
lea    0xe9d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    125c <removeArquivo+0x11c>
lea    -0x20(%rbp),%rdi
lea    0xe94(%rip),%rsi
call   1060 <strcat@plt>
lea    -0x20(%rbp),%rdi
call   1030 <system@plt>
mov    %eax,-0xc(%rbp)
lea    -0x20(%rbp),%rsi
lea    0xe6a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    125c <removeArquivo+0x11c>
lea    -0x20(%rbp),%rdi
lea    0xe6b(%rip),%rsi
call   1060 <strcat@plt>
lea    -0x20(%rbp),%rdi
call   1030 <system@plt>
mov    %eax,-0xc(%rbp)
lea    -0x20(%rbp),%rsi
lea    0xe37(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    125c <removeArquivo+0x11c>
lea    0xe46(%rip),%rdi
call   1030 <system@plt>
mov    %eax,-0xc(%rbp)
lea    0xe43(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    125c <removeArquivo+0x11c>
cmpl   $0xffffffff,-0xc(%rbp)
jne    1272 <removeArquivo+0x132>
movl   $0x0,-0x4(%rbp)
jmp    1279 <removeArquivo+0x139>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<removeArquivo>:
push   %r14
push   %rbx
sub    $0x28,%rsp
movaps 0xeb2(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movl   $0x0,0x20(%rsp)
lea    0xeb2(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xed8(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1060 <scanf@plt>
mov    0xc(%rsp),%eax
add    $0xffffffff,%eax
cmp    $0x3,%eax
ja     11af <removeArquivo+0x5f>
lea    0xe63(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
lea    0xeae(%rip),%rsi
jmp    11c1 <removeArquivo+0x71>
jmp    1205 <removeArquivo+0xb5>
lea    0xebb(%rip),%rsi
jmp    11c1 <removeArquivo+0x71>
lea    0xebc(%rip),%rsi
lea    0x10(%rsp),%r14
mov    %r14,%rdi
call   1070 <strcat@plt>
mov    %r14,%rdi
call   1040 <system@plt>
mov    %eax,%ebx
lea    0xe86(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    1205 <removeArquivo+0xb5>
lea    0xe9f(%rip),%rdi
call   1040 <system@plt>
mov    %eax,%ebx
lea    0xe87(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
cmp    $0xffffffff,%ebx
setne  %al
add    $0x28,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@__const.removeArquivo.comando = [20 x i8] c"rm -f \00\00\00\00\00\00\00\00\00\00\00\00\00\00"
@.str = [52 x i8] c"Deseja remover qual agenda? (1,2,3,4=todas)\0AOpcao__\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [10 x i8] c"file1.dat\00"
@.str.3 = [14 x i8] c"comando = %s\0A\00"
@.str.4 = [10 x i8] c"file2.dat\00"
@.str.5 = [10 x i8] c"file3.dat\00"
@.str.6 = [12 x i8] c"rm -f *.dat\00"
@.str.7 = [23 x i8] c"comando = rm -f *.dat\0A\00"
define i32 @removeArquivo() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca [20 x i8]
%5 = bitcast [20 x i8]* %4 to i8*
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str, i64 0, i64 0))
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%8 = load i32, i32* %2
switch i32 %8, label %33 [
i32 1, label %9
i32 2, label %16
i32 3, label %23
i32 4, label %30
]
9: ; preds = %0
%10 = getelementptr inbounds [20 x i8], [20 x i8]* %4, i64 0, i64 0
%11 = call i32 @strcat(i8* %10, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0))
%12 = getelementptr inbounds [20 x i8], [20 x i8]* %4, i64 0, i64 0
%13 = call i32 @system(i8* %12)
store i32 %13, i32* %3
%14 = getelementptr inbounds [20 x i8], [20 x i8]* %4, i64 0, i64 0
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i8* %14)
br label %34
16: ; preds = %0
%17 = getelementptr inbounds [20 x i8], [20 x i8]* %4, i64 0, i64 0
%18 = call i32 @strcat(i8* %17, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0))
%19 = getelementptr inbounds [20 x i8], [20 x i8]* %4, i64 0, i64 0
%20 = call i32 @system(i8* %19)
store i32 %20, i32* %3
%21 = getelementptr inbounds [20 x i8], [20 x i8]* %4, i64 0, i64 0
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i8* %21)
br label %34
23: ; preds = %0
%24 = getelementptr inbounds [20 x i8], [20 x i8]* %4, i64 0, i64 0
%25 = call i32 @strcat(i8* %24, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0))
%26 = getelementptr inbounds [20 x i8], [20 x i8]* %4, i64 0, i64 0
%27 = call i32 @system(i8* %26)
store i32 %27, i32* %3
%28 = getelementptr inbounds [20 x i8], [20 x i8]* %4, i64 0, i64 0
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i8* %28)
br label %34
30: ; preds = %0
%31 = call i32 @system(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.6, i64 0, i64 0))
store i32 %31, i32* %3
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.7, i64 0, i64 0))
br label %33
33: ; preds = %0, %30
br label %34
34: ; preds = %33, %23, %16, %9
%35 = load i32, i32* %3
%36 = icmp eq i32 %35, -1
br i1 %36, label %37, label %38
37: ; preds = %34
store i32 0, i32* %1
br label %39
38: ; preds = %34
store i32 1, i32* %1
br label %39
39: ; preds = %38, %37
%40 = load i32, i32* %1
ret i32 %40
}

LLVM IR (-O2):
@__const.removeArquivo.comando = [20 x i8] c"rm -f \00\00\00\00\00\00\00\00\00\00\00\00\00\00"
@.str = [52 x i8] c"Deseja remover qual agenda? (1,2,3,4=todas)\0AOpcao__\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [10 x i8] c"file1.dat\00"
@.str.3 = [14 x i8] c"comando = %s\0A\00"
@.str.4 = [10 x i8] c"file2.dat\00"
@.str.5 = [10 x i8] c"file3.dat\00"
@.str.6 = [12 x i8] c"rm -f *.dat\00"
@str = [22 x i8] c"comando = rm -f *.dat\00"
define i32 @removeArquivo() {
%1 = alloca i32
%2 = alloca [20 x i8]
%3 = bitcast i32* %1 to i8*
%4 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 0
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([52 x i8], [52 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%7 = load i32, i32* %1
switch i32 %7, label %23 [
i32 1, label %8
i32 2, label %12
i32 3, label %16
i32 4, label %20
]
8: ; preds = %0
%9 = call i32 @strcat(i8* %4, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0))
%10 = call i32 @system(i8* %4)
%11 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i8* %4)
br label %23
12: ; preds = %0
%13 = call i32 @strcat(i8* %4, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0))
%14 = call i32 @system(i8* %4)
%15 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i8* %4)
br label %23
16: ; preds = %0
%17 = call i32 @strcat(i8* %4, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.5, i64 0, i64 0))
%18 = call i32 @system(i8* %4)
%19 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str.3, i64 0, i64 0), i8* %4)
br label %23
20: ; preds = %0
%21 = call i32 @system(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.6, i64 0, i64 0))
%22 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @str, i64 0, i64 0))
br label %23
23: ; preds = %20, %0, %16, %12, %8
%24 = phi i32 [ undef, %0 ], [ %21, %20 ], [ %18, %16 ], [ %14, %12 ], [ %10, %8 ]
%25 = icmp ne i32 %24, -1
%26 = zext i1 %25 to i32
ret i32 %26
}