#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);
int /*<<< orphan*/ scanf(char *, int *, ...);
int main() {
  int testsQtt;
  scanf("%d", &testsQtt);
  int i;
  char animalType;
  int animalAmount;
  int totalQtt = 0, cQtt = 0, rQtt = 0, sQtt = 0;
  for (i = 0; i < testsQtt; i++) {
    scanf("%d %c", &animalAmount, &animalType);
    if (animalType == 'C')
      cQtt += animalAmount;
    else if (animalType == 'R')
      rQtt += animalAmount;
    else if (animalType == 'S')
      sQtt += animalAmount;
    totalQtt += animalAmount;
  }
  printf("Total: %d cobaias\n", totalQtt);
  printf("Total de coelhos: %d\n", cQtt);
  printf("Total de ratos: %d\n", rQtt);
  printf("Total de sapos: %d\n", sQtt);
  printf("Percentual de coelhos: %.2f %%\n", ((100.0 / totalQtt) * cQtt));
  printf("Percentual de ratos: %.2f %%\n", ((100.0 / totalQtt) * rQtt));
  printf("Percentual de sapos: %.2f %%\n", ((100.0 / totalQtt) * sQtt));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xed2(%rip),%rdi
lea    -0x8(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
movl   $0x0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11f3 <main+0xd3>
lea    0xe94(%rip),%rdi
lea    -0x14(%rbp),%rsi
lea    -0xd(%rbp),%rdx
mov    $0x0,%al
call   1040 <scanf@plt>
movsbl -0xd(%rbp),%eax
cmp    $0x43,%eax
jne    11a1 <main+0x81>
mov    -0x14(%rbp),%eax
add    -0x1c(%rbp),%eax
mov    %eax,-0x1c(%rbp)
jmp    11dc <main+0xbc>
movsbl -0xd(%rbp),%eax
cmp    $0x52,%eax
jne    11bc <main+0x9c>
mov    -0x14(%rbp),%eax
add    -0x20(%rbp),%eax
mov    %eax,-0x20(%rbp)
jmp    11d7 <main+0xb7>
movsbl -0xd(%rbp),%eax
cmp    $0x53,%eax
jne    11d2 <main+0xb2>
mov    -0x14(%rbp),%eax
add    -0x24(%rbp),%eax
mov    %eax,-0x24(%rbp)
jmp    11d7 <main+0xb7>
jmp    11dc <main+0xbc>
mov    -0x14(%rbp),%eax
add    -0x18(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1164 <main+0x44>
cvtsi2sdl -0x18(%rbp),%xmm0
lea    0xe12(%rip),%rdi
call   1030 <printf@plt>
cvtsi2sdl -0x1c(%rbp),%xmm0
lea    0xe14(%rip),%rdi
call   1030 <printf@plt>
cvtsi2sdl -0x20(%rbp),%xmm0
lea    0xe19(%rip),%rdi
call   1030 <printf@plt>
cvtsi2sdl -0x24(%rbp),%xmm0
lea    0xe1c(%rip),%rdi
call   1030 <printf@plt>
cvtsi2sdl -0x18(%rbp),%xmm1
movsd  0xdbc(%rip),%xmm0
divsd  %xmm1,%xmm0
cvtsi2sdl -0x1c(%rbp),%xmm1
mulsd  %xmm1,%xmm0
lea    0xe0a(%rip),%rdi
call   1030 <printf@plt>
cvtsi2sdl -0x18(%rbp),%xmm1
movsd  0xd96(%rip),%xmm0
divsd  %xmm1,%xmm0
cvtsi2sdl -0x20(%rbp),%xmm1
mulsd  %xmm1,%xmm0
lea    0xe04(%rip),%rdi
call   1030 <printf@plt>
cvtsi2sdl -0x18(%rbp),%xmm1
movsd  0xd70(%rip),%xmm0
divsd  %xmm1,%xmm0
cvtsi2sdl -0x24(%rbp),%xmm1
mulsd  %xmm1,%xmm0
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    $0x38,%rsp
lea    0xed3(%rip),%rdi
xor    %r14d,%r14d
lea    0x14(%rsp),%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
cmpl   $0x0,0x14(%rsp)
jle    11e0 <main+0xc0>
lea    0xf(%rsp),%rbx
xor    %ebp,%ebp
xor    %r15d,%r15d
xor    %r14d,%r14d
xor    %r12d,%r12d
xor    %r13d,%r13d
jmp    1184 <main+0x64>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    0x10(%rsp),%eax
add    %eax,%ebp
add    %eax,%r12d
add    $0x1,%r13d
cmp    0x14(%rsp),%r13d
jge    11d9 <main+0xb9>
lea    0xe80(%rip),%rdi
lea    0x10(%rsp),%rsi
mov    %rbx,%rdx
xor    %eax,%eax
call   1040 <scanf@plt>
movzbl 0xf(%rsp),%eax
cmp    $0x43,%al
je     11c0 <main+0xa0>
cmp    $0x52,%al
je     11d0 <main+0xb0>
cmp    $0x53,%al
je     1170 <main+0x50>
mov    0x10(%rsp),%eax
jmp    1176 <main+0x56>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    0x10(%rsp),%eax
add    %eax,%r14d
jmp    1176 <main+0x56>
nopl   0x0(%rax)
mov    0x10(%rsp),%eax
add    %eax,%r15d
jmp    1176 <main+0x56>
cvtsi2sd %r12d,%xmm0
jmp    11e9 <main+0xc9>
xorpd  %xmm0,%xmm0
xor    %r15d,%r15d
xor    %ebp,%ebp
lea    0xe21(%rip),%rdi
movsd  %xmm0,0x18(%rsp)
call   1030 <printf@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %r14d,%xmm0
movsd  %xmm0,0x20(%rsp)
lea    0xe14(%rip),%rdi
call   1030 <printf@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %r15d,%xmm0
movsd  %xmm0,0x28(%rsp)
lea    0xe10(%rip),%rdi
call   1030 <printf@plt>
xorps  %xmm0,%xmm0
cvtsi2sd %ebp,%xmm0
movsd  %xmm0,0x30(%rsp)
lea    0xe0b(%rip),%rdi
call   1030 <printf@plt>
movsd  0xdb0(%rip),%xmm1
divsd  0x18(%rsp),%xmm1
movsd  %xmm1,0x18(%rsp)
movsd  0x20(%rsp),%xmm0
mulsd  %xmm1,%xmm0
lea    0xdf5(%rip),%rdi
call   1030 <printf@plt>
movsd  0x28(%rsp),%xmm0
mulsd  0x18(%rsp),%xmm0
lea    0xdfd(%rip),%rdi
call   1030 <printf@plt>
movsd  0x18(%rsp),%xmm0
mulsd  0x30(%rsp),%xmm0
lea    0xe03(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@.str.1 = [6 x i8] c"%d %c\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 i8
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i32 0, i32* %1
%10 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
store i32 0, i32* %6
store i32 0, i32* %7
store i32 0, i32* %8
store i32 0, i32* %9
store i32 0, i32* %3
br label %11
11: ; preds = %46, %0
%12 = load i32, i32* %3
%13 = load i32, i32* %2
%14 = icmp slt i32 %12, %13
br i1 %14, label %15, label %49
15: ; preds = %11
%16 = call i32 (i8*, i32*, ...) @scanf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32* %5, i8* %4)
%17 = load i8, i8* %4
%18 = sext i8 %17 to i32
%19 = icmp eq i32 %18, 67
br i1 %19, label %20, label %24
20: ; preds = %15
%21 = load i32, i32* %5
%22 = load i32, i32* %7
%23 = add nsw i32 %22, %21
store i32 %23, i32* %7
br label %42
24: ; preds = %15
%25 = load i8, i8* %4
%26 = sext i8 %25 to i32
%27 = icmp eq i32 %26, 82
br i1 %27, label %28, label %32
28: ; preds = %24
%29 = load i32, i32* %5
%30 = load i32, i32* %8
%31 = add nsw i32 %30, %29
store i32 %31, i32* %8
br label %41
32: ; preds = %24
%33 = load i8, i8* %4
%34 = sext i8 %33 to i32
%35 = icmp eq i32 %34, 83
br i1 %35, label %36, label %40
36: ; preds = %32
%37 = load i32, i32* %5
%38 = load i32, i32* %9
%39 = add nsw i32 %38, %37
store i32 %39, i32* %9
br label %40
40: ; preds = %36, %32
br label %41
41: ; preds = %40, %28
br label %42
42: ; preds = %41, %20
%43 = load i32, i32* %5
%44 = load i32, i32* %6
%45 = add nsw i32 %44, %43
store i32 %45, i32* %6
br label %46
46: ; preds = %42
%47 = load i32, i32* %3
%48 = add nsw i32 %47, 1
store i32 %48, i32* %3
br label %11
49: ; preds = %11
%50 = load i32, i32* %6
%51 = sitofp i32 %50 to double
%52 = call i32 @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), double %51)
%53 = load i32, i32* %7
%54 = sitofp i32 %53 to double
%55 = call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0), double %54)
%56 = load i32, i32* %8
%57 = sitofp i32 %56 to double
%58 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0), double %57)
%59 = load i32, i32* %9
%60 = sitofp i32 %59 to double
%61 = call i32 @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.5, i64 0, i64 0), double %60)
%62 = load i32, i32* %6
%63 = sitofp i32 %62 to double
%64 = fdiv double 1.000000e+02, %63
%65 = load i32, i32* %7
%66 = sitofp i32 %65 to double
%67 = fmul double %64, %66
%68 = call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.6, i64 0, i64 0), double %67)
%69 = load i32, i32* %6
%70 = sitofp i32 %69 to double
%71 = fdiv double 1.000000e+02, %70
%72 = load i32, i32* %8
%73 = sitofp i32 %72 to double
%74 = fmul double %71, %73
%75 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.7, i64 0, i64 0), double %74)
%76 = load i32, i32* %6
%77 = sitofp i32 %76 to double
%78 = fdiv double 1.000000e+02, %77
%79 = load i32, i32* %9
%80 = sitofp i32 %79 to double
%81 = fmul double %78, %80
%82 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.8, i64 0, i64 0), double %81)
ret i32 0
}

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