#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 *);
int main() {
  int candidato1 = 0, candidato2 = 0, total = 0, voto = 0;
  float perc1, perc2;
  int continua = 0;
  do {
    printf("\n ---------- Eleicao 2015 --------");
    printf("\n 1 - Candidato 1");
    printf("\n 2 - Candidato 2");
    printf("\n -----------------");
    printf("\n Escolha seu voto:");
    scanf("%d", &voto);
    if (voto == 1) {
      candidato1++;
      total++;
    } else if (voto == 2) {
      candidato2++;
      total++;
    }
    printf("\nDeseja continuar?(1-Sim/0-Nao)");
    scanf("%d", &continua);
  } while (continua == 1);
  perc1 = ((float)candidato1 / total) * 100.00;
  perc2 = ((float)candidato2 / total) * 100.00;
  printf("\n Fim das eleicoes");
  printf("\n Candidato 1 com %.2f%% dos votos", perc1);
  printf("\n Candidato 2 com %.2f%% dos votos", perc2);
  printf("\n Total de votos %d", total);
  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)
movl   $0x0,-0x14(%rbp)
movl   $0x0,-0x20(%rbp)
lea    0xeaf(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xec4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xec8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xecc(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xed2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf62(%rip),%rdi
lea    -0x14(%rbp),%rsi
call   1040 <scanf@plt>
cmpl   $0x1,-0x14(%rbp)
jne    11c9 <main+0xa9>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    11ea <main+0xca>
cmpl   $0x2,-0x14(%rbp)
jne    11e5 <main+0xc5>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    11ea <main+0xca>
lea    0xe86(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf02(%rip),%rdi
lea    -0x20(%rbp),%rsi
call   1040 <scanf@plt>
cmpl   $0x1,-0x20(%rbp)
je     1152 <main+0x32>
cvtsi2ssl -0x8(%rbp),%xmm0
cvtsi2ssl -0x10(%rbp),%xmm1
divss  %xmm1,%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xdd4(%rip),%xmm1
mulsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x18(%rbp)
cvtsi2ssl -0xc(%rbp),%xmm0
cvtsi2ssl -0x10(%rbp),%xmm1
divss  %xmm1,%xmm0
cvtss2sd %xmm0,%xmm0
movsd  0xdad(%rip),%xmm1
mulsd  %xmm1,%xmm0
cvtsd2ss %xmm0,%xmm0
movss  %xmm0,-0x1c(%rbp)
lea    0xe30(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movss  -0x18(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe2c(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movss  -0x1c(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe38(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%esi
lea    0xe4a(%rip),%rdi
mov    $0x0,%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
movl   $0x0,0xc(%rsp)
movl   $0x0,0x8(%rsp)
lea    0xfb8(%rip),%r14
lea    0xf27(%rip),%r12
lea    0x8(%rsp),%r13
xor    %ebx,%ebx
xor    %ebp,%ebp
xor    %r15d,%r15d
jmp    1182 <main+0x62>
nopw   0x0(%rax,%rax,1)
add    $0x1,%ebp
add    $0x1,%ebx
mov    %r12,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %r14,%rdi
mov    %r13,%rsi
call   1040 <scanf@plt>
cmpl   $0x1,0x8(%rsp)
jne    11ec <main+0xcc>
lea    0xe7b(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xe90(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xe94(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xe98(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xe9e(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %r14,%rdi
lea    0xc(%rsp),%rsi
call   1040 <scanf@plt>
mov    0xc(%rsp),%eax
cmp    $0x2,%eax
je     1160 <main+0x40>
cmp    $0x1,%eax
jne    1166 <main+0x46>
add    $0x1,%r15d
jmp    1163 <main+0x43>
cvtsi2ss %r15d,%xmm3
cvtsi2ss %ebx,%xmm0
divss  %xmm0,%xmm3
cvtsi2ss %ebp,%xmm2
movss  0xdfb(%rip),%xmm1
mulss  %xmm1,%xmm3
movss  %xmm3,0x10(%rsp)
divss  %xmm0,%xmm2
mulss  %xmm1,%xmm2
movss  %xmm2,0x14(%rsp)
lea    0xe6f(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
movss  0x10(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe6a(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movss  0x14(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe75(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
lea    0xe8a(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
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 = [35 x i8] c"\0A ---------- Eleicao 2015 --------\00"
@.str.1 = [18 x i8] c"\0A 1 - Candidato 1\00"
@.str.2 = [18 x i8] c"\0A 2 - Candidato 2\00"
@.str.3 = [20 x i8] c"\0A -----------------\00"
@.str.4 = [20 x i8] c"\0A Escolha seu voto:\00"
@.str.5 = [3 x i8] c"%d\00"
@.str.6 = [32 x i8] c"\0ADeseja continuar?(1-Sim/0-Nao)\00"
@.str.7 = [19 x i8] c"\0A Fim das eleicoes\00"
@.str.8 = [35 x i8] c"\0A Candidato 1 com %.2f%% dos votos\00"
@.str.9 = [35 x i8] c"\0A Candidato 2 com %.2f%% dos votos\00"
@.str.10 = [20 x i8] c"\0A Total de votos %d\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca float
%7 = alloca float
%8 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %2
store i32 0, i32* %3
store i32 0, i32* %4
store i32 0, i32* %5
store i32 0, i32* %8
br label %9
9: ; preds = %35, %0
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0))
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0))
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0))
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0))
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0))
%15 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32* %5)
%16 = load i32, i32* %5
%17 = icmp eq i32 %16, 1
br i1 %17, label %18, label %23
18: ; preds = %9
%19 = load i32, i32* %2
%20 = add nsw i32 %19, 1
store i32 %20, i32* %2
%21 = load i32, i32* %4
%22 = add nsw i32 %21, 1
store i32 %22, i32* %4
br label %32
23: ; preds = %9
%24 = load i32, i32* %5
%25 = icmp eq i32 %24, 2
br i1 %25, label %26, label %31
26: ; preds = %23
%27 = load i32, i32* %3
%28 = add nsw i32 %27, 1
store i32 %28, i32* %3
%29 = load i32, i32* %4
%30 = add nsw i32 %29, 1
store i32 %30, i32* %4
br label %31
31: ; preds = %26, %23
br label %32
32: ; preds = %31, %18
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.6, i64 0, i64 0))
%34 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32* %8)
br label %35
35: ; preds = %32
%36 = load i32, i32* %8
%37 = icmp eq i32 %36, 1
br i1 %37, label %9, label %38
38: ; preds = %35
%39 = load i32, i32* %2
%40 = sitofp i32 %39 to float
%41 = load i32, i32* %4
%42 = sitofp i32 %41 to float
%43 = fdiv float %40, %42
%44 = fpext float %43 to double
%45 = fmul double %44, 1.000000e+02
%46 = fptrunc double %45 to float
store float %46, float* %6
%47 = load i32, i32* %3
%48 = sitofp i32 %47 to float
%49 = load i32, i32* %4
%50 = sitofp i32 %49 to float
%51 = fdiv float %48, %50
%52 = fpext float %51 to double
%53 = fmul double %52, 1.000000e+02
%54 = fptrunc double %53 to float
store float %54, float* %7
%55 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.7, i64 0, i64 0))
%56 = load float, float* %6
%57 = fpext float %56 to double
%58 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.8, i64 0, i64 0), double %57)
%59 = load float, float* %7
%60 = fpext float %59 to double
%61 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.9, i64 0, i64 0), double %60)
%62 = load i32, i32* %4
%63 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.10, i64 0, i64 0), i32 %62)
ret i32 0
}

