#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 *calloc(int, int);
int /*<<< orphan*/ printf(char *);
int bad() {
  int array[16];
  int *obj;
  int i;
  for (i = 0; i < 32; i++)
    array[i] = 55;
  obj = calloc(16, sizeof(int));
  for (i = 0; i < 32; i++)
    obj[i] = 77;
  printf("finished bad() function!\n");
  return 0;
}


x86 assembly (clang, -O0):
<bad>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4c(%rbp)
cmpl   $0x20,-0x4c(%rbp)
jge    1153 <bad+0x33>
movslq -0x4c(%rbp),%rax
movl   $0x37,-0x40(%rbp,%rax,4)
mov    -0x4c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4c(%rbp)
jmp    112f <bad+0xf>
mov    $0x10,%edi
mov    $0x4,%esi
call   1040 <calloc@plt>
mov    %rax,-0x48(%rbp)
movl   $0x0,-0x4c(%rbp)
cmpl   $0x20,-0x4c(%rbp)
jge    1194 <bad+0x74>
mov    -0x48(%rbp),%rax
movslq -0x4c(%rbp),%rcx
movl   $0x4d,(%rax,%rcx,4)
mov    -0x4c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4c(%rbp)
jmp    116d <bad+0x4d>
lea    0xe65(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<bad>:
push   %rax
mov    $0x10,%edi
mov    $0x4,%esi
call   1040 <calloc@plt>
movaps 0xec9(%rip),%xmm0
movups %xmm0,(%rax)
movups %xmm0,0x10(%rax)
movups %xmm0,0x20(%rax)
movups %xmm0,0x30(%rax)
movups %xmm0,0x40(%rax)
movups %xmm0,0x50(%rax)
movups %xmm0,0x60(%rax)
movups %xmm0,0x70(%rax)
lea    0xeb3(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [26 x i8] c"finished bad() function!\0A\00"
define i32 @bad() {
%1 = alloca [16 x i32]
%2 = alloca i32*
%3 = alloca i32
store i32 0, i32* %3
br label %4
4: ; preds = %11, %0
%5 = load i32, i32* %3
%6 = icmp slt i32 %5, 32
br i1 %6, label %7, label %14
7: ; preds = %4
%8 = load i32, i32* %3
%9 = sext i32 %8 to i64
%10 = getelementptr inbounds [16 x i32], [16 x i32]* %1, i64 0, i64 %9
store i32 55, i32* %10
br label %11
11: ; preds = %7
%12 = load i32, i32* %3
%13 = add nsw i32 %12, 1
store i32 %13, i32* %3
br label %4
14: ; preds = %4
%15 = call i32* @calloc(i32 16, i32 4)
store i32* %15, i32** %2
store i32 0, i32* %3
br label %16
16: ; preds = %24, %14
%17 = load i32, i32* %3
%18 = icmp slt i32 %17, 32
br i1 %18, label %19, label %27
19: ; preds = %16
%20 = load i32*, i32** %2
%21 = load i32, i32* %3
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds i32, i32* %20, i64 %22
store i32 77, i32* %23
br label %24
24: ; preds = %19
%25 = load i32, i32* %3
%26 = add nsw i32 %25, 1
store i32 %26, i32* %3
br label %16
27: ; preds = %16
%28 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@str = [25 x i8] c"finished bad() function!\00"
define i32 @bad() {
%1 = tail call i32* @calloc(i32 16, i32 4)
%2 = bitcast i32* %1 to <4 x i32>*
store <4 x i32> <i32 77, i32 77, i32 77, i32 77>, <4 x i32>* %2
%3 = getelementptr inbounds i32, i32* %1, i64 4
%4 = bitcast i32* %3 to <4 x i32>*
store <4 x i32> <i32 77, i32 77, i32 77, i32 77>, <4 x i32>* %4
%5 = getelementptr inbounds i32, i32* %1, i64 8
%6 = bitcast i32* %5 to <4 x i32>*
store <4 x i32> <i32 77, i32 77, i32 77, i32 77>, <4 x i32>* %6
%7 = getelementptr inbounds i32, i32* %1, i64 12
%8 = bitcast i32* %7 to <4 x i32>*
store <4 x i32> <i32 77, i32 77, i32 77, i32 77>, <4 x i32>* %8
%9 = getelementptr inbounds i32, i32* %1, i64 16
%10 = bitcast i32* %9 to <4 x i32>*
store <4 x i32> <i32 77, i32 77, i32 77, i32 77>, <4 x i32>* %10
%11 = getelementptr inbounds i32, i32* %1, i64 20
%12 = bitcast i32* %11 to <4 x i32>*
store <4 x i32> <i32 77, i32 77, i32 77, i32 77>, <4 x i32>* %12
%13 = getelementptr inbounds i32, i32* %1, i64 24
%14 = bitcast i32* %13 to <4 x i32>*
store <4 x i32> <i32 77, i32 77, i32 77, i32 77>, <4 x i32>* %14
%15 = getelementptr inbounds i32, i32* %1, i64 28
%16 = bitcast i32* %15 to <4 x i32>*
store <4 x i32> <i32 77, i32 77, i32 77, i32 77>, <4 x i32>* %16
%17 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @str, i64 0, i64 0))
ret i32 0
}