#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 /*<<< orphan*/ scanf(char *, char *, int *);
int main() {
  int credito = 0, soma_credito = 0, soma_nota = 0;
  double cr;
  char conceito;
  while (conceito != '*') {
    soma_credito = soma_credito + credito;
    scanf("%c %d\n", &conceito, &credito);
    if (conceito == 'A')
      soma_nota = soma_nota + (4 * credito);
    else if (conceito == 'B')
      soma_nota = soma_nota + (3 * credito);
    else if (conceito == 'C')
      soma_nota = soma_nota + (2 * credito);
    else if (conceito == 'D')
      soma_nota = soma_nota + credito;
  }
  cr = (double)soma_nota / soma_credito;
  if (soma_credito == 0)
    printf("CR = Indefinido\n");
  else
    printf("CR = %.4f\n", cr);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
movsbl -0x19(%rbp),%eax
cmp    $0x2a,%eax
je     11f6 <main+0xd6>
mov    -0xc(%rbp),%eax
add    -0x8(%rbp),%eax
mov    %eax,-0xc(%rbp)
lea    0xe9f(%rip),%rdi
lea    -0x19(%rbp),%rsi
lea    -0x8(%rbp),%rdx
call   1040 <scanf@plt>
movsbl -0x19(%rbp),%eax
cmp    $0x41,%eax
jne    118e <main+0x6e>
mov    -0x10(%rbp),%eax
mov    -0x8(%rbp),%ecx
shl    $0x2,%ecx
add    %ecx,%eax
mov    %eax,-0x10(%rbp)
jmp    11f1 <main+0xd1>
movsbl -0x19(%rbp),%eax
cmp    $0x42,%eax
jne    11ac <main+0x8c>
mov    -0x10(%rbp),%eax
imul   $0x3,-0x8(%rbp),%ecx
add    %ecx,%eax
mov    %eax,-0x10(%rbp)
jmp    11ec <main+0xcc>
movsbl -0x19(%rbp),%eax
cmp    $0x43,%eax
jne    11cc <main+0xac>
mov    -0x10(%rbp),%eax
mov    -0x8(%rbp),%ecx
shl    $0x1,%ecx
add    %ecx,%eax
mov    %eax,-0x10(%rbp)
jmp    11e7 <main+0xc7>
movsbl -0x19(%rbp),%eax
cmp    $0x44,%eax
jne    11e2 <main+0xc2>
mov    -0x10(%rbp),%eax
add    -0x8(%rbp),%eax
mov    %eax,-0x10(%rbp)
jmp    11e7 <main+0xc7>
jmp    11ec <main+0xcc>
jmp    11f1 <main+0xd1>
jmp    1144 <main+0x24>
cvtsi2sdl -0x10(%rbp),%xmm0
cvtsi2sdl -0xc(%rbp),%xmm1
divsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
cmpl   $0x0,-0xc(%rbp)
jne    1226 <main+0x106>
lea    0xded(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1239 <main+0x119>
movsd  -0x18(%rbp),%xmm0
lea    0xde6(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
movl   $0x0,0x4(%rsp)
xor    %ebx,%ebx
lea    0xf20(%rip),%r14
lea    0x3(%rsp),%r15
lea    0x4(%rsp),%r12
lea    0xea3(%rip),%r13
xor    %ebp,%ebp
jmp    1169 <main+0x39>
add    0x4(%rsp),%ebx
add    0x4(%rsp),%ebp
mov    %r14,%rdi
mov    %r15,%rsi
mov    %r12,%rdx
call   1050 <scanf@plt>
movzbl 0x3(%rsp),%eax
add    $0xd6,%al
cmp    $0x1a,%al
ja     1165 <main+0x35>
movzbl %al,%eax
movslq 0x0(%r13,%rax,4),%rax
add    %r13,%rax
jmp    *%rax
mov    0x4(%rsp),%eax
lea    (%rbx,%rax,4),%ebx
add    0x4(%rsp),%ebp
jmp    1169 <main+0x39>
mov    0x4(%rsp),%eax
lea    (%rax,%rax,2),%eax
add    %ebx,%eax
mov    %eax,%ebx
add    0x4(%rsp),%ebp
jmp    1169 <main+0x39>
mov    0x4(%rsp),%eax
lea    (%rbx,%rax,2),%ebx
add    0x4(%rsp),%ebp
jmp    1169 <main+0x39>
test   %ebp,%ebp
je     11da <main+0xaa>
cvtsi2sd %ebx,%xmm0
cvtsi2sd %ebp,%xmm1
divsd  %xmm1,%xmm0
lea    0xea2(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
jmp    11e6 <main+0xb6>
lea    0xe9d(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [7 x i8] c"%c %d\0A\00"
@.str.2 = [11 x i8] c"CR = %.4f\0A\00"
@str = [16 x i8] c"CR = Indefinido\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8
%3 = bitcast i32* %1 to i8*
store i32 0, i32* %1
br label %4
4: ; preds = %24, %0
%5 = phi i32 [ %25, %24 ], [ 0, %0 ]
%6 = phi i32 [ %27, %24 ], [ 0, %0 ]
%7 = call i32 @scanf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8* %2, i32* %1)
%8 = load i8, i8* %2
switch i8 %8, label %24 [
i8 65, label %9
i8 66, label %13
i8 67, label %17
i8 68, label %21
i8 42, label %28
]
9: ; preds = %4
%10 = load i32, i32* %1
%11 = shl nsw i32 %10, 2
%12 = add nsw i32 %11, %5
br label %24
13: ; preds = %4
%14 = load i32, i32* %1
%15 = mul nsw i32 %14, 3
%16 = add nsw i32 %15, %5
br label %24
17: ; preds = %4
%18 = load i32, i32* %1
%19 = shl nsw i32 %18, 1
%20 = add nsw i32 %19, %5
br label %24
21: ; preds = %4
%22 = load i32, i32* %1
%23 = add nsw i32 %22, %5
br label %24
24: ; preds = %4, %9, %17, %21, %13
%25 = phi i32 [ %23, %21 ], [ %20, %17 ], [ %16, %13 ], [ %12, %9 ], [ %5, %4 ]
%26 = load i32, i32* %1
%27 = add nsw i32 %26, %6
br label %4
28: ; preds = %4
%29 = icmp eq i32 %6, 0
br i1 %29, label %30, label %32
30: ; preds = %28
%31 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @str, i64 0, i64 0))
br label %37
32: ; preds = %28
%33 = sitofp i32 %5 to double
%34 = sitofp i32 %6 to double
%35 = fdiv double %33, %34
%36 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), double %35)
br label %37
37: ; preds = %32, %30
ret i32 0
}