#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 ex10() {
  int conta = 0, neg = 0, pos = 0;
  float saldo, agencia = 0;
  char nome[33];
  while (pos + neg < 10000) {
    printf("Informe o numero da conta [-999 para encerrar]: ");
    scanf("%d", &conta);
    if (conta == -999)
      break;
    printf("Informe o nome (32 caracteres): ");
    scanf("%32s", nome);
    printf("Informe o saldo: ");
    scanf("%f", &saldo);
    agencia += saldo;
    if (saldo >= 0) {
      printf("Conta: %d\n\tNome:%s\n\tSaldo: R$%.2f\n\tPositivo\n\n", conta,
             nome, saldo);
      pos++;
    } else {
      printf("Conta: %d\n\tNome:%s\n\tSaldo: R$%.2f\n\tNegativo\n\n", conta,
             nome, saldo);
      neg++;
    }
  }
  printf("Total de clientes com saldo negativo: %d\n", neg);
  printf("Total de clientes na agencia: %d\n", pos + neg);
  printf("Saldo da agencia: %.2f\n", agencia);
}


x86 assembly (clang, -O0):
<ex10>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x14(%rbp)
mov    -0xc(%rbp),%eax
add    -0x8(%rbp),%eax
cmp    $0x2710,%eax
jge    1240 <ex10+0x120>
lea    0xea3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xec6(%rip),%rdi
lea    -0x4(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
cmpl   $0xfffffc19,-0x4(%rbp)
jne    1188 <ex10+0x68>
jmp    1240 <ex10+0x120>
lea    0xea5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x40(%rbp),%rsi
lea    0xeb4(%rip),%rdi
mov    $0x0,%al
call   1040 <scanf@plt>
lea    0xeab(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeaf(%rip),%rdi
lea    -0x10(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
movss  -0x10(%rbp),%xmm0
addss  -0x14(%rbp),%xmm0
movss  %xmm0,-0x14(%rbp)
movss  -0x10(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomiss %xmm1,%xmm0
jb     1214 <ex10+0xf4>
mov    -0x4(%rbp),%esi
lea    -0x40(%rbp),%rdx
movss  -0x10(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe70(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    123b <ex10+0x11b>
mov    -0x4(%rbp),%esi
lea    -0x40(%rbp),%rdx
movss  -0x10(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe72(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1145 <ex10+0x25>
mov    -0x8(%rbp),%esi
lea    0xe81(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%esi
add    -0x8(%rbp),%esi
lea    0xe97(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movss  -0x14(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xea2(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ex10>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x48,%rsp
movl   $0x0,0xc(%rsp)
lea    0xec7(%rip),%rdi
xor    %ebx,%ebx
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xee8(%rip),%rdi
lea    0xc(%rsp),%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
xorps  %xmm0,%xmm0
cmpl   $0xfffffc19,0xc(%rsp)
ff
mov    $0x0,%ebp
je     127a <ex10+0x15a>
lea    0x20(%rsp),%r12
lea    0x1c(%rsp),%r14
lea    0xc(%rsp),%r15
xor    %ebx,%ebx
xor    %r13d,%r13d
xorps  %xmm0,%xmm0
movss  %xmm0,0x10(%rsp)
nopl   0x0(%rax)
lea    0xea1(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xeb4(%rip),%rdi
mov    %r12,%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
lea    0xea8(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xeac(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
movss  0x1c(%rsp),%xmm0
ucomiss 0xe25(%rip),%xmm0
mov    0xc(%rsp),%esi
movss  %xmm0,0x18(%rsp)
cvtss2sd %xmm0,%xmm0
jae    1210 <ex10+0xf0>
lea    0xeaf(%rip),%rdi
mov    %r12,%rdx
mov    $0x1,%al
call   1030 <printf@plt>
add    $0x1,%ebx
jmp    1225 <ex10+0x105>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
lea    0xe5c(%rip),%rdi
mov    %r12,%rdx
mov    $0x1,%al
call   1030 <printf@plt>
add    $0x1,%r13d
movss  0x10(%rsp),%xmm0
addss  0x18(%rsp),%xmm0
movss  %xmm0,0x10(%rsp)
lea    (%rbx,%r13,1),%ebp
cmp    $0x2710,%ebp
jge    1270 <ex10+0x150>
lea    0xdba(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xddd(%rip),%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
cmpl   $0xfffffc19,0xc(%rsp)
ff
jne    1190 <ex10+0x70>
movss  0x10(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
movsd  %xmm0,0x10(%rsp)
lea    0xe48(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xe62(%rip),%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xe74(%rip),%rdi
movsd  0x10(%rsp),%xmm0
mov    $0x1,%al
call   1030 <printf@plt>
add    $0x48,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [49 x i8] c"Informe o numero da conta [-999 para encerrar]: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [33 x i8] c"Informe o nome (32 caracteres): \00"
@.str.3 = [5 x i8] c"%32s\00"
@.str.4 = [18 x i8] c"Informe o saldo: \00"
@.str.5 = [3 x i8] c"%f\00"
@.str.6 = [46 x i8] c"Conta: %d\0A\09Nome:%s\0A\09Saldo: R$%.2f\0A\09Positivo\0A\0A\00"
@.str.7 = [46 x i8] c"Conta: %d\0A\09Nome:%s\0A\09Saldo: R$%.2f\0A\09Negativo\0A\0A\00"
@.str.8 = [42 x i8] c"Total de clientes com saldo negativo: %d\0A\00"
@.str.9 = [34 x i8] c"Total de clientes na agencia: %d\0A\00"
@.str.10 = [24 x i8] c"Saldo da agencia: %.2f\0A\00"
define void @ex10() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca float
%5 = alloca float
%6 = alloca [33 x i8]
store i32 0, i32* %1
store i32 0, i32* %2
store i32 0, i32* %3
store float 0.000000e+00, float* %5
br label %7
7: ; preds = %45, %0
%8 = load i32, i32* %3
%9 = load i32, i32* %2
%10 = add nsw i32 %8, %9
%11 = icmp slt i32 %10, 10000
br i1 %11, label %12, label %46
12: ; preds = %7
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str, i64 0, i64 0))
%14 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%15 = load i32, i32* %1
%16 = icmp eq i32 %15, -999
br i1 %16, label %17, label %18
17: ; preds = %12
br label %46
18: ; preds = %12
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.2, i64 0, i64 0))
%20 = getelementptr inbounds [33 x i8], [33 x i8]* %6, i64 0, i64 0
%21 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i8* %20)
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.4, i64 0, i64 0))
%23 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), float* %4)
%24 = load float, float* %4
%25 = load float, float* %5
%26 = fadd float %25, %24
store float %26, float* %5
%27 = load float, float* %4
%28 = fcmp oge float %27, 0.000000e+00
br i1 %28, label %29, label %37
29: ; preds = %18
%30 = load i32, i32* %1
%31 = getelementptr inbounds [33 x i8], [33 x i8]* %6, i64 0, i64 0
%32 = load float, float* %4
%33 = fpext float %32 to double
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.6, i64 0, i64 0), i32 %30, i8* %31, double %33)
%35 = load i32, i32* %3
%36 = add nsw i32 %35, 1
store i32 %36, i32* %3
br label %45
37: ; preds = %18
%38 = load i32, i32* %1
%39 = getelementptr inbounds [33 x i8], [33 x i8]* %6, i64 0, i64 0
%40 = load float, float* %4
%41 = fpext float %40 to double
%42 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.7, i64 0, i64 0), i32 %38, i8* %39, double %41)
%43 = load i32, i32* %2
%44 = add nsw i32 %43, 1
store i32 %44, i32* %2
br label %45
45: ; preds = %37, %29
br label %7
46: ; preds = %17, %7
%47 = load i32, i32* %2
%48 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.8, i64 0, i64 0), i32 %47)
%49 = load i32, i32* %3
%50 = load i32, i32* %2
%51 = add nsw i32 %49, %50
%52 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.9, i64 0, i64 0), i32 %51)
%53 = load float, float* %5
%54 = fpext float %53 to double
%55 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.10, i64 0, i64 0), double %54)
ret void
}

