#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*/ printf(char *, char *);
void printStr(char *string) {
  char tmp[4096 + 1];
  int i;
  for (i = 0; i < 4096 + 1; i++) {
    if (string[i] == '\0' && i != 4096 + 1 - 1) {
      tmp[i] = '|';
    } else {
      tmp[i] = string[i];
    }
  }
  printf("string: %s\n", tmp);
}


x86 assembly (clang, -O0):
<printStr>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1020,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0x1014(%rbp)
cmpl   $0x1001,-0x1014(%rbp)
jge    11aa <printStr+0x9a>
mov    -0x8(%rbp),%rax
movslq -0x1014(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x0,%eax
jne    1175 <printStr+0x65>
cmpl   $0x1000,-0x1014(%rbp)
je     1175 <printStr+0x65>
movslq -0x1014(%rbp),%rax
movb   $0x7c,-0x1010(%rbp,%rax,1)
7c
jmp    1191 <printStr+0x81>
mov    -0x8(%rbp),%rax
movslq -0x1014(%rbp),%rcx
mov    (%rax,%rcx,1),%cl
movslq -0x1014(%rbp),%rax
mov    %cl,-0x1010(%rbp,%rax,1)
jmp    1196 <printStr+0x86>
mov    -0x1014(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1014(%rbp)
jmp    1129 <printStr+0x19>
lea    -0x1010(%rbp),%rsi
lea    0xe48(%rip),%rdi
call   1030 <printf@plt>
add    $0x1020,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printStr>:
sub    $0x1008,%rsp
movdqa 0xee0(%rip),%xmm10
movdqa 0xee7(%rip),%xmm14
movdqa 0xeee(%rip),%xmm15
movdqa 0xef5(%rip),%xmm11
movdqa 0xefc(%rip),%xmm9
movdqa 0xf03(%rip),%xmm12
movdqa 0xf0a(%rip),%xmm13
movdqa 0xf12(%rip),%xmm7
xor    %eax,%eax
movdqa 0xf28(%rip),%xmm0
nopl   0x0(%rax,%rax,1)
movdqa %xmm7,%xmm2
movdqa 0xf04(%rip),%xmm5
pcmpeqd %xmm5,%xmm2
pshufd $0xb1,%xmm2,%xmm1
pand   %xmm2,%xmm1
pandn  %xmm0,%xmm1
movdqa %xmm13,%xmm2
pcmpeqd %xmm5,%xmm2
pshufd $0xb1,%xmm2,%xmm8
pand   %xmm2,%xmm8
pandn  %xmm0,%xmm8
packuswb %xmm8,%xmm1
packuswb %xmm1,%xmm1
movdqa %xmm12,%xmm2
pcmpeqd %xmm5,%xmm2
pshufd $0xb1,%xmm2,%xmm3
pand   %xmm2,%xmm3
pandn  %xmm0,%xmm3
movdqa %xmm9,%xmm2
pcmpeqd %xmm5,%xmm2
pshufd $0xb1,%xmm2,%xmm4
pand   %xmm2,%xmm4
pandn  %xmm0,%xmm4
packuswb %xmm4,%xmm3
packuswb %xmm3,%xmm2
packuswb %xmm2,%xmm1
movdqa %xmm11,%xmm3
pcmpeqd %xmm5,%xmm3
pshufd $0xb1,%xmm3,%xmm2
pand   %xmm3,%xmm2
pandn  %xmm0,%xmm2
movdqa %xmm15,%xmm3
pcmpeqd %xmm5,%xmm3
pshufd $0xb1,%xmm3,%xmm4
pand   %xmm3,%xmm4
pandn  %xmm0,%xmm4
packuswb %xmm4,%xmm2
movdqa %xmm14,%xmm3
pcmpeqd %xmm5,%xmm3
pshufd $0xb1,%xmm3,%xmm4
pand   %xmm3,%xmm4
movdqa %xmm10,%xmm3
pcmpeqd %xmm5,%xmm3
pshufd $0xb1,%xmm3,%xmm5
pand   %xmm3,%xmm5
movdqu (%rdi,%rax,1),%xmm3
pandn  %xmm0,%xmm4
pandn  %xmm0,%xmm5
packuswb %xmm5,%xmm4
movdqa %xmm3,%xmm5
pxor   %xmm6,%xmm6
pcmpeqb %xmm6,%xmm5
pxor   %xmm6,%xmm6
packuswb %xmm2,%xmm2
packuswb %xmm4,%xmm4
packuswb %xmm4,%xmm2
shufps $0xcc,%xmm2,%xmm1
andps  %xmm5,%xmm1
movaps %xmm1,%xmm2
andnps %xmm3,%xmm2
movaps 0xe23(%rip),%xmm8
andps  %xmm8,%xmm1
orps   %xmm2,%xmm1
movaps %xmm1,(%rsp,%rax,1)
movdqa %xmm7,%xmm2
movdqa 0xe1c(%rip),%xmm5
pcmpeqd %xmm5,%xmm2
pshufd $0xb1,%xmm2,%xmm1
pand   %xmm2,%xmm1
pandn  %xmm0,%xmm1
movdqa %xmm13,%xmm2
pcmpeqd %xmm5,%xmm2
pshufd $0xb1,%xmm2,%xmm3
pand   %xmm2,%xmm3
pandn  %xmm0,%xmm3
packuswb %xmm3,%xmm1
packuswb %xmm1,%xmm1
movdqa %xmm12,%xmm2
pcmpeqd %xmm5,%xmm2
pshufd $0xb1,%xmm2,%xmm3
pand   %xmm2,%xmm3
pandn  %xmm0,%xmm3
movdqa %xmm9,%xmm2
pcmpeqd %xmm5,%xmm2
pshufd $0xb1,%xmm2,%xmm4
pand   %xmm2,%xmm4
pandn  %xmm0,%xmm4
packuswb %xmm4,%xmm3
packuswb %xmm3,%xmm2
packuswb %xmm2,%xmm1
movdqa %xmm11,%xmm3
pcmpeqd %xmm5,%xmm3
pshufd $0xb1,%xmm3,%xmm2
pand   %xmm3,%xmm2
pandn  %xmm0,%xmm2
movdqa %xmm15,%xmm3
pcmpeqd %xmm5,%xmm3
pshufd $0xb1,%xmm3,%xmm4
pand   %xmm3,%xmm4
pandn  %xmm0,%xmm4
packuswb %xmm4,%xmm2
movdqa %xmm14,%xmm3
pcmpeqd %xmm5,%xmm3
pshufd $0xb1,%xmm3,%xmm4
pand   %xmm3,%xmm4
movdqa %xmm10,%xmm3
pcmpeqd %xmm5,%xmm3
pshufd $0xb1,%xmm3,%xmm5
pand   %xmm3,%xmm5
pandn  %xmm0,%xmm4
pandn  %xmm0,%xmm5
packuswb %xmm5,%xmm4
packuswb %xmm2,%xmm2
packuswb %xmm4,%xmm3
packuswb %xmm3,%xmm2
movdqu 0x10(%rdi,%rax,1),%xmm3
shufps $0xcc,%xmm2,%xmm1
movdqa %xmm3,%xmm2
pcmpeqb %xmm6,%xmm2
andps  %xmm2,%xmm1
movaps %xmm1,%xmm2
andnps %xmm3,%xmm2
andps  %xmm8,%xmm1
orps   %xmm2,%xmm1
movaps %xmm1,0x10(%rsp,%rax,1)
add    $0x20,%rax
movdqa 0xd26(%rip),%xmm1
paddq  %xmm1,%xmm7
paddq  %xmm1,%xmm13
paddq  %xmm1,%xmm12
paddq  %xmm1,%xmm9
paddq  %xmm1,%xmm11
paddq  %xmm1,%xmm15
paddq  %xmm1,%xmm14
paddq  %xmm1,%xmm10
cmp    $0x1000,%rax
jne    1170 <printStr+0x60>
mov    0x1000(%rdi),%al
mov    %al,0x1000(%rsp)
lea    0xcef(%rip),%rdi
mov    %rsp,%rsi
call   1030 <printf@plt>
add    $0x1008,%rsp
ret

LLVM IR (-O0):
@.str = [12 x i8] c"string: %s\0A\00"
define void @printStr(i8* %0) {
%2 = alloca i8*
%3 = alloca [4097 x i8]
%4 = alloca i32
store i8* %0, i8** %2
store i32 0, i32* %4
br label %5
5: ; preds = %33, %1
%6 = load i32, i32* %4
%7 = icmp slt i32 %6, 4097
br i1 %7, label %8, label %36
8: ; preds = %5
%9 = load i8*, i8** %2
%10 = load i32, i32* %4
%11 = sext i32 %10 to i64
%12 = getelementptr inbounds i8, i8* %9, i64 %11
%13 = load i8, i8* %12
%14 = sext i8 %13 to i32
%15 = icmp eq i32 %14, 0
br i1 %15, label %16, label %23
16: ; preds = %8
%17 = load i32, i32* %4
%18 = icmp ne i32 %17, 4096
br i1 %18, label %19, label %23
19: ; preds = %16
%20 = load i32, i32* %4
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds [4097 x i8], [4097 x i8]* %3, i64 0, i64 %21
store i8 124, i8* %22
br label %32
23: ; preds = %16, %8
%24 = load i8*, i8** %2
%25 = load i32, i32* %4
%26 = sext i32 %25 to i64
%27 = getelementptr inbounds i8, i8* %24, i64 %26
%28 = load i8, i8* %27
%29 = load i32, i32* %4
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds [4097 x i8], [4097 x i8]* %3, i64 0, i64 %30
store i8 %28, i8* %31
br label %32
32: ; preds = %23, %19
br label %33
33: ; preds = %32
%34 = load i32, i32* %4
%35 = add nsw i32 %34, 1
store i32 %35, i32* %4
br label %5
36: ; preds = %5
%37 = getelementptr inbounds [4097 x i8], [4097 x i8]* %3, i64 0, i64 0
%38 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* %37)
ret void
}

LLVM IR (-O2):
@.str = [12 x i8] c"string: %s\0A\00"
define void @printStr(i8* nocapture %0) {
%2 = alloca [4097 x i8]
%3 = getelementptr inbounds [4097 x i8], [4097 x i8]* %2, i64 0, i64 0
br label %4
4: ; preds = %4, %1
%5 = phi i64 [ 0, %1 ], [ %26, %4 ]
%6 = phi <16 x i64> [ <i64 0, i64 1, i64 2, i64 3, i64 4, i64 5, i64 6, i64 7, i64 8, i64 9, i64 10, i64 11, i64 12, i64 13, i64 14, i64 15>, %1 ], [ %27, %4 ]
%7 = getelementptr inbounds i8, i8* %0, i64 %5
%8 = bitcast i8* %7 to <16 x i8>*
%9 = load <16 x i8>, <16 x i8>* %8
%10 = icmp eq <16 x i8> %9, zeroinitializer
%11 = icmp ne <16 x i64> %6, <i64 4096, i64 4096, i64 4096, i64 4096, i64 4096, i64 4096, i64 4096, i64 4096, i64 4096, i64 4096, i64 4096, i64 4096, i64 4096, i64 4096, i64 4096, i64 4096>
%12 = select <16 x i1> %10, <16 x i1> %11, <16 x i1> zeroinitializer
%13 = select <16 x i1> %12, <16 x i8> <i8 124, i8 124, i8 124, i8 124, i8 124, i8 124, i8 124, i8 124, i8 124, i8 124, i8 124, i8 124, i8 124, i8 124, i8 124, i8 124>, <16 x i8> %9
%14 = getelementptr inbounds [4097 x i8], [4097 x i8]* %2, i64 0, i64 %5
%15 = bitcast i8* %14 to <16 x i8>*
store <16 x i8> %13, <16 x i8>* %15
%16 = or i64 %5, 16
%17 = getelementptr inbounds i8, i8* %0, i64 %16
%18 = bitcast i8* %17 to <16 x i8>*
%19 = load <16 x i8>, <16 x i8>* %18
%20 = icmp eq <16 x i8> %19, zeroinitializer
%21 = icmp ne <16 x i64> %6, <i64 4080, i64 4080, i64 4080, i64 4080, i64 4080, i64 4080, i64 4080, i64 4080, i64 4080, i64 4080, i64 4080, i64 4080, i64 4080, i64 4080, i64 4080, i64 4080>
%22 = select <16 x i1> %20, <16 x i1> %21, <16 x i1> zeroinitializer
%23 = select <16 x i1> %22, <16 x i8> <i8 124, i8 124, i8 124, i8 124, i8 124, i8 124, i8 124, i8 124, i8 124, i8 124, i8 124, i8 124, i8 124, i8 124, i8 124, i8 124>, <16 x i8> %19
%24 = getelementptr inbounds [4097 x i8], [4097 x i8]* %2, i64 0, i64 %16
%25 = bitcast i8* %24 to <16 x i8>*
store <16 x i8> %23, <16 x i8>* %25
%26 = add nuw nsw i64 %5, 32
%27 = add <16 x i64> %6, <i64 32, i64 32, i64 32, i64 32, i64 32, i64 32, i64 32, i64 32, i64 32, i64 32, i64 32, i64 32, i64 32, i64 32, i64 32, i64 32>
%28 = icmp eq i64 %26, 4096
br i1 %28, label %29, label %4
29: ; preds = %4
%30 = getelementptr inbounds i8, i8* %0, i64 4096
%31 = load i8, i8* %30
%32 = getelementptr inbounds [4097 x i8], [4097 x i8]* %2, i64 0, i64 4096
store i8 %31, i8* %32
%33 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8* %3)
ret void
}