#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 *malloc(long);
char *realloc(char *, long);
int /*<<< orphan*/ strcat(char *, char *);
scalar_t__ strlen(char *);
void ForComments(char **comments, long int *buff_comments, char *str) {
  if (*comments == NULL) {
    *comments = malloc(*buff_comments * sizeof(char));
    assert(*comments != NULL);
  }
  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),%rax
cmpq   $0x0,(%rax)
jne    11a1 <ForComments+0x51>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
shl    $0x0,%rdi
call   1050 <malloc@plt>
mov    %rax,%rcx
mov    -0x8(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x8(%rbp),%rax
cmpq   $0x0,(%rax)
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
mov    -0x8(%rbp),%rax
mov    (%rax),%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     1218 <ForComments+0xc8>
mov    -0x10(%rbp),%rax
mov    (%rax),%rcx
add    $0x3e8,%rcx
mov    %rcx,(%rax)
mov    -0x8(%rbp),%rax
mov    (%rax),%rdi
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
shl    $0x0,%rsi
call   1060 <realloc@plt>
mov    %rax,%rcx
mov    -0x8(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x8(%rbp),%rax
cmpq   $0x0,(%rax)
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
mov    -0x8(%rbp),%rax
mov    (%rax),%rdi
mov    -0x18(%rbp),%rsi
call   1070 <strcat@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ForComments>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%r12
mov    (%rdi),%rbx
test   %rbx,%rbx
jne    1188 <ForComments+0x38>
mov    (%r15),%rdi
call   1050 <malloc@plt>
mov    %rax,(%r12)
xor    %edi,%edi
test   %rax,%rax
setne  %dil
call   1040 <assert@plt>
mov    (%r12),%rbx
mov    %rbx,%rdi
call   1030 <strlen@plt>
mov    %rax,%r13
mov    %r14,%rdi
call   1030 <strlen@plt>
add    %r13,%rax
mov    (%r15),%rsi
cmp    %rsi,%rax
jl     11ce <ForComments+0x7e>
add    $0x3e8,%rsi
mov    %rsi,(%r15)
mov    %rbx,%rdi
call   1060 <realloc@plt>
mov    %rax,(%r12)
xor    %edi,%edi
test   %rax,%rax
setne  %dil
call   1040 <assert@plt>
mov    (%r12),%rbx
mov    %rbx,%rdi
mov    %r14,%rsi
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
jmp    1070 <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 = load i8*, i8** %7
%9 = icmp eq i8* %8, null
br i1 %9, label %10, label %21
10: ; preds = %3
%11 = load i64*, i64** %5
%12 = load i64, i64* %11
%13 = mul i64 %12, 1
%14 = call i8* @malloc(i64 %13)
%15 = load i8**, i8*** %4
store i8* %14, i8** %15
%16 = load i8**, i8*** %4
%17 = load i8*, i8** %16
%18 = icmp ne i8* %17, null
%19 = zext i1 %18 to i32
%20 = call i32 @assert(i32 %19)
br label %21
21: ; preds = %10, %3
%22 = load i8**, i8*** %4
%23 = load i8*, i8** %22
%24 = call i64 @strlen(i8* %23)
%25 = load i8*, i8** %6
%26 = call i64 @strlen(i8* %25)
%27 = add nsw i64 %24, %26
%28 = load i64*, i64** %5
%29 = load i64, i64* %28
%30 = icmp sge i64 %27, %29
br i1 %30, label %31, label %47
31: ; preds = %21
%32 = load i64*, i64** %5
%33 = load i64, i64* %32
%34 = add nsw i64 %33, 1000
store i64 %34, i64* %32
%35 = load i8**, i8*** %4
%36 = load i8*, i8** %35
%37 = load i64*, i64** %5
%38 = load i64, i64* %37
%39 = mul i64 %38, 1
%40 = call i8* @realloc(i8* %36, i64 %39)
%41 = load i8**, i8*** %4
store i8* %40, i8** %41
%42 = load i8**, i8*** %4
%43 = load i8*, i8** %42
%44 = icmp ne i8* %43, null
%45 = zext i1 %44 to i32
%46 = call i32 @assert(i32 %45)
br label %47
47: ; preds = %31, %21
%48 = load i8**, i8*** %4
%49 = load i8*, i8** %48
%50 = load i8*, i8** %6
%51 = call i32 @strcat(i8* %49, i8* %50)
ret void
}

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