#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);
int /*<<< orphan*/ scanf(char *, int *, ...);
int main(void) {
  int casos;
  int quantidade, coelhos = 0, ratos = 0, sapos = 0, total;
  char tipo;
  scanf("%d\n", &casos);
  while (casos-- > 0) {
    scanf("%d %c\n", &quantidade, &tipo);
    switch (tipo) {
    case 'C':
      coelhos += quantidade;
      break;
    case 'R':
      ratos += quantidade;
      break;
    case 'S':
      sapos += quantidade;
    }
  }
  total = coelhos + ratos + sapos;
  printf("Total: %d cobaias\n", total);
  printf("Total de coelhos: %d\n", coelhos);
  printf("Total de ratos: %d\n", ratos);
  printf("Total de sapos: %d\n", sapos);
  printf("Percentual de coelhos: %.2f %%\n", coelhos * 100.0 / total);
  printf("Percentual de ratos: %.2f %%\n", ratos * 100.0 / total);
  printf("Percentual de sapos: %.2f %%\n", sapos * 100.0 / total);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
lea    0xee9(%rip),%rdi
lea    -0x8(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
mov    -0x8(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x8(%rbp)
cmp    $0x0,%eax
jle    11e1 <main+0xc1>
lea    0xe97(%rip),%rdi
xor    %eax,%eax
lea    -0xc(%rbp),%rsi
lea    -0x1d(%rbp),%rdx
call   1040 <scanf@plt>
movsbl -0x1d(%rbp),%eax
mov    %eax,-0x24(%rbp)
sub    $0x43,%eax
je     11b7 <main+0x97>
jmp    1195 <main+0x75>
mov    -0x24(%rbp),%eax
sub    $0x52,%eax
je     11c5 <main+0xa5>
jmp    11a6 <main+0x86>
mov    -0x24(%rbp),%eax
sub    $0x53,%eax
je     11d3 <main+0xb3>
jmp    11dc <main+0xbc>
mov    -0xc(%rbp),%eax
add    -0x10(%rbp),%eax
mov    %eax,-0x10(%rbp)
jmp    11dc <main+0xbc>
mov    -0xc(%rbp),%eax
add    -0x14(%rbp),%eax
mov    %eax,-0x14(%rbp)
jmp    11dc <main+0xbc>
mov    -0xc(%rbp),%eax
add    -0x18(%rbp),%eax
mov    %eax,-0x18(%rbp)
jmp    1156 <main+0x36>
mov    -0x10(%rbp),%eax
add    -0x14(%rbp),%eax
add    -0x18(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%esi
lea    0xe18(%rip),%rdi
call   1030 <printf@plt>
mov    -0x10(%rbp),%esi
lea    0xe1c(%rip),%rdi
call   1030 <printf@plt>
mov    -0x14(%rbp),%esi
lea    0xe23(%rip),%rdi
call   1030 <printf@plt>
mov    -0x18(%rbp),%esi
lea    0xe28(%rip),%rdi
call   1030 <printf@plt>
cvtsi2sdl -0x10(%rbp),%xmm0
movsd  0xdca(%rip),%xmm1
mulsd  %xmm1,%xmm0
cvtsi2sdl -0x1c(%rbp),%xmm1
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%esi
lea    0xe12(%rip),%rdi
call   1030 <printf@plt>
cvtsi2sdl -0x14(%rbp),%xmm0
movsd  0xda0(%rip),%xmm1
mulsd  %xmm1,%xmm0
cvtsi2sdl -0x1c(%rbp),%xmm1
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%esi
lea    0xe08(%rip),%rdi
call   1030 <printf@plt>
cvtsi2sdl -0x18(%rbp),%xmm0
movsd  0xd76(%rip),%xmm1
mulsd  %xmm1,%xmm0
cvtsi2sdl -0x1c(%rbp),%xmm1
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%esi
lea    0xdfc(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
lea    0xeff(%rip),%rdi
xor    %r15d,%r15d
lea    0x8(%rsp),%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
mov    0x8(%rsp),%eax
lea    -0x1(%rax),%ecx
mov    %ecx,0x8(%rsp)
mov    $0x0,%r14d
mov    $0x0,%ebp
test   %eax,%eax
jle    11c7 <main+0xa7>
lea    0xea3(%rip),%r12
lea    0xc(%rsp),%r13
lea    0x7(%rsp),%rbx
xor    %ebp,%ebp
xor    %r14d,%r14d
xor    %r15d,%r15d
jmp    1194 <main+0x74>
nopl   0x0(%rax)
add    0xc(%rsp),%r15d
mov    0x8(%rsp),%eax
lea    -0x1(%rax),%ecx
mov    %ecx,0x8(%rsp)
test   %eax,%eax
jle    11c7 <main+0xa7>
mov    %r12,%rdi
mov    %r13,%rsi
mov    %rbx,%rdx
xor    %eax,%eax
call   1040 <scanf@plt>
movsbl 0x7(%rsp),%eax
cmp    $0x53,%eax
je     11c0 <main+0xa0>
cmp    $0x52,%eax
je     1180 <main+0x60>
cmp    $0x43,%eax
jne    1185 <main+0x65>
add    0xc(%rsp),%ebp
jmp    1185 <main+0x65>
xchg   %ax,%ax
add    0xc(%rsp),%r14d
jmp    1185 <main+0x65>
lea    (%r14,%r15,1),%ebx
add    %ebp,%ebx
lea    0xe3b(%rip),%rdi
mov    %ebx,%esi
call   1030 <printf@plt>
lea    0xe40(%rip),%rdi
mov    %ebp,%esi
call   1030 <printf@plt>
lea    0xe48(%rip),%rdi
mov    %r15d,%esi
call   1030 <printf@plt>
lea    0xe4d(%rip),%rdi
mov    %r14d,%esi
call   1030 <printf@plt>
cvtsi2sd %ebp,%xmm0
cvtsi2sd %ebx,%xmm2
movsd  %xmm2,0x10(%rsp)
mulsd  0xde3(%rip),%xmm0
divsd  %xmm2,%xmm0
cvttsd2si %xmm0,%esi
lea    0xe34(%rip),%rdi
call   1030 <printf@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %r15d,%xmm0
mulsd  0xdbf(%rip),%xmm0
divsd  0x10(%rsp),%xmm0
cvttsd2si %xmm0,%esi
lea    0xe2e(%rip),%rdi
call   1030 <printf@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %r14d,%xmm0
mulsd  0xd99(%rip),%xmm0
divsd  0x10(%rsp),%xmm0
cvttsd2si %xmm0,%esi
lea    0xe26(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%d\0A\00"
@.str.1 = [7 x i8] c"%d %c\0A\00"
@.str.2 = [19 x i8] c"Total: %d cobaias\0A\00"
@.str.3 = [22 x i8] c"Total de coelhos: %d\0A\00"
@.str.4 = [20 x i8] c"Total de ratos: %d\0A\00"
@.str.5 = [20 x i8] c"Total de sapos: %d\0A\00"
@.str.6 = [32 x i8] c"Percentual de coelhos: %.2f %%\0A\00"
@.str.7 = [30 x i8] c"Percentual de ratos: %.2f %%\0A\00"
@.str.8 = [30 x i8] c"Percentual de sapos: %.2f %%\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i8
store i32 0, i32* %1
store i32 0, i32* %4
store i32 0, i32* %5
store i32 0, i32* %6
%9 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32* %2)
br label %10
10: ; preds = %30, %0
%11 = load i32, i32* %2
%12 = add nsw i32 %11, -1
store i32 %12, i32* %2
%13 = icmp sgt i32 %11, 0
br i1 %13, label %14, label %31
14: ; preds = %10
%15 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32* %3, i8* %8)
%16 = load i8, i8* %8
%17 = sext i8 %16 to i32
switch i32 %17, label %30 [
i32 67, label %18
i32 82, label %22
i32 83, label %26
]
18: ; preds = %14
%19 = load i32, i32* %3
%20 = load i32, i32* %4
%21 = add nsw i32 %20, %19
store i32 %21, i32* %4
br label %30
22: ; preds = %14
%23 = load i32, i32* %3
%24 = load i32, i32* %5
%25 = add nsw i32 %24, %23
store i32 %25, i32* %5
br label %30
26: ; preds = %14
%27 = load i32, i32* %3
%28 = load i32, i32* %6
%29 = add nsw i32 %28, %27
store i32 %29, i32* %6
br label %30
30: ; preds = %26, %14, %22, %18
br label %10
31: ; preds = %10
%32 = load i32, i32* %4
%33 = load i32, i32* %5
%34 = add nsw i32 %32, %33
%35 = load i32, i32* %6
%36 = add nsw i32 %34, %35
store i32 %36, i32* %7
%37 = load i32, i32* %7
%38 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i32 %37)
%39 = load i32, i32* %4
%40 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0), i32 %39)
%41 = load i32, i32* %5
%42 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0), i32 %41)
%43 = load i32, i32* %6
%44 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.5, i64 0, i64 0), i32 %43)
%45 = load i32, i32* %4
%46 = sitofp i32 %45 to double
%47 = fmul double %46, 1.000000e+02
%48 = load i32, i32* %7
%49 = sitofp i32 %48 to double
%50 = fdiv double %47, %49
%51 = fptosi double %50 to i32
%52 = call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.6, i64 0, i64 0), i32 %51)
%53 = load i32, i32* %5
%54 = sitofp i32 %53 to double
%55 = fmul double %54, 1.000000e+02
%56 = load i32, i32* %7
%57 = sitofp i32 %56 to double
%58 = fdiv double %55, %57
%59 = fptosi double %58 to i32
%60 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.7, i64 0, i64 0), i32 %59)
%61 = load i32, i32* %6
%62 = sitofp i32 %61 to double
%63 = fmul double %62, 1.000000e+02
%64 = load i32, i32* %7
%65 = sitofp i32 %64 to double
%66 = fdiv double %63, %65
%67 = fptosi double %66 to i32
%68 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.8, i64 0, i64 0), i32 %67)
ret i32 0
}

