#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 */
typedef int /*<<< orphan*/ numbers;

/* Variables and functions */
int EXIT_SUCCESS;
int max_value(int *, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ sort_array(int *, int);
int string_length(char *);
int string_length_short(char *);
int sum_array(int *, int);
int main() {
  int length;
  char string[] = "Lorem ipsum bli blabb und so weiter";
  length = string_length(string);
  printf("%d\n", length);
  char string2[] = "Let's see if this works!";
  length = string_length_short(string2);
  printf("%d\n", length);
  int numbers[] = {4, 16, 256, 2, 64, 128, 2, 32, 512, 8};
  int size = sizeof(numbers) / sizeof(numbers[0]);
  printf("%d\n", sum_array(numbers, size));
  printf("%d\n", max_value(numbers, size));
  sort_array(numbers, size);
  for (int i = 0; i < size; ++i) {
    printf("%d ", numbers[i]);
  }
  printf("\n");
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x30(%rbp),%rdi
lea    0xe73(%rip),%rsi
mov    $0x24,%edx
call   1060 <memcpy@plt>
lea    -0x30(%rbp),%rdi
call   1080 <string_length@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%esi
lea    0xe9c(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    0xe75(%rip),%rax
mov    %rax,-0x50(%rbp)
mov    0xe72(%rip),%rax
mov    %rax,-0x48(%rbp)
mov    0xe6f(%rip),%rax
mov    %rax,-0x40(%rbp)
mov    0xe6d(%rip),%al
mov    %al,-0x38(%rbp)
lea    -0x50(%rbp),%rdi
call   1040 <string_length_short@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%esi
lea    0xe55(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x80(%rbp),%rdi
lea    0xe5a(%rip),%rsi
mov    $0x28,%edx
call   1060 <memcpy@plt>
movl   $0xa,-0x84(%rbp)
lea    -0x80(%rbp),%rdi
mov    -0x84(%rbp),%esi
call   1030 <sum_array@plt>
mov    %eax,%esi
lea    0xe17(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x80(%rbp),%rdi
mov    -0x84(%rbp),%esi
call   1070 <max_value@plt>
mov    %eax,%esi
lea    0xdf8(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x80(%rbp),%rdi
mov    -0x84(%rbp),%esi
call   1090 <sort_array@plt>
movl   $0x0,-0x88(%rbp)
mov    -0x88(%rbp),%eax
cmp    -0x84(%rbp),%eax
jge    12b0 <main+0x140>
movslq -0x88(%rbp),%rax
mov    -0x80(%rbp,%rax,4),%esi
lea    0xdb8(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x88(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x88(%rbp)
jmp    1271 <main+0x101>
lea    0xd94(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    0x2d1b(%rip),%rax
mov    (%rax),%eax
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x78,%rsp
movaps 0xe92(%rip),%xmm0
movaps %xmm0,0x60(%rsp)
movaps 0xe76(%rip),%xmm0
movaps %xmm0,0x50(%rsp)
movl   $0x726574,0x70(%rsp)
lea    0x50(%rsp),%rdi
call   1080 <string_length@plt>
lea    0xea1(%rip),%r14
mov    %r14,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1060 <printf@plt>
movups 0xe7e(%rip),%xmm0
movups %xmm0,0x39(%rsp)
movaps 0xe69(%rip),%xmm0
movaps %xmm0,0x30(%rsp)
lea    0x30(%rsp),%rdi
call   1050 <string_length_short@plt>
mov    %r14,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0xe97(%rip),%rax
mov    %rax,0x20(%rsp)
movaps 0xe7b(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movaps 0xe5f(%rip),%xmm0
movaps %xmm0,(%rsp)
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0xa,%esi
call   1040 <sum_array@plt>
mov    %r14,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %rbx,%rdi
mov    $0xa,%esi
call   1070 <max_value@plt>
mov    %r14,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %rbx,%rdi
mov    $0xa,%esi
call   1090 <sort_array@plt>
mov    (%rsp),%esi
lea    0xdfc(%rip),%rbx
mov    %rbx,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x4(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x8(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0xc(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x10(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x14(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x18(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x1c(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x20(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    0x24(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    0x2cf6(%rip),%rax
mov    (%rax),%eax
add    $0x78,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@__const.main.string = [36 x i8] c"Lorem ipsum bli blabb und so weiter\00"
@.str = [4 x i8] c"%d\0A\00"
@__const.main.string2 = [25 x i8] c"Let's see if this works!\00"
@__const.main.numbers = [10 x i32] [i32 4, i32 16, i32 256, i32 2, i32 64, i32 128, i32 2, i32 32, i32 512, i32 8]
@.str.1 = [4 x i8] c"%d \00"
@.str.2 = [2 x i8] c"\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [36 x i8]
%4 = alloca [25 x i8]
%5 = alloca [10 x i32]
%6 = alloca i32
%7 = alloca i32
store i32 0, i32* %1
%8 = bitcast [36 x i8]* %3 to i8*
%9 = getelementptr inbounds [36 x i8], [36 x i8]* %3, i64 0, i64 0
%10 = call i32 @string_length(i8* %9)
store i32 %10, i32* %2
%11 = load i32, i32* %2
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %11)
%13 = bitcast [25 x i8]* %4 to i8*
%14 = getelementptr inbounds [25 x i8], [25 x i8]* %4, i64 0, i64 0
%15 = call i32 @string_length_short(i8* %14)
store i32 %15, i32* %2
%16 = load i32, i32* %2
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %16)
%18 = bitcast [10 x i32]* %5 to i8*
store i32 10, i32* %6
%19 = getelementptr inbounds [10 x i32], [10 x i32]* %5, i64 0, i64 0
%20 = load i32, i32* %6
%21 = call i32 @sum_array(i32* %19, i32 %20)
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %21)
%23 = getelementptr inbounds [10 x i32], [10 x i32]* %5, i64 0, i64 0
%24 = load i32, i32* %6
%25 = call i32 @max_value(i32* %23, i32 %24)
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %25)
%27 = getelementptr inbounds [10 x i32], [10 x i32]* %5, i64 0, i64 0
%28 = load i32, i32* %6
%29 = call i32 @sort_array(i32* %27, i32 %28)
store i32 0, i32* %7
br label %30
30: ; preds = %40, %0
%31 = load i32, i32* %7
%32 = load i32, i32* %6
%33 = icmp slt i32 %31, %32
br i1 %33, label %34, label %43
34: ; preds = %30
%35 = load i32, i32* %7
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds [10 x i32], [10 x i32]* %5, i64 0, i64 %36
%38 = load i32, i32* %37
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %38)
br label %40
40: ; preds = %34
%41 = load i32, i32* %7
%42 = add nsw i32 %41, 1
store i32 %42, i32* %7
br label %30
43: ; preds = %30
%44 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%45 = load i32, i32* @EXIT_SUCCESS
ret i32 %45
}

LLVM IR (-O2):
@__const.main.string = [36 x i8] c"Lorem ipsum bli blabb und so weiter\00"
@.str = [4 x i8] c"%d\0A\00"
@__const.main.string2 = [25 x i8] c"Let's see if this works!\00"
@__const.main.numbers = [10 x i32] [i32 4, i32 16, i32 256, i32 2, i32 64, i32 128, i32 2, i32 32, i32 512, i32 8]
@.str.1 = [4 x i8] c"%d \00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca [36 x i8]
%2 = alloca [25 x i8]
%3 = alloca [10 x i32]
%4 = getelementptr inbounds [36 x i8], [36 x i8]* %1, i64 0, i64 0
%5 = call i32 @string_length(i8* %4)
%6 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %5)
%7 = getelementptr inbounds [25 x i8], [25 x i8]* %2, i64 0, i64 0
%8 = call i32 @string_length_short(i8* %7)
%9 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %8)
%10 = bitcast [10 x i32]* %3 to i8*
%11 = getelementptr inbounds [10 x i32], [10 x i32]* %3, i64 0, i64 0
%12 = call i32 @sum_array(i32* %11, i32 10)
%13 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %12)
%14 = call i32 @max_value(i32* %11, i32 10)
%15 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %14)
%16 = call i32 @sort_array(i32* %11, i32 10)
%17 = load i32, i32* %11
%18 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %17)
%19 = getelementptr inbounds [10 x i32], [10 x i32]* %3, i64 0, i64 1
%20 = load i32, i32* %19
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %20)
%22 = getelementptr inbounds [10 x i32], [10 x i32]* %3, i64 0, i64 2
%23 = load i32, i32* %22
%24 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %23)
%25 = getelementptr inbounds [10 x i32], [10 x i32]* %3, i64 0, i64 3
%26 = load i32, i32* %25
%27 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %26)
%28 = getelementptr inbounds [10 x i32], [10 x i32]* %3, i64 0, i64 4
%29 = load i32, i32* %28
%30 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %29)
%31 = getelementptr inbounds [10 x i32], [10 x i32]* %3, i64 0, i64 5
%32 = load i32, i32* %31
%33 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %32)
%34 = getelementptr inbounds [10 x i32], [10 x i32]* %3, i64 0, i64 6
%35 = load i32, i32* %34
%36 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %35)
%37 = getelementptr inbounds [10 x i32], [10 x i32]* %3, i64 0, i64 7
%38 = load i32, i32* %37
%39 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %38)
%40 = getelementptr inbounds [10 x i32], [10 x i32]* %3, i64 0, i64 8
%41 = load i32, i32* %40
%42 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %41)
%43 = getelementptr inbounds [10 x i32], [10 x i32]* %3, i64 0, i64 9
%44 = load i32, i32* %43
%45 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %44)
%46 = call i32 @putchar(i32 10)
%47 = load i32, i32* @EXIT_SUCCESS
ret i32 %47
}