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


x86 assembly (clang, -O0):
<ncattname>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %rcx,-0x18(%rbp)
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    -0x18(%rbp),%rcx
call   1030 <nc_inq_attname@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
je     1179 <ncattname+0x59>
mov    -0x1c(%rbp),%esi
mov    -0x8(%rbp),%ecx
lea    0xe9f(%rip),%rdi
lea    0xea2(%rip),%rdx
call   1040 <nc_advise@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    117f <ncattname+0x5f>
mov    -0x10(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ncattname>:
push   %rbp
push   %rbx
push   %rax
mov    %edx,%ebp
mov    %edi,%ebx
call   1030 <nc_inq_attname@plt>
test   %eax,%eax
je     114c <ncattname+0x2c>
lea    0xec9(%rip),%rdi
lea    0xecc(%rip),%rdx
mov    %eax,%esi
mov    %ebx,%ecx
call   1040 <nc_advise@plt>
mov    $0xffffffff,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

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

LLVM IR (-O2):
@.str = [10 x i8] c"ncattname\00"
@.str.1 = [8 x i8] c"ncid %d\00"
define i32 @ncattname(i32 %0, i32 %1, i32 %2, i8* %3) {
%5 = tail call i32 @nc_inq_attname(i32 %0, i32 %1, i32 %2, i8* %3)
%6 = icmp eq i32 %5, 0
br i1 %6, label %9, label %7
7: ; preds = %4
%8 = tail call i32 @nc_advise(i8* getelementptr inbounds ([10 x i8], [10 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 %9
9: ; preds = %4, %7
%10 = phi i32 [ -1, %7 ], [ %2, %4 ]
ret i32 %10
}