#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*/ mcfioC_GetNTupleCategory(int, int, char **);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
int /*<<< orphan*/ strncpy(char *, char *, int);
int mcfio_getntuplecategory_(int *stream, int *id, char *category, int ll) {
  int iret, lret;
  char *aString;
  mcfioC_GetNTupleCategory(*stream, *id, &aString);
  lret = strlen(aString);
  if (ll > lret)
    strcpy(category, aString);
  else
    strncpy(category, aString, (ll - 1));
  return lret;
}


x86 assembly (clang, -O0):
<mcfio_getntuplecategory_>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    -0x8(%rbp),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    (%rax),%esi
lea    -0x30(%rbp),%rdx
call   1050 <mcfioC_GetNTupleCategory@plt>
mov    -0x30(%rbp),%rdi
call   1060 <strlen@plt>
mov    %eax,-0x24(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x24(%rbp),%eax
jle    1196 <mcfio_getntuplecategory_+0x56>
mov    -0x18(%rbp),%rdi
mov    -0x30(%rbp),%rsi
call   1040 <strcpy@plt>
jmp    11a9 <mcfio_getntuplecategory_+0x69>
mov    -0x18(%rbp),%rdi
mov    -0x30(%rbp),%rsi
mov    -0x1c(%rbp),%edx
sub    $0x1,%edx
call   1030 <strncpy@plt>
mov    -0x24(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mcfio_getntuplecategory_>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %ecx,%ebx
mov    %rdx,%r14
mov    (%rdi),%edi
mov    (%rsi),%esi
lea    0x8(%rsp),%rdx
call   1050 <mcfioC_GetNTupleCategory@plt>
mov    0x8(%rsp),%rdi
call   1060 <strlen@plt>
mov    %eax,%ebp
mov    0x8(%rsp),%rsi
cmp    %ebx,%eax
jge    117a <mcfio_getntuplecategory_+0x3a>
mov    %r14,%rdi
call   1040 <strcpy@plt>
jmp    1187 <mcfio_getntuplecategory_+0x47>
add    $0xffffffff,%ebx
mov    %r14,%rdi
mov    %ebx,%edx
call   1030 <strncpy@plt>
mov    %ebp,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define i32 @mcfio_getntuplecategory_(i32* %0, i32* %1, i8* %2, i32 %3) {
%5 = alloca i32*
%6 = alloca i32*
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i8*
store i32* %0, i32** %5
store i32* %1, i32** %6
store i8* %2, i8** %7
store i32 %3, i32* %8
%12 = load i32*, i32** %5
%13 = load i32, i32* %12
%14 = load i32*, i32** %6
%15 = load i32, i32* %14
%16 = call i32 @mcfioC_GetNTupleCategory(i32 %13, i32 %15, i8** %11)
%17 = load i8*, i8** %11
%18 = call i32 @strlen(i8* %17)
store i32 %18, i32* %10
%19 = load i32, i32* %8
%20 = load i32, i32* %10
%21 = icmp sgt i32 %19, %20
br i1 %21, label %22, label %26
22: ; preds = %4
%23 = load i8*, i8** %7
%24 = load i8*, i8** %11
%25 = call i32 @strcpy(i8* %23, i8* %24)
br label %32
26: ; preds = %4
%27 = load i8*, i8** %7
%28 = load i8*, i8** %11
%29 = load i32, i32* %8
%30 = sub nsw i32 %29, 1
%31 = call i32 @strncpy(i8* %27, i8* %28, i32 %30)
br label %32
32: ; preds = %26, %22
%33 = load i32, i32* %10
ret i32 %33
}

LLVM IR (-O2):
define i32 @mcfio_getntuplecategory_(i32* nocapture %0, i32* nocapture %1, i8* %2, i32 %3) {
%5 = alloca i8*
%6 = bitcast i8** %5 to i8*
%7 = load i32, i32* %0
%8 = load i32, i32* %1
%9 = call i32 @mcfioC_GetNTupleCategory(i32 %7, i32 %8, i8** %5)
%10 = load i8*, i8** %5
%11 = call i32 @strlen(i8* %10)
%12 = icmp slt i32 %11, %3
%13 = load i8*, i8** %5
br i1 %12, label %14, label %16
14: ; preds = %4
%15 = call i32 @strcpy(i8* %2, i8* %13)
br label %19
16: ; preds = %4
%17 = add nsw i32 %3, -1
%18 = call i32 @strncpy(i8* %2, i8* %13, i32 %17)
br label %19
19: ; preds = %16, %14
ret i32 %11
}