#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() {
  float perc1, perc2;
  int votos1 = 0, votos2 = 0, voto;
  int continuar;
  float total = 0.00;
  do {
    printf("1-Candidato 1 \n");
    printf("2-Candidato 2 \n");
    printf("Escolha voto \n");
    scanf("%d", &voto);
    if (voto == 1) {
      votos1++;
    }
    if (voto == 2) {
      votos2++;
    }
    printf("\n Deseja continuar(1-s/0-n)");
    scanf("%d", &continuar);
  } while (continuar == 1);
  total = votos1 + votos2;
  perc1 = (votos1 / total);
  perc2 = (votos2 / total);
  printf("\nCandidato 1 com %.2f%%", perc1 * 100);
  printf("\nCandidato 2 com %.2f%% \n", perc2 * 100);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x20(%rbp)
lea    0xeb8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeba(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xebc(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xebd(%rip),%rdi
lea    -0x18(%rbp),%rsi
call   1040 <scanf@plt>
cmpl   $0x1,-0x18(%rbp)
jne    1192 <main+0x72>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
cmpl   $0x2,-0x18(%rbp)
jne    11a5 <main+0x85>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
lea    0xe8a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe79(%rip),%rdi
lea    -0x1c(%rbp),%rsi
call   1040 <scanf@plt>
cmpl   $0x1,-0x1c(%rbp)
je     1145 <main+0x25>
mov    -0x10(%rbp),%eax
add    -0x14(%rbp),%eax
cvtsi2ss %eax,%xmm0
movss  %xmm0,-0x20(%rbp)
cvtsi2ssl -0x10(%rbp),%xmm0
divss  -0x20(%rbp),%xmm0
movss  %xmm0,-0x8(%rbp)
cvtsi2ssl -0x14(%rbp),%xmm0
divss  -0x20(%rbp),%xmm0
movss  %xmm0,-0xc(%rbp)
movss  0xdfe(%rip),%xmm0
mulss  -0x8(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe40(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
movss  0xddf(%rip),%xmm0
mulss  -0xc(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe39(%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
lea    0xebf(%rip),%rbx
lea    0x14(%rsp),%r13
lea    0xeb6(%rip),%rbp
lea    0x10(%rsp),%r14
xor    %r12d,%r12d
xor    %r15d,%r15d
nopl   0x0(%rax)
lea    0xeee(%rip),%rdi
call   1030 <puts@plt>
lea    0xef1(%rip),%rdi
call   1030 <puts@plt>
lea    0xef4(%rip),%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
mov    %r13,%rsi
call   1050 <scanf@plt>
mov    0x14(%rsp),%eax
xor    %ecx,%ecx
cmp    $0x1,%eax
sete   %cl
add    %ecx,%r12d
xor    %ecx,%ecx
cmp    $0x2,%eax
sete   %cl
add    %ecx,%r15d
mov    %rbp,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1050 <scanf@plt>
cmpl   $0x1,0x10(%rsp)
je     1160 <main+0x30>
lea    (%r12,%r15,1),%eax
cvtsi2ss %eax,%xmm0
cvtsi2ss %r12d,%xmm1
divss  %xmm0,%xmm1
cvtsi2ss %r15d,%xmm2
divss  %xmm0,%xmm2
movss  %xmm2,0xc(%rsp)
mulss  0xe13(%rip),%xmm1
xorps  %xmm0,%xmm0
cvtss2sd %xmm1,%xmm0
lea    0xe28(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
movss  0xc(%rsp),%xmm0
mulss  0xdf0(%rip),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe20(%rip),%rdi
mov    $0x1,%al
call   1040 <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 = [16 x i8] c"1-Candidato 1 \0A\00"
@.str.1 = [16 x i8] c"2-Candidato 2 \0A\00"
@.str.2 = [15 x i8] c"Escolha voto \0A\00"
@.str.3 = [3 x i8] c"%d\00"
@.str.4 = [28 x i8] c"\0A Deseja continuar(1-s/0-n)\00"
@.str.5 = [24 x i8] c"\0ACandidato 1 com %.2f%%\00"
@.str.6 = [26 x i8] c"\0ACandidato 2 com %.2f%% \0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca float
%3 = alloca float
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca float
store i32 0, i32* %1
store i32 0, i32* %4
store i32 0, i32* %5
store float 0.000000e+00, float* %8
br label %9
9: ; preds = %28, %0
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0))
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0))
%13 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %6)
%14 = load i32, i32* %6
%15 = icmp eq i32 %14, 1
br i1 %15, label %16, label %19
16: ; preds = %9
%17 = load i32, i32* %4
%18 = add nsw i32 %17, 1
store i32 %18, i32* %4
br label %19
19: ; preds = %16, %9
%20 = load i32, i32* %6
%21 = icmp eq i32 %20, 2
br i1 %21, label %22, label %25
22: ; preds = %19
%23 = load i32, i32* %5
%24 = add nsw i32 %23, 1
store i32 %24, i32* %5
br label %25
25: ; preds = %22, %19
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.4, i64 0, i64 0))
%27 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %7)
br label %28
28: ; preds = %25
%29 = load i32, i32* %7
%30 = icmp eq i32 %29, 1
br i1 %30, label %9, label %31
31: ; preds = %28
%32 = load i32, i32* %4
%33 = load i32, i32* %5
%34 = add nsw i32 %32, %33
%35 = sitofp i32 %34 to float
store float %35, float* %8
%36 = load i32, i32* %4
%37 = sitofp i32 %36 to float
%38 = load float, float* %8
%39 = fdiv float %37, %38
store float %39, float* %2
%40 = load i32, i32* %5
%41 = sitofp i32 %40 to float
%42 = load float, float* %8
%43 = fdiv float %41, %42
store float %43, float* %3
%44 = load float, float* %2
%45 = fmul float %44, 1.000000e+02
%46 = fpext float %45 to double
%47 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.5, i64 0, i64 0), double %46)
%48 = load float, float* %3
%49 = fmul float %48, 1.000000e+02
%50 = fpext float %49 to double
%51 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.6, i64 0, i64 0), double %50)
ret i32 0
}

