#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 *, ...);
void main() {
  float somav = 0.0, somap = 0.0, valor;
  char cod;
  int i;
  for (i = 1; i <= 10; i++) {
    printf("\nCompra %d:\n", i);
    do {
      printf("Insira o codigo: ");
      scanf(" %c", &cod);
      if (cod != 'p' && cod != 'P' && cod != 'v' && cod != 'V')
        printf("Codigo incorreto. Tente novamente.\n");
    } while (cod != 'p' && cod != 'P' && cod != 'v' && cod != 'V');
    printf("Insira o valor da transacao: ");
    scanf(" %f", &valor);
    if (cod == 'v' || cod == 'V')
      somav += valor;
    if (cod == 'p' || cod == 'P')
      somap += valor;
  }
  printf("\nValor total das compras a vista: R$%.2f\n"
         "Valor total das compras a prazo: R$%.2f\n"
         "Valor total das compras efetuadas: R$%.2f\n",
         somav, somap, somav + somap);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
xorps  %xmm0,%xmm0
movss  %xmm0,-0x4(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x8(%rbp)
movl   $0x1,-0x14(%rbp)
cmpl   $0xa,-0x14(%rbp)
jg     1294 <main+0x174>
mov    -0x14(%rbp),%esi
lea    0xead(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeac(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeb0(%rip),%rdi
lea    -0xd(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
movsbl -0xd(%rbp),%eax
cmp    $0x70,%eax
je     11bc <main+0x9c>
movsbl -0xd(%rbp),%eax
cmp    $0x50,%eax
je     11bc <main+0x9c>
movsbl -0xd(%rbp),%eax
cmp    $0x76,%eax
je     11bc <main+0x9c>
movsbl -0xd(%rbp),%eax
cmp    $0x56,%eax
je     11bc <main+0x9c>
lea    0xe6e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11c1 <main+0xa1>
movsbl -0xd(%rbp),%ecx
xor    %eax,%eax
cmp    $0x70,%ecx
mov    %al,-0x15(%rbp)
je     1204 <main+0xe4>
movsbl -0xd(%rbp),%ecx
xor    %eax,%eax
cmp    $0x50,%ecx
mov    %al,-0x15(%rbp)
je     1204 <main+0xe4>
movsbl -0xd(%rbp),%ecx
xor    %eax,%eax
cmp    $0x76,%ecx
mov    %al,-0x15(%rbp)
je     1204 <main+0xe4>
movsbl -0xd(%rbp),%eax
cmp    $0x56,%eax
setne  %al
mov    %al,-0x15(%rbp)
mov    -0x15(%rbp),%al
test   $0x1,%al
jne    115a <main+0x3a>
lea    0xe31(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe41(%rip),%rdi
lea    -0xc(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
movsbl -0xd(%rbp),%eax
cmp    $0x76,%eax
je     1249 <main+0x129>
movsbl -0xd(%rbp),%eax
cmp    $0x56,%eax
jne    1258 <main+0x138>
movss  -0xc(%rbp),%xmm0
addss  -0x4(%rbp),%xmm0
movss  %xmm0,-0x4(%rbp)
movsbl -0xd(%rbp),%eax
cmp    $0x70,%eax
je     1272 <main+0x152>
movsbl -0xd(%rbp),%eax
cmp    $0x50,%eax
jne    1281 <main+0x161>
movss  -0xc(%rbp),%xmm0
addss  -0x8(%rbp),%xmm0
movss  %xmm0,-0x8(%rbp)
jmp    1286 <main+0x166>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    113f <main+0x1f>
movss  -0x4(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
movss  -0x8(%rbp),%xmm1
cvtss2sd %xmm1,%xmm1
movss  -0x4(%rbp),%xmm2
addss  -0x8(%rbp),%xmm2
cvtss2sd %xmm2,%xmm2
lea    0xdae(%rip),%rdi
mov    $0x3,%al
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
xorps  %xmm2,%xmm2
mov    $0x1,%ebx
lea    0xec4(%rip),%r15
lea    0xecf(%rip),%r12
lea    0xb(%rsp),%r13
lea    0xf65(%rip),%rbp
movabs $0x4100000041,%r14
xorps  %xmm3,%xmm3
jmp    1184 <main+0x54>
nop
addss  %xmm1,%xmm2
addss  %xmm0,%xmm3
add    $0x1,%ebx
cmp    $0xb,%ebx
je     124d <main+0x11d>
movss  %xmm3,0xc(%rsp)
movss  %xmm2,0x10(%rsp)
lea    0xe6d(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r12,%rdi
mov    %r13,%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
movzbl 0xb(%rsp),%eax
lea    -0x50(%rax),%ecx
cmp    $0x26,%cl
ja     11e0 <main+0xb0>
movzbl %cl,%ecx
bt     %rcx,%r14
jae    11e0 <main+0xb0>
add    $0xb0,%al
cmp    $0x26,%al
ja     11a0 <main+0x70>
movzbl %al,%eax
bt     %rax,%r14
jae    11a0 <main+0x70>
jmp    11f0 <main+0xc0>
xchg   %ax,%ax
mov    %rbp,%rdi
call   1030 <puts@plt>
movzbl 0xb(%rsp),%eax
jmp    11cd <main+0x9d>
nop
lea    0xe30(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe40(%rip),%rdi
lea    0x14(%rsp),%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
mov    0xb(%rsp),%al
and    $0xdf,%al
movss  0x14(%rsp),%xmm1
movaps %xmm1,%xmm0
cmp    $0x56,%al
je     122c <main+0xfc>
movss  0xdd4(%rip),%xmm0
cmp    $0x50,%al
movss  0x10(%rsp),%xmm2
movss  0xc(%rsp),%xmm3
je     1170 <main+0x40>
movss  0xdb8(%rip),%xmm1
jmp    1170 <main+0x40>
xorps  %xmm0,%xmm0
cvtss2sd %xmm3,%xmm0
xorps  %xmm1,%xmm1
cvtss2sd %xmm2,%xmm1
addss  %xmm2,%xmm3
xorps  %xmm2,%xmm2
cvtss2sd %xmm3,%xmm2
lea    0xddc(%rip),%rdi
mov    $0x3,%al
call   1040 <printf@plt>
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [13 x i8] c"\0ACompra %d:\0A\00"
@.str.1 = [18 x i8] c"Insira o codigo: \00"
@.str.2 = [4 x i8] c" %c\00"
@.str.3 = [36 x i8] c"Codigo incorreto. Tente novamente.\0A\00"
@.str.4 = [30 x i8] c"Insira o valor da transacao: \00"
@.str.5 = [4 x i8] c" %f\00"
@.str.6 = [124 x i8] c"\0AValor total das compras a vista: R$%.2f\0AValor total das compras a prazo: R$%.2f\0AValor total das compras efetuadas: R$%.2f\0A\00"
define void @main() {
%1 = alloca float
%2 = alloca float
%3 = alloca float
%4 = alloca i8
%5 = alloca i32
store float 0.000000e+00, float* %1
store float 0.000000e+00, float* %2
store i32 1, i32* %5
br label %6
6: ; preds = %78, %0
%7 = load i32, i32* %5
%8 = icmp sle i32 %7, 10
br i1 %8, label %9, label %81
9: ; preds = %6
%10 = load i32, i32* %5
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 %10)
br label %12
12: ; preds = %49, %9
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0))
%14 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %4)
%15 = load i8, i8* %4
%16 = sext i8 %15 to i32
%17 = icmp ne i32 %16, 112
br i1 %17, label %18, label %32
18: ; preds = %12
%19 = load i8, i8* %4
%20 = sext i8 %19 to i32
%21 = icmp ne i32 %20, 80
br i1 %21, label %22, label %32
22: ; preds = %18
%23 = load i8, i8* %4
%24 = sext i8 %23 to i32
%25 = icmp ne i32 %24, 118
br i1 %25, label %26, label %32
26: ; preds = %22
%27 = load i8, i8* %4
%28 = sext i8 %27 to i32
%29 = icmp ne i32 %28, 86
br i1 %29, label %30, label %32
30: ; preds = %26
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.3, i64 0, i64 0))
br label %32
32: ; preds = %30, %26, %22, %18, %12
br label %33
33: ; preds = %32
%34 = load i8, i8* %4
%35 = sext i8 %34 to i32
%36 = icmp ne i32 %35, 112
br i1 %36, label %37, label %49
37: ; preds = %33
%38 = load i8, i8* %4
%39 = sext i8 %38 to i32
%40 = icmp ne i32 %39, 80
br i1 %40, label %41, label %49
41: ; preds = %37
%42 = load i8, i8* %4
%43 = sext i8 %42 to i32
%44 = icmp ne i32 %43, 118
br i1 %44, label %45, label %49
45: ; preds = %41
%46 = load i8, i8* %4
%47 = sext i8 %46 to i32
%48 = icmp ne i32 %47, 86
br label %49
49: ; preds = %45, %41, %37, %33
%50 = phi i1 [ false, %41 ], [ false, %37 ], [ false, %33 ], [ %48, %45 ]
br i1 %50, label %12, label %51
51: ; preds = %49
%52 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.4, i64 0, i64 0))
%53 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), float* %3)
%54 = load i8, i8* %4
%55 = sext i8 %54 to i32
%56 = icmp eq i32 %55, 118
br i1 %56, label %61, label %57
57: ; preds = %51
%58 = load i8, i8* %4
%59 = sext i8 %58 to i32
%60 = icmp eq i32 %59, 86
br i1 %60, label %61, label %65
61: ; preds = %57, %51
%62 = load float, float* %3
%63 = load float, float* %1
%64 = fadd float %63, %62
store float %64, float* %1
br label %65
65: ; preds = %61, %57
%66 = load i8, i8* %4
%67 = sext i8 %66 to i32
%68 = icmp eq i32 %67, 112
br i1 %68, label %73, label %69
69: ; preds = %65
%70 = load i8, i8* %4
%71 = sext i8 %70 to i32
%72 = icmp eq i32 %71, 80
br i1 %72, label %73, label %77
73: ; preds = %69, %65
%74 = load float, float* %3
%75 = load float, float* %2
%76 = fadd float %75, %74
store float %76, float* %2
br label %77
77: ; preds = %73, %69
br label %78
78: ; preds = %77
%79 = load i32, i32* %5
%80 = add nsw i32 %79, 1
store i32 %80, i32* %5
br label %6
81: ; preds = %6
%82 = load float, float* %1
%83 = fpext float %82 to double
%84 = load float, float* %2
%85 = fpext float %84 to double
%86 = load float, float* %1
%87 = load float, float* %2
%88 = fadd float %86, %87
%89 = fpext float %88 to double
%90 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([124 x i8], [124 x i8]* @.str.6, i64 0, i64 0), double %83, double %85, double %89)
ret void
}

