#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*/ bar(char *);
int foo2() {
  char c[100000] = {};
  unsigned short nchar;
  for (nchar = 0; nchar != 1000; --nchar) {
    c[nchar] = 'A';
  }
  bar(c);
  return 0;
}


x86 assembly (clang, -O0):
<foo2>:
push   %rbp
mov    %rsp,%rbp
sub    $0x186b0,%rsp
lea    -0x186a0(%rbp),%rdi
xor    %esi,%esi
mov    $0x186a0,%edx
call   1040 <memset@plt>
movw   $0x0,-0x186a2(%rbp)
movzwl -0x186a2(%rbp),%eax
cmp    $0x3e8,%eax
je     117f <foo2+0x5f>
movzwl -0x186a2(%rbp),%eax
movb   $0x41,-0x186a0(%rbp,%rax,1)
41
mov    -0x186a2(%rbp),%ax
add    $0xffff,%ax
mov    %ax,-0x186a2(%rbp)
jmp    1147 <foo2+0x27>
lea    -0x186a0(%rbp),%rdi
call   1030 <bar@plt>
xor    %eax,%eax
add    $0x186b0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<foo2>:
push   %rbx
sub    $0x186a0,%rsp
mov    %rsp,%rdi
xor    %ebx,%ebx
mov    $0x186a0,%edx
xor    %esi,%esi
call   1040 <memset@plt>
nopl   0x0(%rax)
movzwl %bx,%eax
movb   $0x41,(%rsp,%rax,1)
movb   $0x41,0xffff(%rsp,%rbx,1)
41
movl   $0x41414141,0xfffb(%rsp,%rbx,1)
41 41 41 41
add    $0xfffffffffffffffa,%rbx
movzwl %bx,%eax
cmp    $0x3e8,%eax
jne    1140 <foo2+0x20>
mov    %rsp,%rdi
call   1030 <bar@plt>
xor    %eax,%eax
add    $0x186a0,%rsp
pop    %rbx
ret

LLVM IR (-O0):
define i32 @foo2() {
%1 = alloca [100000 x i8]
%2 = alloca i16
%3 = bitcast [100000 x i8]* %1 to i8*
store i16 0, i16* %2
br label %4
4: ; preds = %12, %0
%5 = load i16, i16* %2
%6 = zext i16 %5 to i32
%7 = icmp ne i32 %6, 1000
br i1 %7, label %8, label %15
8: ; preds = %4
%9 = load i16, i16* %2
%10 = zext i16 %9 to i64
%11 = getelementptr inbounds [100000 x i8], [100000 x i8]* %1, i64 0, i64 %10
store i8 65, i8* %11
br label %12
12: ; preds = %8
%13 = load i16, i16* %2
%14 = add i16 %13, -1
store i16 %14, i16* %2
br label %4
15: ; preds = %4
%16 = getelementptr inbounds [100000 x i8], [100000 x i8]* %1, i64 0, i64 0
%17 = call i32 @bar(i8* %16)
ret i32 0
}

LLVM IR (-O2):
define i32 @foo2() {
%1 = alloca [100000 x i8]
%2 = getelementptr inbounds [100000 x i8], [100000 x i8]* %1, i64 0, i64 0
br label %3
3: ; preds = %3, %0
%4 = phi i16 [ 0, %0 ], [ %22, %3 ]
%5 = zext i16 %4 to i64
%6 = getelementptr inbounds [100000 x i8], [100000 x i8]* %1, i64 0, i64 %5
store i8 65, i8* %6
%7 = add i16 %4, -1
%8 = zext i16 %7 to i64
%9 = getelementptr inbounds [100000 x i8], [100000 x i8]* %1, i64 0, i64 %8
store i8 65, i8* %9
%10 = add i16 %4, -2
%11 = zext i16 %10 to i64
%12 = getelementptr inbounds [100000 x i8], [100000 x i8]* %1, i64 0, i64 %11
store i8 65, i8* %12
%13 = add i16 %4, -3
%14 = zext i16 %13 to i64
%15 = getelementptr inbounds [100000 x i8], [100000 x i8]* %1, i64 0, i64 %14
store i8 65, i8* %15
%16 = add i16 %4, -4
%17 = zext i16 %16 to i64
%18 = getelementptr inbounds [100000 x i8], [100000 x i8]* %1, i64 0, i64 %17
store i8 65, i8* %18
%19 = add i16 %4, -5
%20 = zext i16 %19 to i64
%21 = getelementptr inbounds [100000 x i8], [100000 x i8]* %1, i64 0, i64 %20
store i8 65, i8* %21
%22 = add i16 %4, -6
%23 = icmp eq i16 %22, 1000
br i1 %23, label %24, label %3
24: ; preds = %3
%25 = call i32 @bar(i8* %2)
ret i32 0
}