#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 *, ...);
int main() {
  float votocand1 = 0, votocand2 = 0;
  int voto;
  char continuar;
  do {
    printf("\nEntre com o voto");
    printf("\n1 - Dilma");
    printf("\n2 - Aecio");
    printf("\nOpção: ");
    scanf("%d", &voto);
    if (voto == 1)
      votocand1++;
    else if (voto == 2)
      votocand2++;
    printf("\nDeseja continuar(s/n)?");
    scanf(" %c", &continuar);
  } while (continuar == 's' || continuar == 'S');
  printf("\nPercentagem de votos do candidato 1 = %.2f%%",
         ((votocand1 * 100) / (votocand1 + votocand2)));
  printf("\nPercentagem de votos do candidato 2 = %.2f%%",
         ((votocand2 * 100) / (votocand1 + votocand2)));
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x8(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0xc(%rbp)
lea    0xec2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xec6(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xec3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xec0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xebd(%rip),%rdi
lea    -0x10(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
cmpl   $0x1,-0x10(%rbp)
jne    11aa <main+0x8a>
movss  0xe65(%rip),%xmm0
addss  -0x8(%rbp),%xmm0
movss  %xmm0,-0x8(%rbp)
jmp    11cb <main+0xab>
cmpl   $0x2,-0x10(%rbp)
jne    11c6 <main+0xa6>
movss  0xe44(%rip),%xmm0
addss  -0xc(%rbp),%xmm0
movss  %xmm0,-0xc(%rbp)
jmp    11cb <main+0xab>
lea    0xe6c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe76(%rip),%rdi
lea    -0x11(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
movsbl -0x11(%rbp),%ecx
mov    $0x1,%al
cmp    $0x73,%ecx
mov    %al,-0x12(%rbp)
je     120a <main+0xea>
movsbl -0x11(%rbp),%eax
cmp    $0x53,%eax
sete   %al
mov    %al,-0x12(%rbp)
mov    -0x12(%rbp),%al
test   $0x1,%al
jne    113f <main+0x1f>
movss  0xde7(%rip),%xmm0
mulss  -0x8(%rbp),%xmm0
movss  -0x8(%rbp),%xmm1
addss  -0xc(%rbp),%xmm1
divss  %xmm1,%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe1f(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movss  0xdba(%rip),%xmm0
mulss  -0xc(%rbp),%xmm0
movss  -0x8(%rbp),%xmm1
addss  -0xc(%rbp),%xmm1
divss  %xmm1,%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe20(%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
sub    $0x18,%rsp
xorps  %xmm0,%xmm0
movss  %xmm0,0xc(%rsp)
lea    0xef2(%rip),%r13
lea    0xef6(%rip),%rbx
lea    0x14(%rsp),%rbp
lea    0xeed(%rip),%r14
lea    0xefe(%rip),%r15
lea    0xb(%rsp),%r12
xorps  %xmm0,%xmm0
movss  %xmm0,0x10(%rsp)
jmp    11a6 <main+0x86>
nopl   0x0(%rax,%rax,1)
movss  0x10(%rsp),%xmm0
addss  0xe82(%rip),%xmm0
movss  %xmm0,0x10(%rsp)
mov    %r14,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %r15,%rdi
mov    %r12,%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
movzbl 0xb(%rsp),%eax
and    $0xdf,%al
cmp    $0x53,%al
jne    120e <main+0xee>
lea    0xe5b(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xe5f(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xe5c(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %r13,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
mov    0x14(%rsp),%eax
cmp    $0x2,%eax
je     1170 <main+0x50>
cmp    $0x1,%eax
jne    1184 <main+0x64>
movss  0xc(%rsp),%xmm0
addss  0xdfd(%rip),%xmm0
movss  %xmm0,0xc(%rsp)
jmp    1184 <main+0x64>
movss  0xc(%rsp),%xmm1
movaps %xmm1,%xmm0
mulss  0xde5(%rip),%xmm0
addss  0x10(%rsp),%xmm1
movss  %xmm1,0xc(%rsp)
divss  %xmm1,%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe20(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movss  0x10(%rsp),%xmm0
mulss  0xdb5(%rip),%xmm0
divss  0xc(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe28(%rip),%rdi
mov    $0x1,%al
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 = [18 x i8] c"\0AEntre com o voto\00"
@.str.1 = [11 x i8] c"\0A1 - Dilma\00"
@.str.2 = [11 x i8] c"\0A2 - Aecio\00"
@.str.3 = [11 x i8] c"\0AOp\C3\A7\C3\A3o: \00"
@.str.4 = [3 x i8] c"%d\00"
@.str.5 = [24 x i8] c"\0ADeseja continuar(s/n)?\00"
@.str.6 = [4 x i8] c" %c\00"
@.str.7 = [46 x i8] c"\0APercentagem de votos do candidato 1 = %.2f%%\00"
@.str.8 = [46 x i8] c"\0APercentagem de votos do candidato 2 = %.2f%%\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca float
%3 = alloca float
%4 = alloca i32
%5 = alloca i8
store i32 0, i32* %1
store float 0.000000e+00, float* %2
store float 0.000000e+00, float* %3
br label %6
6: ; preds = %35, %0
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0))
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0))
%11 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %4)
%12 = load i32, i32* %4
%13 = icmp eq i32 %12, 1
br i1 %13, label %14, label %17
14: ; preds = %6
%15 = load float, float* %2
%16 = fadd float %15, 1.000000e+00
store float %16, float* %2
br label %24
17: ; preds = %6
%18 = load i32, i32* %4
%19 = icmp eq i32 %18, 2
br i1 %19, label %20, label %23
20: ; preds = %17
%21 = load float, float* %3
%22 = fadd float %21, 1.000000e+00
store float %22, float* %3
br label %23
23: ; preds = %20, %17
br label %24
24: ; preds = %23, %14
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.5, i64 0, i64 0))
%26 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i8* %5)
br label %27
27: ; preds = %24
%28 = load i8, i8* %5
%29 = sext i8 %28 to i32
%30 = icmp eq i32 %29, 115
br i1 %30, label %35, label %31
31: ; preds = %27
%32 = load i8, i8* %5
%33 = sext i8 %32 to i32
%34 = icmp eq i32 %33, 83
br label %35
35: ; preds = %31, %27
%36 = phi i1 [ true, %27 ], [ %34, %31 ]
br i1 %36, label %6, label %37
37: ; preds = %35
%38 = load float, float* %2
%39 = fmul float %38, 1.000000e+02
%40 = load float, float* %2
%41 = load float, float* %3
%42 = fadd float %40, %41
%43 = fdiv float %39, %42
%44 = fpext float %43 to double
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.7, i64 0, i64 0), double %44)
%46 = load float, float* %3
%47 = fmul float %46, 1.000000e+02
%48 = load float, float* %2
%49 = load float, float* %3
%50 = fadd float %48, %49
%51 = fdiv float %47, %50
%52 = fpext float %51 to double
%53 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.8, i64 0, i64 0), double %52)
ret i32 0
}

