#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 *strdup(char const *);
int append_case(char **cases, int *pnum_cases, const char *this_case) {
  int num_cases;
  num_cases = *pnum_cases;
  if (num_cases >= 1000)
    return (1);
  cases[num_cases] = strdup(this_case);
  if (cases[num_cases] == NULL)
    return (1);
  ++(*pnum_cases);
  return (0);
}


x86 assembly (clang, -O0):
<append_case>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    -0x18(%rbp),%rax
mov    (%rax),%eax
mov    %eax,-0x24(%rbp)
cmpl   $0x3e8,-0x24(%rbp)
jl     1146 <append_case+0x36>
movl   $0x1,-0x4(%rbp)
jmp    118f <append_case+0x7f>
mov    -0x20(%rbp),%rdi
call   1030 <strdup@plt>
mov    %rax,%rdx
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
cmpq   $0x0,(%rax,%rcx,8)
jne    117d <append_case+0x6d>
movl   $0x1,-0x4(%rbp)
jmp    118f <append_case+0x7f>
mov    -0x18(%rbp),%rax
mov    (%rax),%ecx
add    $0x1,%ecx
mov    %ecx,(%rax)
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<append_case>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
movslq (%rsi),%rbx
mov    $0x1,%ebp
cmp    $0x3e7,%rbx
jg     1147 <append_case+0x37>
mov    %rsi,%r15
mov    %rdi,%r14
mov    %rdx,%rdi
call   1030 <strdup@plt>
mov    %rax,(%r14,%rbx,8)
test   %rax,%rax
je     1147 <append_case+0x37>
add    $0x1,%ebx
mov    %ebx,(%r15)
xor    %ebp,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define i32 @append_case(i8** nocapture writeonly %0, i32* nocapture %1, i8* nocapture %2) {
%4 = load i32, i32* %1
%5 = icmp sgt i32 %4, 999
br i1 %5, label %13, label %6
6: ; preds = %3
%7 = tail call i8* @strdup(i8* %2)
%8 = sext i32 %4 to i64
%9 = getelementptr inbounds i8*, i8** %0, i64 %8
store i8* %7, i8** %9
%10 = icmp eq i8* %7, null
br i1 %10, label %13, label %11
11: ; preds = %6
%12 = add nsw i32 %4, 1
store i32 %12, i32* %1
br label %13
13: ; preds = %6, %3, %11
%14 = phi i32 [ 0, %11 ], [ 1, %3 ], [ 1, %6 ]
ret i32 %14
}