#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 end {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
struct end *seekndestroy(struct end *, struct end **, int, int);
int teste(int, int /*<<< orphan*/, int, int);
void remover(struct end *p, struct end **pon) {
  int metallica, lars = -1;
  struct end *p_aux;
  printf("Deseja remover um elemento? (1. Sim | 0. Nao)\n");
  scanf("%i", &lars);
  lars = teste(lars, 0, 1, 1);
  while (lars != 0) {
    printf("Deseja remover qual elemento? ");
    scanf("%i", &metallica);
    p_aux = seekndestroy(p, pon, metallica, 2);
    if (p_aux == NULL)
      printf("O elemento procurado (%i) nao existe.\n", metallica);
    printf("Deseja eliminar outro elemento? (1. Sim | 0. Nao)\n");
    scanf("%i", &lars);
    lars = teste(lars, 0, 1, 1);
  }
}


x86 assembly (clang, -O0):
<remover>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0xffffffff,-0x18(%rbp)
lea    0xea2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xec3(%rip),%rdi
lea    -0x18(%rbp),%rsi
call   1050 <scanf@plt>
mov    -0x18(%rbp),%edi
xor    %esi,%esi
mov    $0x1,%ecx
mov    %ecx,%edx
call   1040 <teste@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
je     121d <remover+0xdd>
lea    0xe98(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe87(%rip),%rdi
lea    -0x14(%rbp),%rsi
call   1050 <scanf@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
mov    $0x2,%ecx
call   1060 <seekndestroy@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    11e6 <remover+0xa6>
mov    -0x14(%rbp),%esi
lea    0xe72(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe8b(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe34(%rip),%rdi
lea    -0x18(%rbp),%rsi
call   1050 <scanf@plt>
mov    -0x18(%rbp),%edi
xor    %esi,%esi
mov    $0x1,%ecx
mov    %ecx,%edx
call   1040 <teste@plt>
mov    %eax,-0x18(%rbp)
jmp    1189 <remover+0x49>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<remover>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r14
mov    %rdi,%r12
movl   $0xffffffff,(%rsp)
lea    0xeda(%rip),%rdi
call   1030 <puts@plt>
lea    0xe85(%rip),%rdi
mov    %rsp,%rsi
call   1060 <scanf@plt>
mov    (%rsp),%edi
xor    %esi,%esi
mov    $0x1,%edx
mov    $0x1,%ecx
call   1050 <teste@plt>
mov    %eax,(%rsp)
test   %eax,%eax
je     1234 <remover+0xe4>
lea    0xe57(%rip),%rbx
lea    0x4(%rsp),%r13
lea    0xec2(%rip),%rbp
mov    %rsp,%r15
jmp    11ee <remover+0x9e>
nopw   0x0(%rax,%rax,1)
mov    %rbp,%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1060 <scanf@plt>
mov    (%rsp),%edi
xor    %esi,%esi
mov    $0x1,%edx
mov    $0x1,%ecx
call   1050 <teste@plt>
mov    %eax,(%rsp)
test   %eax,%eax
je     1234 <remover+0xe4>
lea    0xe0e(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    %r13,%rsi
call   1060 <scanf@plt>
mov    0x4(%rsp),%edx
mov    %r12,%rdi
mov    %r14,%rsi
mov    $0x2,%ecx
call   1070 <seekndestroy@plt>
test   %rax,%rax
jne    11c0 <remover+0x70>
mov    0x4(%rsp),%esi
lea    0xdf7(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    11c0 <remover+0x70>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.end = type { i32 }
@.str = [47 x i8] c"Deseja remover um elemento? (1. Sim | 0. Nao)\0A\00"
@.str.1 = [3 x i8] c"%i\00"
@.str.2 = [31 x i8] c"Deseja remover qual elemento? \00"
@.str.3 = [39 x i8] c"O elemento procurado (%i) nao existe.\0A\00"
@.str.4 = [51 x i8] c"Deseja eliminar outro elemento? (1. Sim | 0. Nao)\0A\00"
define void @remover(%struct.end* %0, %struct.end** %1) {
%3 = alloca %struct.end*
%4 = alloca %struct.end**
%5 = alloca i32
%6 = alloca i32
%7 = alloca %struct.end*
store %struct.end* %0, %struct.end** %3
store %struct.end** %1, %struct.end*** %4
store i32 -1, i32* %6
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str, i64 0, i64 0))
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %6)
%10 = load i32, i32* %6
%11 = call i32 @teste(i32 %10, i32 0, i32 1, i32 1)
store i32 %11, i32* %6
br label %12
12: ; preds = %27, %2
%13 = load i32, i32* %6
%14 = icmp ne i32 %13, 0
br i1 %14, label %15, label %32
15: ; preds = %12
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0))
%17 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %5)
%18 = load %struct.end*, %struct.end** %3
%19 = load %struct.end**, %struct.end*** %4
%20 = load i32, i32* %5
%21 = call %struct.end* @seekndestroy(%struct.end* %18, %struct.end** %19, i32 %20, i32 2)
store %struct.end* %21, %struct.end** %7
%22 = load %struct.end*, %struct.end** %7
%23 = icmp eq %struct.end* %22, null
br i1 %23, label %24, label %27
24: ; preds = %15
%25 = load i32, i32* %5
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.3, i64 0, i64 0), i32 %25)
br label %27
27: ; preds = %24, %15
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str.4, i64 0, i64 0))
%29 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %6)
%30 = load i32, i32* %6
%31 = call i32 @teste(i32 %30, i32 0, i32 1, i32 1)
store i32 %31, i32* %6
br label %12
32: ; preds = %12
ret void
}

LLVM IR (-O2):
%struct.end = type { i32 }
@.str.1 = [3 x i8] c"%i\00"
@.str.2 = [31 x i8] c"Deseja remover qual elemento? \00"
@.str.3 = [39 x i8] c"O elemento procurado (%i) nao existe.\0A\00"
@str = [46 x i8] c"Deseja remover um elemento? (1. Sim | 0. Nao)\00"
@str.5 = [50 x i8] c"Deseja eliminar outro elemento? (1. Sim | 0. Nao)\00"
define void @remover(%struct.end* %0, %struct.end** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = bitcast i32* %3 to i8*
%6 = bitcast i32* %4 to i8*
store i32 -1, i32* %4
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([46 x i8], [46 x i8]* @str, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %4)
%9 = load i32, i32* %4
%10 = call i32 @teste(i32 %9, i32 0, i32 1, i32 1)
store i32 %10, i32* %4
%11 = icmp eq i32 %10, 0
br i1 %11, label %27, label %12
12: ; preds = %2, %21
%13 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @.str.2, i64 0, i64 0))
%14 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%15 = load i32, i32* %3
%16 = call %struct.end* @seekndestroy(%struct.end* %0, %struct.end** %1, i32 %15, i32 2)
%17 = icmp eq %struct.end* %16, null
br i1 %17, label %18, label %21
18: ; preds = %12
%19 = load i32, i32* %3
%20 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @.str.3, i64 0, i64 0), i32 %19)
br label %21
21: ; preds = %18, %12
%22 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([50 x i8], [50 x i8]* @str.5, i64 0, i64 0))
%23 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %4)
%24 = load i32, i32* %4
%25 = call i32 @teste(i32 %24, i32 0, i32 1, i32 1)
store i32 %25, i32* %4
%26 = icmp eq i32 %25, 0
br i1 %26, label %27, label %12
27: ; preds = %21, %2
ret void
}