#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 */
typedef struct TYPE_6__ TYPE_2__;
typedef struct TYPE_5__ TYPE_1__;

/* Type definitions */
typedef int ssize_t;
struct TYPE_5__ {
  char *ptr;
};
typedef TYPE_1__ UDF_INIT;
struct TYPE_6__ {
  scalar_t__ *lengths;
  scalar_t__ *args;
};
typedef TYPE_2__ UDF_ARGS;

/* Variables and functions */
scalar_t__ json_finder_minimize(char **, int *, char const *, int);
char *jfmin(UDF_INIT *initid, UDF_ARGS *args, char *result,
            unsigned long *length, char *is_null, char *error) {
  char *json_min;
  ssize_t json_min_size;
  if (json_finder_minimize(&json_min, &json_min_size,
                           (const char *)args->args[0],
                           (ssize_t)args->lengths[0])) {
    *error = 1;
    return NULL;
  }
  initid->ptr = json_min;
  *length = json_min_size - 1;
  return json_min;
}


x86 assembly (clang, -O0):
<jfmin>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    %r8,-0x30(%rbp)
mov    %r9,-0x38(%rbp)
mov    -0x18(%rbp),%rax
mov    0x8(%rax),%rax
mov    (%rax),%rdx
mov    -0x18(%rbp),%rax
mov    (%rax),%rax
mov    (%rax),%rax
mov    %eax,%ecx
lea    -0x40(%rbp),%rdi
lea    -0x44(%rbp),%rsi
call   1030 <json_finder_minimize@plt>
cmp    $0x0,%rax
je     1172 <jfmin+0x62>
mov    -0x38(%rbp),%rax
movb   $0x1,(%rax)
movq   $0x0,-0x8(%rbp)
jmp    1195 <jfmin+0x85>
mov    -0x40(%rbp),%rcx
mov    -0x10(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x44(%rbp),%eax
sub    $0x1,%eax
movslq %eax,%rcx
mov    -0x28(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x40(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<jfmin>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %r9,%rbx
mov    %rcx,%r14
mov    %rdi,%r15
mov    (%rsi),%rax
mov    0x8(%rsi),%rcx
mov    (%rcx),%rdx
mov    (%rax),%ecx
lea    0x8(%rsp),%rdi
lea    0x4(%rsp),%rsi
call   1030 <json_finder_minimize@plt>
test   %rax,%rax
je     1149 <jfmin+0x39>
movb   $0x1,(%rbx)
xor    %eax,%eax
jmp    115d <jfmin+0x4d>
mov    0x8(%rsp),%rax
mov    %rax,(%r15)
movslq 0x4(%rsp),%rcx
add    $0xffffffffffffffff,%rcx
mov    %rcx,(%r14)
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.TYPE_5__ = type { i8* }
%struct.TYPE_6__ = type { i64*, i64* }
define i8* @jfmin(%struct.TYPE_5__* %0, %struct.TYPE_6__* %1, i8* %2, i64* %3, i8* %4, i8* %5) {
%7 = alloca i8*
%8 = alloca %struct.TYPE_5__*
%9 = alloca %struct.TYPE_6__*
%10 = alloca i8*
%11 = alloca i64*
%12 = alloca i8*
%13 = alloca i8*
%14 = alloca i8*
%15 = alloca i32
store %struct.TYPE_5__* %0, %struct.TYPE_5__** %8
store %struct.TYPE_6__* %1, %struct.TYPE_6__** %9
store i8* %2, i8** %10
store i64* %3, i64** %11
store i8* %4, i8** %12
store i8* %5, i8** %13
%16 = load %struct.TYPE_6__*, %struct.TYPE_6__** %9
%17 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %16, i32 0, i32 1
%18 = load i64*, i64** %17
%19 = getelementptr inbounds i64, i64* %18, i64 0
%20 = load i64, i64* %19
%21 = inttoptr i64 %20 to i8*
%22 = load %struct.TYPE_6__*, %struct.TYPE_6__** %9
%23 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %22, i32 0, i32 0
%24 = load i64*, i64** %23
%25 = getelementptr inbounds i64, i64* %24, i64 0
%26 = load i64, i64* %25
%27 = trunc i64 %26 to i32
%28 = call i64 @json_finder_minimize(i8** %14, i32* %15, i8* %21, i32 %27)
%29 = icmp ne i64 %28, 0
br i1 %29, label %30, label %32
30: ; preds = %6
%31 = load i8*, i8** %13
store i8 1, i8* %31
store i8* null, i8** %7
br label %41
32: ; preds = %6
%33 = load i8*, i8** %14
%34 = load %struct.TYPE_5__*, %struct.TYPE_5__** %8
%35 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %34, i32 0, i32 0
store i8* %33, i8** %35
%36 = load i32, i32* %15
%37 = sub nsw i32 %36, 1
%38 = sext i32 %37 to i64
%39 = load i64*, i64** %11
store i64 %38, i64* %39
%40 = load i8*, i8** %14
store i8* %40, i8** %7
br label %41
41: ; preds = %32, %30
%42 = load i8*, i8** %7
ret i8* %42
}

LLVM IR (-O2):
%struct.TYPE_5__ = type { i8* }
%struct.TYPE_6__ = type { i64*, i64* }
define i8* @jfmin(%struct.TYPE_5__* nocapture writeonly %0, %struct.TYPE_6__* nocapture %1, i8* nocapture readnone %2, i64* nocapture writeonly %3, i8* nocapture readnone %4, i8* nocapture writeonly %5) {
%7 = alloca i8*
%8 = alloca i32
%9 = bitcast i8** %7 to i8*
%10 = bitcast i32* %8 to i8*
%11 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %1, i64 0, i32 1
%12 = load i64*, i64** %11
%13 = load i64, i64* %12
%14 = inttoptr i64 %13 to i8*
%15 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %1, i64 0, i32 0
%16 = load i64*, i64** %15
%17 = load i64, i64* %16
%18 = trunc i64 %17 to i32
%19 = call i64 @json_finder_minimize(i8** %7, i32* %8, i8* %14, i32 %18)
%20 = icmp eq i64 %19, 0
br i1 %20, label %22, label %21
21: ; preds = %6
store i8 1, i8* %5
br label %28
22: ; preds = %6
%23 = load i8*, i8** %7
%24 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %0, i64 0, i32 0
store i8* %23, i8** %24
%25 = load i32, i32* %8
%26 = add nsw i32 %25, -1
%27 = sext i32 %26 to i64
store i64 %27, i64* %3
br label %28
28: ; preds = %22, %21
%29 = phi i8* [ null, %21 ], [ %23, %22 ]
ret i8* %29
}