#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*/ memcpy(char *, char *, int);
int strlen(char *);
scalar_t__ xrealloc(char *, int);
void store_hook(char *line, void *data) {
  char **output = (char **)data;
  static int storing = 0;
  while (storing)
    ;
  storing = 1;
  *output = (char *)xrealloc(*output, strlen(*output) + strlen(line) + 1);
  memcpy(*output + strlen(*output), line, strlen(line) + 1);
  storing = 0;
}


x86 assembly (clang, -O0):
<store_hook>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
cmpl   $0x0,0x2eed(%rip)
je     115a <store_hook+0x2a>
jmp    1148 <store_hook+0x18>
movl   $0x1,0x2ed8(%rip)
mov    -0x18(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x38(%rbp)
mov    -0x18(%rbp),%rax
mov    (%rax),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x3c(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x3c(%rbp),%esi
mov    -0x38(%rbp),%rdi
add    %eax,%esi
add    $0x1,%esi
call   1040 <xrealloc@plt>
mov    %rax,%rcx
mov    -0x18(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x18(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x30(%rbp)
mov    -0x18(%rbp),%rax
mov    (%rax),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x30(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x28(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x28(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    %eax,%edx
add    $0x1,%edx
call   1050 <memcpy@plt>
movl   $0x0,0x2e46(%rip)
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<store_hook>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r15
mov    %rdi,%r14
mov    (%rsi),%rbx
mov    %rbx,%rdi
call   1030 <strlen@plt>
mov    %eax,%r12d
mov    %r14,%rdi
call   1030 <strlen@plt>
lea    (%r12,%rax,1),%esi
add    $0x1,%esi
mov    %rbx,%rdi
call   1040 <xrealloc@plt>
mov    %rax,%rbx
mov    %rax,(%r15)
mov    %rax,%rdi
call   1030 <strlen@plt>
movslq %eax,%r15
add    %rbx,%r15
mov    %r14,%rdi
call   1030 <strlen@plt>
lea    0x1(%rax),%edx
mov    %r15,%rdi
mov    %r14,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1050 <memcpy@plt>

LLVM IR (-O0):
@store_hook.storing = internal global i32 0
define void @store_hook(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8**
store i8* %0, i8** %3
store i8* %1, i8** %4
%6 = load i8*, i8** %4
%7 = bitcast i8* %6 to i8**
store i8** %7, i8*** %5
br label %8
8: ; preds = %11, %2
%9 = load i32, i32* @store_hook.storing
%10 = icmp ne i32 %9, 0
br i1 %10, label %11, label %12
11: ; preds = %8
br label %8
12: ; preds = %8
store i32 1, i32* @store_hook.storing
%13 = load i8**, i8*** %5
%14 = load i8*, i8** %13
%15 = load i8**, i8*** %5
%16 = load i8*, i8** %15
%17 = call i32 @strlen(i8* %16)
%18 = load i8*, i8** %3
%19 = call i32 @strlen(i8* %18)
%20 = add nsw i32 %17, %19
%21 = add nsw i32 %20, 1
%22 = call i64 @xrealloc(i8* %14, i32 %21)
%23 = inttoptr i64 %22 to i8*
%24 = load i8**, i8*** %5
store i8* %23, i8** %24
%25 = load i8**, i8*** %5
%26 = load i8*, i8** %25
%27 = load i8**, i8*** %5
%28 = load i8*, i8** %27
%29 = call i32 @strlen(i8* %28)
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds i8, i8* %26, i64 %30
%32 = load i8*, i8** %3
%33 = load i8*, i8** %3
%34 = call i32 @strlen(i8* %33)
%35 = add nsw i32 %34, 1
%36 = call i32 @memcpy(i8* %31, i8* %32, i32 %35)
store i32 0, i32* @store_hook.storing
ret void
}

LLVM IR (-O2):
define void @store_hook(i8* %0, i8* nocapture %1) {
%3 = bitcast i8* %1 to i8**
%4 = load i8*, i8** %3
%5 = tail call i32 @strlen(i8* %4)
%6 = tail call i32 @strlen(i8* %0)
%7 = add i32 %5, 1
%8 = add i32 %7, %6
%9 = tail call i64 @xrealloc(i8* %4, i32 %8)
%10 = inttoptr i64 %9 to i8*
store i8* %10, i8** %3
%11 = tail call i32 @strlen(i8* %10)
%12 = sext i32 %11 to i64
%13 = getelementptr inbounds i8, i8* %10, i64 %12
%14 = tail call i32 @strlen(i8* %0)
%15 = add nsw i32 %14, 1
%16 = tail call i32 @memcpy(i8* %13, i8* %0, i32 %15)
ret void
}