#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 */
scalar_t__ str_inarray(char const *, char const **, int);
void set_array_opt(const char *oarg, const char *arr[], int *size, int max) {
  if (str_inarray(oarg, arr, *size) < 0 && *size < max)
    arr[(*size)++] = oarg;
}


x86 assembly (clang, -O0):
<set_array_opt>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rax
mov    (%rax),%edx
call   1030 <str_inarray@plt>
cmp    $0x0,%rax
jge    116f <set_array_opt+0x5f>
mov    -0x18(%rbp),%rax
mov    (%rax),%eax
cmp    -0x1c(%rbp),%eax
jge    116f <set_array_opt+0x5f>
mov    -0x8(%rbp),%rdx
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%rsi
mov    (%rsi),%ecx
mov    %ecx,%edi
add    $0x1,%edi
mov    %edi,(%rsi)
movslq %ecx,%rcx
mov    %rdx,(%rax,%rcx,8)
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<set_array_opt>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %ecx,%ebp
mov    %rdx,%rbx
mov    %rsi,%r14
mov    %rdi,%r15
mov    (%rdx),%edx
call   1030 <str_inarray@plt>
test   %rax,%rax
jns    113e <set_array_opt+0x2e>
movslq (%rbx),%rax
cmp    %ebp,%eax
jge    113e <set_array_opt+0x2e>
lea    0x1(%rax),%ecx
mov    %ecx,(%rbx)
mov    %r15,(%r14,%rax,8)
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @set_array_opt(i8* %0, i8** %1, i32* %2, i32 %3) {
%5 = alloca i8*
%6 = alloca i8**
%7 = alloca i32*
%8 = alloca i32
store i8* %0, i8** %5
store i8** %1, i8*** %6
store i32* %2, i32** %7
store i32 %3, i32* %8
%9 = load i8*, i8** %5
%10 = load i8**, i8*** %6
%11 = load i32*, i32** %7
%12 = load i32, i32* %11
%13 = call i64 @str_inarray(i8* %9, i8** %10, i32 %12)
%14 = icmp slt i64 %13, 0
br i1 %14, label %15, label %28
15: ; preds = %4
%16 = load i32*, i32** %7
%17 = load i32, i32* %16
%18 = load i32, i32* %8
%19 = icmp slt i32 %17, %18
br i1 %19, label %20, label %28
20: ; preds = %15
%21 = load i8*, i8** %5
%22 = load i8**, i8*** %6
%23 = load i32*, i32** %7
%24 = load i32, i32* %23
%25 = add nsw i32 %24, 1
store i32 %25, i32* %23
%26 = sext i32 %24 to i64
%27 = getelementptr inbounds i8*, i8** %22, i64 %26
store i8* %21, i8** %27
br label %28
28: ; preds = %20, %15, %4
ret void
}

LLVM IR (-O2):
define void @set_array_opt(i8* %0, i8** %1, i32* nocapture %2, i32 %3) {
%5 = load i32, i32* %2
%6 = tail call i64 @str_inarray(i8* %0, i8** %1, i32 %5)
%7 = icmp slt i64 %6, 0
br i1 %7, label %8, label %15
8: ; preds = %4
%9 = load i32, i32* %2
%10 = icmp slt i32 %9, %3
br i1 %10, label %11, label %15
11: ; preds = %8
%12 = add nsw i32 %9, 1
store i32 %12, i32* %2
%13 = sext i32 %9 to i64
%14 = getelementptr inbounds i8*, i8** %1, i64 %13
store i8* %0, i8** %14
br label %15
15: ; preds = %11, %8, %4
ret void
}