#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 *);
void stress_mount_add(char *mnts[], const int max, int *n, const char *name) {
  char *mnt;
  if (*n >= max)
    return;
  mnt = strdup(name);
  if (!mnt)
    return;
  mnts[*n] = mnt;
  (*n)++;
}


x86 assembly (clang, -O0):
<stress_mount_add>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x18(%rbp),%rax
mov    (%rax),%eax
cmp    -0xc(%rbp),%eax
jl     113b <stress_mount_add+0x2b>
jmp    1176 <stress_mount_add+0x66>
mov    -0x20(%rbp),%rdi
call   1030 <strdup@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jne    1158 <stress_mount_add+0x48>
jmp    1176 <stress_mount_add+0x66>
mov    -0x28(%rbp),%rdx
mov    -0x8(%rbp),%rax
mov    -0x18(%rbp),%rcx
movslq (%rcx),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x18(%rbp),%rax
mov    (%rax),%ecx
add    $0x1,%ecx
mov    %ecx,(%rax)
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<stress_mount_add>:
push   %r15
push   %r14
push   %rbx
movslq (%rdx),%rbx
cmp    %esi,%ebx
jge    1139 <stress_mount_add+0x29>
mov    %rdx,%r15
mov    %rdi,%r14
mov    %rcx,%rdi
call   1030 <strdup@plt>
test   %rax,%rax
je     1139 <stress_mount_add+0x29>
mov    %rax,(%r14,%rbx,8)
lea    0x1(%rbx),%eax
mov    %eax,(%r15)
pop    %rbx
pop    %r14
pop    %r15
ret

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

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