#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 */
struct line_list {
  int dummy;
};

/* Variables and functions */
char *Join_line_list(struct line_list *, char *);
int safestrlen(char *);
char *Join_line_list_with_sep(struct line_list *l, char *sep) {
  char *s = Join_line_list(l, sep);
  int len = 0;
  if (sep)
    len = safestrlen(sep);
  if (s) {
    *(s + safestrlen(s) - len) = 0;
    ;
  }
  return (s);
}


x86 assembly (clang, -O0):
<Join_line_list_with_sep>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
call   1030 <Join_line_list@plt>
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
cmpq   $0x0,-0x10(%rbp)
je     115f <Join_line_list_with_sep+0x3f>
mov    -0x10(%rbp),%rdi
call   1040 <safestrlen@plt>
mov    %eax,-0x1c(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     1194 <Join_line_list_with_sep+0x74>
mov    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <safestrlen@plt>
mov    %eax,%ecx
mov    -0x28(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
movslq -0x1c(%rbp),%rdx
xor    %ecx,%ecx
sub    %rdx,%rcx
movb   $0x0,(%rax,%rcx,1)
mov    -0x18(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<Join_line_list_with_sep>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
call   1030 <Join_line_list@plt>
mov    %rax,%r14
test   %rbx,%rbx
je     1165 <Join_line_list_with_sep+0x45>
mov    %rbx,%rdi
call   1040 <safestrlen@plt>
movslq %eax,%rbx
test   %r14,%r14
je     115a <Join_line_list_with_sep+0x3a>
mov    %r14,%rdi
call   1040 <safestrlen@plt>
cltq
mov    %r14,%rcx
add    %rax,%rcx
sub    %rbx,%rcx
movb   $0x0,(%rcx)
mov    %r14,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
xor    %ebx,%ebx
test   %r14,%r14
jne    1144 <Join_line_list_with_sep+0x24>
jmp    115a <Join_line_list_with_sep+0x3a>

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

LLVM IR (-O2):
%struct.line_list = type { i32 }
define i8* @Join_line_list_with_sep(%struct.line_list* %0, i8* %1) {
%3 = tail call i8* @Join_line_list(%struct.line_list* %0, i8* %1)
%4 = icmp eq i8* %1, null
br i1 %4, label %8, label %5
5: ; preds = %2
%6 = tail call i32 @safestrlen(i8* %1)
%7 = sext i32 %6 to i64
br label %8
8: ; preds = %5, %2
%9 = phi i64 [ %7, %5 ], [ 0, %2 ]
%10 = icmp eq i8* %3, null
br i1 %10, label %17, label %11
11: ; preds = %8
%12 = tail call i32 @safestrlen(i8* %3)
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds i8, i8* %3, i64 %13
%15 = sub nsw i64 0, %9
%16 = getelementptr inbounds i8, i8* %14, i64 %15
store i8 0, i8* %16
br label %17
17: ; preds = %11, %8
ret i8* %3
}