#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 atoi(char *);
int /*<<< orphan*/ free(float *);
int heavy_calcs(int, float *, float *);
scalar_t__ malloc(int);
int main(int argc, char *argv[]) {
  int n = (argc > 1) ? atoi(argv[1]) : 1000;
  float *r1 = (float *)malloc(n * sizeof(float));
  float *r2 = (float *)malloc(n * sizeof(float));
  int rc = heavy_calcs(n, r1, r2);
  free(r1);
  free(r2);
  return rc;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x1,-0x8(%rbp)
jle    1175 <main+0x35>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1060 <atoi@plt>
mov    %eax,-0x30(%rbp)
jmp    1182 <main+0x42>
mov    $0x3e8,%eax
mov    %eax,-0x30(%rbp)
jmp    1182 <main+0x42>
mov    -0x30(%rbp),%eax
mov    %eax,-0x14(%rbp)
movslq -0x14(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,-0x20(%rbp)
movslq -0x14(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,-0x28(%rbp)
mov    -0x14(%rbp),%edi
mov    -0x20(%rbp),%rsi
mov    -0x28(%rbp),%rdx
call   1040 <heavy_calcs@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
mov    -0x28(%rbp),%rdi
call   1030 <free@plt>
mov    -0x2c(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
mov    $0x3e8,%r14d
cmp    $0x2,%edi
jl     115b <main+0x1b>
mov    0x8(%rsi),%rdi
call   1060 <atoi@plt>
mov    %eax,%r14d
lea    0x0(,%r14,4),%ebp
mov    %ebp,%edi
call   1050 <malloc@plt>
mov    %rax,%rbx
mov    %ebp,%edi
call   1050 <malloc@plt>
mov    %rax,%rbp
mov    %r14d,%edi
mov    %rbx,%rsi
mov    %rax,%rdx
call   1040 <heavy_calcs@plt>
mov    %eax,%r14d
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %rbp,%rdi
call   1030 <free@plt>
mov    %r14d,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca float*
%8 = alloca float*
%9 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = load i32, i32* %4
%11 = icmp sgt i32 %10, 1
br i1 %11, label %12, label %17
12: ; preds = %2
%13 = load i8**, i8*** %5
%14 = getelementptr inbounds i8*, i8** %13, i64 1
%15 = load i8*, i8** %14
%16 = call i32 @atoi(i8* %15)
br label %18
17: ; preds = %2
br label %18
18: ; preds = %17, %12
%19 = phi i32 [ %16, %12 ], [ 1000, %17 ]
store i32 %19, i32* %6
%20 = load i32, i32* %6
%21 = sext i32 %20 to i64
%22 = mul i64 %21, 4
%23 = trunc i64 %22 to i32
%24 = call i64 @malloc(i32 %23)
%25 = inttoptr i64 %24 to float*
store float* %25, float** %7
%26 = load i32, i32* %6
%27 = sext i32 %26 to i64
%28 = mul i64 %27, 4
%29 = trunc i64 %28 to i32
%30 = call i64 @malloc(i32 %29)
%31 = inttoptr i64 %30 to float*
store float* %31, float** %8
%32 = load i32, i32* %6
%33 = load float*, float** %7
%34 = load float*, float** %8
%35 = call i32 @heavy_calcs(i32 %32, float* %33, float* %34)
store i32 %35, i32* %9
%36 = load float*, float** %7
%37 = call i32 @free(float* %36)
%38 = load float*, float** %8
%39 = call i32 @free(float* %38)
%40 = load i32, i32* %9
ret i32 %40
}

LLVM IR (-O2):
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp sgt i32 %0, 1
br i1 %3, label %4, label %8
4: ; preds = %2
%5 = getelementptr inbounds i8*, i8** %1, i64 1
%6 = load i8*, i8** %5
%7 = tail call i32 @atoi(i8* %6)
br label %8
8: ; preds = %2, %4
%9 = phi i32 [ %7, %4 ], [ 1000, %2 ]
%10 = shl i32 %9, 2
%11 = tail call i64 @malloc(i32 %10)
%12 = inttoptr i64 %11 to float*
%13 = tail call i64 @malloc(i32 %10)
%14 = inttoptr i64 %13 to float*
%15 = tail call i32 @heavy_calcs(i32 %9, float* %12, float* %14)
%16 = tail call i32 @free(float* %12)
%17 = tail call i32 @free(float* %14)
ret i32 %15
}