#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*/ gets(char *);
int /*<<< orphan*/ printf(char *, ...);
int strlen(char *);
main() {
  char palavra[50];
  int numpalavras = 0, tamanho = 0, totalpar = 0, divisor = 0;
  float media;
inicio:
  printf("\nDigite uma palavra: ");
  gets(palavra);
  tamanho = strlen(palavra);
  if (tamanho > 30) {
    printf("\nPalavra excede limite de 30 caracteres.");
    goto inicio;
  } else {
    if ((tamanho % 2) == 0) {
      totalpar = totalpar + tamanho;
      divisor++;
      numpalavras++;
    } else
      numpalavras++;
  }
  if (numpalavras == 3) {
    media = totalpar / divisor;
    printf("\nMedia aritmetica (%d palavras): %f", divisor, media);
  } else
    goto inicio;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x44(%rbp)
movl   $0x0,-0x48(%rbp)
movl   $0x0,-0x4c(%rbp)
movl   $0x0,-0x50(%rbp)
lea    0xe9e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x40(%rbp),%rdi
call   1050 <gets@plt>
lea    -0x40(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x48(%rbp)
cmpl   $0x1e,-0x48(%rbp)
jle    119b <main+0x6b>
lea    0xe87(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    115b <main+0x2b>
mov    -0x48(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cmp    $0x0,%edx
jne    11cf <main+0x9f>
mov    -0x4c(%rbp),%eax
add    -0x48(%rbp),%eax
mov    %eax,-0x4c(%rbp)
mov    -0x50(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x50(%rbp)
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
jmp    11d8 <main+0xa8>
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
jmp    11dd <main+0xad>
cmpl   $0x3,-0x44(%rbp)
jne    1216 <main+0xe6>
mov    -0x4c(%rbp),%eax
cltd
idivl  -0x50(%rbp)
cvtsi2ss %eax,%xmm0
movss  %xmm0,-0x54(%rbp)
mov    -0x50(%rbp),%esi
movss  -0x54(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe35(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
jmp    121b <main+0xeb>
jmp    115b <main+0x2b>
mov    -0x4(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x48,%rsp
lea    0xebb(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
call   1050 <gets@plt>
mov    %rbx,%rdi
call   1030 <strlen@plt>
mov    %eax,%ebx
cmp    $0x1f,%eax
jl     11ab <main+0x7b>
lea    0xea7(%rip),%r14
lea    0xe8a(%rip),%r15
lea    0x10(%rsp),%rbp
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbp,%rdi
call   1050 <gets@plt>
mov    %rbp,%rdi
call   1030 <strlen@plt>
cmp    $0x1e,%eax
jg     1180 <main+0x50>
mov    %eax,%ebx
lea    0xe4e(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0x10(%rsp),%rbp
mov    %rbp,%rdi
call   1050 <gets@plt>
mov    %rbp,%rdi
call   1030 <strlen@plt>
mov    %eax,%ebp
cmp    $0x1f,%eax
jl     121b <main+0xeb>
lea    0xe3a(%rip),%r14
lea    0xe1d(%rip),%r15
lea    0x10(%rsp),%r12
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r12,%rdi
call   1050 <gets@plt>
mov    %r12,%rdi
call   1030 <strlen@plt>
cmp    $0x1e,%eax
jg     11f0 <main+0xc0>
mov    %eax,%ebp
mov    %ebx,%r12d
and    $0x1,%r12d
mov    %ebp,%r13d
and    $0x1,%r13d
lea    0xdd0(%rip),%rdi
xor    %r15d,%r15d
xor    %eax,%eax
call   1040 <printf@plt>
lea    0x10(%rsp),%r14
mov    %r14,%rdi
call   1050 <gets@plt>
mov    %r14,%rdi
call   1030 <strlen@plt>
cmp    $0x1f,%eax
jl     12a1 <main+0x171>
mov    %r12d,0xc(%rsp)
lea    0xdb6(%rip),%r14
lea    0xd99(%rip),%r15
lea    0x10(%rsp),%r12
nopl   0x0(%rax)
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r12,%rdi
call   1050 <gets@plt>
mov    %r12,%rdi
call   1030 <strlen@plt>
cmp    $0x1e,%eax
jg     1270 <main+0x140>
xor    %r15d,%r15d
mov    0xc(%rsp),%r12d
mov    %r13d,%ecx
xor    $0x1,%ecx
mov    %r12d,%edx
xor    $0x1,%edx
add    %ecx,%edx
test   %r13d,%r13d
cmovne %r15d,%ebp
test   %r12d,%r12d
cmovne %r15d,%ebx
add    %ebp,%ebx
mov    %eax,%esi
and    $0x1,%esi
cmovne %r15d,%eax
add    %ebx,%eax
xor    $0x1,%esi
add    %edx,%esi
cltd
idiv   %esi
cvtsi2ss %eax,%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xd5e(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x48,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [22 x i8] c"\0ADigite uma palavra: \00"
@.str.1 = [41 x i8] c"\0APalavra excede limite de 30 caracteres.\00"
@.str.2 = [36 x i8] c"\0AMedia aritmetica (%d palavras): %f\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [50 x i8]
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca float
store i32 0, i32* %1
store i32 0, i32* %3
store i32 0, i32* %4
store i32 0, i32* %5
store i32 0, i32* %6
br label %8
8: ; preds = %46, %16, %0
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
%10 = getelementptr inbounds [50 x i8], [50 x i8]* %2, i64 0, i64 0
%11 = call i32 @gets(i8* %10)
%12 = getelementptr inbounds [50 x i8], [50 x i8]* %2, i64 0, i64 0
%13 = call i32 @strlen(i8* %12)
store i32 %13, i32* %4
%14 = load i32, i32* %4
%15 = icmp sgt i32 %14, 30
br i1 %15, label %16, label %18
16: ; preds = %8
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.1, i64 0, i64 0))
br label %8
18: ; preds = %8
%19 = load i32, i32* %4
%20 = srem i32 %19, 2
%21 = icmp eq i32 %20, 0
br i1 %21, label %22, label %30
22: ; preds = %18
%23 = load i32, i32* %5
%24 = load i32, i32* %4
%25 = add nsw i32 %23, %24
store i32 %25, i32* %5
%26 = load i32, i32* %6
%27 = add nsw i32 %26, 1
store i32 %27, i32* %6
%28 = load i32, i32* %3
%29 = add nsw i32 %28, 1
store i32 %29, i32* %3
br label %33
30: ; preds = %18
%31 = load i32, i32* %3
%32 = add nsw i32 %31, 1
store i32 %32, i32* %3
br label %33
33: ; preds = %30, %22
br label %34
34: ; preds = %33
%35 = load i32, i32* %3
%36 = icmp eq i32 %35, 3
br i1 %36, label %37, label %46
37: ; preds = %34
%38 = load i32, i32* %5
%39 = load i32, i32* %6
%40 = sdiv i32 %38, %39
%41 = sitofp i32 %40 to float
store float %41, float* %7
%42 = load i32, i32* %6
%43 = load float, float* %7
%44 = fpext float %43 to double
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.2, i64 0, i64 0), i32 %42, double %44)
br label %47
46: ; preds = %34
br label %8
47: ; preds = %37
%48 = load i32, i32* %1
ret i32 %48
}

LLVM IR (-O2):
@.str = [22 x i8] c"\0ADigite uma palavra: \00"
@.str.1 = [41 x i8] c"\0APalavra excede limite de 30 caracteres.\00"
@.str.2 = [36 x i8] c"\0AMedia aritmetica (%d palavras): %f\00"
define i32 @main() {
%1 = alloca [50 x i8]
%2 = getelementptr inbounds [50 x i8], [50 x i8]* %1, i64 0, i64 0
%3 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
%4 = call i32 @gets(i8* %2)
%5 = call i32 @strlen(i8* %2)
%6 = icmp sgt i32 %5, 30
br i1 %6, label %7, label %13
7: ; preds = %0, %7
%8 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @.str.1, i64 0, i64 0))
%9 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
%10 = call i32 @gets(i8* %2)
%11 = call i32 @strlen(i8* %2)
%12 = icmp sgt i32 %11, 30
br i1 %12, label %7, label %13
13: ; preds = %7, %0
%14 = phi i32 [ %5, %0 ], [ %11, %7 ]
%15 = and i32 %14, 1
%16 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
%17 = call i32 @gets(i8* %2)
%18 = call i32 @strlen(i8* %2)
%19 = icmp sgt i32 %18, 30
br i1 %19, label %20, label %26
20: ; preds = %13, %20
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @.str.1, i64 0, i64 0))
%22 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
%23 = call i32 @gets(i8* %2)
%24 = call i32 @strlen(i8* %2)
%25 = icmp sgt i32 %24, 30
br i1 %25, label %20, label %26
26: ; preds = %20, %13
%27 = phi i32 [ %18, %13 ], [ %24, %20 ]
%28 = and i32 %27, 1
%29 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
%30 = call i32 @gets(i8* %2)
%31 = call i32 @strlen(i8* %2)
%32 = icmp sgt i32 %31, 30
br i1 %32, label %33, label %39
33: ; preds = %26, %33
%34 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @.str.1, i64 0, i64 0))
%35 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
%36 = call i32 @gets(i8* %2)
%37 = call i32 @strlen(i8* %2)
%38 = icmp sgt i32 %37, 30
br i1 %38, label %33, label %39
39: ; preds = %33, %26
%40 = phi i32 [ %31, %26 ], [ %37, %33 ]
%41 = xor i32 %28, 1
%42 = xor i32 %15, 1
%43 = add nuw nsw i32 %41, %42
%44 = icmp eq i32 %28, 0
%45 = select i1 %44, i32 %27, i32 0
%46 = icmp eq i32 %15, 0
%47 = select i1 %46, i32 %14, i32 0
%48 = add nsw i32 %45, %47
%49 = and i32 %40, 1
%50 = icmp eq i32 %49, 0
%51 = select i1 %50, i32 %40, i32 0
%52 = add nsw i32 %51, %48
%53 = xor i32 %49, 1
%54 = add nuw nsw i32 %53, %43
%55 = sdiv i32 %52, %54
%56 = sitofp i32 %55 to float
%57 = fpext float %56 to double
%58 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([36 x i8], [36 x i8]* @.str.2, i64 0, i64 0), i32 %54, double %57)
ret i32 0
}