LLVM IR (-O2):
@.str = [13 x i8] c"\0ACompra %d:\0A\00"
@.str.1 = [18 x i8] c"Insira o codigo: \00"
@.str.2 = [4 x i8] c" %c\00"
@.str.4 = [30 x i8] c"Insira o valor da transacao: \00"
@.str.5 = [4 x i8] c" %f\00"
@.str.6 = [124 x i8] c"\0AValor total das compras a vista: R$%.2f\0AValor total das compras a prazo: R$%.2f\0AValor total das compras efetuadas: R$%.2f\0A\00"
@str = [35 x i8] c"Codigo incorreto. Tente novamente.\00"
define void @main() {
%1 = alloca float
%2 = alloca i8
%3 = bitcast float* %1 to i8*
br label %4
4: ; preds = %0, %18
%5 = phi i32 [ 1, %0 ], [ %30, %18 ]
%6 = phi float [ 0.000000e+00, %0 ], [ %29, %18 ]
%7 = phi float [ 0.000000e+00, %0 ], [ %26, %18 ]
%8 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i32 %5)
br label %9
9: ; preds = %16, %4
%10 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0))
%11 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %2)
%12 = load i8, i8* %2
switch i8 %12, label %13 [
i8 118, label %16
i8 112, label %16
i8 86, label %16
i8 80, label %16
]
13: ; preds = %9
%14 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @str, i64 0, i64 0))
%15 = load i8, i8* %2
br label %16
16: ; preds = %9, %9, %9, %9, %13
%17 = phi i8 [ %12, %9 ], [ %12, %9 ], [ %12, %9 ], [ %12, %9 ], [ %15, %13 ]
switch i8 %17, label %9 [
i8 118, label %18
i8 112, label %18
i8 86, label %18
i8 80, label %18
]
18: ; preds = %16, %16, %16, %16
%19 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.4, i64 0, i64 0))
%20 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), float* %1)
%21 = load i8, i8* %2
%22 = and i8 %21, -33
%23 = icmp eq i8 %22, 86
%24 = load float, float* %1
%25 = select i1 %23, float %24, float -0.000000e+00
%26 = fadd float %7, %25
%27 = icmp eq i8 %22, 80
%28 = select i1 %27, float %24, float -0.000000e+00
%29 = fadd float %6, %28
%30 = add nuw nsw i32 %5, 1
%31 = icmp eq i32 %30, 11
br i1 %31, label %32, label %4
32: ; preds = %18
%33 = fpext float %26 to double
%34 = fpext float %29 to double
%35 = fadd float %26, %29
%36 = fpext float %35 to double
%37 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([124 x i8], [124 x i8]* @.str.6, i64 0, i64 0), double %33, double %34, double %36)
ret void
}