#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 quantidade = 0, maior = 0;
  printf("Ao finalizar, digite '00', sem aspas, para obter o resultado.\n\n");
  while (1) {
    printf("Insira um numero: ");
    int num;
    scanf("%d", &num);
    if (!num)
      break;
    if (num > maior) {
      maior = num;
      quantidade = 1;
    } else if (num == maior)
      quantidade++;
  }
  printf("Maior numero: %d - quantidade de vezes: %d\n", maior, quantidade);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
lea    0xebc(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeee(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xef3(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1040 <scanf@plt>
cmpl   $0x0,-0x10(%rbp)
jne    1178 <main+0x58>
jmp    11b5 <main+0x95>
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jle    1196 <main+0x76>
mov    -0x10(%rbp),%eax
mov    %eax,-0xc(%rbp)
movl   $0x1,-0x8(%rbp)
jmp    11b0 <main+0x90>
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jne    11ab <main+0x8b>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    11b0 <main+0x90>
jmp    114b <main+0x2b>
mov    -0xc(%rbp),%esi
mov    -0x8(%rbp),%edx
lea    0xe94(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0xf00(%rip),%rdi
call   1030 <puts@plt>
lea    0xeb2(%rip),%rdi
xor    %ebx,%ebx
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xeb5(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1050 <scanf@plt>
mov    0x4(%rsp),%eax
mov    $0x0,%ebp
test   %eax,%eax
je     11d3 <main+0xa3>
mov    $0x1,%r13d
lea    0xe7e(%rip),%r14
lea    0xe8a(%rip),%r15
lea    0x4(%rsp),%r12
xor    %ecx,%ecx
xor    %edx,%edx
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
xor    %ebx,%ebx
cmp    %ecx,%eax
sete   %bl
cmovg  %eax,%ebp
add    %edx,%ebx
cmp    %ecx,%eax
cmovg  %r13d,%ebx
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r15,%rdi
mov    %r12,%rsi
call   1050 <scanf@plt>
mov    0x4(%rsp),%eax
mov    %ebp,%ecx
mov    %ebx,%edx
test   %eax,%eax
jne    11a0 <main+0x70>
lea    0xe3c(%rip),%rdi
mov    %ebp,%esi
mov    %ebx,%edx
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [64 x i8] c"Ao finalizar, digite '00', sem aspas, para obter o resultado.\0A\0A\00"
@.str.1 = [19 x i8] c"Insira um numero: \00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [44 x i8] c"Maior numero: %d - quantidade de vezes: %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %2
store i32 0, i32* %3
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([64 x i8], [64 x i8]* @.str, i64 0, i64 0))
br label %6
6: ; preds = %0, %26
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %4)
%9 = load i32, i32* %4
%10 = icmp ne i32 %9, 0
br i1 %10, label %12, label %11
11: ; preds = %6
br label %27
12: ; preds = %6
%13 = load i32, i32* %4
%14 = load i32, i32* %3
%15 = icmp sgt i32 %13, %14
br i1 %15, label %16, label %18
16: ; preds = %12
%17 = load i32, i32* %4
store i32 %17, i32* %3
store i32 1, i32* %2
br label %26
18: ; preds = %12
%19 = load i32, i32* %4
%20 = load i32, i32* %3
%21 = icmp eq i32 %19, %20
br i1 %21, label %22, label %25
22: ; preds = %18
%23 = load i32, i32* %2
%24 = add nsw i32 %23, 1
store i32 %24, i32* %2
br label %25
25: ; preds = %22, %18
br label %26
26: ; preds = %25, %16
br label %6
27: ; preds = %11
%28 = load i32, i32* %3
%29 = load i32, i32* %2
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.3, i64 0, i64 0), i32 %28, i32 %29)
%31 = load i32, i32* %1
ret i32 %31
}

LLVM IR (-O2):
@.str.1 = [19 x i8] c"Insira um numero: \00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [44 x i8] c"Maior numero: %d - quantidade de vezes: %d\0A\00"
@str = [63 x i8] c"Ao finalizar, digite '00', sem aspas, para obter o resultado.\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([63 x i8], [63 x i8]* @str, i64 0, i64 0))
%3 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0))
%4 = bitcast i32* %1 to i8*
%5 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %1)
%6 = load i32, i32* %1
%7 = icmp eq i32 %6, 0
br i1 %7, label %22, label %8
8: ; preds = %0, %8
%9 = phi i32 [ %20, %8 ], [ %6, %0 ]
%10 = phi i32 [ %17, %8 ], [ 0, %0 ]
%11 = phi i32 [ %16, %8 ], [ 0, %0 ]
%12 = icmp sgt i32 %9, %10
%13 = icmp eq i32 %9, %10
%14 = zext i1 %13 to i32
%15 = add nsw i32 %11, %14
%16 = select i1 %12, i32 1, i32 %15
%17 = select i1 %12, i32 %9, i32 %10
%18 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.1, i64 0, i64 0))
%19 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %1)
%20 = load i32, i32* %1
%21 = icmp eq i32 %20, 0
br i1 %21, label %22, label %8
22: ; preds = %8, %0
%23 = phi i32 [ 0, %0 ], [ %16, %8 ]
%24 = phi i32 [ 0, %0 ], [ %17, %8 ]
%25 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @.str.3, i64 0, i64 0), i32 %24, i32 %23)
ret i32 0
}