#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 */
unsigned char *number_of_forecasts_in_the_ensemble_location(unsigned char **);
int /*<<< orphan*/ sprintf(char *, char *, int);
int f_N_ens(int mode, unsigned char **sec, float *data, unsigned int ndata,
            char *inv_out, void **local) {
  int n;
  unsigned char *p;
  if (mode >= 0) {
    p = number_of_forecasts_in_the_ensemble_location(sec);
    if (p) {
      n = *p;
      if (n == 255)
        n = -1;
      sprintf(inv_out, "%d ens members", n);
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<f_N_ens>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
cmpl   $0x0,-0x4(%rbp)
jl     1196 <f_N_ens+0x76>
mov    -0x10(%rbp),%rdi
call   1030 <number_of_forecasts_in_the_ensemble_location@plt>
mov    %rax,-0x40(%rbp)
cmpq   $0x0,-0x40(%rbp)
je     1191 <f_N_ens+0x71>
mov    -0x40(%rbp),%rax
movzbl (%rax),%eax
mov    %eax,-0x34(%rbp)
cmpl   $0xff,-0x34(%rbp)
jne    117e <f_N_ens+0x5e>
movl   $0xffffffff,-0x34(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x34(%rbp),%edx
lea    0xe74(%rip),%rsi
call   1040 <sprintf@plt>
jmp    1196 <f_N_ens+0x76>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<f_N_ens>:
push   %rbx
test   %edi,%edi
js     1154 <f_N_ens+0x34>
mov    %r8,%rbx
mov    %rsi,%rdi
call   1030 <number_of_forecasts_in_the_ensemble_location@plt>
test   %rax,%rax
je     1154 <f_N_ens+0x34>
movzbl (%rax),%eax
cmp    $0xff,%eax
mov    $0xffffffff,%edx
cmovne %eax,%edx
lea    0xeb4(%rip),%rsi
mov    %rbx,%rdi
call   1040 <sprintf@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [15 x i8] c"%d ens members\00"
define i32 @f_N_ens(i32 %0, i8** %1, float* %2, i32 %3, i8* %4, i8** %5) {
%7 = alloca i32
%8 = alloca i8**
%9 = alloca float*
%10 = alloca i32
%11 = alloca i8*
%12 = alloca i8**
%13 = alloca i32
%14 = alloca i8*
store i32 %0, i32* %7
store i8** %1, i8*** %8
store float* %2, float** %9
store i32 %3, i32* %10
store i8* %4, i8** %11
store i8** %5, i8*** %12
%15 = load i32, i32* %7
%16 = icmp sge i32 %15, 0
br i1 %16, label %17, label %34
17: ; preds = %6
%18 = load i8**, i8*** %8
%19 = call i8* @number_of_forecasts_in_the_ensemble_location(i8** %18)
store i8* %19, i8** %14
%20 = load i8*, i8** %14
%21 = icmp ne i8* %20, null
br i1 %21, label %22, label %33
22: ; preds = %17
%23 = load i8*, i8** %14
%24 = load i8, i8* %23
%25 = zext i8 %24 to i32
store i32 %25, i32* %13
%26 = load i32, i32* %13
%27 = icmp eq i32 %26, 255
br i1 %27, label %28, label %29
28: ; preds = %22
store i32 -1, i32* %13
br label %29
29: ; preds = %28, %22
%30 = load i8*, i8** %11
%31 = load i32, i32* %13
%32 = call i32 @sprintf(i8* %30, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i32 %31)
br label %33
33: ; preds = %29, %17
br label %34
34: ; preds = %33, %6
ret i32 0
}

LLVM IR (-O2):
@.str = [15 x i8] c"%d ens members\00"
define i32 @f_N_ens(i32 %0, i8** %1, float* nocapture readnone %2, i32 %3, i8* nocapture writeonly %4, i8** nocapture readnone %5) {
%7 = icmp sgt i32 %0, -1
br i1 %7, label %8, label %17
8: ; preds = %6
%9 = tail call i8* @number_of_forecasts_in_the_ensemble_location(i8** %1)
%10 = icmp eq i8* %9, null
br i1 %10, label %17, label %11
11: ; preds = %8
%12 = load i8, i8* %9
%13 = zext i8 %12 to i32
%14 = icmp eq i8 %12, -1
%15 = select i1 %14, i32 -1, i32 %13
%16 = tail call i32 @sprintf(i8* dereferenceable(1) %4, i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0), i32 %15)
br label %17
17: ; preds = %8, %11, %6
ret i32 0
}