#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 */
scalar_t__ isdigit(char);
char *malloc(scalar_t__);
int /*<<< orphan*/ snprintf(char *, int, char *, long);
int /*<<< orphan*/ strcat(char *, char *);
int /*<<< orphan*/ strcmp(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
scalar_t__ strlen(char *);
int /*<<< orphan*/ strncmp(char *, char *, int);
long strtol(char *, char **, int);
char *c_types_binding(char *s) {
  char *str_to_return = "CHARACTER(KIND=C_CHAR), DIMENSION(";
  char *name_with_extension;
  if (!strcmp(s, "INTEGER(IntKi)"))
    return ("INTEGER(KIND=C_INT)");
  if (!strcmp(s, "LOGICAL"))
    return ("LOGICAL(KIND=C_BOOL)");
  if (!strcmp(s, "REAL(ReKi)"))
    return ("REAL(KIND=C_FLOAT)");
  if (!strcmp(s, "REAL(SiKi)"))
    return ("REAL(KIND=C_FLOAT)");
  if (!strcmp(s, "REAL(DbKi)"))
    return ("REAL(KIND=C_DOUBLE)");
  if (!strcmp(s, "REAL(R8Ki)"))
    return ("REAL(KIND=C_DOUBLE)");
  if (!strncmp(s, "CHARACTER", 9)) {
    char *p = s, buf[10];
    while (*p) {
      if (isdigit(*p)) {
        long val = strtol(p, &p, 10);
        snprintf(buf, 10, "%lu", val);
      } else {
        p++;
      }
    }
    name_with_extension = malloc(strlen(str_to_return) + 15);
    strcpy(name_with_extension, str_to_return);
    strcat(name_with_extension, buf);
    strcat(name_with_extension, ")");
    return name_with_extension;
  };
  return ("unknown");
}


x86 assembly (clang, -O0):
<c_types_binding>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
lea    0xe5d(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xe71(%rip),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%eax
jne    11d0 <c_types_binding+0x40>
lea    0xe6b(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1386 <c_types_binding+0x1f6>
mov    -0x10(%rbp),%rdi
lea    0xe6b(%rip),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%eax
jne    11f9 <c_types_binding+0x69>
lea    0xe5e(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1386 <c_types_binding+0x1f6>
mov    -0x10(%rbp),%rdi
lea    0xe5f(%rip),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%eax
jne    1222 <c_types_binding+0x92>
lea    0xe55(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1386 <c_types_binding+0x1f6>
mov    -0x10(%rbp),%rdi
lea    0xe54(%rip),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%eax
jne    124b <c_types_binding+0xbb>
lea    0xe2c(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1386 <c_types_binding+0x1f6>
mov    -0x10(%rbp),%rdi
lea    0xe36(%rip),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%eax
jne    1274 <c_types_binding+0xe4>
lea    0xe2c(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1386 <c_types_binding+0x1f6>
mov    -0x10(%rbp),%rdi
lea    0xe2c(%rip),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%eax
jne    129d <c_types_binding+0x10d>
lea    0xe03(%rip),%rax
mov    %rax,-0x8(%rbp)
jmp    1386 <c_types_binding+0x1f6>
mov    -0x10(%rbp),%rdi
lea    0xe0e(%rip),%rsi
mov    $0x9,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%eax
jne    137b <c_types_binding+0x1eb>
mov    -0x10(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
cmpb   $0x0,(%rax)
je     132b <c_types_binding+0x19b>
mov    -0x28(%rbp),%rax
movsbl (%rax),%edi
call   1040 <isdigit@plt>
cmp    $0x0,%rax
je     131a <c_types_binding+0x18a>
mov    -0x28(%rbp),%rdi
lea    -0x28(%rbp),%rsi
mov    $0xa,%edx
call   1090 <strtol@plt>
mov    %rax,-0x40(%rbp)
lea    -0x32(%rbp),%rdi
mov    -0x40(%rbp),%rcx
mov    $0xa,%esi
lea    0xdb0(%rip),%rdx
call   1070 <snprintf@plt>
jmp    1326 <c_types_binding+0x196>
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
jmp    12c3 <c_types_binding+0x133>
mov    -0x18(%rbp),%rdi
call   1060 <strlen@plt>
mov    %rax,%rdi
add    $0xf,%rdi
call   10a0 <malloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1050 <strcpy@plt>
mov    -0x20(%rbp),%rdi
lea    -0x32(%rbp),%rsi
call   10b0 <strcat@plt>
mov    -0x20(%rbp),%rdi
lea    0xd40(%rip),%rsi
call   10b0 <strcat@plt>
mov    -0x20(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    1386 <c_types_binding+0x1f6>
lea    0xd42(%rip),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<c_types_binding>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rdi,%rbx
lea    0xe8e(%rip),%rsi
call   1070 <strcmp@plt>
test   %eax,%eax
je     1234 <c_types_binding+0xb4>
lea    0xe9d(%rip),%rsi
mov    %rbx,%rdi
call   1070 <strcmp@plt>
test   %eax,%eax
je     123d <c_types_binding+0xbd>
lea    0xea3(%rip),%rsi
mov    %rbx,%rdi
call   1070 <strcmp@plt>
lea    0xe9f(%rip),%r14
test   %eax,%eax
je     1244 <c_types_binding+0xc4>
lea    0xea7(%rip),%rsi
mov    %rbx,%rdi
call   1070 <strcmp@plt>
test   %eax,%eax
je     1244 <c_types_binding+0xc4>
lea    0xe9f(%rip),%rsi
mov    %rbx,%rdi
call   1070 <strcmp@plt>
lea    0xe9b(%rip),%r14
test   %eax,%eax
je     1244 <c_types_binding+0xc4>
lea    0xea4(%rip),%rsi
mov    %rbx,%rdi
call   1070 <strcmp@plt>
test   %eax,%eax
je     1244 <c_types_binding+0xc4>
lea    0xe9c(%rip),%rsi
mov    %rbx,%rdi
mov    $0x9,%edx
call   1030 <strncmp@plt>
test   %eax,%eax
je     1253 <c_types_binding+0xd3>
lea    0xe92(%rip),%r14
jmp    1244 <c_types_binding+0xc4>
lea    0xdf7(%rip),%r14
jmp    1244 <c_types_binding+0xc4>
lea    0xe0a(%rip),%r14
mov    %r14,%rax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret
mov    %rbx,(%rsp)
mov    (%rbx),%al
test   %al,%al
je     12b3 <c_types_binding+0x133>
mov    %rsp,%r14
lea    0xe59(%rip),%r15
lea    0xe(%rsp),%r12
jmp    127d <c_types_binding+0xfd>
add    $0x1,%rbx
mov    %rbx,(%rsp)
movzbl (%rbx),%eax
test   %al,%al
je     12b3 <c_types_binding+0x133>
movsbl %al,%edi
call   1040 <isdigit@plt>
test   %rax,%rax
je     126e <c_types_binding+0xee>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0xa,%edx
call   1080 <strtol@plt>
mov    %r12,%rdi
mov    $0xa,%esi
mov    %r15,%rdx
mov    %rax,%rcx
call   1060 <snprintf@plt>
mov    (%rsp),%rbx
jmp    1276 <c_types_binding+0xf6>
mov    $0x31,%edi
call   1090 <malloc@plt>
mov    %rax,%r14
lea    0xd39(%rip),%rsi
mov    %rax,%rdi
call   1050 <strcpy@plt>
lea    0xe(%rsp),%rsi
mov    %r14,%rdi
call   10a0 <strcat@plt>
lea    0xdc6(%rip),%rsi
mov    %r14,%rdi
call   10a0 <strcat@plt>
jmp    1244 <c_types_binding+0xc4>

LLVM IR (-O0):
@.str = [35 x i8] c"CHARACTER(KIND=C_CHAR), DIMENSION(\00"
@.str.1 = [15 x i8] c"INTEGER(IntKi)\00"
@.str.2 = [20 x i8] c"INTEGER(KIND=C_INT)\00"
@.str.3 = [8 x i8] c"LOGICAL\00"
@.str.4 = [21 x i8] c"LOGICAL(KIND=C_BOOL)\00"
@.str.5 = [11 x i8] c"REAL(ReKi)\00"
@.str.6 = [19 x i8] c"REAL(KIND=C_FLOAT)\00"
@.str.7 = [11 x i8] c"REAL(SiKi)\00"
@.str.8 = [11 x i8] c"REAL(DbKi)\00"
@.str.9 = [20 x i8] c"REAL(KIND=C_DOUBLE)\00"
@.str.10 = [11 x i8] c"REAL(R8Ki)\00"
@.str.11 = [10 x i8] c"CHARACTER\00"
@.str.12 = [4 x i8] c"%lu\00"
@.str.13 = [2 x i8] c")\00"
@.str.14 = [8 x i8] c"unknown\00"
define i8* @c_types_binding(i8* %0) {
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca [10 x i8]
%8 = alloca i64
store i8* %0, i8** %3
store i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0), i8** %4
%9 = load i8*, i8** %3
%10 = call i32 @strcmp(i8* %9, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0))
%11 = icmp ne i32 %10, 0
br i1 %11, label %13, label %12
12: ; preds = %1
store i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), i8** %2
br label %78
13: ; preds = %1
%14 = load i8*, i8** %3
%15 = call i32 @strcmp(i8* %14, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0))
%16 = icmp ne i32 %15, 0
br i1 %16, label %18, label %17
17: ; preds = %13
store i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i64 0, i64 0), i8** %2
br label %78
18: ; preds = %13
%19 = load i8*, i8** %3
%20 = call i32 @strcmp(i8* %19, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.5, i64 0, i64 0))
%21 = icmp ne i32 %20, 0
br i1 %21, label %23, label %22
22: ; preds = %18
store i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.6, i64 0, i64 0), i8** %2
br label %78
23: ; preds = %18
%24 = load i8*, i8** %3
%25 = call i32 @strcmp(i8* %24, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.7, i64 0, i64 0))
%26 = icmp ne i32 %25, 0
br i1 %26, label %28, label %27
27: ; preds = %23
store i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.6, i64 0, i64 0), i8** %2
br label %78
28: ; preds = %23
%29 = load i8*, i8** %3
%30 = call i32 @strcmp(i8* %29, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.8, i64 0, i64 0))
%31 = icmp ne i32 %30, 0
br i1 %31, label %33, label %32
32: ; preds = %28
store i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.9, i64 0, i64 0), i8** %2
br label %78
33: ; preds = %28
%34 = load i8*, i8** %3
%35 = call i32 @strcmp(i8* %34, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.10, i64 0, i64 0))
%36 = icmp ne i32 %35, 0
br i1 %36, label %38, label %37
37: ; preds = %33
store i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.9, i64 0, i64 0), i8** %2
br label %78
38: ; preds = %33
%39 = load i8*, i8** %3
%40 = call i32 @strncmp(i8* %39, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.11, i64 0, i64 0), i32 9)
%41 = icmp ne i32 %40, 0
br i1 %41, label %77, label %42
42: ; preds = %38
%43 = load i8*, i8** %3
store i8* %43, i8** %6
br label %44
44: ; preds = %62, %42
%45 = load i8*, i8** %6
%46 = load i8, i8* %45
%47 = icmp ne i8 %46, 0
br i1 %47, label %48, label %63
48: ; preds = %44
%49 = load i8*, i8** %6
%50 = load i8, i8* %49
%51 = call i64 @isdigit(i8 signext %50)
%52 = icmp ne i64 %51, 0
br i1 %52, label %53, label %59
53: ; preds = %48
%54 = load i8*, i8** %6
%55 = call i64 @strtol(i8* %54, i8** %6, i32 10)
store i64 %55, i64* %8
%56 = getelementptr inbounds [10 x i8], [10 x i8]* %7, i64 0, i64 0
%57 = load i64, i64* %8
%58 = call i32 @snprintf(i8* %56, i32 10, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.12, i64 0, i64 0), i64 %57)
br label %62
59: ; preds = %48
%60 = load i8*, i8** %6
%61 = getelementptr inbounds i8, i8* %60, i32 1
store i8* %61, i8** %6
br label %62
62: ; preds = %59, %53
br label %44
63: ; preds = %44
%64 = load i8*, i8** %4
%65 = call i64 @strlen(i8* %64)
%66 = add nsw i64 %65, 15
%67 = call i8* @malloc(i64 %66)
store i8* %67, i8** %5
%68 = load i8*, i8** %5
%69 = load i8*, i8** %4
%70 = call i32 @strcpy(i8* %68, i8* %69)
%71 = load i8*, i8** %5
%72 = getelementptr inbounds [10 x i8], [10 x i8]* %7, i64 0, i64 0
%73 = call i32 @strcat(i8* %71, i8* %72)
%74 = load i8*, i8** %5
%75 = call i32 @strcat(i8* %74, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.13, i64 0, i64 0))
%76 = load i8*, i8** %5
store i8* %76, i8** %2
br label %78
77: ; preds = %38
store i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.14, i64 0, i64 0), i8** %2
br label %78
78: ; preds = %77, %63, %37, %32, %27, %22, %17, %12
%79 = load i8*, i8** %2
ret i8* %79
}

