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

/* Variables and functions */
int count(struct nodod **);
int excluiNodo(struct nodod **, int);
int /*<<< orphan*/ imprime(struct nodod **);
int insereAntesValor(struct nodod **, int, int);
int /*<<< orphan*/ insereUltimo(struct nodod **, int);
int /*<<< orphan*/ printf(char *, ...);
int rand();
int /*<<< orphan*/ scanf(char *, int *);
int /*<<< orphan*/ srand(int /*<<< orphan*/);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int main() {
  int i = 0;
  struct nodod *p = NULL;
  srand(time(NULL));
  for (i = 0; i < 25; i++) {
    int rnd = rand() % 100;
    insereUltimo(&p, i);
  }
  imprime(&p);
  int valPsq;
  printf("Digite um valor a ser pesquisado na LDE circular: ");
  scanf("%i", &valPsq);
  int valIns;
  printf(
      "Digite o valor a ser inserido antes do valor anterior, se encontrado: ");
  scanf("%i", &valIns);
  int statusInsereAntesValor = insereAntesValor(&p, valPsq, valIns);
  if (statusInsereAntesValor == 0) {
    printf("Valor de pesquisa não encontrado.\n");
  } else if (statusInsereAntesValor == -1) {
    printf("Não foi possível alocar a estrutura.\n");
  }
  imprime(&p);
  int valDel;
  printf("Digite um valor a ser deletado da LDE circular: ");
  scanf("%i", &valDel);
  int statusExcluiNodo = excluiNodo(&p, valDel);
  if (statusExcluiNodo == 0) {
    printf("O valor selecionado não foi encontrado.\n");
  }
  imprime(&p);
  printf("A LDE circular possui %i nodos.\n", count(&p));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movq   $0x0,-0x10(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1080 <time@plt>
mov    %eax,%edi
call   1070 <srand@plt>
movl   $0x0,-0x8(%rbp)
cmpl   $0x19,-0x8(%rbp)
jge    120b <main+0x6b>
mov    $0x0,%al
call   10c0 <rand@plt>
mov    $0x64,%ecx
cltd
idiv   %ecx
mov    %edx,-0x14(%rbp)
mov    -0x8(%rbp),%esi
lea    -0x10(%rbp),%rdi
call   10a0 <insereUltimo@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    11d5 <main+0x35>
lea    -0x10(%rbp),%rdi
call   1060 <imprime@plt>
lea    0xde5(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe0a(%rip),%rdi
lea    -0x18(%rbp),%rsi
call   1090 <scanf@plt>
lea    0xdfd(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xdec(%rip),%rdi
lea    -0x1c(%rbp),%rsi
call   1090 <scanf@plt>
mov    -0x18(%rbp),%esi
mov    -0x1c(%rbp),%edx
lea    -0x10(%rbp),%rdi
call   1050 <insereAntesValor@plt>
mov    %eax,-0x20(%rbp)
cmpl   $0x0,-0x20(%rbp)
jne    127f <main+0xdf>
lea    0xe0a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    129c <main+0xfc>
cmpl   $0xffffffff,-0x20(%rbp)
jne    1297 <main+0xf7>
lea    0xe11(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    129c <main+0xfc>
lea    -0x10(%rbp),%rdi
call   1060 <imprime@plt>
lea    0xe1d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xd79(%rip),%rdi
lea    -0x24(%rbp),%rsi
call   1090 <scanf@plt>
mov    -0x24(%rbp),%esi
lea    -0x10(%rbp),%rdi
call   10b0 <excluiNodo@plt>
mov    %eax,-0x28(%rbp)
cmpl   $0x0,-0x28(%rbp)
jne    12ea <main+0x14a>
lea    0xe17(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x10(%rbp),%rdi
call   1060 <imprime@plt>
lea    -0x10(%rbp),%rdi
call   1030 <count@plt>
mov    %eax,%esi
lea    0xe1f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x18,%rsp
movq   $0x0,(%rsp)
xor    %edi,%edi
call   1090 <time@plt>
mov    %eax,%edi
call   1080 <srand@plt>
xor    %eax,%eax
call   10d0 <rand@plt>
mov    %rsp,%rbx
mov    %rbx,%rdi
xor    %esi,%esi
call   10b0 <insereUltimo@plt>
xor    %eax,%eax
call   10d0 <rand@plt>
mov    %rbx,%rdi
mov    $0x1,%esi
call   10b0 <insereUltimo@plt>
xor    %eax,%eax
call   10d0 <rand@plt>
mov    %rbx,%rdi
mov    $0x2,%esi
call   10b0 <insereUltimo@plt>
xor    %eax,%eax
call   10d0 <rand@plt>
mov    %rbx,%rdi
mov    $0x3,%esi
call   10b0 <insereUltimo@plt>
xor    %eax,%eax
call   10d0 <rand@plt>
mov    %rbx,%rdi
mov    $0x4,%esi
call   10b0 <insereUltimo@plt>
xor    %eax,%eax
call   10d0 <rand@plt>
mov    %rbx,%rdi
mov    $0x5,%esi
call   10b0 <insereUltimo@plt>
xor    %eax,%eax
call   10d0 <rand@plt>
mov    %rbx,%rdi
mov    $0x6,%esi
call   10b0 <insereUltimo@plt>
xor    %eax,%eax
call   10d0 <rand@plt>
mov    %rbx,%rdi
mov    $0x7,%esi
call   10b0 <insereUltimo@plt>
xor    %eax,%eax
call   10d0 <rand@plt>
mov    %rbx,%rdi
mov    $0x8,%esi
call   10b0 <insereUltimo@plt>
xor    %eax,%eax
call   10d0 <rand@plt>
mov    %rbx,%rdi
mov    $0x9,%esi
call   10b0 <insereUltimo@plt>
xor    %eax,%eax
call   10d0 <rand@plt>
mov    %rbx,%rdi
mov    $0xa,%esi
call   10b0 <insereUltimo@plt>
xor    %eax,%eax
call   10d0 <rand@plt>
mov    %rbx,%rdi
mov    $0xb,%esi
call   10b0 <insereUltimo@plt>
xor    %eax,%eax
call   10d0 <rand@plt>
mov    %rbx,%rdi
mov    $0xc,%esi
call   10b0 <insereUltimo@plt>
xor    %eax,%eax
call   10d0 <rand@plt>
mov    %rbx,%rdi
mov    $0xd,%esi
call   10b0 <insereUltimo@plt>
xor    %eax,%eax
call   10d0 <rand@plt>
mov    %rbx,%rdi
mov    $0xe,%esi
call   10b0 <insereUltimo@plt>
xor    %eax,%eax
call   10d0 <rand@plt>
mov    %rbx,%rdi
mov    $0xf,%esi
call   10b0 <insereUltimo@plt>
xor    %eax,%eax
call   10d0 <rand@plt>
mov    %rbx,%rdi
mov    $0x10,%esi
call   10b0 <insereUltimo@plt>
xor    %eax,%eax
call   10d0 <rand@plt>
mov    %rbx,%rdi
mov    $0x11,%esi
call   10b0 <insereUltimo@plt>
xor    %eax,%eax
call   10d0 <rand@plt>
mov    %rbx,%rdi
mov    $0x12,%esi
call   10b0 <insereUltimo@plt>
xor    %eax,%eax
call   10d0 <rand@plt>
mov    %rbx,%rdi
mov    $0x13,%esi
call   10b0 <insereUltimo@plt>
xor    %eax,%eax
call   10d0 <rand@plt>
mov    %rbx,%rdi
mov    $0x14,%esi
call   10b0 <insereUltimo@plt>
xor    %eax,%eax
call   10d0 <rand@plt>
mov    %rbx,%rdi
mov    $0x15,%esi
call   10b0 <insereUltimo@plt>
xor    %eax,%eax
call   10d0 <rand@plt>
mov    %rbx,%rdi
mov    $0x16,%esi
call   10b0 <insereUltimo@plt>
xor    %eax,%eax
call   10d0 <rand@plt>
mov    %rbx,%rdi
mov    $0x17,%esi
call   10b0 <insereUltimo@plt>
xor    %eax,%eax
call   10d0 <rand@plt>
mov    %rbx,%rdi
mov    $0x18,%esi
call   10b0 <insereUltimo@plt>
mov    %rbx,%rdi
call   1070 <imprime@plt>
lea    0xc30(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xc55(%rip),%r14
lea    0x14(%rsp),%rsi
mov    %r14,%rdi
call   10a0 <scanf@plt>
lea    0xc44(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0x10(%rsp),%rsi
mov    %r14,%rdi
call   10a0 <scanf@plt>
mov    0x14(%rsp),%esi
mov    0x10(%rsp),%edx
mov    %rbx,%rdi
call   1060 <insereAntesValor@plt>
test   %eax,%eax
je     1428 <main+0x278>
cmp    $0xffffffff,%eax
jne    1434 <main+0x284>
lea    0xcd2(%rip),%rdi
jmp    142f <main+0x27f>
lea    0xcf0(%rip),%rdi
call   1040 <puts@plt>
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1070 <imprime@plt>
lea    0xc37(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xbdf(%rip),%rdi
lea    0xc(%rsp),%rsi
call   10a0 <scanf@plt>
mov    0xc(%rsp),%esi
mov    %rbx,%rdi
call   10c0 <excluiNodo@plt>
test   %eax,%eax
jne    147a <main+0x2ca>
lea    0xc5a(%rip),%rdi
call   1040 <puts@plt>
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1070 <imprime@plt>
mov    %rbx,%rdi
call   1030 <count@plt>
lea    0xc1a(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.nodod = type { i32 }
@.str = [51 x i8] c"Digite um valor a ser pesquisado na LDE circular: \00"
@.str.1 = [3 x i8] c"%i\00"
@.str.2 = [71 x i8] c"Digite o valor a ser inserido antes do valor anterior, se encontrado: \00"
@.str.3 = [36 x i8] c"Valor de pesquisa n\C3\A3o encontrado.\0A\00"
@.str.4 = [40 x i8] c"N\C3\A3o foi poss\C3\ADvel alocar a estrutura.\0A\00"
@.str.5 = [49 x i8] c"Digite um valor a ser deletado da LDE circular: \00"
@.str.6 = [42 x i8] c"O valor selecionado n\C3\A3o foi encontrado.\0A\00"
@.str.7 = [33 x i8] c"A LDE circular possui %i nodos.\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca %struct.nodod*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %2
store %struct.nodod* null, %struct.nodod** %3
%10 = call i32 @time(i32* null)
%11 = call i32 @srand(i32 %10)
store i32 0, i32* %2
br label %12
12: ; preds = %20, %0
%13 = load i32, i32* %2
%14 = icmp slt i32 %13, 25
br i1 %14, label %15, label %23
15: ; preds = %12
%16 = call i32 (...) @rand()
%17 = srem i32 %16, 100
store i32 %17, i32* %4
%18 = load i32, i32* %2
%19 = call i32 @insereUltimo(%struct.nodod** %3, i32 %18)
br label %20
20: ; preds = %15
%21 = load i32, i32* %2
%22 = add nsw i32 %21, 1
store i32 %22, i32* %2
br label %12
23: ; preds = %12
%24 = call i32 @imprime(%struct.nodod** %3)
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str, i64 0, i64 0))
%26 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %5)
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([71 x i8], [71 x i8]* @.str.2, i64 0, i64 0))
%28 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %6)
%29 = load i32, i32* %5
%30 = load i32, i32* %6
%31 = call i32 @insereAntesValor(%struct.nodod** %3, i32 %29, i32 %30)
store i32 %31, i32* %7
%32 = load i32, i32* %7
%33 = icmp eq i32 %32, 0
br i1 %33, label %34, label %36
34: ; preds = %23
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.3, i64 0, i64 0))
br label %42
36: ; preds = %23
%37 = load i32, i32* %7
%38 = icmp eq i32 %37, -1
br i1 %38, label %39, label %41
39: ; preds = %36
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.4, i64 0, i64 0))
br label %41
41: ; preds = %39, %36
br label %42
42: ; preds = %41, %34
%43 = call i32 @imprime(%struct.nodod** %3)
%44 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.5, i64 0, i64 0))
%45 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %8)
%46 = load i32, i32* %8
%47 = call i32 @excluiNodo(%struct.nodod** %3, i32 %46)
store i32 %47, i32* %9
%48 = load i32, i32* %9
%49 = icmp eq i32 %48, 0
br i1 %49, label %50, label %52
50: ; preds = %42
%51 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.6, i64 0, i64 0))
br label %52
52: ; preds = %50, %42
%53 = call i32 @imprime(%struct.nodod** %3)
%54 = call i32 @count(%struct.nodod** %3)
%55 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.7, i64 0, i64 0), i32 %54)
ret i32 0
}

