#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 main() {
  int cant;
  float cost, fact = 0;
  ;
  while (cant != 0) {
    printf("Ingrese la cantidad de articulos vendidos: ");
    scanf("%d", &cant);
    if (cant > 0) {
      printf("Ingrese el costo del articulo: ");
      scanf("%f", &cost);
      fact = fact + (cant * cost);
    } else {
      printf("\nEl precio a pagar es: %f", fact);
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
xorps  %xmm0,%xmm0
movss  %xmm0,-0x10(%rbp)
cmpl   $0x0,-0x8(%rbp)
je     11c8 <main+0xa8>
lea    0xeb8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xed6(%rip),%rdi
lea    -0x8(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
cmpl   $0x0,-0x8(%rbp)
jle    11ac <main+0x8c>
lea    0xebd(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xee6(%rip),%rdi
lea    -0xc(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
movss  -0x10(%rbp),%xmm1
cvtsi2ssl -0x8(%rbp),%xmm0
movss  -0xc(%rbp),%xmm2
mulss  %xmm2,%xmm0
addss  %xmm1,%xmm0
movss  %xmm0,-0x10(%rbp)
jmp    11c3 <main+0xa3>
movss  -0x10(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe93(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
jmp    1137 <main+0x17>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
xorps  %xmm0,%xmm0
movss  %xmm0,0xc(%rsp)
lea    0xec2(%rip),%r14
lea    0xee7(%rip),%r15
lea    0x10(%rsp),%rbx
lea    0xede(%rip),%r12
lea    0xf0e(%rip),%r13
lea    0x14(%rsp),%rbp
jmp    1180 <main+0x60>
nop
movss  0xc(%rsp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xede(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
mov    0x10(%rsp),%eax
test   %eax,%eax
je     11da <main+0xba>
mov    %r14,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
cmpl   $0x0,0x10(%rsp)
jle    1160 <main+0x40>
mov    %r12,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %r13,%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
mov    0x10(%rsp),%eax
xorps  %xmm0,%xmm0
cvtsi2ss %eax,%xmm0
mulss  0x14(%rsp),%xmm0
movss  0xc(%rsp),%xmm1
addss  %xmm0,%xmm1
movss  %xmm1,0xc(%rsp)
test   %eax,%eax
jne    1180 <main+0x60>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [44 x i8] c"Ingrese la cantidad de articulos vendidos: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [32 x i8] c"Ingrese el costo del articulo: \00"
@.str.3 = [3 x i8] c"%f\00"
@.str.4 = [26 x i8] c"\0AEl precio a pagar es: %f\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca float
%4 = alloca float
store i32 0, i32* %1
store float 0.000000e+00, float* %4
br label %5
5: ; preds = %25, %0
%6 = load i32, i32* %2
%7 = icmp ne i32 %6, 0
br i1 %7, label %8, label %26
8: ; preds = %5
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str, i64 0, i64 0))
%10 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%11 = load i32, i32* %2
%12 = icmp sgt i32 %11, 0
br i1 %12, label %13, label %21
13: ; preds = %8
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0))
%15 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), float* %3)
%16 = load float, float* %4
%17 = load i32, i32* %2
%18 = sitofp i32 %17 to float
%19 = load float, float* %3
%20 = call float @llvm.fmuladd.f32(float %18, float %19, float %16)
store float %20, float* %4
br label %25
21: ; preds = %8
%22 = load float, float* %4
%23 = fpext float %22 to double
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.4, i64 0, i64 0), double %23)
br label %25
25: ; preds = %21, %13
br label %5
26: ; preds = %5
ret i32 0
}

LLVM IR (-O2):
@.str = [44 x i8] c"Ingrese la cantidad de articulos vendidos: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [32 x i8] c"Ingrese el costo del articulo: \00"
@.str.3 = [3 x i8] c"%f\00"
@.str.4 = [26 x i8] c"\0AEl precio a pagar es: %f\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca float
%3 = bitcast i32* %1 to i8*
%4 = bitcast float* %2 to i8*
br label %5
5: ; preds = %0, %22
%6 = phi float [ %24, %22 ], [ 0.000000e+00, %0 ]
%7 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 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 sgt i32 %9, 0
br i1 %10, label %11, label %18
11: ; preds = %5
%12 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 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 i32, i32* %1
%15 = sitofp i32 %14 to float
%16 = load float, float* %2
%17 = call float @llvm.fmuladd.f32(float %15, float %16, float %6)
br label %22
18: ; preds = %5
%19 = fpext float %6 to double
%20 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.4, i64 0, i64 0), double %19)
%21 = load i32, i32* %1
br label %22
22: ; preds = %18, %11
%23 = phi i32 [ %14, %11 ], [ %21, %18 ]
%24 = phi float [ %17, %11 ], [ %6, %18 ]
%25 = icmp eq i32 %23, 0
br i1 %25, label %26, label %5
26: ; preds = %22
ret i32 0
}