#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_mkFunc(char *, char *, char *);
char *UTIL_appendStr(char *, char *);
char *UTIL_itoa(int);
char *UTIL_mallocStr(scalar_t__);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ strcat(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
scalar_t__ strlen(char *);
char *ocgenReadOpFunc(char *typeName, char *compType, int numBytes) {
  char *funcName = UTIL_appendStr("read", typeName);
  char *numBytesText = UTIL_itoa(numBytes);
  char *arg = "()";
  char *funcBody1 = UTIL_mallocStr(strlen("Bytecode.read") + strlen(compType) +
                                   strlen(numBytesText));
  char *funcBody2, *func;
  strcpy(funcBody1, "Bytecode.read");
  strcat(funcBody1, compType);
  strcat(funcBody1, numBytesText);
  free(numBytesText);
  funcBody2 = UTIL_appendStr(funcBody1, " ()");
  free(funcBody1);
  func = OC_mkFunc(funcName, arg, funcBody2);
  free(funcName);
  free(funcBody2);
  return func;
}


x86 assembly (clang, -O0):
<ocgenReadOpFunc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    -0x8(%rbp),%rsi
lea    0xe6b(%rip),%rdi
call   1090 <UTIL_appendStr@plt>
mov    %rax,-0x20(%rbp)
mov    -0x14(%rbp),%edi
call   1030 <UTIL_itoa@plt>
mov    %rax,-0x28(%rbp)
lea    0xe55(%rip),%rax
mov    %rax,-0x30(%rbp)
lea    0xe3b(%rip),%rdi
call   1060 <strlen@plt>
mov    %rax,-0x58(%rbp)
mov    -0x10(%rbp),%rdi
call   1060 <strlen@plt>
mov    %rax,%rcx
mov    -0x58(%rbp),%rax
add    %rcx,%rax
mov    %rax,-0x50(%rbp)
mov    -0x28(%rbp),%rdi
call   1060 <strlen@plt>
mov    -0x50(%rbp),%rdi
add    %rax,%rdi
call   1080 <UTIL_mallocStr@plt>
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rdi
lea    0xdf7(%rip),%rsi
call   1050 <strcpy@plt>
mov    -0x38(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   10a0 <strcat@plt>
mov    -0x38(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   10a0 <strcat@plt>
mov    -0x28(%rbp),%rdi
call   1040 <free@plt>
mov    -0x38(%rbp),%rdi
lea    0xdd2(%rip),%rsi
call   1090 <UTIL_appendStr@plt>
mov    %rax,-0x40(%rbp)
mov    -0x38(%rbp),%rdi
call   1040 <free@plt>
mov    -0x20(%rbp),%rdi
mov    -0x30(%rbp),%rsi
mov    -0x40(%rbp),%rdx
call   1070 <OC_mkFunc@plt>
mov    %rax,-0x48(%rbp)
mov    -0x20(%rbp),%rdi
call   1040 <free@plt>
mov    -0x40(%rbp),%rdi
call   1040 <free@plt>
mov    -0x48(%rbp),%rax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ocgenReadOpFunc>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %edx,%ebx
mov    %rsi,%r15
mov    %rdi,%rsi
lea    0xe71(%rip),%rdi
call   1090 <UTIL_appendStr@plt>
mov    %rax,%r14
mov    %ebx,%edi
call   1030 <UTIL_itoa@plt>
mov    %rax,%r13
mov    %r15,%rdi
call   1060 <strlen@plt>
mov    %rax,%r12
mov    %r13,%rdi
call   1060 <strlen@plt>
lea    (%r12,%rax,1),%rdi
add    $0xd,%rdi
call   1080 <UTIL_mallocStr@plt>
mov    %rax,%rbx
lea    0xe2c(%rip),%rsi
mov    %rax,%rdi
call   1050 <strcpy@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   10a0 <strcat@plt>
mov    %rbx,%rdi
mov    %r13,%rsi
call   10a0 <strcat@plt>
mov    %r13,%rdi
call   1040 <free@plt>
lea    0xe0d(%rip),%rsi
mov    %rbx,%rdi
call   1090 <UTIL_appendStr@plt>
mov    %rax,%r15
mov    %rbx,%rdi
call   1040 <free@plt>
lea    0xdf4(%rip),%rsi
mov    %r14,%rdi
mov    %r15,%rdx
call   1070 <OC_mkFunc@plt>
mov    %rax,%rbx
mov    %r14,%rdi
call   1040 <free@plt>
mov    %r15,%rdi
call   1040 <free@plt>
mov    %rbx,%rax
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [5 x i8] c"read\00"
@.str.1 = [3 x i8] c"()\00"
@.str.2 = [14 x i8] c"Bytecode.read\00"
@.str.3 = [4 x i8] c" ()\00"
define i8* @ocgenReadOpFunc(i8* %0, i8* %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i8*
%12 = alloca i8*
store i8* %0, i8** %4
store i8* %1, i8** %5
store i32 %2, i32* %6
%13 = load i8*, i8** %4
%14 = call i8* @UTIL_appendStr(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %13)
store i8* %14, i8** %7
%15 = load i32, i32* %6
%16 = call i8* @UTIL_itoa(i32 %15)
store i8* %16, i8** %8
store i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8** %9
%17 = call i64 @strlen(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0))
%18 = load i8*, i8** %5
%19 = call i64 @strlen(i8* %18)
%20 = add nsw i64 %17, %19
%21 = load i8*, i8** %8
%22 = call i64 @strlen(i8* %21)
%23 = add nsw i64 %20, %22
%24 = call i8* @UTIL_mallocStr(i64 %23)
store i8* %24, i8** %10
%25 = load i8*, i8** %10
%26 = call i32 @strcpy(i8* %25, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0))
%27 = load i8*, i8** %10
%28 = load i8*, i8** %5
%29 = call i32 @strcat(i8* %27, i8* %28)
%30 = load i8*, i8** %10
%31 = load i8*, i8** %8
%32 = call i32 @strcat(i8* %30, i8* %31)
%33 = load i8*, i8** %8
%34 = call i32 @free(i8* %33)
%35 = load i8*, i8** %10
%36 = call i8* @UTIL_appendStr(i8* %35, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
store i8* %36, i8** %11
%37 = load i8*, i8** %10
%38 = call i32 @free(i8* %37)
%39 = load i8*, i8** %7
%40 = load i8*, i8** %9
%41 = load i8*, i8** %11
%42 = call i8* @OC_mkFunc(i8* %39, i8* %40, i8* %41)
store i8* %42, i8** %12
%43 = load i8*, i8** %7
%44 = call i32 @free(i8* %43)
%45 = load i8*, i8** %11
%46 = call i32 @free(i8* %45)
%47 = load i8*, i8** %12
ret i8* %47
}

LLVM IR (-O2):
@.str = [5 x i8] c"read\00"
@.str.1 = [3 x i8] c"()\00"
@.str.2 = [14 x i8] c"Bytecode.read\00"
@.str.3 = [4 x i8] c" ()\00"
define i8* @ocgenReadOpFunc(i8* %0, i8* %1, i32 %2) {
%4 = tail call i8* @UTIL_appendStr(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %0)
%5 = tail call i8* @UTIL_itoa(i32 %2)
%6 = tail call i64 @strlen(i8* dereferenceable(1) %1)
%7 = add nsw i64 %6, 13
%8 = tail call i64 @strlen(i8* dereferenceable(1) %5)
%9 = add nsw i64 %7, %8
%10 = tail call i8* @UTIL_mallocStr(i64 %9)
%11 = tail call i32 @strcpy(i8* %10, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0))
%12 = tail call i32 @strcat(i8* %10, i8* %1)
%13 = tail call i32 @strcat(i8* %10, i8* %5)
%14 = tail call i32 @free(i8* %5)
%15 = tail call i8* @UTIL_appendStr(i8* %10, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
%16 = tail call i32 @free(i8* %10)
%17 = tail call i8* @OC_mkFunc(i8* %4, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %15)
%18 = tail call i32 @free(i8* %4)
%19 = tail call i32 @free(i8* %15)
ret i8* %17
}