LLVM IR (-O2):
@.str = [49 x i8] c"Informe o numero da conta [-999 para encerrar]: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [33 x i8] c"Informe o nome (32 caracteres): \00"
@.str.3 = [5 x i8] c"%32s\00"
@.str.4 = [18 x i8] c"Informe o saldo: \00"
@.str.5 = [3 x i8] c"%f\00"
@.str.6 = [46 x i8] c"Conta: %d\0A\09Nome:%s\0A\09Saldo: R$%.2f\0A\09Positivo\0A\0A\00"
@.str.7 = [46 x i8] c"Conta: %d\0A\09Nome:%s\0A\09Saldo: R$%.2f\0A\09Negativo\0A\0A\00"
@.str.8 = [42 x i8] c"Total de clientes com saldo negativo: %d\0A\00"
@.str.9 = [34 x i8] c"Total de clientes na agencia: %d\0A\00"
@.str.10 = [24 x i8] c"Saldo da agencia: %.2f\0A\00"
define void @ex10() {
%1 = alloca i32
%2 = alloca float
%3 = alloca [33 x i8]
%4 = bitcast i32* %1 to i8*
store i32 0, i32* %1
%5 = bitcast float* %2 to i8*
%6 = getelementptr inbounds [33 x i8], [33 x i8]* %3, i64 0, i64 0
%7 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([49 x i8], [49 x i8]* @.str, i64 0, i64 0))
%8 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%9 = load i32, i32* %1
%10 = icmp eq i32 %9, -999
br i1 %10, label %42, label %16
11: ; preds = %35
%12 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([49 x i8], [49 x i8]* @.str, i64 0, i64 0))
%13 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%14 = load i32, i32* %1
%15 = icmp eq i32 %14, -999
br i1 %15, label %40, label %16
16: ; preds = %0, %11
%17 = phi i32 [ %36, %11 ], [ 0, %0 ]
%18 = phi i32 [ %37, %11 ], [ 0, %0 ]
%19 = phi float [ %25, %11 ], [ 0.000000e+00, %0 ]
%20 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.2, i64 0, i64 0))
%21 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0), i8* %6)
%22 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.4, i64 0, i64 0))
%23 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.5, i64 0, i64 0), float* %2)
%24 = load float, float* %2
%25 = fadd float %19, %24
%26 = fcmp ult float %24, 0.000000e+00
%27 = load i32, i32* %1
%28 = fpext float %24 to double
br i1 %26, label %32, label %29
29: ; preds = %16
%30 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([46 x i8], [46 x i8]* @.str.6, i64 0, i64 0), i32 %27, i8* %6, double %28)
%31 = add nsw i32 %18, 1
br label %35
32: ; preds = %16
%33 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([46 x i8], [46 x i8]* @.str.7, i64 0, i64 0), i32 %27, i8* %6, double %28)
%34 = add nsw i32 %17, 1
br label %35
35: ; preds = %32, %29
%36 = phi i32 [ %17, %29 ], [ %34, %32 ]
%37 = phi i32 [ %31, %29 ], [ %18, %32 ]
%38 = add nsw i32 %37, %36
%39 = icmp slt i32 %38, 10000
br i1 %39, label %11, label %40
40: ; preds = %11, %35
%41 = fpext float %25 to double
br label %42
42: ; preds = %40, %0
%43 = phi i32 [ 0, %0 ], [ %36, %40 ]
%44 = phi double [ 0.000000e+00, %0 ], [ %41, %40 ]
%45 = phi i32 [ 0, %0 ], [ %38, %40 ]
%46 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @.str.8, i64 0, i64 0), i32 %43)
%47 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.9, i64 0, i64 0), i32 %45)
%48 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.10, i64 0, i64 0), double %44)
ret void
}