#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 *, ...);
void ex9() {
  int conta, neg = 0, pos = 0;
  float saldo;
  while (1) {
    printf("Informe o numero da conta [negativo para encerrar]: ");
    scanf("%d", &conta);
    if (conta < 0)
      break;
    printf("Informe o saldo: ");
    scanf("%f", &saldo);
    if (saldo >= 0) {
      printf("Conta: %d\n\tSaldo: R$%.2f\n\tPositivo\n\n", conta, saldo);
      pos++;
    } else {
      printf("Conta: %d\n\tSaldo: R$%.2f\n\tNegativo\n\n", conta, saldo);
      neg++;
    }
  }
  printf("Percentual de saldos negativos: %.2f%%\n",
         (float)neg / (pos + neg) * 100);
}


x86 assembly (clang, -O0):
<ex9>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
lea    0xec7(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeee(%rip),%rdi
lea    -0x4(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
cmpl   $0x0,-0x4(%rbp)
jge    1165 <ex9+0x45>
jmp    11e6 <ex9+0xc6>
lea    0xed0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xed4(%rip),%rdi
lea    -0x10(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
movss  -0x10(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jb     11be <ex9+0x9e>
mov    -0x4(%rbp),%esi
movss  -0x10(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xea8(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    11e1 <ex9+0xc1>
mov    -0x4(%rbp),%esi
movss  -0x10(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xea5(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1136 <ex9+0x16>
cvtsi2ssl -0x8(%rbp),%xmm0
mov    -0xc(%rbp),%eax
add    -0x8(%rbp),%eax
cvtsi2ss %eax,%xmm1
divss  %xmm1,%xmm0
movss  0xdff(%rip),%xmm1
mulss  %xmm1,%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe8b(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ex9>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
lea    0xed6(%rip),%rdi
xor    %r14d,%r14d
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xefa(%rip),%rdi
mov    %rsp,%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
cmpl   $0x0,(%rsp)
mov    $0x0,%r15d
js     11f8 <ex9+0xd8>
lea    0x4(%rsp),%r13
lea    0xe9f(%rip),%rbx
lea    0xecd(%rip),%rbp
mov    %rsp,%r12
xor    %r15d,%r15d
xor    %r14d,%r14d
jmp    11af <ex9+0x8f>
nopl   0x0(%rax,%rax,1)
lea    0xef3(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
add    $0x1,%r14d
mov    %rbx,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %rbp,%rdi
mov    %r12,%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
cmpl   $0x0,(%rsp)
js     11f8 <ex9+0xd8>
lea    0xe8a(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xe8e(%rip),%rdi
mov    %r13,%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
movss  0x4(%rsp),%xmm0
ucomiss 0xe29(%rip),%xmm0
mov    (%rsp),%esi
cvtss2sd %xmm0,%xmm0
jb     1180 <ex9+0x60>
lea    0xe6a(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
add    $0x1,%r15d
jmp    1192 <ex9+0x72>
xorps  %xmm0,%xmm0
cvtsi2ss %r14d,%xmm0
add    %r14d,%r15d
cvtsi2ss %r15d,%xmm1
divss  %xmm1,%xmm0
mulss  0xdec(%rip),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe80(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [53 x i8] c"Informe o numero da conta [negativo para encerrar]: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [18 x i8] c"Informe o saldo: \00"
@.str.3 = [3 x i8] c"%f\00"
@.str.4 = [37 x i8] c"Conta: %d\0A\09Saldo: R$%.2f\0A\09Positivo\0A\0A\00"
@.str.5 = [37 x i8] c"Conta: %d\0A\09Saldo: R$%.2f\0A\09Negativo\0A\0A\00"
@.str.6 = [40 x i8] c"Percentual de saldos negativos: %.2f%%\0A\00"
define void @ex9() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca float
store i32 0, i32* %2
store i32 0, i32* %3
br label %5
5: ; preds = %0, %30
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str, i64 0, i64 0))
%7 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%8 = load i32, i32* %1
%9 = icmp slt i32 %8, 0
br i1 %9, label %10, label %11
10: ; preds = %5
br label %31
11: ; preds = %5
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0))
%13 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), float* %4)
%14 = load float, float* %4
%15 = fcmp oge float %14, 0.000000e+00
br i1 %15, label %16, label %23
16: ; preds = %11
%17 = load i32, i32* %1
%18 = load float, float* %4
%19 = fpext float %18 to double
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.4, i64 0, i64 0), i32 %17, double %19)
%21 = load i32, i32* %3
%22 = add nsw i32 %21, 1
store i32 %22, i32* %3
br label %30
23: ; preds = %11
%24 = load i32, i32* %1
%25 = load float, float* %4
%26 = fpext float %25 to double
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.5, i64 0, i64 0), i32 %24, double %26)
%28 = load i32, i32* %2
%29 = add nsw i32 %28, 1
store i32 %29, i32* %2
br label %30
30: ; preds = %23, %16
br label %5
31: ; preds = %10
%32 = load i32, i32* %2
%33 = sitofp i32 %32 to float
%34 = load i32, i32* %3
%35 = load i32, i32* %2
%36 = add nsw i32 %34, %35
%37 = sitofp i32 %36 to float
%38 = fdiv float %33, %37
%39 = fmul float %38, 1.000000e+02
%40 = fpext float %39 to double
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.6, i64 0, i64 0), double %40)
ret void
}

