#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*/ assert(int /*<<< orphan*/);
char *realloc(char *, long);
int /*<<< orphan*/ strcat(char *, char *);
scalar_t__ strlen(char *);
void ForComments(char *comments, long int *buff_comments, char *str) {
  if ((long)(strlen(comments) + strlen(str)) >= *buff_comments) {
    *buff_comments += 1000;
    comments = realloc(comments, *buff_comments * sizeof(char));
    assert(comments != NULL);
  }
  strcat(comments, str);
}


x86 assembly (clang, -O0):
<ForComments>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %rax,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <strlen@plt>
mov    %rax,%rcx
mov    -0x20(%rbp),%rax
add    %rcx,%rax
mov    -0x10(%rbp),%rcx
cmp    (%rcx),%rax
jl     11bc <ForComments+0x7c>
mov    -0x10(%rbp),%rax
mov    (%rax),%rcx
add    $0x3e8,%rcx
mov    %rcx,(%rax)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
shl    $0x0,%rsi
call   1050 <realloc@plt>
mov    %rax,-0x8(%rbp)
cmpq   $0x0,-0x8(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1060 <strcat@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ForComments>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%rbx
call   1030 <strlen@plt>
mov    %rax,%r12
mov    %r14,%rdi
call   1030 <strlen@plt>
add    %r12,%rax
mov    (%r15),%rsi
cmp    %rsi,%rax
jl     118f <ForComments+0x4f>
add    $0x3e8,%rsi
mov    %rsi,(%r15)
mov    %rbx,%rdi
call   1050 <realloc@plt>
mov    %rax,%rbx
xor    %edi,%edi
test   %rax,%rax
setne  %dil
call   1040 <assert@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1060 <strcat@plt>

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

LLVM IR (-O2):
define void @ForComments(i8* %0, i64* nocapture %1, i8* %2) {
%4 = tail call i64 @strlen(i8* dereferenceable(1) %0)
%5 = tail call i64 @strlen(i8* dereferenceable(1) %2)
%6 = add nsw i64 %5, %4
%7 = load i64, i64* %1
%8 = icmp slt i64 %6, %7
br i1 %8, label %15, label %9
9: ; preds = %3
%10 = add nsw i64 %7, 1000
store i64 %10, i64* %1
%11 = tail call i8* @realloc(i8* %0, i64 %10)
%12 = icmp ne i8* %11, null
%13 = zext i1 %12 to i32
%14 = tail call i32 @assert(i32 %13)
br label %15
15: ; preds = %9, %3
%16 = phi i8* [ %11, %9 ], [ %0, %3 ]
%17 = tail call i32 @strcat(i8* %16, i8* %2)
ret void
}