#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 */
int /*<<< orphan*/ abort();
int getCustomCount(int);
const char *getCustom(int argc, char *argv[], int i) {
  int x = 0;
  char *result = NULL;
  if ((argc < 0) || (argv == NULL) || (i < 0)) {
    abort();
  }
  for (x = 0; x < argc; x++) {
    if (argv[x] == NULL) {
      abort();
    }
  }
  if (i < getCustomCount(argc)) {
    result = argv[i + 1];
  } else {
    result = "";
  }
  return result;
}


x86 assembly (clang, -O0):
<getCustom>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
cmpl   $0x0,-0x4(%rbp)
jl     1160 <getCustom+0x40>
cmpq   $0x0,-0x10(%rbp)
je     1160 <getCustom+0x40>
cmpl   $0x0,-0x14(%rbp)
jge    1167 <getCustom+0x47>
mov    $0x0,%al
call   1030 <abort@plt>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    11a7 <getCustom+0x87>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
cmpq   $0x0,(%rax,%rcx,8)
jne    1194 <getCustom+0x74>
mov    $0x0,%al
call   1030 <abort@plt>
jmp    1199 <getCustom+0x79>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    116e <getCustom+0x4e>
mov    -0x14(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x4(%rbp),%edi
call   1040 <getCustomCount@plt>
mov    %eax,%ecx
mov    -0x24(%rbp),%eax
cmp    %ecx,%eax
jge    11dc <getCustom+0xbc>
mov    -0x10(%rbp),%rax
mov    -0x14(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x20(%rbp)
jmp    11e7 <getCustom+0xc7>
lea    0xe1d(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getCustom>:
push   %rbp
push   %rbx
push   %rax
test   %rsi,%rsi
je     1171 <getCustom+0x51>
mov    %edx,%ebp
mov    %edx,%eax
or     %edi,%eax
js     1171 <getCustom+0x51>
mov    %rsi,%rbx
test   %edi,%edi
jle    1150 <getCustom+0x30>
mov    %edi,%eax
xor    %ecx,%ecx
nopl   0x0(%rax,%rax,1)
cmpq   $0x0,(%rbx,%rcx,8)
je     1171 <getCustom+0x51>
add    $0x1,%rcx
cmp    %rcx,%rax
jne    1140 <getCustom+0x20>
call   1040 <getCustomCount@plt>
cmp    %ebp,%eax
jle    1163 <getCustom+0x43>
movslq %ebp,%rax
mov    0x8(%rbx,%rax,8),%rax
jmp    116a <getCustom+0x4a>
lea    0xe96(%rip),%rax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret
xor    %eax,%eax
call   1030 <abort@plt>

LLVM IR (-O0):
@.str = [1 x i8] zeroinitializer
define i8* @getCustom(i32 %0, i8** %1, i32 %2) {
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i8*
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 %2, i32* %6
store i32 0, i32* %7
store i8* null, i8** %8
%9 = load i32, i32* %4
%10 = icmp slt i32 %9, 0
br i1 %10, label %17, label %11
11: ; preds = %3
%12 = load i8**, i8*** %5
%13 = icmp eq i8** %12, null
br i1 %13, label %17, label %14
14: ; preds = %11
%15 = load i32, i32* %6
%16 = icmp slt i32 %15, 0
br i1 %16, label %17, label %19
17: ; preds = %14, %11, %3
%18 = call i32 (...) @abort()
unreachable
19: ; preds = %14
store i32 0, i32* %7
br label %20
20: ; preds = %34, %19
%21 = load i32, i32* %7
%22 = load i32, i32* %4
%23 = icmp slt i32 %21, %22
br i1 %23, label %24, label %37
24: ; preds = %20
%25 = load i8**, i8*** %5
%26 = load i32, i32* %7
%27 = sext i32 %26 to i64
%28 = getelementptr inbounds i8*, i8** %25, i64 %27
%29 = load i8*, i8** %28
%30 = icmp eq i8* %29, null
br i1 %30, label %31, label %33
31: ; preds = %24
%32 = call i32 (...) @abort()
unreachable
33: ; preds = %24
br label %34
34: ; preds = %33
%35 = load i32, i32* %7
%36 = add nsw i32 %35, 1
store i32 %36, i32* %7
br label %20
37: ; preds = %20
%38 = load i32, i32* %6
%39 = load i32, i32* %4
%40 = call i32 @getCustomCount(i32 %39)
%41 = icmp slt i32 %38, %40
br i1 %41, label %42, label %49
42: ; preds = %37
%43 = load i8**, i8*** %5
%44 = load i32, i32* %6
%45 = add nsw i32 %44, 1
%46 = sext i32 %45 to i64
%47 = getelementptr inbounds i8*, i8** %43, i64 %46
%48 = load i8*, i8** %47
store i8* %48, i8** %8
br label %50
49: ; preds = %37
store i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0), i8** %8
br label %50
50: ; preds = %49, %42
%51 = load i8*, i8** %8
ret i8* %51
}

LLVM IR (-O2):
@.str = [1 x i8] zeroinitializer
define i8* @getCustom(i32 %0, i8** %1, i32 %2) {
%4 = icmp eq i8** %1, null
%5 = or i32 %2, %0
%6 = icmp slt i32 %5, 0
%7 = or i1 %4, %6
br i1 %7, label %12, label %8
8: ; preds = %3
%9 = icmp sgt i32 %0, 0
br i1 %9, label %10, label %24
10: ; preds = %8
%11 = zext i32 %0 to i64
br label %16
12: ; preds = %3
%13 = tail call i32 (...) @abort()
unreachable
14: ; preds = %16
%15 = icmp eq i64 %21, %11
br i1 %15, label %24, label %16
16: ; preds = %10, %14
%17 = phi i64 [ 0, %10 ], [ %21, %14 ]
%18 = getelementptr inbounds i8*, i8** %1, i64 %17
%19 = load i8*, i8** %18
%20 = icmp eq i8* %19, null
%21 = add nuw nsw i64 %17, 1
br i1 %20, label %22, label %14
22: ; preds = %16
%23 = tail call i32 (...) @abort()
unreachable
24: ; preds = %14, %8
%25 = tail call i32 @getCustomCount(i32 %0)
%26 = icmp sgt i32 %25, %2
br i1 %26, label %27, label %32
27: ; preds = %24
%28 = add nsw i32 %2, 1
%29 = sext i32 %28 to i64
%30 = getelementptr inbounds i8*, i8** %1, i64 %29
%31 = load i8*, i8** %30
br label %32
32: ; preds = %24, %27
%33 = phi i8* [ %31, %27 ], [ getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0), %24 ]
ret i8* %33
}