LLVM IR (-O2):
@.str = [53 x i8] c"Informe o numero da conta [negativo para encerrar]: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [18 x i8] c"Informe o saldo: \00"
@.str.3 = [3 x i8] c"%f\00"
@.str.4 = [37 x i8] c"Conta: %d\0A\09Saldo: R$%.2f\0A\09Positivo\0A\0A\00"
@.str.5 = [37 x i8] c"Conta: %d\0A\09Saldo: R$%.2f\0A\09Negativo\0A\0A\00"
@.str.6 = [40 x i8] c"Percentual de saldos negativos: %.2f%%\0A\00"
define void @ex9() {
%1 = alloca i32
%2 = alloca float
%3 = bitcast i32* %1 to i8*
%4 = bitcast float* %2 to i8*
%5 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([53 x i8], [53 x i8]* @.str, i64 0, i64 0))
%6 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%7 = load i32, i32* %1
%8 = icmp slt i32 %7, 0
br i1 %8, label %31, label %9
9: ; preds = %0, %24
%10 = phi i32 [ %26, %24 ], [ 0, %0 ]
%11 = phi i32 [ %25, %24 ], [ 0, %0 ]
%12 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0))
%13 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), float* %2)
%14 = load float, float* %2
%15 = fcmp ult float %14, 0.000000e+00
%16 = load i32, i32* %1
%17 = fpext float %14 to double
br i1 %15, label %21, label %18
18: ; preds = %9
%19 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str.4, i64 0, i64 0), i32 %16, double %17)
%20 = add nsw i32 %10, 1
br label %24
21: ; preds = %9
%22 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str.5, i64 0, i64 0), i32 %16, double %17)
%23 = add nsw i32 %11, 1
br label %24
24: ; preds = %21, %18
%25 = phi i32 [ %11, %18 ], [ %23, %21 ]
%26 = phi i32 [ %20, %18 ], [ %10, %21 ]
%27 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([53 x i8], [53 x i8]* @.str, i64 0, i64 0))
%28 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%29 = load i32, i32* %1
%30 = icmp slt i32 %29, 0
br i1 %30, label %31, label %9
31: ; preds = %24, %0
%32 = phi i32 [ 0, %0 ], [ %25, %24 ]
%33 = phi i32 [ 0, %0 ], [ %26, %24 ]
%34 = sitofp i32 %32 to float
%35 = add nsw i32 %33, %32
%36 = sitofp i32 %35 to float
%37 = fdiv float %34, %36
%38 = fmul float %37, 1.000000e+02
%39 = fpext float %38 to double
%40 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @.str.6, i64 0, i64 0), double %39)
ret void
}