#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 *alloc_impl(int, char *, int);
int /*<<< orphan*/ free_impl(int *, char *, int);
int /*<<< orphan*/ printf(char *, ...);
void test_alloc() {
  int i, len = 10;
  int *arr =
      alloc_impl(len * sizeof(int),
                 "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/"
                 "outputs/2022-01-22/02-19-57/repos/cheeseywhiz/cheeseywhiz/"
                 "refs/heads/master/printf/main.c",
                 46);
  for (i = 0; i < len; ++i)
    arr[i] = i;
  for (i = 0; i < len; ++i)
    printf("%d ", arr[i]);
  printf("\n");
  free_impl(arr,
            "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
            "2022-01-22/02-19-57/repos/cheeseywhiz/cheeseywhiz/refs/heads/"
            "master/printf/main.c",
            52);
}


x86 assembly (clang, -O0):
<test_alloc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0xa,-0x8(%rbp)
movslq -0x8(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%edi
lea    0xeb0(%rip),%rsi
mov    $0x2e,%edx
call   1050 <alloc_impl@plt>
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    118d <test_alloc+0x5d>
mov    -0x4(%rbp),%edx
mov    -0x10(%rbp),%rax
movslq -0x4(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    1165 <test_alloc+0x35>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11c7 <test_alloc+0x97>
mov    -0x10(%rbp),%rax
movslq -0x4(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xee0(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4(%rbp)
jmp    1194 <test_alloc+0x64>
lea    0xec8(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%rdi
lea    0xe20(%rip),%rsi
mov    $0x34,%edx
call   1030 <free_impl@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_alloc>:
push   %r15
push   %r14
push   %rbx
lea    0xed4(%rip),%r14
mov    $0x28,%edi
mov    %r14,%rsi
mov    $0x2e,%edx
call   1060 <alloc_impl@plt>
mov    %rax,%rbx
movaps 0xe98(%rip),%xmm0
movups %xmm0,(%rax)
movaps 0xe9e(%rip),%xmm0
movups %xmm0,0x10(%rax)
movabs $0x900000008,%rax
mov    %rax,0x20(%rbx)
lea    0xf27(%rip),%r15
mov    %r15,%rdi
xor    %esi,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x4(%rbx),%esi
mov    %r15,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x8(%rbx),%esi
mov    %r15,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0xc(%rbx),%esi
mov    %r15,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x10(%rbx),%esi
mov    %r15,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x14(%rbx),%esi
mov    %r15,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x18(%rbx),%esi
mov    %r15,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x1c(%rbx),%esi
mov    %r15,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x20(%rbx),%esi
mov    %r15,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x24(%rbx),%esi
mov    %r15,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x34,%edx
pop    %rbx
pop    %r14
pop    %r15
jmp    1040 <free_impl@plt>

LLVM IR (-O0):
@.str = [146 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/cheeseywhiz/cheeseywhiz/refs/heads/master/printf/main.c\00"
@.str.1 = [4 x i8] c"%d \00"
@.str.2 = [2 x i8] c"\0A\00"
define void @test_alloc() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32*
store i32 10, i32* %2
%4 = load i32, i32* %2
%5 = sext i32 %4 to i64
%6 = mul i64 %5, 4
%7 = trunc i64 %6 to i32
%8 = call i32* @alloc_impl(i32 %7, i8* getelementptr inbounds ([146 x i8], [146 x i8]* @.str, i64 0, i64 0), i32 46)
store i32* %8, i32** %3
store i32 0, i32* %1
br label %9
9: ; preds = %19, %0
%10 = load i32, i32* %1
%11 = load i32, i32* %2
%12 = icmp slt i32 %10, %11
br i1 %12, label %13, label %22
13: ; preds = %9
%14 = load i32, i32* %1
%15 = load i32*, i32** %3
%16 = load i32, i32* %1
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds i32, i32* %15, i64 %17
store i32 %14, i32* %18
br label %19
19: ; preds = %13
%20 = load i32, i32* %1
%21 = add nsw i32 %20, 1
store i32 %21, i32* %1
br label %9
22: ; preds = %9
store i32 0, i32* %1
br label %23
23: ; preds = %34, %22
%24 = load i32, i32* %1
%25 = load i32, i32* %2
%26 = icmp slt i32 %24, %25
br i1 %26, label %27, label %37
27: ; preds = %23
%28 = load i32*, i32** %3
%29 = load i32, i32* %1
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds i32, i32* %28, i64 %30
%32 = load i32, i32* %31
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %32)
br label %34
34: ; preds = %27
%35 = load i32, i32* %1
%36 = add nsw i32 %35, 1
store i32 %36, i32* %1
br label %23
37: ; preds = %23
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%39 = load i32*, i32** %3
%40 = call i32 @free_impl(i32* %39, i8* getelementptr inbounds ([146 x i8], [146 x i8]* @.str, i64 0, i64 0), i32 52)
ret void
}

LLVM IR (-O2):
@.str = [146 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/cheeseywhiz/cheeseywhiz/refs/heads/master/printf/main.c\00"
@.str.1 = [4 x i8] c"%d \00"
define void @test_alloc() {
%1 = tail call i32* @alloc_impl(i32 40, i8* getelementptr inbounds ([146 x i8], [146 x i8]* @.str, i64 0, i64 0), i32 46)
%2 = getelementptr inbounds i32, i32* %1, i64 1
%3 = getelementptr inbounds i32, i32* %1, i64 2
%4 = getelementptr inbounds i32, i32* %1, i64 3
%5 = bitcast i32* %1 to <4 x i32>*
store <4 x i32> <i32 0, i32 1, i32 2, i32 3>, <4 x i32>* %5
%6 = getelementptr inbounds i32, i32* %1, i64 4
%7 = getelementptr inbounds i32, i32* %1, i64 5
%8 = getelementptr inbounds i32, i32* %1, i64 6
%9 = getelementptr inbounds i32, i32* %1, i64 7
%10 = bitcast i32* %6 to <4 x i32>*
store <4 x i32> <i32 4, i32 5, i32 6, i32 7>, <4 x i32>* %10
%11 = getelementptr inbounds i32, i32* %1, i64 8
store i32 8, i32* %11
%12 = getelementptr inbounds i32, i32* %1, i64 9
store i32 9, i32* %12
%13 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 0)
%14 = load i32, i32* %2
%15 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %14)
%16 = load i32, i32* %3
%17 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %16)
%18 = load i32, i32* %4
%19 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %18)
%20 = load i32, i32* %6
%21 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %20)
%22 = load i32, i32* %7
%23 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %22)
%24 = load i32, i32* %8
%25 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %24)
%26 = load i32, i32* %9
%27 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %26)
%28 = load i32, i32* %11
%29 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %28)
%30 = load i32, i32* %12
%31 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %30)
%32 = tail call i32 @putchar(i32 10)
%33 = tail call i32 @free_impl(i32* %1, i8* getelementptr inbounds ([146 x i8], [146 x i8]* @.str, i64 0, i64 0), i32 52)
ret void
}