LLVM IR (-O2):
@.str = [35 x i8] c"CHARACTER(KIND=C_CHAR), DIMENSION(\00"
@.str.1 = [15 x i8] c"INTEGER(IntKi)\00"
@.str.2 = [20 x i8] c"INTEGER(KIND=C_INT)\00"
@.str.3 = [8 x i8] c"LOGICAL\00"
@.str.4 = [21 x i8] c"LOGICAL(KIND=C_BOOL)\00"
@.str.5 = [11 x i8] c"REAL(ReKi)\00"
@.str.6 = [19 x i8] c"REAL(KIND=C_FLOAT)\00"
@.str.7 = [11 x i8] c"REAL(SiKi)\00"
@.str.8 = [11 x i8] c"REAL(DbKi)\00"
@.str.9 = [20 x i8] c"REAL(KIND=C_DOUBLE)\00"
@.str.10 = [11 x i8] c"REAL(R8Ki)\00"
@.str.11 = [10 x i8] c"CHARACTER\00"
@.str.12 = [4 x i8] c"%lu\00"
@.str.13 = [2 x i8] c")\00"
@.str.14 = [8 x i8] c"unknown\00"
define i8* @c_types_binding(i8* %0) {
%2 = alloca i8*
%3 = alloca [10 x i8]
%4 = tail call i32 @strcmp(i8* dereferenceable(1) %0, i8* dereferenceable(15) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0))
%5 = icmp eq i32 %4, 0
br i1 %5, label %49, label %6
6: ; preds = %1
%7 = tail call i32 @strcmp(i8* dereferenceable(1) %0, i8* dereferenceable(8) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0))
%8 = icmp eq i32 %7, 0
br i1 %8, label %49, label %9
9: ; preds = %6
%10 = tail call i32 @strcmp(i8* dereferenceable(1) %0, i8* dereferenceable(11) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.5, i64 0, i64 0))
%11 = icmp eq i32 %10, 0
br i1 %11, label %49, label %12
12: ; preds = %9
%13 = tail call i32 @strcmp(i8* dereferenceable(1) %0, i8* dereferenceable(11) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.7, i64 0, i64 0))
%14 = icmp eq i32 %13, 0
br i1 %14, label %49, label %15
15: ; preds = %12
%16 = tail call i32 @strcmp(i8* dereferenceable(1) %0, i8* dereferenceable(11) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.8, i64 0, i64 0))
%17 = icmp eq i32 %16, 0
br i1 %17, label %49, label %18
18: ; preds = %15
%19 = tail call i32 @strcmp(i8* dereferenceable(1) %0, i8* dereferenceable(11) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.10, i64 0, i64 0))
%20 = icmp eq i32 %19, 0
br i1 %20, label %49, label %21
21: ; preds = %18
%22 = tail call i32 @strncmp(i8* %0, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.11, i64 0, i64 0), i32 9)
%23 = icmp eq i32 %22, 0
br i1 %23, label %24, label %49
24: ; preds = %21
%25 = bitcast i8** %2 to i8*
store i8* %0, i8** %2
%26 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 0
%27 = load i8, i8* %0
%28 = icmp eq i8 %27, 0
br i1 %28, label %44, label %29
29: ; preds = %24, %40
%30 = phi i8 [ %42, %40 ], [ %27, %24 ]
%31 = phi i8* [ %41, %40 ], [ %0, %24 ]
%32 = call i64 @isdigit(i8 signext %30)
%33 = icmp eq i64 %32, 0
br i1 %33, label %38, label %34
34: ; preds = %29
%35 = call i64 @strtol(i8* %31, i8** %2, i32 10)
%36 = call i32 @snprintf(i8* %26, i32 10, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.12, i64 0, i64 0), i64 %35)
%37 = load i8*, i8** %2
br label %40
38: ; preds = %29
%39 = getelementptr inbounds i8, i8* %31, i64 1
store i8* %39, i8** %2
br label %40
40: ; preds = %38, %34
%41 = phi i8* [ %39, %38 ], [ %37, %34 ]
%42 = load i8, i8* %41
%43 = icmp eq i8 %42, 0
br i1 %43, label %44, label %29
44: ; preds = %40, %24
%45 = call dereferenceable_or_null(49) i8* @malloc(i64 49)
%46 = call i32 @strcpy(i8* %45, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0))
%47 = call i32 @strcat(i8* %45, i8* %26)
%48 = call i32 @strcat(i8* %45, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.13, i64 0, i64 0))
br label %49
49: ; preds = %21, %18, %15, %12, %9, %6, %1, %44
%50 = phi i8* [ %45, %44 ], [ getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0), %1 ], [ getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i64 0, i64 0), %6 ], [ getelementptr inbounds ([19 x i8], [19 x i8]* @.str.6, i64 0, i64 0), %9 ], [ getelementptr inbounds ([19 x i8], [19 x i8]* @.str.6, i64 0, i64 0), %12 ], [ getelementptr inbounds ([20 x i8], [20 x i8]* @.str.9, i64 0, i64 0), %15 ], [ getelementptr inbounds ([20 x i8], [20 x i8]* @.str.9, i64 0, i64 0), %18 ], [ getelementptr inbounds ([8 x i8], [8 x i8]* @.str.14, i64 0, i64 0), %21 ]
ret i8* %50
}