#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*/ msg(char *);
int /*<<< orphan*/ printf(char *, ...);
scalar_t__ strToDub(double *, char *);
scalar_t__ strcmp(char *, char *);
int vypocetNeboVysledek(char *argv[], double *vysledek, double *pocet,
                        char *a) {
  double cislo;
  if (strcmp(argv[1], "select") == 0) {
    if (strToDub(&cislo, a))
      printf("%.10g\n", cislo);
    else
      printf("%s\n", a);
  } else {
    if (!strToDub(&cislo, a)) {
      msg("cislo");
      return 0;
    }
    if ((*pocet) == 0 &&
        (strcmp(argv[1], "min") == 0 || strcmp(argv[1], "max") == 0))
      (*vysledek) = cislo;
    if (strcmp(argv[1], "min") == 0) {
      if ((*vysledek) > cislo) {
        (*vysledek) = cislo;
      }
    }
    if (strcmp(argv[1], "max") == 0) {
      if ((*vysledek) < cislo) {
        (*vysledek) = cislo;
      }
    }
    if (strcmp(argv[1], "avg") == 0) {
      (*vysledek) = ((*vysledek) * (*pocet) + cislo) / ((*pocet) + 1);
    }
    if (strcmp(argv[1], "sum") == 0) {
      (*vysledek) += cislo;
    }
    (*pocet)++;
  }
  return 1;
}


