#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ complete_part_line(char const *, char **,
                                      int /*<<< orphan*/ *);
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ print_clean(char const *);
char *str_concat_wrap(char const *, char *, int /*<<< orphan*/ *,
                      int /*<<< orphan*/);
void merge_print_line(const char *line, const char *p, FILE *stream) {
  char *buf = NULL;
  char *merged_esc = NULL;
  const char *esc = "";
  const char char_restore = *p;
  complete_part_line(p + 1, &buf, stream);
  if (buf) {
    esc = merged_esc = str_concat_wrap(p, buf, NULL, 0);
    *(char *)p = '\0';
    free(buf);
  }
  print_clean(line);
  *(char *)p = char_restore;
  print_clean(esc);
  free(merged_esc);
}


x86 assembly (clang, -O0):
<merge_print_line>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
movq   $0x0,-0x28(%rbp)
lea    0xe95(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%al
mov    %al,-0x31(%rbp)
mov    -0x10(%rbp),%rdi
add    $0x1,%rdi
mov    -0x18(%rbp),%rdx
lea    -0x20(%rbp),%rsi
call   1050 <complete_part_line@plt>
cmpq   $0x0,-0x20(%rbp)
je     11c3 <merge_print_line+0x83>
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%rsi
xor    %eax,%eax
mov    %eax,%edx
xor    %ecx,%ecx
call   1040 <str_concat_wrap@plt>
mov    %rax,-0x28(%rbp)
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rax
movb   $0x0,(%rax)
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
mov    -0x8(%rbp),%rdi
call   1060 <print_clean@plt>
mov    -0x31(%rbp),%cl
mov    -0x10(%rbp),%rax
mov    %cl,(%rax)
mov    -0x30(%rbp),%rdi
call   1060 <print_clean@plt>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<merge_print_line>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%rbx
mov    %rdi,%r14
movq   $0x0,0x8(%rsp)
mov    (%rsi),%bpl
lea    0x1(%rsi),%rdi
lea    0x8(%rsp),%rsi
call   1050 <complete_part_line@plt>
mov    0x8(%rsp),%rsi
test   %rsi,%rsi
je     1197 <merge_print_line+0x57>
mov    %rbx,%rdi
xor    %edx,%edx
xor    %ecx,%ecx
call   1040 <str_concat_wrap@plt>
mov    %rax,%r15
movb   $0x0,(%rbx)
mov    0x8(%rsp),%rdi
call   1030 <free@plt>
mov    %r15,%r12
jmp    11a1 <merge_print_line+0x61>
lea    0xe62(%rip),%r15
xor    %r12d,%r12d
mov    %r14,%rdi
call   1060 <print_clean@plt>
mov    %bpl,(%rbx)
mov    %r15,%rdi
call   1060 <print_clean@plt>
mov    %r12,%rdi
call   1030 <free@plt>
add    $0x10,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [1 x i8] zeroinitializer
define void @merge_print_line(i8* %0, i8* %1, i32* %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i8
store i8* %0, i8** %4
store i8* %1, i8** %5
store i32* %2, i32** %6
store i8* null, i8** %7
store i8* null, i8** %8
store i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0), i8** %9
%11 = load i8*, i8** %5
%12 = load i8, i8* %11
store i8 %12, i8* %10
%13 = load i8*, i8** %5
%14 = getelementptr inbounds i8, i8* %13, i64 1
%15 = load i32*, i32** %6
%16 = call i32 @complete_part_line(i8* %14, i8** %7, i32* %15)
%17 = load i8*, i8** %7
%18 = icmp ne i8* %17, null
br i1 %18, label %19, label %26
19: ; preds = %3
%20 = load i8*, i8** %5
%21 = load i8*, i8** %7
%22 = call i8* @str_concat_wrap(i8* %20, i8* %21, i32* null, i32 0)
store i8* %22, i8** %8
store i8* %22, i8** %9
%23 = load i8*, i8** %5
store i8 0, i8* %23
%24 = load i8*, i8** %7
%25 = call i32 @free(i8* %24)
br label %26
26: ; preds = %19, %3
%27 = load i8*, i8** %4
%28 = call i32 @print_clean(i8* %27)
%29 = load i8, i8* %10
%30 = load i8*, i8** %5
store i8 %29, i8* %30
%31 = load i8*, i8** %9
%32 = call i32 @print_clean(i8* %31)
%33 = load i8*, i8** %8
%34 = call i32 @free(i8* %33)
ret void
}

LLVM IR (-O2):
@.str = [1 x i8] zeroinitializer
define void @merge_print_line(i8* %0, i8* %1, i32* %2) {
%4 = alloca i8*
%5 = bitcast i8** %4 to i8*
store i8* null, i8** %4
%6 = load i8, i8* %1
%7 = getelementptr inbounds i8, i8* %1, i64 1
%8 = call i32 @complete_part_line(i8* %7, i8** %4, i32* %2)
%9 = load i8*, i8** %4
%10 = icmp eq i8* %9, null
br i1 %10, label %15, label %11
11: ; preds = %3
%12 = call i8* @str_concat_wrap(i8* %1, i8* %9, i32* null, i32 0)
store i8 0, i8* %1
%13 = load i8*, i8** %4
%14 = call i32 @free(i8* %13)
br label %15
15: ; preds = %11, %3
%16 = phi i8* [ %12, %11 ], [ getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0), %3 ]
%17 = phi i8* [ %12, %11 ], [ null, %3 ]
%18 = call i32 @print_clean(i8* %0)
store i8 %6, i8* %1
%19 = call i32 @print_clean(i8* %16)
%20 = call i32 @free(i8* %17)
ret void
}