#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 /*<<< orphan*/ printf(char *, int, ...);
int /*<<< orphan*/ puts(char *);
int rec_sum(int, int);
int rec_sum_array(int *, int /*<<< orphan*/);
int /*<<< orphan*/ rec_sum_array2(int *, int *, int /*<<< orphan*/);
int main() {
  int a = 0;
  int b = 10;
  int c = -20;
  int arr[] = {2, 7, 3, 2, 5, -17, 34, -2, 9};
  int arr2[15] = {5, 2, 77, 100};
  int result;
  puts("\nAufgabe a)");
  result = rec_sum(a, b);
  printf("Die Summe aller Zahlen zwischen %d und %d ist %d\n", a, b, result);
  result = rec_sum(a, c);
  printf("Die Summe aller Zahlen zwischen %d und %d ist %d\n", a, c, result);
  puts("\nAufgabe b)");
  result = rec_sum_array(arr, 0);
  printf("Die Summe aller Zahlen im Array arr beträgt %d\n", result);
  puts("\nAufgabe c)");
  rec_sum_array2(&result, arr, 0);
  printf("Die Summe aller Zahlen im Array arr beträgt %d\n", result);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0xa,-0xc(%rbp)
movl   $0xffffffec,-0x10(%rbp)
lea    -0x40(%rbp),%rdi
lea    0xe5e(%rip),%rsi
mov    $0x24,%edx
call   1080 <memcpy@plt>
lea    -0x80(%rbp),%rdi
xor    %esi,%esi
mov    $0x3c,%edx
call   1070 <memset@plt>
movl   $0x5,-0x80(%rbp)
movl   $0x2,-0x7c(%rbp)
movl   $0x4d,-0x78(%rbp)
movl   $0x64,-0x74(%rbp)
lea    0xe45(%rip),%rdi
call   1050 <puts@plt>
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
call   1090 <rec_sum@plt>
mov    %eax,-0x84(%rbp)
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
mov    -0x84(%rbp),%ecx
lea    0xe28(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%esi
call   1090 <rec_sum@plt>
mov    %eax,-0x84(%rbp)
mov    -0x8(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    -0x84(%rbp),%ecx
lea    0xdfd(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xe21(%rip),%rdi
call   1050 <puts@plt>
lea    -0x40(%rbp),%rdi
xor    %esi,%esi
call   1030 <rec_sum_array@plt>
mov    %eax,-0x84(%rbp)
mov    -0x84(%rbp),%esi
lea    0xe0a(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xe2d(%rip),%rdi
call   1050 <puts@plt>
lea    -0x40(%rbp),%rsi
lea    -0x84(%rbp),%rdi
xor    %edx,%edx
call   1040 <rec_sum_array2@plt>
mov    -0x84(%rbp),%esi
lea    0xdd8(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
xor    %eax,%eax
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x38,%rsp
mov    0xec3(%rip),%eax
mov    %eax,0x30(%rsp)
movaps 0xea8(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movaps 0xe8c(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
lea    0xea4(%rip),%rdi
call   1050 <puts@plt>
xor    %edi,%edi
mov    $0xa,%esi
call   1070 <rec_sum@plt>
lea    0xe98(%rip),%rbx
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0xa,%edx
mov    %eax,%ecx
xor    %eax,%eax
call   1060 <printf@plt>
xor    %edi,%edi
mov    $0xffffffec,%esi
call   1070 <rec_sum@plt>
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0xffffffec,%edx
mov    %eax,%ecx
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xe91(%rip),%rdi
call   1050 <puts@plt>
lea    0x10(%rsp),%r14
mov    %r14,%rdi
xor    %esi,%esi
call   1030 <rec_sum_array@plt>
mov    %eax,0xc(%rsp)
lea    0xe7e(%rip),%rbx
mov    %rbx,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xe9c(%rip),%rdi
call   1050 <puts@plt>
lea    0xc(%rsp),%rdi
mov    %r14,%rsi
xor    %edx,%edx
call   1040 <rec_sum_array2@plt>
mov    0xc(%rsp),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1060 <printf@plt>
xor    %eax,%eax
add    $0x38,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@__const.main.arr = [9 x i32] [i32 2, i32 7, i32 3, i32 2, i32 5, i32 -17, i32 34, i32 -2, i32 9]
@.str = [12 x i8] c"\0AAufgabe a)\00"
@.str.1 = [50 x i8] c"Die Summe aller Zahlen zwischen %d und %d ist %d\0A\00"
@.str.2 = [12 x i8] c"\0AAufgabe b)\00"
@.str.3 = [49 x i8] c"Die Summe aller Zahlen im Array arr betr\C3\A4gt %d\0A\00"
@.str.4 = [12 x i8] c"\0AAufgabe c)\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca [9 x i32]
%6 = alloca [15 x i32]
%7 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %2
store i32 10, i32* %3
store i32 -20, i32* %4
%8 = bitcast [9 x i32]* %5 to i8*
%9 = bitcast [15 x i32]* %6 to i8*
%10 = bitcast i8* %9 to <{ i32, i32, i32, i32, [11 x i32] }>*
%11 = getelementptr inbounds <{ i32, i32, i32, i32, [11 x i32] }>, <{ i32, i32, i32, i32, [11 x i32] }>* %10, i32 0, i32 0
store i32 5, i32* %11
%12 = getelementptr inbounds <{ i32, i32, i32, i32, [11 x i32] }>, <{ i32, i32, i32, i32, [11 x i32] }>* %10, i32 0, i32 1
store i32 2, i32* %12
%13 = getelementptr inbounds <{ i32, i32, i32, i32, [11 x i32] }>, <{ i32, i32, i32, i32, [11 x i32] }>* %10, i32 0, i32 2
store i32 77, i32* %13
%14 = getelementptr inbounds <{ i32, i32, i32, i32, [11 x i32] }>, <{ i32, i32, i32, i32, [11 x i32] }>* %10, i32 0, i32 3
store i32 100, i32* %14
%15 = call i32 @puts(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
%16 = load i32, i32* %2
%17 = load i32, i32* %3
%18 = call i32 @rec_sum(i32 %16, i32 %17)
store i32 %18, i32* %7
%19 = load i32, i32* %2
%20 = load i32, i32* %3
%21 = load i32, i32* %7
%22 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.1, i64 0, i64 0), i32 %19, i32 %20, i32 %21)
%23 = load i32, i32* %2
%24 = load i32, i32* %4
%25 = call i32 @rec_sum(i32 %23, i32 %24)
store i32 %25, i32* %7
%26 = load i32, i32* %2
%27 = load i32, i32* %4
%28 = load i32, i32* %7
%29 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.1, i64 0, i64 0), i32 %26, i32 %27, i32 %28)
%30 = call i32 @puts(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
%31 = getelementptr inbounds [9 x i32], [9 x i32]* %5, i64 0, i64 0
%32 = call i32 @rec_sum_array(i32* %31, i32 0)
store i32 %32, i32* %7
%33 = load i32, i32* %7
%34 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.3, i64 0, i64 0), i32 %33)
%35 = call i32 @puts(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0))
%36 = getelementptr inbounds [9 x i32], [9 x i32]* %5, i64 0, i64 0
%37 = call i32 @rec_sum_array2(i32* %7, i32* %36, i32 0)
%38 = load i32, i32* %7
%39 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.3, i64 0, i64 0), i32 %38)
ret i32 0
}

