#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_mkRef(char *);
char *OC_mkSome(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 *OC_mkNeededness(int neededness, int tyenvsize) {
  char *length = UTIL_itoa(tyenvsize);
  char *init;
  char *some;
  char *ref;
  if (neededness == tyenvsize) {
    init = UTIL_mallocStr(strlen(length) + 20);
    strcpy(init, "(Array.make ");
    strcat(init, length);
    free(length);
    strcat(init, " true)");
  } else {
    char *num = UTIL_itoa(neededness);
    init = UTIL_mallocStr(strlen(length) + strlen(num) + 60);
    strcpy(init, "(Array.init ");
    strcat(init, length);
    free(length);
    strcat(init, " (fun x -> if x >= ");
    strcat(init, num);
    free(num);
    strcat(init, " then false else true))");
  }
  some = OC_mkSome(init);
  free(init);
  ref = OC_mkRef(some);
  free(some);
  return ref;
}


x86 assembly (clang, -O0):
<OC_mkNeededness>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    -0x8(%rbp),%edi
call   1030 <UTIL_itoa@plt>
mov    %rax,-0x10(%rbp)
mov    -0x4(%rbp),%eax
cmp    -0x8(%rbp),%eax
jne    11fa <OC_mkNeededness+0x7a>
mov    -0x10(%rbp),%rdi
call   1060 <strlen@plt>
mov    %rax,%rdi
add    $0x14,%rdi
call   1090 <UTIL_mallocStr@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xe36(%rip),%rsi
call   1050 <strcpy@plt>
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   10a0 <strcat@plt>
mov    -0x10(%rbp),%rdi
call   1040 <free@plt>
mov    -0x18(%rbp),%rdi
lea    0xe1d(%rip),%rsi
call   10a0 <strcat@plt>
jmp    128c <OC_mkNeededness+0x10c>
mov    -0x4(%rbp),%edi
call   1030 <UTIL_itoa@plt>
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rdi
call   1060 <strlen@plt>
mov    %rax,-0x38(%rbp)
mov    -0x30(%rbp),%rdi
call   1060 <strlen@plt>
mov    -0x38(%rbp),%rdi
add    %rax,%rdi
add    $0x3c,%rdi
call   1090 <UTIL_mallocStr@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xdd9(%rip),%rsi
call   1050 <strcpy@plt>
mov    -0x18(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   10a0 <strcat@plt>
mov    -0x10(%rbp),%rdi
call   1040 <free@plt>
mov    -0x18(%rbp),%rdi
lea    0xdc0(%rip),%rsi
call   10a0 <strcat@plt>
mov    -0x18(%rbp),%rdi
mov    -0x30(%rbp),%rsi
call   10a0 <strcat@plt>
mov    -0x30(%rbp),%rdi
call   1040 <free@plt>
mov    -0x18(%rbp),%rdi
lea    0xdae(%rip),%rsi
call   10a0 <strcat@plt>
mov    -0x18(%rbp),%rdi
call   1070 <OC_mkSome@plt>
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <free@plt>
mov    -0x20(%rbp),%rdi
call   1080 <OC_mkRef@plt>
mov    %rax,-0x28(%rbp)
mov    -0x20(%rbp),%rdi
call   1040 <free@plt>
mov    -0x28(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<OC_mkNeededness>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %esi,%ebp
mov    %edi,%ebx
mov    %esi,%edi
call   1030 <UTIL_itoa@plt>
mov    %rax,%r14
cmp    %ebp,%ebx
jne    11d8 <OC_mkNeededness+0x58>
mov    %r14,%rdi
call   1060 <strlen@plt>
lea    0x14(%rax),%rdi
call   1090 <UTIL_mallocStr@plt>
mov    %rax,%rbx
lea    0xe4c(%rip),%rsi
mov    %rax,%rdi
call   1050 <strcpy@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   10a0 <strcat@plt>
mov    %r14,%rdi
call   1040 <free@plt>
lea    0xe37(%rip),%rsi
jmp    1250 <OC_mkNeededness+0xd0>
mov    %ebx,%edi
call   1030 <UTIL_itoa@plt>
mov    %rax,%r15
mov    %r14,%rdi
call   1060 <strlen@plt>
mov    %rax,%rbx
mov    %r15,%rdi
call   1060 <strlen@plt>
lea    (%rbx,%rax,1),%rdi
add    $0x3c,%rdi
call   1090 <UTIL_mallocStr@plt>
mov    %rax,%rbx
lea    0xe08(%rip),%rsi
mov    %rax,%rdi
call   1050 <strcpy@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   10a0 <strcat@plt>
mov    %r14,%rdi
call   1040 <free@plt>
lea    0xdf3(%rip),%rsi
mov    %rbx,%rdi
call   10a0 <strcat@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
call   10a0 <strcat@plt>
mov    %r15,%rdi
call   1040 <free@plt>
lea    0xde5(%rip),%rsi
mov    %rbx,%rdi
call   10a0 <strcat@plt>
mov    %rbx,%rdi
call   1070 <OC_mkSome@plt>
mov    %rax,%rbp
mov    %rbx,%rdi
call   1040 <free@plt>
mov    %rbp,%rdi
call   1080 <OC_mkRef@plt>
mov    %rax,%rbx
mov    %rbp,%rdi
call   1040 <free@plt>
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [13 x i8] c"(Array.make \00"
@.str.1 = [7 x i8] c" true)\00"
@.str.2 = [13 x i8] c"(Array.init \00"
@.str.3 = [20 x i8] c" (fun x -> if x >= \00"
@.str.4 = [24 x i8] c" then false else true))\00"
define i8* @OC_mkNeededness(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i8*
store i32 %0, i32* %3
store i32 %1, i32* %4
%10 = load i32, i32* %4
%11 = call i8* @UTIL_itoa(i32 %10)
store i8* %11, i8** %5
%12 = load i32, i32* %3
%13 = load i32, i32* %4
%14 = icmp eq i32 %12, %13
br i1 %14, label %15, label %29
15: ; preds = %2
%16 = load i8*, i8** %5
%17 = call i64 @strlen(i8* %16)
%18 = add nsw i64 %17, 20
%19 = call i8* @UTIL_mallocStr(i64 %18)
store i8* %19, i8** %6
%20 = load i8*, i8** %6
%21 = call i32 @strcpy(i8* %20, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
%22 = load i8*, i8** %6
%23 = load i8*, i8** %5
%24 = call i32 @strcat(i8* %22, i8* %23)
%25 = load i8*, i8** %5
%26 = call i32 @free(i8* %25)
%27 = load i8*, i8** %6
%28 = call i32 @strcat(i8* %27, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
br label %55
29: ; preds = %2
%30 = load i32, i32* %3
%31 = call i8* @UTIL_itoa(i32 %30)
store i8* %31, i8** %9
%32 = load i8*, i8** %5
%33 = call i64 @strlen(i8* %32)
%34 = load i8*, i8** %9
%35 = call i64 @strlen(i8* %34)
%36 = add nsw i64 %33, %35
%37 = add nsw i64 %36, 60
%38 = call i8* @UTIL_mallocStr(i64 %37)
store i8* %38, i8** %6
%39 = load i8*, i8** %6
%40 = call i32 @strcpy(i8* %39, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0))
%41 = load i8*, i8** %6
%42 = load i8*, i8** %5
%43 = call i32 @strcat(i8* %41, i8* %42)
%44 = load i8*, i8** %5
%45 = call i32 @free(i8* %44)
%46 = load i8*, i8** %6
%47 = call i32 @strcat(i8* %46, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0))
%48 = load i8*, i8** %6
%49 = load i8*, i8** %9
%50 = call i32 @strcat(i8* %48, i8* %49)
%51 = load i8*, i8** %9
%52 = call i32 @free(i8* %51)
%53 = load i8*, i8** %6
%54 = call i32 @strcat(i8* %53, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0))
br label %55
55: ; preds = %29, %15
%56 = load i8*, i8** %6
%57 = call i8* @OC_mkSome(i8* %56)
store i8* %57, i8** %7
%58 = load i8*, i8** %6
%59 = call i32 @free(i8* %58)
%60 = load i8*, i8** %7
%61 = call i8* @OC_mkRef(i8* %60)
store i8* %61, i8** %8
%62 = load i8*, i8** %7
%63 = call i32 @free(i8* %62)
%64 = load i8*, i8** %8
ret i8* %64
}

LLVM IR (-O2):
@.str = [13 x i8] c"(Array.make \00"
@.str.1 = [7 x i8] c" true)\00"
@.str.2 = [13 x i8] c"(Array.init \00"
@.str.3 = [20 x i8] c" (fun x -> if x >= \00"
@.str.4 = [24 x i8] c" then false else true))\00"
define i8* @OC_mkNeededness(i32 %0, i32 %1) {
%3 = tail call i8* @UTIL_itoa(i32 %1)
%4 = icmp eq i32 %0, %1
br i1 %4, label %5, label %13
5: ; preds = %2
%6 = tail call i64 @strlen(i8* dereferenceable(1) %3)
%7 = add nsw i64 %6, 20
%8 = tail call i8* @UTIL_mallocStr(i64 %7)
%9 = tail call i32 @strcpy(i8* %8, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
%10 = tail call i32 @strcat(i8* %8, i8* %3)
%11 = tail call i32 @free(i8* %3)
%12 = tail call i32 @strcat(i8* %8, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
br label %27
13: ; preds = %2
%14 = tail call i8* @UTIL_itoa(i32 %0)
%15 = tail call i64 @strlen(i8* dereferenceable(1) %3)
%16 = tail call i64 @strlen(i8* dereferenceable(1) %14)
%17 = add i64 %15, 60
%18 = add i64 %17, %16
%19 = tail call i8* @UTIL_mallocStr(i64 %18)
%20 = tail call i32 @strcpy(i8* %19, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.2, i64 0, i64 0))
%21 = tail call i32 @strcat(i8* %19, i8* %3)
%22 = tail call i32 @free(i8* %3)
%23 = tail call i32 @strcat(i8* %19, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0))
%24 = tail call i32 @strcat(i8* %19, i8* %14)
%25 = tail call i32 @free(i8* %14)
%26 = tail call i32 @strcat(i8* %19, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0))
br label %27
27: ; preds = %13, %5
%28 = phi i8* [ %8, %5 ], [ %19, %13 ]
%29 = tail call i8* @OC_mkSome(i8* %28)
%30 = tail call i32 @free(i8* %28)
%31 = tail call i8* @OC_mkRef(i8* %29)
%32 = tail call i32 @free(i8* %29)
ret i8* %31
}