#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 count[6] = {0, 0, 0, 0, 0, 0};
  int i = 1;
  while (i) {
    printf("Enter Your Vote(0 to quit): ");
    scanf("%d", &i);
    if (i > 0 && i < 6)
      count[i - 1]++;
    else
      count[5]++;
  }
  for (i = 0; i < 5; i++) {
    printf("No. of Votes for Candidate %d is: %d \n", i + 1, count[i]);
  }
  printf("No. of Spoilt Votes is: %d \n", count[5] - 1);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x20(%rbp),%rdi
xor    %esi,%esi
mov    $0x18,%edx
call   1040 <memset@plt>
movl   $0x1,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
je     11b8 <main+0x88>
lea    0xe99(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xea8(%rip),%rdi
lea    -0x24(%rbp),%rsi
call   1050 <scanf@plt>
cmpl   $0x0,-0x24(%rbp)
jle    11aa <main+0x7a>
cmpl   $0x6,-0x24(%rbp)
jge    11aa <main+0x7a>
mov    -0x24(%rbp),%eax
sub    $0x1,%eax
cltq
mov    -0x20(%rbp,%rax,4),%ecx
add    $0x1,%ecx
mov    %ecx,-0x20(%rbp,%rax,4)
jmp    11b3 <main+0x83>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1156 <main+0x26>
movl   $0x0,-0x24(%rbp)
cmpl   $0x5,-0x24(%rbp)
jge    11f3 <main+0xc3>
mov    -0x24(%rbp),%esi
add    $0x1,%esi
movslq -0x24(%rbp),%rax
mov    -0x20(%rbp,%rax,4),%edx
lea    0xe42(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    11bf <main+0x8f>
mov    -0xc(%rbp),%esi
sub    $0x1,%esi
lea    0xe47(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x28,%rsp
xorps  %xmm0,%xmm0
movaps %xmm0,0x10(%rsp)
movq   $0x0,0x20(%rsp)
movl   $0x1,0xc(%rsp)
lea    0x24(%rsp),%r12
lea    0xeb0(%rip),%r14
lea    0xec6(%rip),%r15
lea    0xc(%rsp),%rbx
nopl   0x0(%rax)
mov    %r14,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1040 <scanf@plt>
mov    0xc(%rsp),%eax
lea    -0x1(%rax),%ecx
cmp    $0x5,%ecx
lea    0x10(%rsp,%rcx,4),%rcx
cmovae %r12,%rcx
addl   $0x1,(%rcx)
cmp    $0x1,%eax
jae    1160 <main+0x40>
movl   $0x0,0xc(%rsp)
lea    0xe81(%rip),%rbx
xor    %esi,%esi
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
movslq %esi,%rax
add    $0x1,%esi
mov    0x10(%rsp,%rax,4),%edx
mov    %rbx,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0xc(%rsp),%eax
lea    0x1(%rax),%esi
mov    %esi,0xc(%rsp)
cmp    $0x4,%eax
jl     11b0 <main+0x90>
mov    0x24(%rsp),%esi
add    $0xffffffff,%esi
lea    0xe65(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [29 x i8] c"Enter Your Vote(0 to quit): \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [39 x i8] c"No. of Votes for Candidate %d is: %d \0A\00"
@.str.3 = [29 x i8] c"No. of Spoilt Votes is: %d \0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [6 x i32]
%3 = alloca i32
store i32 0, i32* %1
%4 = bitcast [6 x i32]* %2 to i8*
store i32 1, i32* %3
br label %5
5: ; preds = %27, %0
%6 = load i32, i32* %3
%7 = icmp ne i32 %6, 0
br i1 %7, label %8, label %28
8: ; preds = %5
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
%10 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%11 = load i32, i32* %3
%12 = icmp sgt i32 %11, 0
br i1 %12, label %13, label %23
13: ; preds = %8
%14 = load i32, i32* %3
%15 = icmp slt i32 %14, 6
br i1 %15, label %16, label %23
16: ; preds = %13
%17 = load i32, i32* %3
%18 = sub nsw i32 %17, 1
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds [6 x i32], [6 x i32]* %2, i64 0, i64 %19
%21 = load i32, i32* %20
%22 = add nsw i32 %21, 1
store i32 %22, i32* %20
br label %27
23: ; preds = %13, %8
%24 = getelementptr inbounds [6 x i32], [6 x i32]* %2, i64 0, i64 5
%25 = load i32, i32* %24
%26 = add nsw i32 %25, 1
store i32 %26, i32* %24
br label %27
27: ; preds = %23, %16
br label %5
28: ; preds = %5
store i32 0, i32* %3
br label %29
29: ; preds = %40, %28
%30 = load i32, i32* %3
%31 = icmp slt i32 %30, 5
br i1 %31, label %32, label %43
32: ; preds = %29
%33 = load i32, i32* %3
%34 = add nsw i32 %33, 1
%35 = load i32, i32* %3
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds [6 x i32], [6 x i32]* %2, i64 0, i64 %36
%38 = load i32, i32* %37
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.2, i64 0, i64 0), i32 %34, i32 %38)
br label %40
40: ; preds = %32
%41 = load i32, i32* %3
%42 = add nsw i32 %41, 1
store i32 %42, i32* %3
br label %29
43: ; preds = %29
%44 = getelementptr inbounds [6 x i32], [6 x i32]* %2, i64 0, i64 5
%45 = load i32, i32* %44
%46 = sub nsw i32 %45, 1
%47 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.3, i64 0, i64 0), i32 %46)
ret i32 0
}

LLVM IR (-O2):
@.str = [29 x i8] c"Enter Your Vote(0 to quit): \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [39 x i8] c"No. of Votes for Candidate %d is: %d \0A\00"
@.str.3 = [29 x i8] c"No. of Spoilt Votes is: %d \0A\00"
define i32 @main() {
%1 = alloca [6 x i32]
%2 = alloca i32
%3 = bitcast [6 x i32]* %1 to i8*
%4 = bitcast i32* %2 to i8*
store i32 1, i32* %2
%5 = getelementptr inbounds [6 x i32], [6 x i32]* %1, i64 0, i64 5
br label %7
6: ; preds = %7
store i32 0, i32* %2
br label %19
7: ; preds = %0, %7
%8 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%10 = load i32, i32* %2
%11 = add i32 %10, -1
%12 = icmp ult i32 %11, 5
%13 = zext i32 %11 to i64
%14 = getelementptr inbounds [6 x i32], [6 x i32]* %1, i64 0, i64 %13
%15 = select i1 %12, i32* %14, i32* %5
%16 = load i32, i32* %15
%17 = add nsw i32 %16, 1
store i32 %17, i32* %15
%18 = icmp eq i32 %10, 0
br i1 %18, label %6, label %7
19: ; preds = %6, %19
%20 = phi i32 [ 0, %6 ], [ %27, %19 ]
%21 = add nsw i32 %20, 1
%22 = sext i32 %20 to i64
%23 = getelementptr inbounds [6 x i32], [6 x i32]* %1, i64 0, i64 %22
%24 = load i32, i32* %23
%25 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @.str.2, i64 0, i64 0), i32 %21, i32 %24)
%26 = load i32, i32* %2
%27 = add nsw i32 %26, 1
store i32 %27, i32* %2
%28 = icmp slt i32 %26, 4
br i1 %28, label %19, label %29
29: ; preds = %19
%30 = load i32, i32* %5
%31 = add nsw i32 %30, -1
%32 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.3, i64 0, i64 0), i32 %31)
ret i32 0
}