#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(void *, void const *, char, int);
int /*<<< orphan*/ memccpy(void *, void const *, char, int);
scalar_t__ memcmp(char *, char *, int);
int /*<<< orphan*/ printf(char *, ...);
void test_memccpy() {
  printf("-----------------------ft_memccpy\n");
  char str5[20] = "1234567890ABCDEF";
  char str6[20] = "1234567890ABCDEF";
  memccpy((void *)str5, (const void *)"IAcMALIVE", 'c', 15);
  ft_memccpy((void *)str6, (const void *)"IAcMALIVE", 'c', 15);
  if (memcmp(str5, str6, 10) != 0) {
    printf(">>>>>>>FAIL<<<<<<<\n");
    printf("   memccpy = \"%s\"\n", (char *)str5);
    printf("ft_memccpy = \"%s\"\n", (char *)str6);
  } else
    printf(">>>>>SUCCESS<<<<<\n");
}


x86 assembly (clang, -O0):
<test_memccpy>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
lea    0xeb1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    0xf23(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xf20(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    0xf1e(%rip),%eax
mov    %eax,-0x10(%rbp)
mov    0xf24(%rip),%rax
mov    %rax,-0x40(%rbp)
mov    0xf21(%rip),%rax
mov    %rax,-0x38(%rbp)
mov    0xf1f(%rip),%eax
mov    %eax,-0x30(%rbp)
lea    -0x20(%rbp),%rdi
lea    0xe84(%rip),%rsi
mov    $0x63,%edx
mov    $0xf,%ecx
call   1060 <memccpy@plt>
lea    -0x40(%rbp),%rdi
lea    0xe6a(%rip),%rsi
mov    $0x63,%edx
mov    $0xf,%ecx
call   1050 <ft_memccpy@plt>
lea    -0x20(%rbp),%rdi
lea    -0x40(%rbp),%rsi
mov    $0xa,%edx
call   1040 <memcmp@plt>
cmp    $0x0,%rax
je     121b <test_memccpy+0xdb>
lea    0xe42(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x20(%rbp),%rsi
lea    0xe44(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x40(%rbp),%rsi
lea    0xe45(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    1229 <test_memccpy+0xe9>
lea    0xe45(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_memccpy>:
push   %rbx
sub    $0x40,%rsp
lea    0xef8(%rip),%rdi
call   1030 <puts@plt>
movaps 0xea8(%rip),%xmm0
movaps %xmm0,(%rsp)
movl   $0x0,0x10(%rsp)
movaps %xmm0,0x20(%rsp)
movl   $0x0,0x30(%rsp)
movw   $0x4149,(%rsp)
movb   $0x63,0x2(%rsp)
lea    0xe91(%rip),%rsi
lea    0x20(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x63,%edx
mov    $0xf,%ecx
call   1060 <ft_memccpy@plt>
mov    %rsp,%rdi
mov    %rbx,%rsi
mov    $0xa,%edx
call   1050 <memcmp@plt>
test   %rax,%rax
je     11e1 <test_memccpy+0xa1>
lea    0xec2(%rip),%rdi
call   1030 <puts@plt>
lea    0xe5c(%rip),%rdi
mov    %rsp,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe5e(%rip),%rdi
lea    0x20(%rsp),%rsi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    11ed <test_memccpy+0xad>
lea    0xe7e(%rip),%rdi
call   1030 <puts@plt>
add    $0x40,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [35 x i8] c"-----------------------ft_memccpy\0A\00"
@__const.test_memccpy.str5 = [20 x i8] c"1234567890ABCDEF\00\00\00\00"
@__const.test_memccpy.str6 = [20 x i8] c"1234567890ABCDEF\00\00\00\00"
@.str.1 = [10 x i8] c"IAcMALIVE\00"
@.str.2 = [20 x i8] c">>>>>>>FAIL<<<<<<<\0A\00"
@.str.3 = [19 x i8] c" memccpy = \22%s\22\0A\00"
@.str.4 = [19 x i8] c"ft_memccpy = \22%s\22\0A\00"
@.str.5 = [19 x i8] c">>>>>SUCCESS<<<<<\0A\00"
define void @test_memccpy() {
%1 = alloca [20 x i8]
%2 = alloca [20 x i8]
%3 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0))
%4 = bitcast [20 x i8]* %1 to i8*
%5 = bitcast [20 x i8]* %2 to i8*
%6 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 0
%7 = call i32 @memccpy(i8* %6, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8 signext 99, i32 15)
%8 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 0
%9 = call i32 @ft_memccpy(i8* %8, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8 signext 99, i32 15)
%10 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 0
%11 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 0
%12 = call i64 @memcmp(i8* %10, i8* %11, i32 10)
%13 = icmp ne i64 %12, 0
br i1 %13, label %14, label %20
14: ; preds = %0
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.2, i64 0, i64 0))
%16 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 0
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0), i8* %16)
%18 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 0
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0), i8* %18)
br label %22
20: ; preds = %0
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.5, i64 0, i64 0))
br label %22
22: ; preds = %20, %14
ret void
}

LLVM IR (-O2):
@__const.test_memccpy.str6 = [20 x i8] c"1234567890ABCDEF\00\00\00\00"
@.str.1 = [10 x i8] c"IAcMALIVE\00"
@.str.3 = [19 x i8] c" memccpy = \22%s\22\0A\00"
@.str.4 = [19 x i8] c"ft_memccpy = \22%s\22\0A\00"
@str = [34 x i8] c"-----------------------ft_memccpy\00"
@str.6 = [18 x i8] c">>>>>SUCCESS<<<<<\00"
@str.7 = [19 x i8] c">>>>>>>FAIL<<<<<<<\00"
define void @test_memccpy() {
%1 = alloca [20 x i8]
%2 = alloca [20 x i8]
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @str, i64 0, i64 0))
%4 = getelementptr inbounds [20 x i8], [20 x i8]* %1, i64 0, i64 0
%5 = getelementptr inbounds [20 x i8], [20 x i8]* %2, i64 0, i64 0
%6 = call i32 @ft_memccpy(i8* %5, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i8 signext 99, i32 15)
%7 = call i64 @memcmp(i8* %4, i8* %5, i32 10)
%8 = icmp eq i64 %7, 0
br i1 %8, label %13, label %9
9: ; preds = %0
%10 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @str.7, i64 0, i64 0))
%11 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0), i8* %4)
%12 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0), i8* %5)
br label %15
13: ; preds = %0
%14 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @str.6, i64 0, i64 0))
br label %15
15: ; preds = %13, %9
ret void
}