#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 *malloc(int);
int /*<<< orphan*/ print_array(int *, int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ quicksort(int *, int);
int main(int argc, char *argv[]) {
  int *array;
  array = malloc(4 * 5);
  array[0] = 3;
  array[1] = 5;
  array[2] = 1;
  array[3] = 4;
  array[4] = 2;
  print_array(array, 5);
  printf("Bug1\n");
  quicksort(array, 5);
  print_array(array, 5);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x14,%edi
call   1060 <malloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
movl   $0x3,(%rax)
mov    -0x18(%rbp),%rax
movl   $0x5,0x4(%rax)
mov    -0x18(%rbp),%rax
movl   $0x1,0x8(%rax)
mov    -0x18(%rbp),%rax
movl   $0x4,0xc(%rax)
mov    -0x18(%rbp),%rax
movl   $0x2,0x10(%rax)
mov    -0x18(%rbp),%rdi
mov    $0x5,%esi
call   1030 <print_array@plt>
lea    0xe51(%rip),%rdi
call   1050 <printf@plt>
mov    -0x18(%rbp),%rdi
mov    $0x5,%esi
call   1040 <quicksort@plt>
mov    -0x18(%rbp),%rdi
mov    $0x5,%esi
call   1030 <print_array@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
mov    $0x14,%edi
call   1060 <malloc@plt>
mov    %rax,%rbx
movaps 0xeab(%rip),%xmm0
movups %xmm0,(%rax)
movl   $0x2,0x10(%rax)
mov    %rax,%rdi
mov    $0x5,%esi
call   1040 <print_array@plt>
lea    0xe9d(%rip),%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
mov    $0x5,%esi
call   1050 <quicksort@plt>
mov    %rbx,%rdi
mov    $0x5,%esi
call   1040 <print_array@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [6 x i8] c"Bug1\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = call i32* @malloc(i32 20)
store i32* %7, i32** %6
%8 = load i32*, i32** %6
%9 = getelementptr inbounds i32, i32* %8, i64 0
store i32 3, i32* %9
%10 = load i32*, i32** %6
%11 = getelementptr inbounds i32, i32* %10, i64 1
store i32 5, i32* %11
%12 = load i32*, i32** %6
%13 = getelementptr inbounds i32, i32* %12, i64 2
store i32 1, i32* %13
%14 = load i32*, i32** %6
%15 = getelementptr inbounds i32, i32* %14, i64 3
store i32 4, i32* %15
%16 = load i32*, i32** %6
%17 = getelementptr inbounds i32, i32* %16, i64 4
store i32 2, i32* %17
%18 = load i32*, i32** %6
%19 = call i32 @print_array(i32* %18, i32 5)
%20 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%21 = load i32*, i32** %6
%22 = call i32 @quicksort(i32* %21, i32 5)
%23 = load i32*, i32** %6
%24 = call i32 @print_array(i32* %23, i32 5)
ret i32 0
}

LLVM IR (-O2):
@str = [5 x i8] c"Bug1\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i32* @malloc(i32 20)
%4 = bitcast i32* %3 to <4 x i32>*
store <4 x i32> <i32 3, i32 5, i32 1, i32 4>, <4 x i32>* %4
%5 = getelementptr inbounds i32, i32* %3, i64 4
store i32 2, i32* %5
%6 = tail call i32 @print_array(i32* %3, i32 5)
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @str, i64 0, i64 0))
%8 = tail call i32 @quicksort(i32* %3, i32 5)
%9 = tail call i32 @print_array(i32* %3, i32 5)
ret i32 0
}