#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*/ memset(char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ strncpy(char *, char *, int);
void TestPointers() {
  char buf[257];
  memset(buf, 0, sizeof(char) * 257);
  char *p = buf;
  strncpy(
      buf,
      "AAA This is a test string that is long but does not fill the buffer.",
      256);
  *p = 'B';
  const char const *p2 = buf + 1;
  const char *p3 = buf + 1;
  char const *p4 = buf + 1;
  p2++;
  p3++;
  p4++;
  int foo = 0;
}


x86 assembly (clang, -O0):
<TestPointers>:
push   %rbp
mov    %rsp,%rbp
sub    $0x140,%rsp
lea    -0x110(%rbp),%rdi
xor    %esi,%esi
mov    $0x101,%edx
call   1040 <memset@plt>
lea    -0x110(%rbp),%rax
mov    %rax,-0x118(%rbp)
lea    -0x110(%rbp),%rdi
lea    0xea6(%rip),%rsi
mov    $0x100,%edx
call   1030 <strncpy@plt>
mov    -0x118(%rbp),%rax
movb   $0x42,(%rax)
lea    -0x110(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x120(%rbp)
lea    -0x110(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x128(%rbp)
lea    -0x110(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x130(%rbp)
mov    -0x120(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x120(%rbp)
mov    -0x128(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x128(%rbp)
mov    -0x130(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x130(%rbp)
movl   $0x0,-0x134(%rbp)
add    $0x140,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<TestPointers>:
push   %rbx
sub    $0x110,%rsp
mov    %rsp,%rbx
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x101,%edx
call   1040 <memset@plt>
lea    0xebf(%rip),%rsi
mov    %rbx,%rdi
mov    $0x100,%edx
call   1030 <strncpy@plt>
add    $0x110,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [69 x i8] c"AAA This is a test string that is long but does not fill the buffer.\00"
define void @TestPointers() {
%1 = alloca [257 x i8]
%2 = alloca i8*
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
%7 = getelementptr inbounds [257 x i8], [257 x i8]* %1, i64 0, i64 0
%8 = call i32 @memset(i8* %7, i32 0, i32 257)
%9 = getelementptr inbounds [257 x i8], [257 x i8]* %1, i64 0, i64 0
store i8* %9, i8** %2
%10 = getelementptr inbounds [257 x i8], [257 x i8]* %1, i64 0, i64 0
%11 = call i32 @strncpy(i8* %10, i8* getelementptr inbounds ([69 x i8], [69 x i8]* @.str, i64 0, i64 0), i32 256)
%12 = load i8*, i8** %2
store i8 66, i8* %12
%13 = getelementptr inbounds [257 x i8], [257 x i8]* %1, i64 0, i64 0
%14 = getelementptr inbounds i8, i8* %13, i64 1
store i8* %14, i8** %3
%15 = getelementptr inbounds [257 x i8], [257 x i8]* %1, i64 0, i64 0
%16 = getelementptr inbounds i8, i8* %15, i64 1
store i8* %16, i8** %4
%17 = getelementptr inbounds [257 x i8], [257 x i8]* %1, i64 0, i64 0
%18 = getelementptr inbounds i8, i8* %17, i64 1
store i8* %18, i8** %5
%19 = load i8*, i8** %3
%20 = getelementptr inbounds i8, i8* %19, i32 1
store i8* %20, i8** %3
%21 = load i8*, i8** %4
%22 = getelementptr inbounds i8, i8* %21, i32 1
store i8* %22, i8** %4
%23 = load i8*, i8** %5
%24 = getelementptr inbounds i8, i8* %23, i32 1
store i8* %24, i8** %5
store i32 0, i32* %6
ret void
}

LLVM IR (-O2):
@.str = [69 x i8] c"AAA This is a test string that is long but does not fill the buffer.\00"
define void @TestPointers() {
%1 = alloca [257 x i8]
%2 = getelementptr inbounds [257 x i8], [257 x i8]* %1, i64 0, i64 0
%3 = call i32 @memset(i8* %2, i32 0, i32 257)
%4 = call i32 @strncpy(i8* %2, i8* getelementptr inbounds ([69 x i8], [69 x i8]* @.str, i64 0, i64 0), i32 256)
ret void
}