#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*/ move(int, int);
int /*<<< orphan*/ printw(char *, ...);
int /*<<< orphan*/ refresh();
void progressbar2(int nSolveIters, int flag, int prog, double percent,
                  double minsnr, double median) {
  if (flag == 0) {
    move(9, 25 + prog);
    printw("#");
    if (percent < 100) {
      move(10, 25);
      printw("                         ");
    }
    refresh();
  } else if (flag == 1) {
    move(7, 38);
    printw("                    ");
    move(8, 38);
    printw("                    ");
    if (minsnr < 1000) {
      move(7, 25);
      printw("Min(SNR)    %3.3f", minsnr);
    } else {
      move(7, 25);
      printw("Min(SNR)    %.3e", minsnr);
    }
    if (median < 1000) {
      move(8, 25);
      printw("Median(SNR) %3.3f", median);
    } else {
      move(8, 25);
      printw("Median(SNR) %.3e", median);
    }
    refresh();
  }
}


x86 assembly (clang, -O0):
<progressbar2>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
movsd  %xmm0,-0x18(%rbp)
movsd  %xmm1,-0x20(%rbp)
movsd  %xmm2,-0x28(%rbp)
cmpl   $0x0,-0x8(%rbp)
jne    11b4 <progressbar2+0x84>
mov    -0xc(%rbp),%esi
add    $0x19,%esi
mov    $0x9,%edi
call   1050 <move@plt>
lea    0xe9f(%rip),%rdi
mov    $0x0,%al
call   1030 <printw@plt>
movsd  0xe88(%rip),%xmm0
ucomisd -0x18(%rbp),%xmm0
jbe    11a8 <progressbar2+0x78>
mov    $0xa,%edi
mov    $0x19,%esi
call   1050 <move@plt>
lea    0xe71(%rip),%rdi
mov    $0x0,%al
call   1030 <printw@plt>
mov    $0x0,%al
call   1040 <refresh@plt>
jmp    12bc <progressbar2+0x18c>
cmpl   $0x1,-0x8(%rbp)
jne    12b7 <progressbar2+0x187>
mov    $0x7,%edi
mov    $0x26,%esi
call   1050 <move@plt>
lea    0xe43(%rip),%rdi
mov    $0x0,%al
call   1030 <printw@plt>
mov    $0x8,%edi
mov    $0x26,%esi
call   1050 <move@plt>
lea    0xe26(%rip),%rdi
mov    $0x0,%al
call   1030 <printw@plt>
movsd  0xe00(%rip),%xmm0
ucomisd -0x20(%rbp),%xmm0
jbe    1232 <progressbar2+0x102>
mov    $0x7,%edi
mov    $0x19,%esi
call   1050 <move@plt>
movsd  -0x20(%rbp),%xmm0
lea    0xe06(%rip),%rdi
mov    $0x1,%al
call   1030 <printw@plt>
jmp    1254 <progressbar2+0x124>
mov    $0x7,%edi
mov    $0x19,%esi
call   1050 <move@plt>
movsd  -0x20(%rbp),%xmm0
lea    0xdf1(%rip),%rdi
mov    $0x1,%al
call   1030 <printw@plt>
movsd  0xda4(%rip),%xmm0
ucomisd -0x28(%rbp),%xmm0
jbe    128e <progressbar2+0x15e>
mov    $0x8,%edi
mov    $0x19,%esi
call   1050 <move@plt>
movsd  -0x28(%rbp),%xmm0
lea    0xdcd(%rip),%rdi
mov    $0x1,%al
call   1030 <printw@plt>
jmp    12b0 <progressbar2+0x180>
mov    $0x8,%edi
mov    $0x19,%esi
call   1050 <move@plt>
movsd  -0x28(%rbp),%xmm0
lea    0xdb8(%rip),%rdi
mov    $0x1,%al
call   1030 <printw@plt>
mov    $0x0,%al
call   1040 <refresh@plt>
jmp    12bc <progressbar2+0x18c>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<progressbar2>:
push   %rbx
sub    $0x10,%rsp
cmp    $0x1,%esi
je     1199 <progressbar2+0x69>
test   %esi,%esi
jne    1260 <progressbar2+0x130>
add    $0x19,%edx
mov    $0x9,%edi
mov    %edx,%esi
movsd  %xmm0,(%rsp)
call   1050 <move@plt>
lea    0xeb3(%rip),%rdi
xor    %eax,%eax
call   1030 <printw@plt>
movsd  0xe9c(%rip),%xmm0
ucomisd (%rsp),%xmm0
jbe    1254 <progressbar2+0x124>
mov    $0xa,%edi
mov    $0x19,%esi
call   1050 <move@plt>
lea    0xe85(%rip),%rdi
xor    %eax,%eax
call   1030 <printw@plt>
jmp    1254 <progressbar2+0x124>
mov    $0x7,%edi
mov    $0x26,%esi
movsd  %xmm2,(%rsp)
movsd  %xmm1,0x8(%rsp)
call   1050 <move@plt>
lea    0xe5d(%rip),%rbx
mov    %rbx,%rdi
xor    %eax,%eax
call   1030 <printw@plt>
mov    $0x8,%edi
mov    $0x26,%esi
call   1050 <move@plt>
mov    %rbx,%rdi
xor    %eax,%eax
call   1030 <printw@plt>
mov    $0x7,%edi
mov    $0x19,%esi
call   1050 <move@plt>
movsd  0xe0c(%rip),%xmm1
movsd  0x8(%rsp),%xmm0
ucomisd %xmm0,%xmm1
lea    0xe27(%rip),%rax
lea    0xe32(%rip),%rdi
cmova  %rax,%rdi
mov    $0x1,%al
call   1030 <printw@plt>
movsd  0xde1(%rip),%xmm0
ucomisd (%rsp),%xmm0
lea    0xe24(%rip),%rax
lea    0xe2f(%rip),%rbx
cmova  %rax,%rbx
mov    $0x8,%edi
mov    $0x19,%esi
call   1050 <move@plt>
mov    %rbx,%rdi
movsd  (%rsp),%xmm0
mov    $0x1,%al
call   1030 <printw@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
jmp    1040 <refresh@plt>
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [2 x i8] c"#\00"
@.str.1 = [26 x i8] c" \00"
@.str.2 = [21 x i8] c" \00"
@.str.3 = [18 x i8] c"Min(SNR) %3.3f\00"
@.str.4 = [17 x i8] c"Min(SNR) %.3e\00"
@.str.5 = [18 x i8] c"Median(SNR) %3.3f\00"
@.str.6 = [17 x i8] c"Median(SNR) %.3e\00"
define void @progressbar2(i32 %0, i32 %1, i32 %2, double %3, double %4, double %5) {
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca double
%11 = alloca double
%12 = alloca double
store i32 %0, i32* %7
store i32 %1, i32* %8
store i32 %2, i32* %9
store double %3, double* %10
store double %4, double* %11
store double %5, double* %12
%13 = load i32, i32* %8
%14 = icmp eq i32 %13, 0
br i1 %14, label %15, label %27
15: ; preds = %6
%16 = load i32, i32* %9
%17 = add nsw i32 25, %16
%18 = call i32 @move(i32 9, i32 %17)
%19 = call i32 (i8*, ...) @printw(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%20 = load double, double* %10
%21 = fcmp olt double %20, 1.000000e+02
br i1 %21, label %22, label %25
22: ; preds = %15
%23 = call i32 @move(i32 10, i32 25)
%24 = call i32 (i8*, ...) @printw(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0))
br label %25
25: ; preds = %22, %15
%26 = call i32 (...) @refresh()
br label %59
27: ; preds = %6
%28 = load i32, i32* %8
%29 = icmp eq i32 %28, 1
br i1 %29, label %30, label %58
30: ; preds = %27
%31 = call i32 @move(i32 7, i32 38)
%32 = call i32 (i8*, ...) @printw(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0))
%33 = call i32 @move(i32 8, i32 38)
%34 = call i32 (i8*, ...) @printw(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0))
%35 = load double, double* %11
%36 = fcmp olt double %35, 1.000000e+03
br i1 %36, label %37, label %41
37: ; preds = %30
%38 = call i32 @move(i32 7, i32 25)
%39 = load double, double* %11
%40 = call i32 (i8*, ...) @printw(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0), double %39)
br label %45
41: ; preds = %30
%42 = call i32 @move(i32 7, i32 25)
%43 = load double, double* %11
%44 = call i32 (i8*, ...) @printw(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0), double %43)
br label %45
45: ; preds = %41, %37
%46 = load double, double* %12
%47 = fcmp olt double %46, 1.000000e+03
br i1 %47, label %48, label %52
48: ; preds = %45
%49 = call i32 @move(i32 8, i32 25)
%50 = load double, double* %12
%51 = call i32 (i8*, ...) @printw(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.5, i64 0, i64 0), double %50)
br label %56
52: ; preds = %45
%53 = call i32 @move(i32 8, i32 25)
%54 = load double, double* %12
%55 = call i32 (i8*, ...) @printw(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.6, i64 0, i64 0), double %54)
br label %56
56: ; preds = %52, %48
%57 = call i32 (...) @refresh()
br label %58
58: ; preds = %56, %27
br label %59
59: ; preds = %58, %25
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c"#\00"
@.str.1 = [26 x i8] c" \00"
@.str.2 = [21 x i8] c" \00"
@.str.3 = [18 x i8] c"Min(SNR) %3.3f\00"
@.str.4 = [17 x i8] c"Min(SNR) %.3e\00"
@.str.5 = [18 x i8] c"Median(SNR) %3.3f\00"
@.str.6 = [17 x i8] c"Median(SNR) %.3e\00"
define void @progressbar2(i32 %0, i32 %1, i32 %2, double %3, double %4, double %5) {
switch i32 %1, label %30 [
i32 0, label %7
i32 1, label %15
]
7: ; preds = %6
%8 = add nsw i32 %2, 25
%9 = tail call i32 @move(i32 9, i32 %8)
%10 = tail call i32 (i8*, ...) @printw(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%11 = fcmp olt double %3, 1.000000e+02
br i1 %11, label %12, label %28
12: ; preds = %7
%13 = tail call i32 @move(i32 10, i32 25)
%14 = tail call i32 (i8*, ...) @printw(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0))
br label %28
15: ; preds = %6
%16 = tail call i32 @move(i32 7, i32 38)
%17 = tail call i32 (i8*, ...) @printw(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0))
%18 = tail call i32 @move(i32 8, i32 38)
%19 = tail call i32 (i8*, ...) @printw(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0))
%20 = fcmp olt double %4, 1.000000e+03
%21 = tail call i32 @move(i32 7, i32 25)
%22 = select i1 %20, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.4, i64 0, i64 0)
%23 = tail call i32 (i8*, ...) @printw(i8* %22, double %4)
%24 = fcmp olt double %5, 1.000000e+03
%25 = select i1 %24, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.6, i64 0, i64 0)
%26 = tail call i32 @move(i32 8, i32 25)
%27 = tail call i32 (i8*, ...) @printw(i8* %25, double %5)
br label %28
28: ; preds = %7, %12, %15
%29 = tail call i32 (...) @refresh()
br label %30
30: ; preds = %28, %6
ret void
}