LLVM IR (-O2):
@.str = [35 x i8] c"\0A ---------- Eleicao 2015 --------\00"
@.str.1 = [18 x i8] c"\0A 1 - Candidato 1\00"
@.str.2 = [18 x i8] c"\0A 2 - Candidato 2\00"
@.str.3 = [20 x i8] c"\0A -----------------\00"
@.str.4 = [20 x i8] c"\0A Escolha seu voto:\00"
@.str.5 = [3 x i8] c"%d\00"
@.str.6 = [32 x i8] c"\0ADeseja continuar?(1-Sim/0-Nao)\00"
@.str.7 = [19 x i8] c"\0A Fim das eleicoes\00"
@.str.8 = [35 x i8] c"\0A Candidato 1 com %.2f%% dos votos\00"
@.str.9 = [35 x i8] c"\0A Candidato 2 com %.2f%% dos votos\00"
@.str.10 = [20 x i8] c"\0A Total de votos %d\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = bitcast i32* %1 to i8*
store i32 0, i32* %1
%4 = bitcast i32* %2 to i8*
store i32 0, i32* %2
br label %5
5: ; preds = %22, %0
%6 = phi i32 [ 0, %0 ], [ %23, %22 ]
%7 = phi i32 [ 0, %0 ], [ %24, %22 ]
%8 = phi i32 [ 0, %0 ], [ %25, %22 ]
%9 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0))
%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*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0))
%12 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0))
%13 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0))
%14 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32* %1)
%15 = load i32, i32* %1
switch i32 %15, label %22 [
i32 1, label %16
i32 2, label %19
]
16: ; preds = %5
%17 = add nsw i32 %8, 1
%18 = add nsw i32 %6, 1
br label %22
19: ; preds = %5
%20 = add nsw i32 %7, 1
%21 = add nsw i32 %6, 1
br label %22
22: ; preds = %5, %19, %16
%23 = phi i32 [ %18, %16 ], [ %21, %19 ], [ %6, %5 ]
%24 = phi i32 [ %7, %16 ], [ %20, %19 ], [ %7, %5 ]
%25 = phi i32 [ %17, %16 ], [ %8, %19 ], [ %8, %5 ]
%26 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str.6, i64 0, i64 0))
%27 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), i32* %2)
%28 = load i32, i32* %2
%29 = icmp eq i32 %28, 1
br i1 %29, label %5, label %30
30: ; preds = %22
%31 = sitofp i32 %25 to float
%32 = sitofp i32 %23 to float
%33 = fdiv float %31, %32
%34 = fmul float %33, 1.000000e+02
%35 = sitofp i32 %24 to float
%36 = fdiv float %35, %32
%37 = fmul float %36, 1.000000e+02
%38 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.7, i64 0, i64 0))
%39 = fpext float %34 to double
%40 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str.8, i64 0, i64 0), double %39)
%41 = fpext float %37 to double
%42 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str.9, i64 0, i64 0), double %41)
%43 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.10, i64 0, i64 0), i32 %23)
ret i32 0
}