#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 n;
  double precio, total = 0;
  do {
    do {
      printf("\nIntroduzca la cantidad vendida: ");
      scanf("%d", &n);
      if (n < 0)
        printf("Cantidad no valida");
    } while (n < 0);
    if (n > 0) {
      printf("Introduzca el precio: ");
      do {
        scanf("%lf", &precio);
        if (precio < 0)
          printf("Precio no valido");
        else
          total += n * precio;
      } while (precio < 0);
    }
  } while (n != 0);
  printf("Total vendido = %f", total);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x18(%rbp)
jmp    113c <main+0x1c>
lea    0xebd(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xed1(%rip),%rdi
lea    -0x8(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
cmpl   $0x0,-0x8(%rbp)
jge    1174 <main+0x54>
lea    0xeb8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1179 <main+0x59>
cmpl   $0x0,-0x8(%rbp)
jl     113c <main+0x1c>
cmpl   $0x0,-0x8(%rbp)
jle    1202 <main+0xe2>
lea    0xea4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xead(%rip),%rdi
lea    -0x10(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
xorps  %xmm0,%xmm0
ucomisd -0x10(%rbp),%xmm0
jbe    11ce <main+0xae>
lea    0xe91(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11ea <main+0xca>
cvtsi2sdl -0x8(%rbp),%xmm0
movsd  -0x10(%rbp),%xmm2
movsd  -0x18(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
movsd  %xmm0,-0x18(%rbp)
jmp    11ef <main+0xcf>
xorps  %xmm0,%xmm0
ucomisd -0x10(%rbp),%xmm0
ja     119b <main+0x7b>
jmp    1202 <main+0xe2>
jmp    1207 <main+0xe7>
cmpl   $0x0,-0x8(%rbp)
jne    1137 <main+0x17>
movsd  -0x18(%rbp),%xmm0
lea    0xe47(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
lea    0xef5(%rip),%r15
lea    0x4(%rsp),%rbx
lea    0xeec(%rip),%r12
lea    0xf0f(%rip),%rbp
lea    0x10(%rsp),%r13
lea    0xf07(%rip),%r14
xorpd  %xmm0,%xmm0
movsd  %xmm0,0x8(%rsp)
jmp    1170 <main+0x50>
cmpl   $0x0,0x4(%rsp)
je     1227 <main+0x107>
nopl   0x0(%rax,%rax,1)
lea    0xe91(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
mov    0x4(%rsp),%eax
test   %eax,%eax
jns    11a5 <main+0x85>
mov    %r12,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x4(%rsp),%eax
test   %eax,%eax
js     1170 <main+0x50>
test   %eax,%eax
je     1227 <main+0x107>
lea    0xe90(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
jmp    11e7 <main+0xc7>
nopl   0x0(%rax)
xorps  %xmm1,%xmm1
cvtsi2sdl 0x4(%rsp),%xmm1
mulsd  %xmm0,%xmm1
movsd  0x8(%rsp),%xmm3
addsd  %xmm1,%xmm3
movsd  %xmm3,0x8(%rsp)
ucomisd %xmm0,%xmm2
jbe    1160 <main+0x40>
mov    %rbp,%rdi
mov    %r13,%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
movsd  0x10(%rsp),%xmm0
xorpd  %xmm1,%xmm1
ucomisd %xmm0,%xmm1
xorpd  %xmm2,%xmm2
jbe    11c0 <main+0xa0>
mov    %r14,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
xorpd  %xmm2,%xmm2
movsd  0x10(%rsp),%xmm0
ucomisd %xmm0,%xmm2
ja     11e7 <main+0xc7>
jmp    1160 <main+0x40>
lea    0xe3e(%rip),%rdi
movsd  0x8(%rsp),%xmm0
mov    $0x1,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [34 x i8] c"\0AIntroduzca la cantidad vendida: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [19 x i8] c"Cantidad no valida\00"
@.str.3 = [23 x i8] c"Introduzca el precio: \00"
@.str.4 = [4 x i8] c"%lf\00"
@.str.5 = [17 x i8] c"Precio no valido\00"
@.str.6 = [19 x i8] c"Total vendido = %f\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca double
%4 = alloca double
store i32 0, i32* %1
store double 0.000000e+00, double* %4
br label %5
5: ; preds = %40, %0
br label %6
6: ; preds = %14, %5
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 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* %2)
%9 = load i32, i32* %2
%10 = icmp slt i32 %9, 0
br i1 %10, label %11, label %13
11: ; preds = %6
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0))
br label %13
13: ; preds = %11, %6
br label %14
14: ; preds = %13
%15 = load i32, i32* %2
%16 = icmp slt i32 %15, 0
br i1 %16, label %6, label %17
17: ; preds = %14
%18 = load i32, i32* %2
%19 = icmp sgt i32 %18, 0
br i1 %19, label %20, label %39
20: ; preds = %17
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0))
br label %22
22: ; preds = %35, %20
%23 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), double* %3)
%24 = load double, double* %3
%25 = fcmp olt double %24, 0.000000e+00
br i1 %25, label %26, label %28
26: ; preds = %22
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.5, i64 0, i64 0))
br label %34
28: ; preds = %22
%29 = load i32, i32* %2
%30 = sitofp i32 %29 to double
%31 = load double, double* %3
%32 = load double, double* %4
%33 = call double @llvm.fmuladd.f64(double %30, double %31, double %32)
store double %33, double* %4
br label %34
34: ; preds = %28, %26
br label %35
35: ; preds = %34
%36 = load double, double* %3
%37 = fcmp olt double %36, 0.000000e+00
br i1 %37, label %22, label %38
38: ; preds = %35
br label %39
39: ; preds = %38, %17
br label %40
40: ; preds = %39
%41 = load i32, i32* %2
%42 = icmp ne i32 %41, 0
br i1 %42, label %5, label %43
43: ; preds = %40
%44 = load double, double* %4
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.6, i64 0, i64 0), double %44)
ret i32 0
}

