#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*/ bugv_c(float, char *, char const *, char const *, size_t);
char *getKeyValue(char const *, int /*<<< orphan*/);
size_t strlen(char const *);
int /*<<< orphan*/ strncpy(char *, char const *, size_t);
void keya_len_c(const char *keyword, char *value, size_t vlen,
                const char *keydef) {
  char *s;
  s = getKeyValue(keyword, 0);
  if (s && strlen(s) > vlen)
    bugv_c('f',
           "KeyA: value \"%s\" of keyword \"%s\" is doesn\'t fit in its "
           "Fortran buffer, which is only %zd bytes.",
           s, keyword, vlen);
  if ((s == (char *)NULL) && strlen(keydef) > vlen)
    bugv_c(
        'f',
        "KeyA: default value \"%s\" of keyword \"%s\" is would not fit in its "
        "Fortran buffer, which is only %zd bytes.",
        keydef, keyword, vlen);
  (void)strncpy(value, ((s == (char *)NULL) ? keydef : s), vlen);
  return;
}


x86 assembly (clang, -O0):
<keya_len_c>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
xor    %esi,%esi
call   1050 <getKeyValue@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     11a5 <keya_len_c+0x65>
mov    -0x28(%rbp),%rdi
call   1040 <strlen@plt>
cmp    -0x18(%rbp),%rax
jbe    11a5 <keya_len_c+0x65>
mov    -0x28(%rbp),%rsi
mov    -0x8(%rbp),%rdx
mov    -0x18(%rbp),%rcx
movss  0xe67(%rip),%xmm0
lea    0xe64(%rip),%rdi
call   1060 <bugv_c@plt>
cmpq   $0x0,-0x28(%rbp)
jne    11e3 <keya_len_c+0xa3>
mov    -0x20(%rbp),%rdi
call   1040 <strlen@plt>
cmp    -0x18(%rbp),%rax
jbe    11e3 <keya_len_c+0xa3>
mov    -0x20(%rbp),%rsi
mov    -0x8(%rbp),%rdx
mov    -0x18(%rbp),%rcx
movss  0xe29(%rip),%xmm0
lea    0xe86(%rip),%rdi
call   1060 <bugv_c@plt>
mov    -0x10(%rbp),%rax
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    1203 <keya_len_c+0xc3>
mov    -0x20(%rbp),%rax
mov    %rax,-0x38(%rbp)
jmp    120b <keya_len_c+0xcb>
mov    -0x28(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x30(%rbp),%rdi
mov    -0x38(%rbp),%rsi
mov    -0x18(%rbp),%rdx
call   1030 <strncpy@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<keya_len_c>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %rcx,%r13
mov    %rdx,%r12
mov    %rsi,%r14
mov    %rdi,%r15
xor    %esi,%esi
call   1050 <getKeyValue@plt>
test   %rax,%rax
je     1190 <keya_len_c+0x50>
mov    %rax,%rbx
mov    %rax,%rdi
call   1040 <strlen@plt>
cmp    %r12,%rax
jbe    11bd <keya_len_c+0x7d>
lea    0xe8c(%rip),%rdi
movss  0xe80(%rip),%xmm0
mov    %rbx,%rsi
mov    %r15,%rdx
mov    %r12,%rcx
call   1060 <bugv_c@plt>
jmp    11bd <keya_len_c+0x7d>
mov    %r13,%rdi
call   1040 <strlen@plt>
cmp    %r12,%rax
jbe    11ba <keya_len_c+0x7a>
lea    0xec0(%rip),%rdi
movss  0xe54(%rip),%xmm0
mov    %r13,%rsi
mov    %r15,%rdx
mov    %r12,%rcx
call   1060 <bugv_c@plt>
mov    %r13,%rbx
mov    %r14,%rdi
mov    %rbx,%rsi
mov    %r12,%rdx
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
jmp    1030 <strncpy@plt>

LLVM IR (-O0):
@.str = [96 x i8] c"KeyA: value \22%s\22 of keyword \22%s\22 is doesn't fit in its Fortran buffer, which is only %zd bytes.\00"
@.str.1 = [106 x i8] c"KeyA: default value \22%s\22 of keyword \22%s\22 is would not fit in its Fortran buffer, which is only %zd bytes.\00"
define void @keya_len_c(i8* %0, i8* %1, i64 %2, i8* %3) {
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i64
%8 = alloca i8*
%9 = alloca i8*
store i8* %0, i8** %5
store i8* %1, i8** %6
store i64 %2, i64* %7
store i8* %3, i8** %8
%10 = load i8*, i8** %5
%11 = call i8* @getKeyValue(i8* %10, i32 0)
store i8* %11, i8** %9
%12 = load i8*, i8** %9
%13 = icmp ne i8* %12, null
br i1 %13, label %14, label %24
14: ; preds = %4
%15 = load i8*, i8** %9
%16 = call i64 @strlen(i8* %15)
%17 = load i64, i64* %7
%18 = icmp ugt i64 %16, %17
br i1 %18, label %19, label %24
19: ; preds = %14
%20 = load i8*, i8** %9
%21 = load i8*, i8** %5
%22 = load i64, i64* %7
%23 = call i32 @bugv_c(float 1.020000e+02, i8* getelementptr inbounds ([96 x i8], [96 x i8]* @.str, i64 0, i64 0), i8* %20, i8* %21, i64 %22)
br label %24
24: ; preds = %19, %14, %4
%25 = load i8*, i8** %9
%26 = icmp eq i8* %25, null
br i1 %26, label %27, label %37
27: ; preds = %24
%28 = load i8*, i8** %8
%29 = call i64 @strlen(i8* %28)
%30 = load i64, i64* %7
%31 = icmp ugt i64 %29, %30
br i1 %31, label %32, label %37
32: ; preds = %27
%33 = load i8*, i8** %8
%34 = load i8*, i8** %5
%35 = load i64, i64* %7
%36 = call i32 @bugv_c(float 1.020000e+02, i8* getelementptr inbounds ([106 x i8], [106 x i8]* @.str.1, i64 0, i64 0), i8* %33, i8* %34, i64 %35)
br label %37
37: ; preds = %32, %27, %24
%38 = load i8*, i8** %6
%39 = load i8*, i8** %9
%40 = icmp eq i8* %39, null
br i1 %40, label %41, label %43
41: ; preds = %37
%42 = load i8*, i8** %8
br label %45
43: ; preds = %37
%44 = load i8*, i8** %9
br label %45
45: ; preds = %43, %41
%46 = phi i8* [ %42, %41 ], [ %44, %43 ]
%47 = load i64, i64* %7
%48 = call i32 @strncpy(i8* %38, i8* %46, i64 %47)
ret void
}

LLVM IR (-O2):
@.str = [96 x i8] c"KeyA: value \22%s\22 of keyword \22%s\22 is doesn't fit in its Fortran buffer, which is only %zd bytes.\00"
@.str.1 = [106 x i8] c"KeyA: default value \22%s\22 of keyword \22%s\22 is would not fit in its Fortran buffer, which is only %zd bytes.\00"
define void @keya_len_c(i8* %0, i8* %1, i64 %2, i8* %3) {
%5 = tail call i8* @getKeyValue(i8* %0, i32 0)
%6 = icmp eq i8* %5, null
br i1 %6, label %12, label %7
7: ; preds = %4
%8 = tail call i64 @strlen(i8* %5)
%9 = icmp ugt i64 %8, %2
br i1 %9, label %10, label %17
10: ; preds = %7
%11 = tail call i32 @bugv_c(float 1.020000e+02, i8* getelementptr inbounds ([96 x i8], [96 x i8]* @.str, i64 0, i64 0), i8* %5, i8* %0, i64 %2)
br label %17
12: ; preds = %4
%13 = tail call i64 @strlen(i8* dereferenceable(1) %3)
%14 = icmp ugt i64 %13, %2
br i1 %14, label %15, label %17
15: ; preds = %12
%16 = tail call i32 @bugv_c(float 1.020000e+02, i8* getelementptr inbounds ([106 x i8], [106 x i8]* @.str.1, i64 0, i64 0), i8* %3, i8* %0, i64 %2)
br label %17
17: ; preds = %7, %10, %15, %12
%18 = phi i8* [ %3, %15 ], [ %3, %12 ], [ %5, %10 ], [ %5, %7 ]
%19 = tail call i32 @strncpy(i8* %1, i8* %18, i64 %2)
ret void
}