x86 assembly (clang, -O0):
<vypocetNeboVysledek>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xea1(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    11bc <vypocetNeboVysledek+0x7c>
mov    -0x28(%rbp),%rsi
lea    -0x30(%rbp),%rdi
call   1050 <strToDub@plt>
cmp    $0x0,%rax
je     11a5 <vypocetNeboVysledek+0x65>
movsd  -0x30(%rbp),%xmm0
lea    0xe76(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
jmp    11b7 <vypocetNeboVysledek+0x77>
mov    -0x28(%rbp),%rsi
lea    0xe66(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1373 <vypocetNeboVysledek+0x233>
mov    -0x28(%rbp),%rsi
lea    -0x30(%rbp),%rdi
call   1050 <strToDub@plt>
cmp    $0x0,%rax
jne    11eb <vypocetNeboVysledek+0xab>
lea    0xe40(%rip),%rdi
call   1060 <msg@plt>
movl   $0x0,-0x4(%rbp)
jmp    137a <vypocetNeboVysledek+0x23a>
mov    -0x20(%rbp),%rax
movsd  (%rax),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    124f <vypocetNeboVysledek+0x10f>
jp     124f <vypocetNeboVysledek+0x10f>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe0b(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
je     1242 <vypocetNeboVysledek+0x102>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xdf1(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    124f <vypocetNeboVysledek+0x10f>
movsd  -0x30(%rbp),%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xdc2(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    1292 <vypocetNeboVysledek+0x152>
mov    -0x18(%rbp),%rax
movsd  (%rax),%xmm0
ucomisd -0x30(%rbp),%xmm0
jbe    128d <vypocetNeboVysledek+0x14d>
movsd  -0x30(%rbp),%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,(%rax)
jmp    1292 <vypocetNeboVysledek+0x152>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xd83(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    12d9 <vypocetNeboVysledek+0x199>
mov    -0x18(%rbp),%rax
movsd  (%rax),%xmm1
movsd  -0x30(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    12d4 <vypocetNeboVysledek+0x194>
movsd  -0x30(%rbp),%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,(%rax)
jmp    12d9 <vypocetNeboVysledek+0x199>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xd40(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    1330 <vypocetNeboVysledek+0x1f0>
mov    -0x18(%rbp),%rax
movsd  (%rax),%xmm0
mov    -0x20(%rbp),%rax
movsd  (%rax),%xmm2
movsd  -0x30(%rbp),%xmm1
mulsd  %xmm2,%xmm0
addsd  %xmm1,%xmm0
mov    -0x20(%rbp),%rax
movsd  0xce0(%rip),%xmm1
addsd  (%rax),%xmm1
divsd  %xmm1,%xmm0
mov    -0x18(%rbp),%rax
movsd  %xmm0,(%rax)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xced(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    135f <vypocetNeboVysledek+0x21f>
movsd  -0x30(%rbp),%xmm0
mov    -0x18(%rbp),%rax
addsd  (%rax),%xmm0
movsd  %xmm0,(%rax)
mov    -0x20(%rbp),%rax
movsd  0xc95(%rip),%xmm0
addsd  (%rax),%xmm0
movsd  %xmm0,(%rax)
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<vypocetNeboVysledek>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %rcx,%r13
mov    %rdx,%r15
mov    %rsi,%r14
mov    %rdi,%r12
mov    0x8(%rdi),%rdi
lea    0xe94(%rip),%rsi
call   1050 <strcmp@plt>
mov    %rax,%rbx
lea    0x8(%rsp),%rdi
mov    %r13,%rsi
call   1060 <strToDub@plt>
test   %rbx,%rbx
je     12ac <vypocetNeboVysledek+0x15c>
test   %rax,%rax
je     12c7 <vypocetNeboVysledek+0x177>
movsd  (%r15),%xmm0
xorpd  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    11e3 <vypocetNeboVysledek+0x93>
jp     11e3 <vypocetNeboVysledek+0x93>
mov    0x8(%r12),%rdi
lea    0xe64(%rip),%rsi
call   1050 <strcmp@plt>
test   %rax,%rax
je     11d8 <vypocetNeboVysledek+0x88>
mov    0x8(%r12),%rdi
lea    0xe52(%rip),%rsi
call   1050 <strcmp@plt>
test   %rax,%rax
jne    11e3 <vypocetNeboVysledek+0x93>
movsd  0x8(%rsp),%xmm0
movsd  %xmm0,(%r14)
mov    0x8(%r12),%rdi
lea    0xe2d(%rip),%rsi
call   1050 <strcmp@plt>
test   %rax,%rax
jne    120f <vypocetNeboVysledek+0xbf>
movsd  (%r14),%xmm1
movsd  0x8(%rsp),%xmm0
ucomisd %xmm0,%xmm1
jbe    120f <vypocetNeboVysledek+0xbf>
movsd  %xmm0,(%r14)
mov    0x8(%r12),%rdi
lea    0xe05(%rip),%rsi
call   1050 <strcmp@plt>
test   %rax,%rax
jne    1237 <vypocetNeboVysledek+0xe7>
movsd  0x8(%rsp),%xmm0
ucomisd (%r14),%xmm0
jbe    1237 <vypocetNeboVysledek+0xe7>
movsd  %xmm0,(%r14)
mov    0x8(%r12),%rdi
lea    0xde1(%rip),%rsi
call   1050 <strcmp@plt>
test   %rax,%rax
jne    1272 <vypocetNeboVysledek+0x122>
movsd  (%r15),%xmm0
movsd  (%r14),%xmm1
mulsd  %xmm0,%xmm1
addsd  0x8(%rsp),%xmm1
addsd  0xd97(%rip),%xmm0
divsd  %xmm0,%xmm1
movsd  %xmm1,(%r14)
mov    0x8(%r12),%rdi
lea    0xdaa(%rip),%rsi
call   1050 <strcmp@plt>
test   %rax,%rax
jne    1298 <vypocetNeboVysledek+0x148>
movsd  0x8(%rsp),%xmm0
addsd  (%r14),%xmm0
movsd  %xmm0,(%r14)
movsd  (%r15),%xmm0
addsd  0xd5b(%rip),%xmm0
movsd  %xmm0,(%r15)
jmp    12df <vypocetNeboVysledek+0x18f>
test   %rax,%rax
je     12d7 <vypocetNeboVysledek+0x187>
movsd  0x8(%rsp),%xmm0
lea    0xd51(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
jmp    12df <vypocetNeboVysledek+0x18f>
lea    0xd48(%rip),%rdi
call   1070 <msg@plt>
xor    %eax,%eax
jmp    12e4 <vypocetNeboVysledek+0x194>
mov    %r13,%rdi
call   1030 <puts@plt>
mov    $0x1,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [7 x i8] c"select\00"
@.str.1 = [7 x i8] c"%.10g\0A\00"
@.str.2 = [4 x i8] c"%s\0A\00"
@.str.3 = [6 x i8] c"cislo\00"
@.str.4 = [4 x i8] c"min\00"
@.str.5 = [4 x i8] c"max\00"
@.str.6 = [4 x i8] c"avg\00"
@.str.7 = [4 x i8] c"sum\00"
define i32 @vypocetNeboVysledek(i8** %0, double* %1, double* %2, i8* %3) {
%5 = alloca i32
%6 = alloca i8**
%7 = alloca double*
%8 = alloca double*
%9 = alloca i8*
%10 = alloca double
store i8** %0, i8*** %6
store double* %1, double** %7
store double* %2, double** %8
store i8* %3, i8** %9
%11 = load i8**, i8*** %6
%12 = getelementptr inbounds i8*, i8** %11, i64 1
%13 = load i8*, i8** %12
%14 = call i64 @strcmp(i8* %13, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%15 = icmp eq i64 %14, 0
br i1 %15, label %16, label %27
16: ; preds = %4
%17 = load i8*, i8** %9
%18 = call i64 @strToDub(double* %10, i8* %17)
%19 = icmp ne i64 %18, 0
br i1 %19, label %20, label %23
20: ; preds = %16
%21 = load double, double* %10
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), double %21)
br label %26
23: ; preds = %16
%24 = load i8*, i8** %9
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* %24)
br label %26
26: ; preds = %23, %20
br label %115
27: ; preds = %4
%28 = load i8*, i8** %9
%29 = call i64 @strToDub(double* %10, i8* %28)
%30 = icmp ne i64 %29, 0
br i1 %30, label %33, label %31
31: ; preds = %27
%32 = call i32 @msg(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
store i32 0, i32* %5
br label %116
33: ; preds = %27
%34 = load double*, double** %8
%35 = load double, double* %34
%36 = fcmp oeq double %35, 0.000000e+00
br i1 %36, label %37, label %52
37: ; preds = %33
%38 = load i8**, i8*** %6
%39 = getelementptr inbounds i8*, i8** %38, i64 1
%40 = load i8*, i8** %39
%41 = call i64 @strcmp(i8* %40, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
%42 = icmp eq i64 %41, 0
br i1 %42, label %49, label %43
43: ; preds = %37
%44 = load i8**, i8*** %6
%45 = getelementptr inbounds i8*, i8** %44, i64 1
%46 = load i8*, i8** %45
%47 = call i64 @strcmp(i8* %46, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0))
%48 = icmp eq i64 %47, 0
br i1 %48, label %49, label %52
49: ; preds = %43, %37
%50 = load double, double* %10
%51 = load double*, double** %7
store double %50, double* %51
br label %52
52: ; preds = %49, %43, %33
%53 = load i8**, i8*** %6
%54 = getelementptr inbounds i8*, i8** %53, i64 1
%55 = load i8*, i8** %54
%56 = call i64 @strcmp(i8* %55, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
%57 = icmp eq i64 %56, 0
br i1 %57, label %58, label %67
58: ; preds = %52
%59 = load double*, double** %7
%60 = load double, double* %59
%61 = load double, double* %10
%62 = fcmp ogt double %60, %61
br i1 %62, label %63, label %66
63: ; preds = %58
%64 = load double, double* %10
%65 = load double*, double** %7
store double %64, double* %65
br label %66
66: ; preds = %63, %58
br label %67
67: ; preds = %66, %52
%68 = load i8**, i8*** %6
%69 = getelementptr inbounds i8*, i8** %68, i64 1
%70 = load i8*, i8** %69
%71 = call i64 @strcmp(i8* %70, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0))
%72 = icmp eq i64 %71, 0
br i1 %72, label %73, label %82
73: ; preds = %67
%74 = load double*, double** %7
%75 = load double, double* %74
%76 = load double, double* %10
%77 = fcmp olt double %75, %76
br i1 %77, label %78, label %81
78: ; preds = %73
%79 = load double, double* %10
%80 = load double*, double** %7
store double %79, double* %80
br label %81
81: ; preds = %78, %73
br label %82
82: ; preds = %81, %67
%83 = load i8**, i8*** %6
%84 = getelementptr inbounds i8*, i8** %83, i64 1
%85 = load i8*, i8** %84
%86 = call i64 @strcmp(i8* %85, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0))
%87 = icmp eq i64 %86, 0
br i1 %87, label %88, label %100
88: ; preds = %82
%89 = load double*, double** %7
%90 = load double, double* %89
%91 = load double*, double** %8
%92 = load double, double* %91
%93 = load double, double* %10
%94 = call double @llvm.fmuladd.f64(double %90, double %92, double %93)
%95 = load double*, double** %8
%96 = load double, double* %95
%97 = fadd double %96, 1.000000e+00
%98 = fdiv double %94, %97
%99 = load double*, double** %7
store double %98, double* %99
br label %100
100: ; preds = %88, %82
%101 = load i8**, i8*** %6
%102 = getelementptr inbounds i8*, i8** %101, i64 1
%103 = load i8*, i8** %102
%104 = call i64 @strcmp(i8* %103, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0))
%105 = icmp eq i64 %104, 0
br i1 %105, label %106, label %111
106: ; preds = %100
%107 = load double, double* %10
%108 = load double*, double** %7
%109 = load double, double* %108
%110 = fadd double %109, %107
store double %110, double* %108
br label %111
111: ; preds = %106, %100
%112 = load double*, double** %8
%113 = load double, double* %112
%114 = fadd double %113, 1.000000e+00
store double %114, double* %112
br label %115
115: ; preds = %111, %26
store i32 1, i32* %5
br label %116
116: ; preds = %115, %31
%117 = load i32, i32* %5
ret i32 %117
}

LLVM IR (-O2):
@.str = [7 x i8] c"select\00"
@.str.1 = [7 x i8] c"%.10g\0A\00"
@.str.3 = [6 x i8] c"cislo\00"
@.str.4 = [4 x i8] c"min\00"
@.str.5 = [4 x i8] c"max\00"
@.str.6 = [4 x i8] c"avg\00"
@.str.7 = [4 x i8] c"sum\00"
define i32 @vypocetNeboVysledek(i8** nocapture %0, double* nocapture %1, double* nocapture %2, i8* %3) {
%5 = alloca double
%6 = bitcast double* %5 to i8*
%7 = getelementptr inbounds i8*, i8** %0, i64 1
%8 = load i8*, i8** %7
%9 = tail call i64 @strcmp(i8* %8, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%10 = icmp eq i64 %9, 0
%11 = call i64 @strToDub(double* %5, i8* %3)
%12 = icmp eq i64 %11, 0
br i1 %10, label %13, label %19
13: ; preds = %4
br i1 %12, label %17, label %14
14: ; preds = %13
%15 = load double, double* %5
%16 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), double %15)
br label %75
17: ; preds = %13
%18 = call i32 @puts(i8* dereferenceable(1) %3)
br label %75
19: ; preds = %4
br i1 %12, label %20, label %22
20: ; preds = %19
%21 = call i32 @msg(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
br label %75
22: ; preds = %19
%23 = load double, double* %2
%24 = fcmp oeq double %23, 0.000000e+00
br i1 %24, label %25, label %35
25: ; preds = %22
%26 = load i8*, i8** %7
%27 = call i64 @strcmp(i8* %26, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
%28 = icmp eq i64 %27, 0
br i1 %28, label %33, label %29
29: ; preds = %25
%30 = load i8*, i8** %7
%31 = call i64 @strcmp(i8* %30, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0))
%32 = icmp eq i64 %31, 0
br i1 %32, label %33, label %35
33: ; preds = %29, %25
%34 = load double, double* %5
store double %34, double* %1
br label %35
35: ; preds = %33, %29, %22
%36 = load i8*, i8** %7
%37 = call i64 @strcmp(i8* %36, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0))
%38 = icmp eq i64 %37, 0
br i1 %38, label %39, label %44
39: ; preds = %35
%40 = load double, double* %1
%41 = load double, double* %5
%42 = fcmp ogt double %40, %41
br i1 %42, label %43, label %44
43: ; preds = %39
store double %41, double* %1
br label %44
44: ; preds = %39, %43, %35
%45 = load i8*, i8** %7
%46 = call i64 @strcmp(i8* %45, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0))
%47 = icmp eq i64 %46, 0
br i1 %47, label %48, label %53
48: ; preds = %44
%49 = load double, double* %1
%50 = load double, double* %5
%51 = fcmp olt double %49, %50
br i1 %51, label %52, label %53
52: ; preds = %48
store double %50, double* %1
br label %53
53: ; preds = %48, %52, %44
%54 = load i8*, i8** %7
%55 = call i64 @strcmp(i8* %54, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.6, i64 0, i64 0))
%56 = icmp eq i64 %55, 0
br i1 %56, label %57, label %64
57: ; preds = %53
%58 = load double, double* %1
%59 = load double, double* %2
%60 = load double, double* %5
%61 = call double @llvm.fmuladd.f64(double %58, double %59, double %60)
%62 = fadd double %59, 1.000000e+00
%63 = fdiv double %61, %62
store double %63, double* %1
br label %64
64: ; preds = %57, %53
%65 = load i8*, i8** %7
%66 = call i64 @strcmp(i8* %65, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.7, i64 0, i64 0))
%67 = icmp eq i64 %66, 0
br i1 %67, label %68, label %72
68: ; preds = %64
%69 = load double, double* %5
%70 = load double, double* %1
%71 = fadd double %69, %70
store double %71, double* %1
br label %72
72: ; preds = %68, %64
%73 = load double, double* %2
%74 = fadd double %73, 1.000000e+00
store double %74, double* %2
br label %75
75: ; preds = %72, %17, %14, %20
%76 = phi i32 [ 0, %20 ], [ 1, %14 ], [ 1, %17 ], [ 1, %72 ]
ret i32 %76
}