#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_memccpy(char *, char *, char, int);
int /*<<< orphan*/ memccpy(char *, char *, char, int);
scalar_t__ memcmp(char *, char *, int);
int /*<<< orphan*/ printf(char *, ...);
void test_memccpy1() {
  char buff1[] = "abcdefghijklmnopqrstuvwxyz";
  char buff2[] = "abcdefghijklmnopqrstuvwxyz";
  char *src = "string with\200inside !";
  char *begin1 = buff1;
  char *begin2 = buff2;
  memccpy(buff1, src, '\200', 21);
  ft_memccpy(buff2, src, '\200', 21);
  if (memcmp(buff1, buff2, 25) != 0) {
    printf(">>>>>>>FAIL<<<<<<<\n");
    printf("   memccpy = \"%s\"\n", begin1);
    printf("ft_memccpy = \"%s\"\n", begin2);
  } else
    printf(">>>>>SUCCESS<<<<<\n");
}


x86 assembly (clang, -O0):
<test_memccpy1>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    0xeb1(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xeae(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    0xeab(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    0xea8(%rip),%ax
mov    %ax,-0x8(%rbp)
mov    0xea0(%rip),%al
mov    %al,-0x6(%rbp)
mov    0xe7c(%rip),%rax
mov    %rax,-0x40(%rbp)
mov    0xe79(%rip),%rax
mov    %rax,-0x38(%rbp)
mov    0xe76(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    0xe73(%rip),%ax
mov    %ax,-0x28(%rbp)
mov    0xe6b(%rip),%al
mov    %al,-0x26(%rbp)
lea    0xe62(%rip),%rax
mov    %rax,-0x48(%rbp)
lea    -0x20(%rbp),%rax
mov    %rax,-0x50(%rbp)
lea    -0x40(%rbp),%rax
mov    %rax,-0x58(%rbp)
lea    -0x20(%rbp),%rdi
mov    -0x48(%rbp),%rsi
mov    $0xffffff80,%edx
mov    $0x15,%ecx
call   1060 <memccpy@plt>
lea    -0x40(%rbp),%rdi
mov    -0x48(%rbp),%rsi
mov    $0xffffff80,%edx
mov    $0x15,%ecx
call   1050 <ft_memccpy@plt>
lea    -0x20(%rbp),%rdi
lea    -0x40(%rbp),%rsi
mov    $0x19,%edx
call   1040 <memcmp@plt>
cmp    $0x0,%rax
je     124e <test_memccpy1+0x10e>
lea    0xe12(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x50(%rbp),%rsi
lea    0xe14(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x58(%rbp),%rsi
lea    0xe15(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    125c <test_memccpy1+0x11c>
lea    0xe15(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_memccpy1>:
push   %rbx
sub    $0x40,%rsp
movups 0xebf(%rip),%xmm0
movups %xmm0,0xb(%rsp)
movaps 0xea8(%rip),%xmm1
movaps %xmm1,(%rsp)
movups %xmm0,0x2b(%rsp)
movaps %xmm1,0x20(%rsp)
movabs $0x7720676e69727473,%rax
67 20 77
mov    %rax,(%rsp)
movl   $0x80687469,0x8(%rsp)
80
lea    0xe98(%rip),%rsi
lea    0x20(%rsp),%rbx
mov    %rbx,%rdi
mov    $0xffffff80,%edx
mov    $0x15,%ecx
call   1060 <ft_memccpy@plt>
mov    %rsp,%rdi
mov    %rbx,%rsi
mov    $0x19,%edx
call   1050 <memcmp@plt>
test   %rax,%rax
je     11e1 <test_memccpy1+0xa1>
lea    0xeb2(%rip),%rdi
call   1030 <puts@plt>
lea    0xe6e(%rip),%rdi
mov    %rsp,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe70(%rip),%rdi
lea    0x20(%rsp),%rsi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    11ed <test_memccpy1+0xad>
lea    0xe6e(%rip),%rdi
call   1030 <puts@plt>
add    $0x40,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@__const.test_memccpy1.buff1 = [27 x i8] c"abcdefghijklmnopqrstuvwxyz\00"
@__const.test_memccpy1.buff2 = [27 x i8] c"abcdefghijklmnopqrstuvwxyz\00"
@.str = [21 x i8] c"string with\80inside !\00"
@.str.1 = [20 x i8] c">>>>>>>FAIL<<<<<<<\0A\00"
@.str.2 = [19 x i8] c" memccpy = \22%s\22\0A\00"
@.str.3 = [19 x i8] c"ft_memccpy = \22%s\22\0A\00"
@.str.4 = [19 x i8] c">>>>>SUCCESS<<<<<\0A\00"
define void @test_memccpy1() {
%1 = alloca [27 x i8]
%2 = alloca [27 x i8]
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = bitcast [27 x i8]* %1 to i8*
%7 = bitcast [27 x i8]* %2 to i8*
store i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i8** %3
%8 = getelementptr inbounds [27 x i8], [27 x i8]* %1, i64 0, i64 0
store i8* %8, i8** %4
%9 = getelementptr inbounds [27 x i8], [27 x i8]* %2, i64 0, i64 0
store i8* %9, i8** %5
%10 = getelementptr inbounds [27 x i8], [27 x i8]* %1, i64 0, i64 0
%11 = load i8*, i8** %3
%12 = call i32 @memccpy(i8* %10, i8* %11, i8 signext -128, i32 21)
%13 = getelementptr inbounds [27 x i8], [27 x i8]* %2, i64 0, i64 0
%14 = load i8*, i8** %3
%15 = call i32 @ft_memccpy(i8* %13, i8* %14, i8 signext -128, i32 21)
%16 = getelementptr inbounds [27 x i8], [27 x i8]* %1, i64 0, i64 0
%17 = getelementptr inbounds [27 x i8], [27 x i8]* %2, i64 0, i64 0
%18 = call i64 @memcmp(i8* %16, i8* %17, i32 25)
%19 = icmp ne i64 %18, 0
br i1 %19, label %20, label %26
20: ; preds = %0
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0))
%22 = load i8*, i8** %4
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i8* %22)
%24 = load i8*, i8** %5
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0), i8* %24)
br label %28
26: ; preds = %0
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0))
br label %28
28: ; preds = %26, %20
ret void
}

LLVM IR (-O2):
@__const.test_memccpy1.buff2 = [27 x i8] c"abcdefghijklmnopqrstuvwxyz\00"
@.str = [21 x i8] c"string with\80inside !\00"
@.str.2 = [19 x i8] c" memccpy = \22%s\22\0A\00"
@.str.3 = [19 x i8] c"ft_memccpy = \22%s\22\0A\00"
@str = [18 x i8] c">>>>>SUCCESS<<<<<\00"
@str.5 = [19 x i8] c">>>>>>>FAIL<<<<<<<\00"
define void @test_memccpy1() {
%1 = alloca [27 x i8]
%2 = alloca [27 x i8]
%3 = getelementptr inbounds [27 x i8], [27 x i8]* %1, i64 0, i64 0
%4 = getelementptr inbounds [27 x i8], [27 x i8]* %2, i64 0, i64 0
%5 = call i32 @ft_memccpy(i8* %4, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i8 signext -128, i32 21)
%6 = call i64 @memcmp(i8* %3, i8* %4, i32 25)
%7 = icmp eq i64 %6, 0
br i1 %7, label %12, label %8
8: ; preds = %0
%9 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str.5, i64 0, i64 0))
%10 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.2, i64 0, i64 0), i8* %3)
%11 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0), i8* %4)
br label %14
12: ; preds = %0
%13 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str, i64 0, i64 0))
br label %14
14: ; preds = %12, %8
ret void
}