LLVM IR (-O2):
@.str = [34 x i8] c"\0AIntroduzca la cantidad vendida: \00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [19 x i8] c"Cantidad no valida\00"
@.str.3 = [23 x i8] c"Introduzca el precio: \00"
@.str.4 = [4 x i8] c"%lf\00"
@.str.5 = [17 x i8] c"Precio no valido\00"
@.str.6 = [19 x i8] c"Total vendido = %f\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca double
%3 = bitcast i32* %1 to i8*
%4 = bitcast double* %2 to i8*
br label %5
5: ; preds = %37, %0
%6 = phi double [ 0.000000e+00, %0 ], [ %35, %37 ]
br label %7
7: ; preds = %12, %5
%8 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str, i64 0, i64 0))
%9 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%10 = load i32, i32* %1
%11 = icmp slt i32 %10, 0
br i1 %11, label %12, label %16
12: ; preds = %7
%13 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0))
%14 = load i32, i32* %1
%15 = icmp slt i32 %14, 0
br i1 %15, label %7, label %16
16: ; preds = %7, %12
%17 = phi i32 [ %14, %12 ], [ %10, %7 ]
%18 = icmp eq i32 %17, 0
br i1 %18, label %40, label %19
19: ; preds = %16
%20 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0))
br label %21
21: ; preds = %33, %19
%22 = phi double [ %6, %19 ], [ %35, %33 ]
%23 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), double* %2)
%24 = load double, double* %2
%25 = fcmp olt double %24, 0.000000e+00
br i1 %25, label %26, label %29
26: ; preds = %21
%27 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.5, i64 0, i64 0))
%28 = load double, double* %2
br label %33
29: ; preds = %21
%30 = load i32, i32* %1
%31 = sitofp i32 %30 to double
%32 = call double @llvm.fmuladd.f64(double %31, double %24, double %22)
br label %33
33: ; preds = %26, %29
%34 = phi double [ %28, %26 ], [ %24, %29 ]
%35 = phi double [ %22, %26 ], [ %32, %29 ]
%36 = fcmp olt double %34, 0.000000e+00
br i1 %36, label %21, label %37
37: ; preds = %33
%38 = load i32, i32* %1
%39 = icmp eq i32 %38, 0
br i1 %39, label %40, label %5
40: ; preds = %16, %37
%41 = phi double [ %35, %37 ], [ %6, %16 ]
%42 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.6, i64 0, i64 0), double %41)
ret i32 0
}