LLVM IR (-O2):
@.str = [4 x i8] c"%d\0A\00"
@.str.1 = [7 x i8] c"%d %c\0A\00"
@.str.2 = [19 x i8] c"Total: %d cobaias\0A\00"
@.str.3 = [22 x i8] c"Total de coelhos: %d\0A\00"
@.str.4 = [20 x i8] c"Total de ratos: %d\0A\00"
@.str.5 = [20 x i8] c"Total de sapos: %d\0A\00"
@.str.6 = [32 x i8] c"Percentual de coelhos: %.2f %%\0A\00"
@.str.7 = [30 x i8] c"Percentual de ratos: %.2f %%\0A\00"
@.str.8 = [30 x i8] c"Percentual de sapos: %.2f %%\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i8
%4 = bitcast i32* %1 to i8*
%5 = bitcast i32* %2 to i8*
%6 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32* %1)
%7 = load i32, i32* %1
%8 = add nsw i32 %7, -1
store i32 %8, i32* %1
%9 = icmp sgt i32 %7, 0
br i1 %9, label %10, label %33
10: ; preds = %0, %26
%11 = phi i32 [ %29, %26 ], [ 0, %0 ]
%12 = phi i32 [ %28, %26 ], [ 0, %0 ]
%13 = phi i32 [ %27, %26 ], [ 0, %0 ]
%14 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i32* %2, i8* %3)
%15 = load i8, i8* %3
%16 = sext i8 %15 to i32
switch i32 %16, label %26 [
i32 67, label %17
i32 82, label %20
i32 83, label %23
]
17: ; preds = %10
%18 = load i32, i32* %2
%19 = add nsw i32 %18, %11
br label %26
20: ; preds = %10
%21 = load i32, i32* %2
%22 = add nsw i32 %21, %13
br label %26
23: ; preds = %10
%24 = load i32, i32* %2
%25 = add nsw i32 %24, %12
br label %26
26: ; preds = %23, %10, %20, %17
%27 = phi i32 [ %13, %10 ], [ %13, %23 ], [ %22, %20 ], [ %13, %17 ]
%28 = phi i32 [ %12, %10 ], [ %25, %23 ], [ %12, %20 ], [ %12, %17 ]
%29 = phi i32 [ %11, %10 ], [ %11, %23 ], [ %11, %20 ], [ %19, %17 ]
%30 = load i32, i32* %1
%31 = add nsw i32 %30, -1
store i32 %31, i32* %1
%32 = icmp sgt i32 %30, 0
br i1 %32, label %10, label %33
33: ; preds = %26, %0
%34 = phi i32 [ 0, %0 ], [ %27, %26 ]
%35 = phi i32 [ 0, %0 ], [ %28, %26 ]
%36 = phi i32 [ 0, %0 ], [ %29, %26 ]
%37 = add i32 %35, %34
%38 = add i32 %37, %36
%39 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i32 %38)
%40 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0), i32 %36)
%41 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0), i32 %34)
%42 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.5, i64 0, i64 0), i32 %35)
%43 = sitofp i32 %36 to double
%44 = fmul double %43, 1.000000e+02
%45 = sitofp i32 %38 to double
%46 = fdiv double %44, %45
%47 = fptosi double %46 to i32
%48 = call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.6, i64 0, i64 0), i32 %47)
%49 = sitofp i32 %34 to double
%50 = fmul double %49, 1.000000e+02
%51 = fdiv double %50, %45
%52 = fptosi double %51 to i32
%53 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.7, i64 0, i64 0), i32 %52)
%54 = sitofp i32 %35 to double
%55 = fmul double %54, 1.000000e+02
%56 = fdiv double %55, %45
%57 = fptosi double %56 to i32
%58 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.8, i64 0, i64 0), i32 %57)
ret i32 0
}