#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 *, double, double, double, double);
int strlen(char *);
void opcao_1(char *texto) {
  char value;
  double carac = 0, palav = 0, frase = 0;
  double media = 0;
  int i;
  for (i = 0; i < strlen(texto); i++) {
    value = texto[i];
    carac++;
    if (value == '\n' || value == ' ') {
      palav++;
    }
    if (value == '.' || value == '!' || value == '?') {
      frase++;
    }
  }
  media = (double)carac / (double)frase;
  printf("%d\n%d\n%d\n%.1lf", carac, palav, frase, media);
}


x86 assembly (clang, -O0):
<opcao_1>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x18(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x20(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x28(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x30(%rbp)
movl   $0x0,-0x34(%rbp)
mov    -0x34(%rbp),%eax
mov    %eax,-0x38(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x38(%rbp),%eax
cmp    %ecx,%eax
jge    1207 <opcao_1+0xe7>
mov    -0x8(%rbp),%rax
movslq -0x34(%rbp),%rcx
mov    (%rax,%rcx,1),%al
mov    %al,-0x9(%rbp)
movsd  0xe7b(%rip),%xmm0
addsd  -0x18(%rbp),%xmm0
movsd  %xmm0,-0x18(%rbp)
movsbl -0x9(%rbp),%eax
cmp    $0xa,%eax
je     11a9 <opcao_1+0x89>
movsbl -0x9(%rbp),%eax
cmp    $0x20,%eax
jne    11bb <opcao_1+0x9b>
movsd  0xe4f(%rip),%xmm0
addsd  -0x20(%rbp),%xmm0
movsd  %xmm0,-0x20(%rbp)
movsbl -0x9(%rbp),%eax
cmp    $0x2e,%eax
je     11e2 <opcao_1+0xc2>
movsbl -0x9(%rbp),%eax
cmp    $0x21,%eax
je     11e2 <opcao_1+0xc2>
movsbl -0x9(%rbp),%eax
cmp    $0x3f,%eax
jne    11f4 <opcao_1+0xd4>
movsd  0xe16(%rip),%xmm0
addsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x28(%rbp)
jmp    11f9 <opcao_1+0xd9>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    1153 <opcao_1+0x33>
movsd  -0x18(%rbp),%xmm0
divsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x30(%rbp)
movsd  -0x18(%rbp),%xmm0
movsd  -0x20(%rbp),%xmm1
movsd  -0x28(%rbp),%xmm2
movsd  -0x30(%rbp),%xmm3
lea    0xdd7(%rip),%rdi
call   1040 <printf@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<opcao_1>:
push   %r15
push   %r14
push   %rbx
sub    $0x20,%rsp
mov    %rdi,%r14
call   1030 <strlen@plt>
test   %eax,%eax
jle    11d7 <opcao_1+0xb7>
xorpd  %xmm0,%xmm0
movsd  %xmm0,0x10(%rsp)
xor    %ebx,%ebx
movsd  0xeb3(%rip),%xmm2
movabs $0x8000400200000000,%r15
xorpd  %xmm0,%xmm0
movsd  %xmm0,0x8(%rsp)
xorpd  %xmm1,%xmm1
jmp    1191 <opcao_1+0x71>
nopw   0x0(%rax,%rax,1)
add    $0x1,%rbx
mov    %r14,%rdi
call   1030 <strlen@plt>
cltq
cmp    %rax,%rbx
movsd  0x18(%rsp),%xmm1
movsd  0xe71(%rip),%xmm2
jge    11ef <opcao_1+0xcf>
movzbl (%r14,%rbx,1),%eax
addsd  %xmm2,%xmm1
cmp    $0x20,%al
je     11a2 <opcao_1+0x82>
cmp    $0xa,%al
jne    11b2 <opcao_1+0x92>
movsd  0x8(%rsp),%xmm0
addsd  %xmm2,%xmm0
movsd  %xmm0,0x8(%rsp)
cmp    $0x3f,%al
movsd  %xmm1,0x18(%rsp)
ja     1170 <opcao_1+0x50>
movzbl %al,%eax
bt     %rax,%r15
jae    1170 <opcao_1+0x50>
movsd  0x10(%rsp),%xmm0
addsd  %xmm2,%xmm0
movsd  %xmm0,0x10(%rsp)
jmp    1170 <opcao_1+0x50>
xorpd  %xmm1,%xmm1
xorpd  %xmm0,%xmm0
movsd  %xmm0,0x8(%rsp)
xorpd  %xmm0,%xmm0
movsd  %xmm0,0x10(%rsp)
movapd %xmm1,%xmm3
movsd  0x10(%rsp),%xmm2
divsd  %xmm2,%xmm3
lea    0xe04(%rip),%rdi
movapd %xmm1,%xmm0
movsd  0x8(%rsp),%xmm1
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %r15
jmp    1040 <printf@plt>

LLVM IR (-O0):
@.str = [15 x i8] c"%d\0A%d\0A%d\0A%.1lf\00"
define void @opcao_1(i8* %0) {
%2 = alloca i8*
%3 = alloca i8
%4 = alloca double
%5 = alloca double
%6 = alloca double
%7 = alloca double
%8 = alloca i32
store i8* %0, i8** %2
store double 0.000000e+00, double* %4
store double 0.000000e+00, double* %5
store double 0.000000e+00, double* %6
store double 0.000000e+00, double* %7
store i32 0, i32* %8
br label %9
9: ; preds = %48, %1
%10 = load i32, i32* %8
%11 = load i8*, i8** %2
%12 = call i32 @strlen(i8* %11)
%13 = icmp slt i32 %10, %12
br i1 %13, label %14, label %51
14: ; preds = %9
%15 = load i8*, i8** %2
%16 = load i32, i32* %8
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds i8, i8* %15, i64 %17
%19 = load i8, i8* %18
store i8 %19, i8* %3
%20 = load double, double* %4
%21 = fadd double %20, 1.000000e+00
store double %21, double* %4
%22 = load i8, i8* %3
%23 = sext i8 %22 to i32
%24 = icmp eq i32 %23, 10
br i1 %24, label %29, label %25
25: ; preds = %14
%26 = load i8, i8* %3
%27 = sext i8 %26 to i32
%28 = icmp eq i32 %27, 32
br i1 %28, label %29, label %32
29: ; preds = %25, %14
%30 = load double, double* %5
%31 = fadd double %30, 1.000000e+00
store double %31, double* %5
br label %32
32: ; preds = %29, %25
%33 = load i8, i8* %3
%34 = sext i8 %33 to i32
%35 = icmp eq i32 %34, 46
br i1 %35, label %44, label %36
36: ; preds = %32
%37 = load i8, i8* %3
%38 = sext i8 %37 to i32
%39 = icmp eq i32 %38, 33
br i1 %39, label %44, label %40
40: ; preds = %36
%41 = load i8, i8* %3
%42 = sext i8 %41 to i32
%43 = icmp eq i32 %42, 63
br i1 %43, label %44, label %47
44: ; preds = %40, %36, %32
%45 = load double, double* %6
%46 = fadd double %45, 1.000000e+00
store double %46, double* %6
br label %47
47: ; preds = %44, %40
br label %48
48: ; preds = %47
%49 = load i32, i32* %8
%50 = add nsw i32 %49, 1
store i32 %50, i32* %8
br label %9
51: ; preds = %9
%52 = load double, double* %4
%53 = load double, double* %6
%54 = fdiv double %52, %53
store double %54, double* %7
%55 = load double, double* %4
%56 = load double, double* %5
%57 = load double, double* %6
%58 = load double, double* %7
%59 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), double %55, double %56, double %57, double %58)
ret void
}

LLVM IR (-O2):
@.str = [15 x i8] c"%d\0A%d\0A%d\0A%.1lf\00"
define void @opcao_1(i8* %0) {
%2 = tail call i32 @strlen(i8* %0)
%3 = icmp sgt i32 %2, 0
br i1 %3, label %4, label %24
4: ; preds = %1, %18
%5 = phi i64 [ %20, %18 ], [ 0, %1 ]
%6 = phi double [ %19, %18 ], [ 0.000000e+00, %1 ]
%7 = phi double [ %15, %18 ], [ 0.000000e+00, %1 ]
%8 = phi double [ %11, %18 ], [ 0.000000e+00, %1 ]
%9 = getelementptr inbounds i8, i8* %0, i64 %5
%10 = load i8, i8* %9
%11 = fadd double %8, 1.000000e+00
switch i8 %10, label %14 [
i8 32, label %12
i8 10, label %12
]
12: ; preds = %4, %4
%13 = fadd double %7, 1.000000e+00
br label %14
14: ; preds = %4, %12
%15 = phi double [ %13, %12 ], [ %7, %4 ]
switch i8 %10, label %18 [
i8 63, label %16
i8 46, label %16
i8 33, label %16
]
16: ; preds = %14, %14, %14
%17 = fadd double %6, 1.000000e+00
br label %18
18: ; preds = %14, %16
%19 = phi double [ %17, %16 ], [ %6, %14 ]
%20 = add nuw nsw i64 %5, 1
%21 = tail call i32 @strlen(i8* %0)
%22 = sext i32 %21 to i64
%23 = icmp slt i64 %20, %22
br i1 %23, label %4, label %24
24: ; preds = %18, %1
%25 = phi double [ 0.000000e+00, %1 ], [ %11, %18 ]
%26 = phi double [ 0.000000e+00, %1 ], [ %15, %18 ]
%27 = phi double [ 0.000000e+00, %1 ], [ %19, %18 ]
%28 = fdiv double %25, %27
%29 = tail call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), double %25, double %26, double %27, double %28)
ret void
}