#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 /*<<< orphan*/ system(char *);
float media() {
  int i = 1, flg = 1, num;
  float media = 0;
  while (flg) {
    printf("Informe o numero %d: ", i);
    scanf("%d", &num);
    i++;
    media += num;
    printf("Continuar?\n1 - Sim\n0 - Nao\n");
    scanf("%d", &flg);
    system("cls");
  }
  media /= (i - 1);
  return media;
}


x86 assembly (clang, -O0):
<media>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x1,-0x4(%rbp)
movl   $0x1,-0x8(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x10(%rbp)
cmpl   $0x0,-0x8(%rbp)
je     11c0 <media+0x90>
mov    -0x4(%rbp),%esi
lea    0xe9e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xea6(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1050 <scanf@plt>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
cvtsi2ssl -0xc(%rbp),%xmm0
addss  -0x10(%rbp),%xmm0
movss  %xmm0,-0x10(%rbp)
lea    0xe81(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe70(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1050 <scanf@plt>
lea    0xe7f(%rip),%rdi
call   1030 <system@plt>
jmp    114e <media+0x1e>
mov    -0x4(%rbp),%eax
sub    $0x1,%eax
cvtsi2ss %eax,%xmm1
movss  -0x10(%rbp),%xmm0
divss  %xmm1,%xmm0
movss  %xmm0,-0x10(%rbp)
movss  -0x10(%rbp),%xmm0
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<media>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
movl   $0x1,0x10(%rsp)
xorps  %xmm0,%xmm0
movss  %xmm0,0xc(%rsp)
lea    0xeb0(%rip),%rbx
lea    0x14(%rsp),%r15
lea    0xeab(%rip),%r12
lea    0x10(%rsp),%r13
lea    0xe9b(%rip),%r14
xor    %ebp,%ebp
add    $0x1,%ebp
lea    0xe76(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1060 <scanf@plt>
xorps  %xmm0,%xmm0
cvtsi2ssl 0x14(%rsp),%xmm0
movss  0xc(%rsp),%xmm1
addss  %xmm0,%xmm1
movss  %xmm1,0xc(%rsp)
mov    %r12,%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
mov    %r13,%rsi
call   1060 <scanf@plt>
mov    %r14,%rdi
call   1040 <system@plt>
cmpl   $0x0,0x10(%rsp)
jne    1180 <media+0x40>
xorps  %xmm1,%xmm1
cvtsi2ss %ebp,%xmm1
movss  0xc(%rsp),%xmm0
divss  %xmm1,%xmm0
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [22 x i8] c"Informe o numero %d: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [28 x i8] c"Continuar?\0A1 - Sim\0A0 - Nao\0A\00"
@.str.3 = [4 x i8] c"cls\00"
define float @media() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca float
store i32 1, i32* %1
store i32 1, i32* %2
store float 0.000000e+00, float* %4
br label %5
5: ; preds = %8, %0
%6 = load i32, i32* %2
%7 = icmp ne i32 %6, 0
br i1 %7, label %8, label %21
8: ; preds = %5
%9 = load i32, i32* %1
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i32 %9)
%11 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%12 = load i32, i32* %1
%13 = add nsw i32 %12, 1
store i32 %13, i32* %1
%14 = load i32, i32* %3
%15 = sitofp i32 %14 to float
%16 = load float, float* %4
%17 = fadd float %16, %15
store float %17, float* %4
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0))
%19 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%20 = call i32 @system(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
br label %5
21: ; preds = %5
%22 = load i32, i32* %1
%23 = sub nsw i32 %22, 1
%24 = sitofp i32 %23 to float
%25 = load float, float* %4
%26 = fdiv float %25, %24
store float %26, float* %4
%27 = load float, float* %4
ret float %27
}

LLVM IR (-O2):
@.str = [22 x i8] c"Informe o numero %d: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.3 = [4 x i8] c"cls\00"
@str = [27 x i8] c"Continuar?\0A1 - Sim\0A0 - Nao\00"
define float @media() {
%1 = alloca i32
%2 = alloca i32
%3 = bitcast i32* %1 to i8*
store i32 1, i32* %1
%4 = bitcast i32* %2 to i8*
br label %5
5: ; preds = %0, %5
%6 = phi float [ 0.000000e+00, %0 ], [ %13, %5 ]
%7 = phi i32 [ 1, %0 ], [ %10, %5 ]
%8 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0), i32 %7)
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%10 = add nuw nsw i32 %7, 1
%11 = load i32, i32* %2
%12 = sitofp i32 %11 to float
%13 = fadd float %6, %12
%14 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @str, i64 0, i64 0))
%15 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%16 = call i32 @system(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
%17 = load i32, i32* %1
%18 = icmp eq i32 %17, 0
br i1 %18, label %19, label %5
19: ; preds = %5
%20 = sitofp i32 %7 to float
%21 = fdiv float %13, %20
ret float %21
}