#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 findCandidate(int *, int);
scalar_t__ isMajority(int *, int, int);
int /*<<< orphan*/ printf(char *, ...);
void printMajority(int a[], int size) {
  int cand = findCandidate(a, size);
  if (isMajority(a, size, cand))
    printf("Majority element: %d", cand);
  else
    printf("No Majority Element");
}


x86 assembly (clang, -O0):
<printMajority>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
call   1050 <findCandidate@plt>
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
call   1040 <isMajority@plt>
cmp    $0x0,%rax
je     117d <printMajority+0x4d>
mov    -0x10(%rbp),%esi
lea    0xe8f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    118b <printMajority+0x5b>
lea    0xe91(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printMajority>:
push   %rbp
push   %r14
push   %rbx
mov    %esi,%ebp
mov    %rdi,%rbx
call   1050 <findCandidate@plt>
mov    %eax,%r14d
mov    %rbx,%rdi
mov    %ebp,%esi
mov    %eax,%edx
call   1040 <isMajority@plt>
test   %rax,%rax
je     1167 <printMajority+0x37>
lea    0xea7(%rip),%rdi
mov    %r14d,%esi
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
jmp    1030 <printf@plt>
lea    0xea7(%rip),%rdi
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
jmp    1030 <printf@plt>

LLVM IR (-O0):
@.str = [21 x i8] c"Majority element: %d\00"
@.str.1 = [20 x i8] c"No Majority Element\00"
define void @printMajority(i32* %0, i32 %1) {
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i32
store i32* %0, i32** %3
store i32 %1, i32* %4
%6 = load i32*, i32** %3
%7 = load i32, i32* %4
%8 = call i32 @findCandidate(i32* %6, i32 %7)
store i32 %8, i32* %5
%9 = load i32*, i32** %3
%10 = load i32, i32* %4
%11 = load i32, i32* %5
%12 = call i64 @isMajority(i32* %9, i32 %10, i32 %11)
%13 = icmp ne i64 %12, 0
br i1 %13, label %14, label %17
14: ; preds = %2
%15 = load i32, i32* %5
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i32 %15)
br label %19
17: ; preds = %2
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0))
br label %19
19: ; preds = %17, %14
ret void
}

LLVM IR (-O2):
@.str = [21 x i8] c"Majority element: %d\00"
@.str.1 = [20 x i8] c"No Majority Element\00"
define void @printMajority(i32* %0, i32 %1) {
%3 = tail call i32 @findCandidate(i32* %0, i32 %1)
%4 = tail call i64 @isMajority(i32* %0, i32 %1, i32 %3)
%5 = icmp eq i64 %4, 0
br i1 %5, label %8, label %6
6: ; preds = %2
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i32 %3)
br label %10
8: ; preds = %2
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0))
br label %10
10: ; preds = %8, %6
ret void
}