#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 *, int);
int strlen(char *);
void main() {
  char a[1000];
  int i;
  for (i = 0; i < 1000; i++) {
    a[i] = -1 - i;
  }
  printf("%d\n", strlen(a));
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x400,%rsp
movl   $0x0,-0x3f4(%rbp)
cmpl   $0x3e8,-0x3f4(%rbp)
jge    1174 <main+0x54>
mov    $0xffffffff,%eax
sub    -0x3f4(%rbp),%eax
mov    %al,%cl
movslq -0x3f4(%rbp),%rax
mov    %cl,-0x3f0(%rbp,%rax,1)
mov    -0x3f4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x3f4(%rbp)
jmp    1135 <main+0x15>
lea    -0x3f0(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%esi
lea    0xe77(%rip),%rdi
call   1040 <printf@plt>
add    $0x400,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x3e8,%rsp
movdqa 0xed1(%rip),%xmm0
mov    $0x10,%eax
pcmpeqd %xmm1,%xmm1
movdqa 0xed0(%rip),%xmm2
movdqa 0xed8(%rip),%xmm3
nopl   0x0(%rax,%rax,1)
movdqa %xmm0,%xmm4
pxor   %xmm1,%xmm4
movdqa %xmm4,-0x10(%rsp,%rax,1)
movdqa %xmm2,%xmm4
psubb  %xmm0,%xmm4
movdqa %xmm4,(%rsp,%rax,1)
paddb  %xmm3,%xmm0
add    $0x20,%rax
cmp    $0x3f0,%rax
jne    1150 <main+0x30>
movabs $0x18191a1b1c1d1e1f,%rax
1a 19 18
mov    %rax,0x3e0(%rsp)
mov    %rsp,%rdi
call   1030 <strlen@plt>
lea    0xe94(%rip),%rdi
mov    %eax,%esi
call   1040 <printf@plt>
add    $0x3e8,%rsp
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%d\0A\00"
define void @main() {
%1 = alloca [1000 x i8]
%2 = alloca i32
store i32 0, i32* %2
br label %3
3: ; preds = %13, %0
%4 = load i32, i32* %2
%5 = icmp slt i32 %4, 1000
br i1 %5, label %6, label %16
6: ; preds = %3
%7 = load i32, i32* %2
%8 = sub nsw i32 -1, %7
%9 = trunc i32 %8 to i8
%10 = load i32, i32* %2
%11 = sext i32 %10 to i64
%12 = getelementptr inbounds [1000 x i8], [1000 x i8]* %1, i64 0, i64 %11
store i8 %9, i8* %12
br label %13
13: ; preds = %6
%14 = load i32, i32* %2
%15 = add nsw i32 %14, 1
store i32 %15, i32* %2
br label %3
16: ; preds = %3
%17 = getelementptr inbounds [1000 x i8], [1000 x i8]* %1, i64 0, i64 0
%18 = call i32 @strlen(i8* %17)
%19 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %18)
ret void
}

LLVM IR (-O2):
@.str = [4 x i8] c"%d\0A\00"
define void @main() {
%1 = alloca [1000 x i8]
%2 = getelementptr inbounds [1000 x i8], [1000 x i8]* %1, i64 0, i64 0
br label %3
3: ; preds = %3, %0
%4 = phi i64 [ 0, %0 ], [ %13, %3 ]
%5 = phi <16 x i8> [ <i8 0, i8 1, i8 2, i8 3, i8 4, i8 5, i8 6, i8 7, i8 8, i8 9, i8 10, i8 11, i8 12, i8 13, i8 14, i8 15>, %0 ], [ %14, %3 ]
%6 = xor <16 x i8> %5, <i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1, i8 -1>
%7 = getelementptr inbounds [1000 x i8], [1000 x i8]* %1, i64 0, i64 %4
%8 = bitcast i8* %7 to <16 x i8>*
store <16 x i8> %6, <16 x i8>* %8
%9 = or i64 %4, 16
%10 = sub <16 x i8> <i8 -17, i8 -17, i8 -17, i8 -17, i8 -17, i8 -17, i8 -17, i8 -17, i8 -17, i8 -17, i8 -17, i8 -17, i8 -17, i8 -17, i8 -17, i8 -17>, %5
%11 = getelementptr inbounds [1000 x i8], [1000 x i8]* %1, i64 0, i64 %9
%12 = bitcast i8* %11 to <16 x i8>*
store <16 x i8> %10, <16 x i8>* %12
%13 = add nuw nsw i64 %4, 32
%14 = add <16 x i8> %5, <i8 32, i8 32, i8 32, i8 32, i8 32, i8 32, i8 32, i8 32, i8 32, i8 32, i8 32, i8 32, i8 32, i8 32, i8 32, i8 32>
%15 = icmp eq i64 %13, 992
br i1 %15, label %16, label %3
16: ; preds = %3
%17 = getelementptr inbounds [1000 x i8], [1000 x i8]* %1, i64 0, i64 992
store i8 31, i8* %17
%18 = getelementptr inbounds [1000 x i8], [1000 x i8]* %1, i64 0, i64 993
store i8 30, i8* %18
%19 = getelementptr inbounds [1000 x i8], [1000 x i8]* %1, i64 0, i64 994
store i8 29, i8* %19
%20 = getelementptr inbounds [1000 x i8], [1000 x i8]* %1, i64 0, i64 995
store i8 28, i8* %20
%21 = getelementptr inbounds [1000 x i8], [1000 x i8]* %1, i64 0, i64 996
store i8 27, i8* %21
%22 = getelementptr inbounds [1000 x i8], [1000 x i8]* %1, i64 0, i64 997
store i8 26, i8* %22
%23 = getelementptr inbounds [1000 x i8], [1000 x i8]* %1, i64 0, i64 998
store i8 25, i8* %23
%24 = getelementptr inbounds [1000 x i8], [1000 x i8]* %1, i64 0, i64 999
store i8 24, i8* %24
%25 = call i32 @strlen(i8* %2)
%26 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %25)
ret void
}