LLVM IR (-O2):
@__const.main.arr = [9 x i32] [i32 2, i32 7, i32 3, i32 2, i32 5, i32 -17, i32 34, i32 -2, i32 9]
@.str = [12 x i8] c"\0AAufgabe a)\00"
@.str.1 = [50 x i8] c"Die Summe aller Zahlen zwischen %d und %d ist %d\0A\00"
@.str.2 = [12 x i8] c"\0AAufgabe b)\00"
@.str.3 = [49 x i8] c"Die Summe aller Zahlen im Array arr betr\C3\A4gt %d\0A\00"
@.str.4 = [12 x i8] c"\0AAufgabe c)\00"
define i32 @main() {
%1 = alloca [9 x i32]
%2 = alloca i32
%3 = bitcast [9 x i32]* %1 to i8*
%4 = bitcast i32* %2 to i8*
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0))
%6 = tail call i32 @rec_sum(i32 0, i32 10)
%7 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.1, i64 0, i64 0), i32 0, i32 10, i32 %6)
%8 = tail call i32 @rec_sum(i32 0, i32 -20)
%9 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([50 x i8], [50 x i8]* @.str.1, i64 0, i64 0), i32 0, i32 -20, i32 %8)
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
%11 = getelementptr inbounds [9 x i32], [9 x i32]* %1, i64 0, i64 0
%12 = call i32 @rec_sum_array(i32* %11, i32 0)
store i32 %12, i32* %2
%13 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.3, i64 0, i64 0), i32 %12)
%14 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0))
%15 = call i32 @rec_sum_array2(i32* %2, i32* %11, i32 0)
%16 = load i32, i32* %2
%17 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str.3, i64 0, i64 0), i32 %16)
ret i32 0
}