#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*/ nc_advise(char *, int const, char *, int);
int nc_inq_varid(int, char const *, int *);
int ncvarid(int ncid, const char *name) {
  int varid = -1;
  const int status = nc_inq_varid(ncid, name, &varid);
  if (status != 0) {
    nc_advise("ncvarid", status, "ncid %d", ncid);
    return -1;
  }
  return varid;
}


x86 assembly (clang, -O0):
<ncvarid>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0xffffffff,-0x14(%rbp)
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    -0x14(%rbp),%rdx
call   1030 <nc_inq_varid@plt>
mov    %eax,-0x18(%rbp)
cmpl   $0x0,-0x18(%rbp)
je     1178 <ncvarid+0x58>
mov    -0x18(%rbp),%esi
mov    -0x8(%rbp),%ecx
lea    0xea0(%rip),%rdi
lea    0xea1(%rip),%rdx
call   1040 <nc_advise@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    117e <ncvarid+0x5e>
mov    -0x14(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ncvarid>:
push   %rbx
sub    $0x10,%rsp
mov    %edi,%ebx
movl   $0xffffffff,0xc(%rsp)
ff
lea    0xc(%rsp),%rdx
call   1030 <nc_inq_varid@plt>
test   %eax,%eax
je     115b <ncvarid+0x3b>
lea    0xebc(%rip),%rdi
lea    0xebd(%rip),%rdx
mov    %eax,%esi
mov    %ebx,%ecx
call   1040 <nc_advise@plt>
mov    $0xffffffff,%eax
jmp    115f <ncvarid+0x3f>
mov    0xc(%rsp),%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [8 x i8] c"ncvarid\00"
@.str.1 = [8 x i8] c"ncid %d\00"
define i32 @ncvarid(i32 %0, i8* %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
store i32 %0, i32* %4
store i8* %1, i8** %5
store i32 -1, i32* %6
%8 = load i32, i32* %4
%9 = load i8*, i8** %5
%10 = call i32 @nc_inq_varid(i32 %8, i8* %9, i32* %6)
store i32 %10, i32* %7
%11 = load i32, i32* %7
%12 = icmp ne i32 %11, 0
br i1 %12, label %13, label %17
13: ; preds = %2
%14 = load i32, i32* %7
%15 = load i32, i32* %4
%16 = call i32 @nc_advise(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 %14, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i32 %15)
store i32 -1, i32* %3
br label %19
17: ; preds = %2
%18 = load i32, i32* %6
store i32 %18, i32* %3
br label %19
19: ; preds = %17, %13
%20 = load i32, i32* %3
ret i32 %20
}

LLVM IR (-O2):
@.str = [8 x i8] c"ncvarid\00"
@.str.1 = [8 x i8] c"ncid %d\00"
define i32 @ncvarid(i32 %0, i8* %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
store i32 -1, i32* %3
%5 = call i32 @nc_inq_varid(i32 %0, i8* %1, i32* %3)
%6 = icmp eq i32 %5, 0
br i1 %6, label %9, label %7
7: ; preds = %2
%8 = call i32 @nc_advise(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0), i32 %5, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i32 %0)
br label %11
9: ; preds = %2
%10 = load i32, i32* %3
br label %11
11: ; preds = %9, %7
%12 = phi i32 [ -1, %7 ], [ %10, %9 ]
ret i32 %12
}