#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*/ memccpy(char *, char *, char, int);
int /*<<< orphan*/ printf(char *, char *);
int main(int argc, char *argv[]) {
  char str[] = "Copy no more than N bytes of SRC to DEST";
  char str2[] = "Return the position in DEST one byte past where C was copied";
  memccpy(str2, str, 'N', 30);
  printf("%s\n", str);
  printf("%s\n", str2);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x40(%rbp),%rdi
lea    0xeac(%rip),%rsi
mov    $0x29,%edx
call   1040 <memcpy@plt>
lea    -0x80(%rbp),%rdi
lea    0xec7(%rip),%rsi
mov    $0x3d,%edx
call   1040 <memcpy@plt>
lea    -0x80(%rbp),%rdi
lea    -0x40(%rbp),%rsi
mov    $0x4e,%edx
mov    $0x1e,%ecx
call   1050 <memccpy@plt>
lea    -0x40(%rbp),%rsi
lea    0xed8(%rip),%rdi
call   1030 <printf@plt>
lea    -0x80(%rbp),%rsi
lea    0xec8(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x70,%rsp
movups 0xee9(%rip),%xmm0
movups %xmm0,0x19(%rsp)
movaps 0xed4(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movaps 0xeb8(%rip),%xmm0
movaps %xmm0,(%rsp)
movups 0xf0a(%rip),%xmm0
movups %xmm0,0x5d(%rsp)
movaps 0xef1(%rip),%xmm0
movaps %xmm0,0x50(%rsp)
movaps 0xed5(%rip),%xmm0
movaps %xmm0,0x40(%rsp)
movaps 0xeb9(%rip),%xmm0
movaps %xmm0,0x30(%rsp)
lea    0x30(%rsp),%r14
mov    %rsp,%r15
mov    %r14,%rdi
mov    %r15,%rsi
mov    $0x4e,%edx
mov    $0x1e,%ecx
call   1040 <memccpy@plt>
lea    0xecd(%rip),%rbx
mov    %rbx,%rdi
mov    %r15,%rsi
call   1030 <printf@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x70,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@__const.main.str = [41 x i8] c"Copy no more than N bytes of SRC to DEST\00"
@__const.main.str2 = [61 x i8] c"Return the position in DEST one byte past where C was copied\00"
@.str = [4 x i8] c"%s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [41 x i8]
%7 = alloca [61 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = bitcast [41 x i8]* %6 to i8*
%9 = bitcast [61 x i8]* %7 to i8*
%10 = getelementptr inbounds [61 x i8], [61 x i8]* %7, i64 0, i64 0
%11 = getelementptr inbounds [41 x i8], [41 x i8]* %6, i64 0, i64 0
%12 = call i32 @memccpy(i8* %10, i8* %11, i8 signext 78, i32 30)
%13 = getelementptr inbounds [41 x i8], [41 x i8]* %6, i64 0, i64 0
%14 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %13)
%15 = getelementptr inbounds [61 x i8], [61 x i8]* %7, i64 0, i64 0
%16 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %15)
ret i32 0
}

LLVM IR (-O2):
@__const.main.str = [41 x i8] c"Copy no more than N bytes of SRC to DEST\00"
@__const.main.str2 = [61 x i8] c"Return the position in DEST one byte past where C was copied\00"
@.str = [4 x i8] c"%s\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [41 x i8]
%4 = alloca [61 x i8]
%5 = getelementptr inbounds [41 x i8], [41 x i8]* %3, i64 0, i64 0
%6 = getelementptr inbounds [61 x i8], [61 x i8]* %4, i64 0, i64 0
%7 = call i32 @memccpy(i8* %6, i8* %5, i8 signext 78, i32 30)
%8 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %5)
%9 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %6)
ret i32 0
}