#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*/ ft_memcpy(char *, char const *, size_t);
size_t ft_strlen(char const *);
char *ft_strnew(size_t);
char *ft_strjoinc(char const *s1, char const c) {
  char *join;
  size_t len_s1;
  len_s1 = ft_strlen(s1);
  join = ft_strnew(len_s1 + 2);
  if (join == NULL)
    return (NULL);
  ft_memcpy(join, s1, len_s1);
  join[len_s1] = c;
  return (join);
}


x86 assembly (clang, -O0):
<ft_strjoinc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %sil,%al
mov    %rdi,-0x10(%rbp)
mov    %al,-0x11(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <ft_strlen@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rdi
add    $0x2,%rdi
call   1040 <ft_strnew@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    1178 <ft_strjoinc+0x48>
movq   $0x0,-0x8(%rbp)
jmp    119f <ft_strjoinc+0x6f>
mov    -0x20(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x28(%rbp),%rdx
call   1050 <ft_memcpy@plt>
mov    -0x11(%rbp),%dl
mov    -0x20(%rbp),%rax
mov    -0x28(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x20(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ft_strjoinc>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %esi,%r14d
mov    %rdi,%r15
call   1030 <ft_strlen@plt>
mov    %rax,%rbp
lea    0x2(%rax),%rdi
call   1040 <ft_strnew@plt>
mov    %rax,%rbx
test   %rax,%rax
je     1168 <ft_strjoinc+0x38>
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %rbp,%rdx
call   1050 <ft_memcpy@plt>
mov    %r14b,(%rbx,%rbp,1)
mov    %rbx,%rax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i8* @ft_strjoinc(i8* %0, i8 signext %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8
%6 = alloca i8*
%7 = alloca i64
store i8* %0, i8** %4
store i8 %1, i8* %5
%8 = load i8*, i8** %4
%9 = call i64 @ft_strlen(i8* %8)
store i64 %9, i64* %7
%10 = load i64, i64* %7
%11 = add i64 %10, 2
%12 = call i8* @ft_strnew(i64 %11)
store i8* %12, i8** %6
%13 = load i8*, i8** %6
%14 = icmp eq i8* %13, null
br i1 %14, label %15, label %16
15: ; preds = %2
store i8* null, i8** %3
br label %26
16: ; preds = %2
%17 = load i8*, i8** %6
%18 = load i8*, i8** %4
%19 = load i64, i64* %7
%20 = call i32 @ft_memcpy(i8* %17, i8* %18, i64 %19)
%21 = load i8, i8* %5
%22 = load i8*, i8** %6
%23 = load i64, i64* %7
%24 = getelementptr inbounds i8, i8* %22, i64 %23
store i8 %21, i8* %24
%25 = load i8*, i8** %6
store i8* %25, i8** %3
br label %26
26: ; preds = %16, %15
%27 = load i8*, i8** %3
ret i8* %27
}

LLVM IR (-O2):
define i8* @ft_strjoinc(i8* %0, i8 signext %1) {
%3 = tail call i64 @ft_strlen(i8* %0)
%4 = add i64 %3, 2
%5 = tail call i8* @ft_strnew(i64 %4)
%6 = icmp eq i8* %5, null
br i1 %6, label %10, label %7
7: ; preds = %2
%8 = tail call i32 @ft_memcpy(i8* %5, i8* %0, i64 %3)
%9 = getelementptr inbounds i8, i8* %5, i64 %3
store i8 %1, i8* %9
br label %10
10: ; preds = %2, %7
ret i8* %5
}