#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*/ free(void *);
scalar_t__ malloc(int);
int /*<<< orphan*/ transpose(int *, int *, int);
void prof(void) {
  int *d = (int *)malloc((sizeof(int) * 9973 * 9973));
  int *s = (int *)malloc((sizeof(int) * 9973 * 9973));
  for (int c = 0; c < 1000; c++)
    transpose(d, s, 9973);
  free((void *)d);
  free((void *)s);
}


x86 assembly (clang, -O0):
<prof>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    $0x17b699e4,%edi
call   1050 <malloc@plt>
mov    %rax,-0x8(%rbp)
mov    $0x17b699e4,%edi
call   1050 <malloc@plt>
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x3e8,-0x14(%rbp)
jge    1188 <prof+0x58>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    $0x26f5,%edx
call   1040 <transpose@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    115b <prof+0x2b>
mov    -0x8(%rbp),%rdi
call   1030 <free@plt>
mov    -0x10(%rbp),%rdi
call   1030 <free@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<prof>:
push   %rbp
push   %r14
push   %rbx
mov    $0x17b699e4,%edi
call   1050 <malloc@plt>
mov    %rax,%r14
mov    $0x17b699e4,%edi
call   1050 <malloc@plt>
mov    %rax,%rbx
mov    $0x3e8,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %r14,%rdi
mov    %rbx,%rsi
mov    $0x26f5,%edx
call   1040 <transpose@plt>
add    $0xffffffff,%ebp
jne    1160 <prof+0x30>
mov    %r14,%rdi
call   1030 <free@plt>
mov    %rbx,%rdi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1030 <free@plt>

LLVM IR (-O0):
define void @prof() {
%1 = alloca i32*
%2 = alloca i32*
%3 = alloca i32
%4 = call i64 @malloc(i32 397842916)
%5 = inttoptr i64 %4 to i32*
store i32* %5, i32** %1
%6 = call i64 @malloc(i32 397842916)
%7 = inttoptr i64 %6 to i32*
store i32* %7, i32** %2
store i32 0, i32* %3
br label %8
8: ; preds = %15, %0
%9 = load i32, i32* %3
%10 = icmp slt i32 %9, 1000
br i1 %10, label %11, label %18
11: ; preds = %8
%12 = load i32*, i32** %1
%13 = load i32*, i32** %2
%14 = call i32 @transpose(i32* %12, i32* %13, i32 9973)
br label %15
15: ; preds = %11
%16 = load i32, i32* %3
%17 = add nsw i32 %16, 1
store i32 %17, i32* %3
br label %8
18: ; preds = %8
%19 = load i32*, i32** %1
%20 = bitcast i32* %19 to i8*
%21 = call i32 @free(i8* %20)
%22 = load i32*, i32** %2
%23 = bitcast i32* %22 to i8*
%24 = call i32 @free(i8* %23)
ret void
}

LLVM IR (-O2):
define void @prof() {
%1 = tail call i64 @malloc(i32 397842916)
%2 = inttoptr i64 %1 to i32*
%3 = tail call i64 @malloc(i32 397842916)
%4 = inttoptr i64 %3 to i32*
br label %10
5: ; preds = %10
%6 = inttoptr i64 %1 to i8*
%7 = tail call i32 @free(i8* %6)
%8 = inttoptr i64 %3 to i8*
%9 = tail call i32 @free(i8* %8)
ret void
10: ; preds = %0, %10
%11 = phi i32 [ 0, %0 ], [ %13, %10 ]
%12 = tail call i32 @transpose(i32* %2, i32* %4, i32 9973)
%13 = add nuw nsw i32 %11, 1
%14 = icmp eq i32 %13, 1000
br i1 %14, label %5, label %10
}