#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*/ buf;

/* Variables and functions */
int /*<<< orphan*/ assert(int);
int memccpy(char *, char *, char, int);
int /*<<< orphan*/ memset(char *, int, int);
int main() {
  char buf[100];
  memset(buf, 0x1, sizeof(buf));
  assert(memccpy(buf, "Hello World\n", ' ', sizeof(buf)));
  assert(buf[6] == 0x1);
  assert(!*(char *)(memccpy(buf, "Hello, World", 0, sizeof(buf)) - 1));
  assert(buf[13] == 0x1);
  assert(!memccpy(buf, "Hello, World\n", 0, 5));
  return (0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x70(%rbp),%rdi
mov    $0x1,%esi
mov    $0x64,%edx
call   1030 <memset@plt>
lea    -0x70(%rbp),%rdi
lea    0xea3(%rip),%rsi
mov    $0x20,%edx
mov    $0x64,%ecx
call   1050 <memccpy@plt>
mov    %eax,%edi
call   1040 <assert@plt>
movsbl -0x6a(%rbp),%eax
cmp    $0x1,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
lea    -0x70(%rbp),%rdi
lea    0xe7b(%rip),%rsi
xor    %edx,%edx
mov    $0x64,%ecx
call   1050 <memccpy@plt>
sub    $0x1,%eax
cltq
cmpb   $0x0,(%rax)
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
movsbl -0x63(%rbp),%eax
cmp    $0x1,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
lea    -0x70(%rbp),%rdi
lea    0xe46(%rip),%rsi
xor    %edx,%edx
mov    $0x5,%ecx
call   1050 <memccpy@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
xor    %eax,%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
LLVM IR (-O0):
@.str = [13 x i8] c"Hello World\0A\00"
@.str.1 = [13 x i8] c"Hello, World\00"
@.str.2 = [14 x i8] c"Hello, World\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [100 x i8]
store i32 0, i32* %1
%3 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%4 = call i32 @memset(i8* %3, i32 1, i32 100)
%5 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%6 = call i32 @memccpy(i8* %5, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0), i8 signext 32, i32 100)
%7 = call i32 @assert(i32 %6)
%8 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 6
%9 = load i8, i8* %8
%10 = sext i8 %9 to i32
%11 = icmp eq i32 %10, 1
%12 = zext i1 %11 to i32
%13 = call i32 @assert(i32 %12)
%14 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%15 = call i32 @memccpy(i8* %14, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.1, i64 0, i64 0), i8 signext 0, i32 100)
%16 = sub nsw i32 %15, 1
%17 = sext i32 %16 to i64
%18 = inttoptr i64 %17 to i8*
%19 = load i8, i8* %18
%20 = icmp ne i8 %19, 0
%21 = xor i1 %20, true
%22 = zext i1 %21 to i32
%23 = call i32 @assert(i32 %22)
%24 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 13
%25 = load i8, i8* %24
%26 = sext i8 %25 to i32
%27 = icmp eq i32 %26, 1
%28 = zext i1 %27 to i32
%29 = call i32 @assert(i32 %28)
%30 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%31 = call i32 @memccpy(i8* %30, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64 0), i8 signext 0, i32 5)
%32 = icmp ne i32 %31, 0
%33 = xor i1 %32, true
%34 = zext i1 %33 to i32
%35 = call i32 @assert(i32 %34)
ret i32 0
}

LLVM IR (-O2):