LLVM IR (-O2):
%struct.nodod = type { i32 }
@.str = [51 x i8] c"Digite um valor a ser pesquisado na LDE circular: \00"
@.str.1 = [3 x i8] c"%i\00"
@.str.2 = [71 x i8] c"Digite o valor a ser inserido antes do valor anterior, se encontrado: \00"
@.str.5 = [49 x i8] c"Digite um valor a ser deletado da LDE circular: \00"
@.str.7 = [33 x i8] c"A LDE circular possui %i nodos.\0A\00"
@str = [41 x i8] c"O valor selecionado n\C3\A3o foi encontrado.\00"
@str.8 = [39 x i8] c"N\C3\A3o foi poss\C3\ADvel alocar a estrutura.\00"
@str.9 = [35 x i8] c"Valor de pesquisa n\C3\A3o encontrado.\00"
define i32 @main() {
%1 = alloca %struct.nodod*
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = bitcast %struct.nodod** %1 to i8*
store %struct.nodod* null, %struct.nodod** %1
%6 = tail call i32 @time(i32* null)
%7 = tail call i32 @srand(i32 %6)
%8 = call i32 (...) @rand()
%9 = call i32 @insereUltimo(%struct.nodod** %1, i32 0)
%10 = call i32 (...) @rand()
%11 = call i32 @insereUltimo(%struct.nodod** %1, i32 1)
%12 = call i32 (...) @rand()
%13 = call i32 @insereUltimo(%struct.nodod** %1, i32 2)
%14 = call i32 (...) @rand()
%15 = call i32 @insereUltimo(%struct.nodod** %1, i32 3)
%16 = call i32 (...) @rand()
%17 = call i32 @insereUltimo(%struct.nodod** %1, i32 4)
%18 = call i32 (...) @rand()
%19 = call i32 @insereUltimo(%struct.nodod** %1, i32 5)
%20 = call i32 (...) @rand()
%21 = call i32 @insereUltimo(%struct.nodod** %1, i32 6)
%22 = call i32 (...) @rand()
%23 = call i32 @insereUltimo(%struct.nodod** %1, i32 7)
%24 = call i32 (...) @rand()
%25 = call i32 @insereUltimo(%struct.nodod** %1, i32 8)
%26 = call i32 (...) @rand()
%27 = call i32 @insereUltimo(%struct.nodod** %1, i32 9)
%28 = call i32 (...) @rand()
%29 = call i32 @insereUltimo(%struct.nodod** %1, i32 10)
%30 = call i32 (...) @rand()
%31 = call i32 @insereUltimo(%struct.nodod** %1, i32 11)
%32 = call i32 (...) @rand()
%33 = call i32 @insereUltimo(%struct.nodod** %1, i32 12)
%34 = call i32 (...) @rand()
%35 = call i32 @insereUltimo(%struct.nodod** %1, i32 13)
%36 = call i32 (...) @rand()
%37 = call i32 @insereUltimo(%struct.nodod** %1, i32 14)
%38 = call i32 (...) @rand()
%39 = call i32 @insereUltimo(%struct.nodod** %1, i32 15)
%40 = call i32 (...) @rand()
%41 = call i32 @insereUltimo(%struct.nodod** %1, i32 16)
%42 = call i32 (...) @rand()
%43 = call i32 @insereUltimo(%struct.nodod** %1, i32 17)
%44 = call i32 (...) @rand()
%45 = call i32 @insereUltimo(%struct.nodod** %1, i32 18)
%46 = call i32 (...) @rand()
%47 = call i32 @insereUltimo(%struct.nodod** %1, i32 19)
%48 = call i32 (...) @rand()
%49 = call i32 @insereUltimo(%struct.nodod** %1, i32 20)
%50 = call i32 (...) @rand()
%51 = call i32 @insereUltimo(%struct.nodod** %1, i32 21)
%52 = call i32 (...) @rand()
%53 = call i32 @insereUltimo(%struct.nodod** %1, i32 22)
%54 = call i32 (...) @rand()
%55 = call i32 @insereUltimo(%struct.nodod** %1, i32 23)
%56 = call i32 (...) @rand()
%57 = call i32 @insereUltimo(%struct.nodod** %1, i32 24)
%58 = call i32 @imprime(%struct.nodod** %1)
%59 = bitcast i32* %2 to i8*
%60 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([51 x i8], [51 x i8]* @.str, i64 0, i64 0))
%61 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%62 = bitcast i32* %3 to i8*
%63 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([71 x i8], [71 x i8]* @.str.2, i64 0, i64 0))
%64 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%65 = load i32, i32* %2
%66 = load i32, i32* %3
%67 = call i32 @insereAntesValor(%struct.nodod** %1, i32 %65, i32 %66)
switch i32 %67, label %72 [
i32 0, label %69
i32 -1, label %68
]
68: ; preds = %0
br label %69
69: ; preds = %0, %68
%70 = phi i8* [ getelementptr inbounds ([39 x i8], [39 x i8]* @str.8, i64 0, i64 0), %68 ], [ getelementptr inbounds ([35 x i8], [35 x i8]* @str.9, i64 0, i64 0), %0 ]
%71 = call i32 @puts(i8* dereferenceable(1) %70)
br label %72
72: ; preds = %69, %0
%73 = call i32 @imprime(%struct.nodod** %1)
%74 = bitcast i32* %4 to i8*
%75 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([49 x i8], [49 x i8]* @.str.5, i64 0, i64 0))
%76 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %4)
%77 = load i32, i32* %4
%78 = call i32 @excluiNodo(%struct.nodod** %1, i32 %77)
%79 = icmp eq i32 %78, 0
br i1 %79, label %80, label %82
80: ; preds = %72
%81 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @str, i64 0, i64 0))
br label %82
82: ; preds = %80, %72
%83 = call i32 @imprime(%struct.nodod** %1)
%84 = call i32 @count(%struct.nodod** %1)
%85 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.7, i64 0, i64 0), i32 %84)
ret i32 0
}