#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*/ strcpy(char *, char *);
void foo() {
  int i, j;
  int num_outer_loops = 10000;
  int num_inner_loops = 1000;
  char dest[1200];
  char *src = "a";
  for (i = 0; i < num_outer_loops; i++) {
    for (j = 0; j < num_inner_loops; j++) {
      strcpy(dest, src);
    }
  }
}


x86 assembly (clang, -O0):
<foo>:
push   %rbp
mov    %rsp,%rbp
sub    $0x4d0,%rsp
movl   $0x2710,-0xc(%rbp)
movl   $0x3e8,-0x10(%rbp)
lea    0xed0(%rip),%rax
mov    %rax,-0x4c8(%rbp)
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    1191 <foo+0x81>
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    117e <foo+0x6e>
lea    -0x4c0(%rbp),%rdi
mov    -0x4c8(%rbp),%rsi
call   1030 <strcpy@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1151 <foo+0x41>
jmp    1183 <foo+0x73>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    113e <foo+0x2e>
add    $0x4d0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<foo>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x4b8,%rsp
xor    %r15d,%r15d
lea    0xed9(%rip),%r14
mov    %rsp,%rbx
nopw   0x0(%rax,%rax,1)
mov    $0x3e8,%ebp
cs nopw 0x0(%rax,%rax,1)
nop
mov    %rbx,%rdi
mov    %r14,%rsi
call   1030 <strcpy@plt>
add    $0xffffffff,%ebp
jne    1140 <foo+0x30>
add    $0x1,%r15d
cmp    $0x2710,%r15d
jne    1130 <foo+0x20>
add    $0x4b8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c"a\00"
define void @foo() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca [1200 x i8]
%6 = alloca i8*
store i32 10000, i32* %3
store i32 1000, i32* %4
store i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0), i8** %6
store i32 0, i32* %1
br label %7
7: ; preds = %24, %0
%8 = load i32, i32* %1
%9 = load i32, i32* %3
%10 = icmp slt i32 %8, %9
br i1 %10, label %11, label %27
11: ; preds = %7
store i32 0, i32* %2
br label %12
12: ; preds = %20, %11
%13 = load i32, i32* %2
%14 = load i32, i32* %4
%15 = icmp slt i32 %13, %14
br i1 %15, label %16, label %23
16: ; preds = %12
%17 = getelementptr inbounds [1200 x i8], [1200 x i8]* %5, i64 0, i64 0
%18 = load i8*, i8** %6
%19 = call i32 @strcpy(i8* %17, i8* %18)
br label %20
20: ; preds = %16
%21 = load i32, i32* %2
%22 = add nsw i32 %21, 1
store i32 %22, i32* %2
br label %12
23: ; preds = %12
br label %24
24: ; preds = %23
%25 = load i32, i32* %1
%26 = add nsw i32 %25, 1
store i32 %26, i32* %1
br label %7
27: ; preds = %7
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c"a\00"
define void @foo() {
%1 = alloca [1200 x i8]
%2 = getelementptr inbounds [1200 x i8], [1200 x i8]* %1, i64 0, i64 0
br label %3
3: ; preds = %0, %10
%4 = phi i32 [ 0, %0 ], [ %11, %10 ]
br label %5
5: ; preds = %3, %5
%6 = phi i32 [ 0, %3 ], [ %8, %5 ]
%7 = call i32 @strcpy(i8* %2, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%8 = add nuw nsw i32 %6, 1
%9 = icmp eq i32 %8, 1000
br i1 %9, label %10, label %5
10: ; preds = %5
%11 = add nuw nsw i32 %4, 1
%12 = icmp eq i32 %11, 10000
br i1 %12, label %13, label %3
13: ; preds = %10
ret void
}