#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 */
char *C_mkOneLineComments(char *);
char *UTIL_mallocStr(size_t);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ strcat(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
char *C_mkKindTabEntry(char *name, char *arity, char *comments) {
  char *commentText = (comments) ? C_mkOneLineComments(comments) : NULL;
  size_t length = ((commentText) ? strlen(commentText) + strlen("    ") : 0) +
                  strlen(name) + strlen(arity) + strlen("    ") * 2 + 10;
  char *entry = UTIL_mallocStr(length);
  strcpy(entry, "    ");
  if (commentText) {
    strcat(entry, commentText);
    strcat(entry, "\n");
    strcat(entry, "    ");
    free(commentText);
  }
  strcat(entry, "{\"");
  strcat(entry, name);
  strcat(entry, "\",");
  strcat(entry, "    ");
  strcat(entry, arity);
  strcat(entry, "}");
  return entry;
}


x86 assembly (clang, -O0):
<C_mkKindTabEntry>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     1191 <C_mkKindTabEntry+0x31>
mov    -0x18(%rbp),%rdi
call   1060 <C_mkOneLineComments@plt>
mov    %rax,-0x38(%rbp)
jmp    119c <C_mkKindTabEntry+0x3c>
xor    %eax,%eax
mov    %rax,-0x38(%rbp)
jmp    119c <C_mkKindTabEntry+0x3c>
mov    -0x38(%rbp),%rax
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
je     11d6 <C_mkKindTabEntry+0x76>
mov    -0x20(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,-0x40(%rbp)
lea    0xe3e(%rip),%rdi
call   1050 <strlen@plt>
mov    %eax,%ecx
mov    -0x40(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x3c(%rbp)
jmp    11e0 <C_mkKindTabEntry+0x80>
xor    %eax,%eax
mov    %eax,-0x3c(%rbp)
jmp    11e0 <C_mkKindTabEntry+0x80>
mov    -0x3c(%rbp),%eax
mov    %eax,-0x4c(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,%ecx
mov    -0x4c(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x48(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,%ecx
mov    -0x48(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x44(%rbp)
lea    0xded(%rip),%rdi
call   1050 <strlen@plt>
mov    %eax,%ecx
mov    -0x44(%rbp),%eax
shl    $0x1,%ecx
add    %ecx,%eax
add    $0xa,%eax
cltq
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
call   1070 <UTIL_mallocStr@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rdi
lea    0xdbd(%rip),%rsi
call   1040 <strcpy@plt>
cmpq   $0x0,-0x20(%rbp)
je     1289 <C_mkKindTabEntry+0x129>
mov    -0x30(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1080 <strcat@plt>
mov    -0x30(%rbp),%rdi
lea    0xd9a(%rip),%rsi
call   1080 <strcat@plt>
mov    -0x30(%rbp),%rdi
lea    0xd85(%rip),%rsi
call   1080 <strcat@plt>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
mov    -0x30(%rbp),%rdi
lea    0xd73(%rip),%rsi
call   1080 <strcat@plt>
mov    -0x30(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1080 <strcat@plt>
mov    -0x30(%rbp),%rdi
lea    0xd59(%rip),%rsi
call   1080 <strcat@plt>
mov    -0x30(%rbp),%rdi
lea    0xd3f(%rip),%rsi
call   1080 <strcat@plt>
mov    -0x30(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1080 <strcat@plt>
mov    -0x30(%rbp),%rdi
lea    0xd2f(%rip),%rsi
call   1080 <strcat@plt>
mov    -0x30(%rbp),%rax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<C_mkKindTabEntry>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
mov    %rsi,%rbp
mov    %rdi,%rbx
mov    $0xa,%r15d
mov    $0x1,%r14b
test   %rdx,%rdx
je     11b6 <C_mkKindTabEntry+0x56>
mov    %rdx,%rdi
call   1060 <C_mkOneLineComments@plt>
test   %rax,%rax
je     11b6 <C_mkKindTabEntry+0x56>
mov    %rax,%r12
mov    %rax,%rdi
call   1050 <strlen@plt>
mov    %eax,%r14d
lea    0xe5c(%rip),%rdi
call   1050 <strlen@plt>
lea    (%rax,%r14,1),%r15d
add    $0xa,%r15d
xor    %r14d,%r14d
jmp    11b9 <C_mkKindTabEntry+0x59>
xor    %r12d,%r12d
mov    %rbx,0x8(%rsp)
mov    %rbx,%rdi
call   1050 <strlen@plt>
mov    %eax,%ebx
mov    %rbp,0x10(%rsp)
mov    %rbp,%rdi
call   1050 <strlen@plt>
mov    %eax,%ebp
lea    0xe22(%rip),%r13
mov    %r13,%rdi
call   1050 <strlen@plt>
add    %r15d,%ebx
add    %ebp,%ebx
lea    (%rbx,%rax,2),%eax
movslq %eax,%rdi
call   1070 <UTIL_mallocStr@plt>
mov    %rax,%rbx
mov    %rax,%rdi
mov    %r13,%rsi
call   1040 <strcpy@plt>
test   %r14b,%r14b
jne    123a <C_mkKindTabEntry+0xda>
mov    %rbx,%rdi
mov    %r12,%rsi
call   1080 <strcat@plt>
lea    0xdea(%rip),%rsi
mov    %rbx,%rdi
call   1080 <strcat@plt>
lea    0xdd6(%rip),%rsi
mov    %rbx,%rdi
call   1080 <strcat@plt>
mov    %r12,%rdi
call   1030 <free@plt>
lea    0xdc6(%rip),%rsi
mov    %rbx,%rdi
call   1080 <strcat@plt>
mov    %rbx,%rdi
mov    0x8(%rsp),%rsi
call   1080 <strcat@plt>
lea    0xdad(%rip),%rsi
mov    %rbx,%rdi
call   1080 <strcat@plt>
lea    0xd94(%rip),%rsi
mov    %rbx,%rdi
call   1080 <strcat@plt>
mov    %rbx,%rdi
mov    0x10(%rsp),%rsi
call   1080 <strcat@plt>
lea    0xd85(%rip),%rsi
mov    %rbx,%rdi
call   1080 <strcat@plt>
mov    %rbx,%rax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [5 x i8] c" \00"
@.str.1 = [2 x i8] c"\0A\00"
@.str.2 = [3 x i8] c"{\22\00"
@.str.3 = [3 x i8] c"\22,\00"
@.str.4 = [2 x i8] c"}\00"
define i8* @C_mkKindTabEntry(i8* %0, i8* %1, i8* %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i64
%9 = alloca i8*
store i8* %0, i8** %4
store i8* %1, i8** %5
store i8* %2, i8** %6
%10 = load i8*, i8** %6
%11 = icmp ne i8* %10, null
br i1 %11, label %12, label %15
12: ; preds = %3
%13 = load i8*, i8** %6
%14 = call i8* @C_mkOneLineComments(i8* %13)
br label %16
15: ; preds = %3
br label %16
16: ; preds = %15, %12
%17 = phi i8* [ %14, %12 ], [ null, %15 ]
store i8* %17, i8** %7
%18 = load i8*, i8** %7
%19 = icmp ne i8* %18, null
br i1 %19, label %20, label %25
20: ; preds = %16
%21 = load i8*, i8** %7
%22 = call i32 @strlen(i8* %21)
%23 = call i32 @strlen(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%24 = add nsw i32 %22, %23
br label %26
25: ; preds = %16
br label %26
26: ; preds = %25, %20
%27 = phi i32 [ %24, %20 ], [ 0, %25 ]
%28 = load i8*, i8** %4
%29 = call i32 @strlen(i8* %28)
%30 = add nsw i32 %27, %29
%31 = load i8*, i8** %5
%32 = call i32 @strlen(i8* %31)
%33 = add nsw i32 %30, %32
%34 = call i32 @strlen(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%35 = mul nsw i32 %34, 2
%36 = add nsw i32 %33, %35
%37 = add nsw i32 %36, 10
%38 = sext i32 %37 to i64
store i64 %38, i64* %8
%39 = load i64, i64* %8
%40 = call i8* @UTIL_mallocStr(i64 %39)
store i8* %40, i8** %9
%41 = load i8*, i8** %9
%42 = call i32 @strcpy(i8* %41, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%43 = load i8*, i8** %7
%44 = icmp ne i8* %43, null
br i1 %44, label %45, label %55
45: ; preds = %26
%46 = load i8*, i8** %9
%47 = load i8*, i8** %7
%48 = call i32 @strcat(i8* %46, i8* %47)
%49 = load i8*, i8** %9
%50 = call i32 @strcat(i8* %49, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%51 = load i8*, i8** %9
%52 = call i32 @strcat(i8* %51, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%53 = load i8*, i8** %7
%54 = call i32 @free(i8* %53)
br label %55
55: ; preds = %45, %26
%56 = load i8*, i8** %9
%57 = call i32 @strcat(i8* %56, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%58 = load i8*, i8** %9
%59 = load i8*, i8** %4
%60 = call i32 @strcat(i8* %58, i8* %59)
%61 = load i8*, i8** %9
%62 = call i32 @strcat(i8* %61, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%63 = load i8*, i8** %9
%64 = call i32 @strcat(i8* %63, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%65 = load i8*, i8** %9
%66 = load i8*, i8** %5
%67 = call i32 @strcat(i8* %65, i8* %66)
%68 = load i8*, i8** %9
%69 = call i32 @strcat(i8* %68, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%70 = load i8*, i8** %9
ret i8* %70
}

LLVM IR (-O2):
@.str = [5 x i8] c" \00"
@.str.1 = [2 x i8] c"\0A\00"
@.str.2 = [3 x i8] c"{\22\00"
@.str.3 = [3 x i8] c"\22,\00"
@.str.4 = [2 x i8] c"}\00"
define i8* @C_mkKindTabEntry(i8* %0, i8* %1, i8* %2) {
%4 = icmp eq i8* %2, null
br i1 %4, label %13, label %5
5: ; preds = %3
%6 = tail call i8* @C_mkOneLineComments(i8* %2)
%7 = icmp eq i8* %6, null
br i1 %7, label %13, label %8
8: ; preds = %5
%9 = tail call i32 @strlen(i8* %6)
%10 = tail call i32 @strlen(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%11 = add nsw i32 %10, %9
%12 = add i32 %11, 10
br label %13
13: ; preds = %3, %5, %8
%14 = phi i1 [ false, %8 ], [ true, %5 ], [ true, %3 ]
%15 = phi i8* [ %6, %8 ], [ null, %5 ], [ null, %3 ]
%16 = phi i32 [ %12, %8 ], [ 10, %5 ], [ 10, %3 ]
%17 = tail call i32 @strlen(i8* %0)
%18 = tail call i32 @strlen(i8* %1)
%19 = tail call i32 @strlen(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%20 = shl nsw i32 %19, 1
%21 = add i32 %16, %17
%22 = add i32 %21, %18
%23 = add i32 %22, %20
%24 = sext i32 %23 to i64
%25 = tail call i8* @UTIL_mallocStr(i64 %24)
%26 = tail call i32 @strcpy(i8* %25, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
br i1 %14, label %32, label %27
27: ; preds = %13
%28 = tail call i32 @strcat(i8* %25, i8* %15)
%29 = tail call i32 @strcat(i8* %25, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%30 = tail call i32 @strcat(i8* %25, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%31 = tail call i32 @free(i8* %15)
br label %32
32: ; preds = %27, %13
%33 = tail call i32 @strcat(i8* %25, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%34 = tail call i32 @strcat(i8* %25, i8* %0)
%35 = tail call i32 @strcat(i8* %25, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0))
%36 = tail call i32 @strcat(i8* %25, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
%37 = tail call i32 @strcat(i8* %25, i8* %1)
%38 = tail call i32 @strcat(i8* %25, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
ret i8* %25
}