#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*/ strlen(char *);
int array_push(char *v, char **array, int count) {
  for (int i = 0; i < count; ++i) {
    if (!strlen(array[i])) {
      array[i] = v;
      return 1;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<array_push>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    117f <array_push+0x6f>
mov    -0x18(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1030 <strlen@plt>
cmp    $0x0,%eax
jne    116c <array_push+0x5c>
mov    -0x10(%rbp),%rdx
mov    -0x18(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
movl   $0x1,-0x4(%rbp)
jmp    1186 <array_push+0x76>
jmp    1171 <array_push+0x61>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    112a <array_push+0x1a>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<array_push>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
test   %edx,%edx
jle    1166 <array_push+0x56>
mov    %edx,%ebp
mov    %rsi,%r15
mov    %rdi,%r14
mov    (%rsi),%rdi
call   1030 <strlen@plt>
test   %eax,%eax
je     116a <array_push+0x5a>
mov    %ebp,%ebx
mov    $0x1,%ebp
cs nopw 0x0(%rax,%rax,1)
cmp    %rbp,%rbx
je     1174 <array_push+0x64>
mov    (%r15,%rbp,8),%rdi
call   1030 <strlen@plt>
add    $0x1,%rbp
test   %eax,%eax
jne    1140 <array_push+0x30>
add    $0xffffffffffffffff,%rbp
cmp    %rbx,%rbp
setb   %al
mov    %r14,(%r15,%rbp,8)
jmp    1177 <array_push+0x67>
xor    %eax,%eax
jmp    1177 <array_push+0x67>
mov    $0x1,%al
xor    %ebp,%ebp
mov    %r14,(%r15,%rbp,8)
jmp    1177 <array_push+0x67>
seta   %al
movzbl %al,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @array_push(i8* %0, i8** %1, i32 %2) {
%4 = alloca i32
%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 0, i32* %8
br label %9
9: ; preds = %28, %3
%10 = load i32, i32* %8
%11 = load i32, i32* %7
%12 = icmp slt i32 %10, %11
br i1 %12, label %13, label %31
13: ; preds = %9
%14 = load i8**, i8*** %6
%15 = load i32, i32* %8
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds i8*, i8** %14, i64 %16
%18 = load i8*, i8** %17
%19 = call i32 @strlen(i8* %18)
%20 = icmp ne i32 %19, 0
br i1 %20, label %27, label %21
21: ; preds = %13
%22 = load i8*, i8** %5
%23 = load i8**, i8*** %6
%24 = load i32, i32* %8
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds i8*, i8** %23, i64 %25
store i8* %22, i8** %26
store i32 1, i32* %4
br label %32
27: ; preds = %13
br label %28
28: ; preds = %27
%29 = load i32, i32* %8
%30 = add nsw i32 %29, 1
store i32 %30, i32* %8
br label %9
31: ; preds = %9
store i32 0, i32* %4
br label %32
32: ; preds = %31, %21
%33 = load i32, i32* %4
ret i32 %33
}

LLVM IR (-O2):
define i32 @array_push(i8* %0, i8** nocapture %1, i32 %2) {
%4 = icmp sgt i32 %2, 0
br i1 %4, label %5, label %29
5: ; preds = %3
%6 = zext i32 %2 to i64
%7 = zext i32 %2 to i64
%8 = load i8*, i8** %1
%9 = tail call i32 @strlen(i8* %8)
%10 = icmp eq i32 %9, 0
br i1 %10, label %19, label %23
11: ; preds = %23
%12 = getelementptr inbounds i8*, i8** %1, i64 %25
%13 = load i8*, i8** %12
%14 = tail call i32 @strlen(i8* %13)
%15 = icmp eq i32 %14, 0
br i1 %15, label %16, label %23
16: ; preds = %11
%17 = icmp ult i64 %25, %6
%18 = and i64 %25, 4294967295
br label %19
19: ; preds = %16, %5
%20 = phi i64 [ %18, %16 ], [ 0, %5 ]
%21 = phi i1 [ %17, %16 ], [ true, %5 ]
%22 = getelementptr inbounds i8*, i8** %1, i64 %20
store i8* %0, i8** %22
br label %29
23: ; preds = %5, %11
%24 = phi i64 [ %25, %11 ], [ 0, %5 ]
%25 = add nuw nsw i64 %24, 1
%26 = icmp eq i64 %25, %7
br i1 %26, label %27, label %11
27: ; preds = %23
%28 = icmp ult i64 %25, %6
br label %29
29: ; preds = %27, %3, %19
%30 = phi i1 [ %21, %19 ], [ false, %3 ], [ %28, %27 ]
%31 = zext i1 %30 to i32
ret i32 %31
}