#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*/ BNCIO2(long, int);
int /*<<< orphan*/ BNCTerminate();
int /*<<< orphan*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stdout;
long int BNCWaveformUpload(long int len, long int waveup[]) {
  long int ii;
  printf(" - waveform of %li data points\n", len);
  BNCIO2(26, 27);
  for (ii = 0; ii < len; ii++) {
    BNCIO2(waveup[ii], 18);
    printf("\r - waveform of %li data points downloaded ", ii + 1);
    fflush(stdout);
  }
  BNCTerminate();
  printf("\n");
  return 0;
}


x86 assembly (clang, -O0):
<BNCWaveformUpload>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rsi
lea    0xea5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x1a,%edi
mov    $0x1b,%esi
call   1040 <BNCIO2@plt>
movq   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%rax
cmp    -0x8(%rbp),%rax
jge    11d2 <BNCWaveformUpload+0x92>
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
mov    $0x12,%esi
call   1040 <BNCIO2@plt>
mov    -0x18(%rbp),%rsi
add    $0x1,%rsi
lea    0xe74(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    0x2e26(%rip),%rax
mov    (%rax),%edi
call   1060 <fflush@plt>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    1179 <BNCWaveformUpload+0x39>
mov    $0x0,%al
call   1050 <BNCTerminate@plt>
lea    0xe3e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<BNCWaveformUpload>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %rsi,%r14
mov    %rdi,%r15
lea    0xe9a(%rip),%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x1a,%edi
mov    $0x1b,%esi
call   1050 <BNCIO2@plt>
test   %r15,%r15
jle    11d7 <BNCWaveformUpload+0x87>
neg    %r15
mov    $0x1,%ebx
lea    0xe8d(%rip),%r12
mov    0x2e46(%rip),%r13
nopw   0x0(%rax,%rax,1)
mov    -0x8(%r14,%rbx,8),%rdi
mov    $0x12,%esi
call   1050 <BNCIO2@plt>
mov    %r12,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x0(%r13),%edi
call   1070 <fflush@plt>
lea    (%r15,%rbx,1),%rax
add    $0x1,%rax
add    $0x1,%rbx
cmp    $0x1,%rax
jne    11a0 <BNCWaveformUpload+0x50>
xor    %eax,%eax
call   1060 <BNCTerminate@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [32 x i8] c" - waveform of %li data points\0A\00"
@.str.1 = [44 x i8] c"\0D - waveform of %li data points downloaded \00"
@stdout = global i32 0
@.str.2 = [2 x i8] c"\0A\00"
define i64 @BNCWaveformUpload(i64 %0, i64* %1) {
%3 = alloca i64
%4 = alloca i64*
%5 = alloca i64
store i64 %0, i64* %3
store i64* %1, i64** %4
%6 = load i64, i64* %3
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), i64 %6)
%8 = call i32 @BNCIO2(i64 26, i32 27)
store i64 0, i64* %5
br label %9
9: ; preds = %24, %2
%10 = load i64, i64* %5
%11 = load i64, i64* %3
%12 = icmp slt i64 %10, %11
br i1 %12, label %13, label %27
13: ; preds = %9
%14 = load i64*, i64** %4
%15 = load i64, i64* %5
%16 = getelementptr inbounds i64, i64* %14, i64 %15
%17 = load i64, i64* %16
%18 = call i32 @BNCIO2(i64 %17, i32 18)
%19 = load i64, i64* %5
%20 = add nsw i64 %19, 1
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([44 x i8], [44 x i8]* @.str.1, i64 0, i64 0), i64 %20)
%22 = load i32, i32* @stdout
%23 = call i32 @fflush(i32 %22)
br label %24
24: ; preds = %13
%25 = load i64, i64* %5
%26 = add nsw i64 %25, 1
store i64 %26, i64* %5
br label %9
27: ; preds = %9
%28 = call i32 (...) @BNCTerminate()
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
ret i64 0
}

LLVM IR (-O2):
@.str = [32 x i8] c" - waveform of %li data points\0A\00"
@.str.1 = [44 x i8] c"\0D - waveform of %li data points downloaded \00"
@stdout = global i32 0
define i64 @BNCWaveformUpload(i64 %0, i64* nocapture %1) {
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), i64 %0)
%4 = tail call i32 @BNCIO2(i64 26, i32 27)
%5 = icmp sgt i64 %0, 0
br i1 %5, label %6, label %16
6: ; preds = %2, %6
%7 = phi i64 [ %11, %6 ], [ 0, %2 ]
%8 = getelementptr inbounds i64, i64* %1, i64 %7
%9 = load i64, i64* %8
%10 = tail call i32 @BNCIO2(i64 %9, i32 18)
%11 = add nuw nsw i64 %7, 1
%12 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([44 x i8], [44 x i8]* @.str.1, i64 0, i64 0), i64 %11)
%13 = load i32, i32* @stdout
%14 = tail call i32 @fflush(i32 %13)
%15 = icmp eq i64 %11, %0
br i1 %15, label %16, label %6
16: ; preds = %6, %2
%17 = tail call i32 (...) @BNCTerminate()
%18 = tail call i32 @putchar(i32 10)
ret i64 0
}