#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 count(int *);
int /*<<< orphan*/ print_list(int *);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ sort_list(int *);
int main(int argc, char *argv[]) {
  int list[] = {30, 1,  3,  6,  7,  8,  4,  16, 29,        10,
                11, 12, 20, 5,  9,  23, 26, 22, 24,        13,
                14, 17, 18, 19, 27, 28, 2,  25, 2147483647};
  int list_length = count(list);
  printf("Got a list of length: %d\n", list_length);
  print_list(list);
  sort_list(list);
  print_list(list);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x90(%rbp),%rdi
lea    0xe90(%rip),%rsi
mov    $0x74,%edx
call   1060 <memcpy@plt>
lea    -0x90(%rbp),%rdi
call   1030 <count@plt>
mov    %eax,-0x94(%rbp)
mov    -0x94(%rbp),%esi
lea    0xedb(%rip),%rdi
call   1050 <printf@plt>
lea    -0x90(%rbp),%rdi
call   1040 <print_list@plt>
lea    -0x90(%rbp),%rdi
call   1070 <sort_list@plt>
lea    -0x90(%rbp),%rdi
call   1040 <print_list@plt>
xor    %eax,%eax
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x80,%rsp
mov    0xf22(%rip),%eax
mov    %eax,0x70(%rsp)
movaps 0xf07(%rip),%xmm0
movaps %xmm0,0x60(%rsp)
movaps 0xeeb(%rip),%xmm0
movaps %xmm0,0x50(%rsp)
movaps 0xecf(%rip),%xmm0
movaps %xmm0,0x40(%rsp)
movaps 0xeb3(%rip),%xmm0
movaps %xmm0,0x30(%rsp)
movaps 0xe97(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movaps 0xe7b(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movaps 0xe5f(%rip),%xmm0
movaps %xmm0,(%rsp)
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1030 <count@plt>
lea    0xebd(%rip),%rdi
mov    %eax,%esi
call   1050 <printf@plt>
mov    %rbx,%rdi
call   1040 <print_list@plt>
mov    %rbx,%rdi
call   1060 <sort_list@plt>
mov    %rbx,%rdi
call   1040 <print_list@plt>
xor    %eax,%eax
add    $0x80,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@__const.main.list = [29 x i32] [i32 30, i32 1, i32 3, i32 6, i32 7, i32 8, i32 4, i32 16, i32 29, i32 10, i32 11, i32 12, i32 20, i32 5, i32 9, i32 23, i32 26, i32 22, i32 24, i32 13, i32 14, i32 17, i32 18, i32 19, i32 27, i32 28, i32 2, i32 25, i32 2147483647]
@.str = [26 x i8] c"Got a list of length: %d\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8**
%5 = alloca [29 x i32]
%6 = alloca i32
store i32 %0, i32* %3
store i8** %1, i8*** %4
%7 = bitcast [29 x i32]* %5 to i8*
%8 = getelementptr inbounds [29 x i32], [29 x i32]* %5, i64 0, i64 0
%9 = call i32 @count(i32* %8)
store i32 %9, i32* %6
%10 = load i32, i32* %6
%11 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i32 %10)
%12 = getelementptr inbounds [29 x i32], [29 x i32]* %5, i64 0, i64 0
%13 = call i32 @print_list(i32* %12)
%14 = getelementptr inbounds [29 x i32], [29 x i32]* %5, i64 0, i64 0
%15 = call i32 @sort_list(i32* %14)
%16 = getelementptr inbounds [29 x i32], [29 x i32]* %5, i64 0, i64 0
%17 = call i32 @print_list(i32* %16)
ret i32 0
}

LLVM IR (-O2):
@__const.main.list = [29 x i32] [i32 30, i32 1, i32 3, i32 6, i32 7, i32 8, i32 4, i32 16, i32 29, i32 10, i32 11, i32 12, i32 20, i32 5, i32 9, i32 23, i32 26, i32 22, i32 24, i32 13, i32 14, i32 17, i32 18, i32 19, i32 27, i32 28, i32 2, i32 25, i32 2147483647]
@.str = [26 x i8] c"Got a list of length: %d\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [29 x i32]
%4 = bitcast [29 x i32]* %3 to i8*
%5 = getelementptr inbounds [29 x i32], [29 x i32]* %3, i64 0, i64 0
%6 = call i32 @count(i32* %5)
%7 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i32 %6)
%8 = call i32 @print_list(i32* %5)
%9 = call i32 @sort_list(i32* %5)
%10 = call i32 @print_list(i32* %5)
ret i32 0
}