LLVM IR (-O2):
@.str.3 = [3 x i8] c"%d\00"
@.str.4 = [28 x i8] c"\0A Deseja continuar(1-s/0-n)\00"
@.str.5 = [24 x i8] c"\0ACandidato 1 com %.2f%%\00"
@.str.6 = [26 x i8] c"\0ACandidato 2 com %.2f%% \0A\00"
@str = [15 x i8] c"1-Candidato 1 \00"
@str.7 = [15 x i8] c"2-Candidato 2 \00"
@str.8 = [14 x i8] c"Escolha voto \00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = bitcast i32* %1 to i8*
%4 = bitcast i32* %2 to i8*
br label %5
5: ; preds = %5, %0
%6 = phi i32 [ 0, %0 ], [ %15, %5 ]
%7 = phi i32 [ 0, %0 ], [ %18, %5 ]
%8 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str, i64 0, i64 0))
%9 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str.7, i64 0, i64 0))
%10 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @str.8, i64 0, i64 0))
%11 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %1)
%12 = load i32, i32* %1
%13 = icmp eq i32 %12, 1
%14 = zext i1 %13 to i32
%15 = add nuw nsw i32 %6, %14
%16 = icmp eq i32 %12, 2
%17 = zext i1 %16 to i32
%18 = add nuw nsw i32 %7, %17
%19 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.4, i64 0, i64 0))
%20 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %2)
%21 = load i32, i32* %2
%22 = icmp eq i32 %21, 1
br i1 %22, label %5, label %23
23: ; preds = %5
%24 = add nuw nsw i32 %15, %18
%25 = sitofp i32 %24 to float
%26 = sitofp i32 %15 to float
%27 = fdiv float %26, %25
%28 = sitofp i32 %18 to float
%29 = fdiv float %28, %25
%30 = fmul float %27, 1.000000e+02
%31 = fpext float %30 to double
%32 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.5, i64 0, i64 0), double %31)
%33 = fmul float %29, 1.000000e+02
%34 = fpext float %33 to double
%35 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.6, i64 0, i64 0), double %34)
ret i32 0
}