LLVM IR (-O2):
@.str = [18 x i8] c"\0AEntre com o voto\00"
@.str.1 = [11 x i8] c"\0A1 - Dilma\00"
@.str.2 = [11 x i8] c"\0A2 - Aecio\00"
@.str.3 = [11 x i8] c"\0AOp\C3\A7\C3\A3o: \00"
@.str.4 = [3 x i8] c"%d\00"
@.str.5 = [24 x i8] c"\0ADeseja continuar(s/n)?\00"
@.str.6 = [4 x i8] c" %c\00"
@.str.7 = [46 x i8] c"\0APercentagem de votos do candidato 1 = %.2f%%\00"
@.str.8 = [46 x i8] c"\0APercentagem de votos do candidato 2 = %.2f%%\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8
%3 = bitcast i32* %1 to i8*
br label %4
4: ; preds = %17, %0
%5 = phi float [ 0.000000e+00, %0 ], [ %18, %17 ]
%6 = phi float [ 0.000000e+00, %0 ], [ %19, %17 ]
%7 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
%8 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
%9 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0))
%10 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.3, i64 0, i64 0))
%11 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %1)
%12 = load i32, i32* %1
switch i32 %12, label %17 [
i32 1, label %13
i32 2, label %15
]
13: ; preds = %4
%14 = fadd float %5, 1.000000e+00
br label %17
15: ; preds = %4
%16 = fadd float %6, 1.000000e+00
br label %17
17: ; preds = %4, %15, %13
%18 = phi float [ %14, %13 ], [ %5, %15 ], [ %5, %4 ]
%19 = phi float [ %6, %13 ], [ %16, %15 ], [ %6, %4 ]
%20 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.5, i64 0, i64 0))
%21 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0), i8* %2)
%22 = load i8, i8* %2
%23 = and i8 %22, -33
%24 = icmp eq i8 %23, 83
br i1 %24, label %4, label %25
25: ; preds = %17
%26 = fmul float %18, 1.000000e+02
%27 = fadd float %18, %19
%28 = fdiv float %26, %27
%29 = fpext float %28 to double
%30 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([46 x i8], [46 x i8]* @.str.7, i64 0, i64 0), double %29)
%31 = fmul float %19, 1.000000e+02
%32 = fdiv float %31, %27
%33 = fpext float %32 to double
%34 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([46 x i8], [46 x i8]* @.str.8, i64 0, i64 0), double %33)
ret i32 0
}