#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 *OC_mkTabInit();
char *OC_mkVarDef(char *, char *);
char *UTIL_mallocStr(size_t);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ strcat(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
char *OC_mkBuildTabFunc(char *funcName, char *entries) {
  char *func;
  char *inits = OC_mkTabInit();
  size_t length = strlen(entries) + strlen("t") + strlen(inits) + 30;
  char *def = UTIL_mallocStr(length + 1);
  strcpy(def, "function () ->\n  ");
  strcat(def, inits);
  free(inits);
  strcat(def, entries);
  strcat(def, "t");
  strcat(def, "\n\n");
  func = OC_mkVarDef(funcName, def);
  free(def);
  return func;
}


x86 assembly (clang, -O0):
<OC_mkBuildTabFunc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x0,%al
call   1080 <OC_mkTabInit@plt>
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,-0x38(%rbp)
lea    0xe62(%rip),%rdi
call   1050 <strlen@plt>
mov    %eax,%ecx
mov    -0x38(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x34(%rbp)
mov    -0x20(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,%ecx
mov    -0x34(%rbp),%eax
add    %ecx,%eax
add    $0x1e,%eax
cltq
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
add    $0x1,%rdi
call   1070 <UTIL_mallocStr@plt>
mov    %rax,-0x30(%rbp)
mov    -0x30(%rbp),%rdi
lea    0xe20(%rip),%rsi
call   1040 <strcpy@plt>
mov    -0x30(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1090 <strcat@plt>
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
mov    -0x30(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1090 <strcat@plt>
mov    -0x30(%rbp),%rdi
lea    0xdeb(%rip),%rsi
call   1090 <strcat@plt>
mov    -0x30(%rbp),%rdi
lea    0xdef(%rip),%rsi
call   1090 <strcat@plt>
mov    -0x8(%rbp),%rdi
mov    -0x30(%rbp),%rsi
call   1060 <OC_mkVarDef@plt>
mov    %rax,-0x18(%rbp)
mov    -0x30(%rbp),%rdi
call   1030 <free@plt>
mov    -0x18(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<OC_mkBuildTabFunc>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r12
mov    %rdi,%r14
xor    %eax,%eax
call   1080 <OC_mkTabInit@plt>
mov    %rax,%r13
mov    %r12,%rdi
call   1050 <strlen@plt>
mov    %eax,%ebx
lea    0xe64(%rip),%r15
mov    %r15,%rdi
call   1050 <strlen@plt>
mov    %eax,%ebp
add    %ebx,%ebp
mov    %r13,%rdi
call   1050 <strlen@plt>
add    %ebp,%eax
movslq %eax,%rdi
add    $0x1f,%rdi
call   1070 <UTIL_mallocStr@plt>
mov    %rax,%rbx
lea    0xe3a(%rip),%rsi
mov    %rax,%rdi
call   1040 <strcpy@plt>
mov    %rbx,%rdi
mov    %r13,%rsi
call   1090 <strcat@plt>
mov    %r13,%rdi
call   1030 <free@plt>
mov    %rbx,%rdi
mov    %r12,%rsi
call   1090 <strcat@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   1090 <strcat@plt>
lea    0xe14(%rip),%rsi
mov    %rbx,%rdi
call   1090 <strcat@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1060 <OC_mkVarDef@plt>
mov    %rax,%rbp
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %rbp,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c"t\00"
@.str.1 = [18 x i8] c"function () ->\0A \00"
@.str.2 = [3 x i8] c"\0A\0A\00"
define i8* @OC_mkBuildTabFunc(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i64
%8 = alloca i8*
store i8* %0, i8** %3
store i8* %1, i8** %4
%9 = call i8* (...) @OC_mkTabInit()
store i8* %9, i8** %6
%10 = load i8*, i8** %4
%11 = call i32 @strlen(i8* %10)
%12 = call i32 @strlen(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%13 = add nsw i32 %11, %12
%14 = load i8*, i8** %6
%15 = call i32 @strlen(i8* %14)
%16 = add nsw i32 %13, %15
%17 = add nsw i32 %16, 30
%18 = sext i32 %17 to i64
store i64 %18, i64* %7
%19 = load i64, i64* %7
%20 = add i64 %19, 1
%21 = call i8* @UTIL_mallocStr(i64 %20)
store i8* %21, i8** %8
%22 = load i8*, i8** %8
%23 = call i32 @strcpy(i8* %22, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0))
%24 = load i8*, i8** %8
%25 = load i8*, i8** %6
%26 = call i32 @strcat(i8* %24, i8* %25)
%27 = load i8*, i8** %6
%28 = call i32 @free(i8* %27)
%29 = load i8*, i8** %8
%30 = load i8*, i8** %4
%31 = call i32 @strcat(i8* %29, i8* %30)
%32 = load i8*, i8** %8
%33 = call i32 @strcat(i8* %32, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%34 = load i8*, i8** %8
%35 = call i32 @strcat(i8* %34, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%36 = load i8*, i8** %3
%37 = load i8*, i8** %8
%38 = call i8* @OC_mkVarDef(i8* %36, i8* %37)
store i8* %38, i8** %5
%39 = load i8*, i8** %8
%40 = call i32 @free(i8* %39)
%41 = load i8*, i8** %5
ret i8* %41
}

LLVM IR (-O2):
@.str = [2 x i8] c"t\00"
@.str.1 = [18 x i8] c"function () ->\0A \00"
@.str.2 = [3 x i8] c"\0A\0A\00"
define i8* @OC_mkBuildTabFunc(i8* %0, i8* %1) {
%3 = tail call i8* (...) @OC_mkTabInit()
%4 = tail call i32 @strlen(i8* %1)
%5 = tail call i32 @strlen(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%6 = add nsw i32 %5, %4
%7 = tail call i32 @strlen(i8* %3)
%8 = add nsw i32 %6, %7
%9 = sext i32 %8 to i64
%10 = add nsw i64 %9, 31
%11 = tail call i8* @UTIL_mallocStr(i64 %10)
%12 = tail call i32 @strcpy(i8* %11, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0))
%13 = tail call i32 @strcat(i8* %11, i8* %3)
%14 = tail call i32 @free(i8* %3)
%15 = tail call i32 @strcat(i8* %11, i8* %1)
%16 = tail call i32 @strcat(i8* %11, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%17 = tail call i32 @strcat(i8* %11, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0))
%18 = tail call i8* @OC_mkVarDef(i8* %0, i8* %11)
%19 = tail call i32 @free(i8* %11)
ret i8* %18
}