#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 *, char, ...);
int strlen(char *);
int main() {
  int i = 0;
  int arr1[10] = {1, 2, 3, 4, 5};
  for (i = 0; i < 10; i++) {
    printf("Am Index %d liegt der Wert %d\n", i, arr1[i]);
  }
  int arr[10] = {0, 1, 2, 3, 4, 5, 12, 13, 42, 10};
  int sum = 0;
  for (i = 0; i < 10; i++) {
    sum = sum + arr[i];
  }
  printf("Durchschnitt: %f\n", sum / 10.0);
  char arr3[] = {'d', 'u', 'r', ' ', 't', 't'};
  for (i = 0; i < strlen(arr3); i++) {
    printf("%c", arr3[i]);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
lea    -0x30(%rbp),%rdi
xor    %esi,%esi
mov    $0x28,%edx
call   1050 <memset@plt>
movl   $0x1,-0x30(%rbp)
movl   $0x2,-0x2c(%rbp)
movl   $0x3,-0x28(%rbp)
movl   $0x4,-0x24(%rbp)
movl   $0x5,-0x20(%rbp)
movl   $0x0,-0x8(%rbp)
cmpl   $0xa,-0x8(%rbp)
jge    11c4 <main+0x84>
mov    -0x8(%rbp),%eax
movslq -0x8(%rbp),%rcx
mov    -0x30(%rbp,%rcx,4),%edx
lea    0xe5c(%rip),%rdi
movsbl %al,%esi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1190 <main+0x50>
lea    -0x60(%rbp),%rdi
lea    0xe71(%rip),%rsi
mov    $0x28,%edx
call   1060 <memcpy@plt>
movl   $0x0,-0x64(%rbp)
movl   $0x0,-0x8(%rbp)
cmpl   $0xa,-0x8(%rbp)
jge    120d <main+0xcd>
mov    -0x64(%rbp),%eax
movslq -0x8(%rbp),%rcx
add    -0x60(%rbp,%rcx,4),%eax
mov    %eax,-0x64(%rbp)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    11e7 <main+0xa7>
cvtsi2sdl -0x64(%rbp),%xmm0
movsd  0xde6(%rip),%xmm1
divsd  %xmm1,%xmm0
cvttsd2si %xmm0,%eax
lea    0xdfe(%rip),%rdi
movsbl %al,%esi
mov    $0x0,%al
call   1040 <printf@plt>
mov    0xe2f(%rip),%eax
mov    %eax,-0x6a(%rbp)
mov    0xe29(%rip),%ax
mov    %ax,-0x66(%rbp)
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x70(%rbp)
lea    -0x6a(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x70(%rbp),%eax
cmp    %ecx,%eax
jge    128f <main+0x14f>
movslq -0x8(%rbp),%rax
lea    0xdc4(%rip),%rdi
movsbl -0x6a(%rbp,%rax,1),%esi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    124e <main+0x10e>
xor    %eax,%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
lea    0xed0(%rip),%rbx
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x1,%edx
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    $0x1,%esi
mov    $0x2,%edx
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    $0x2,%esi
mov    $0x3,%edx
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    $0x3,%esi
mov    $0x4,%edx
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    $0x4,%esi
mov    $0x5,%edx
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    $0x5,%esi
xor    %edx,%edx
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    $0x6,%esi
xor    %edx,%edx
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    $0x7,%esi
xor    %edx,%edx
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    $0x8,%esi
xor    %edx,%edx
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    $0x9,%esi
xor    %edx,%edx
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe32(%rip),%rdi
mov    $0x9,%esi
xor    %eax,%eax
call   1040 <printf@plt>
movw   $0x7474,0xc(%rsp)
movl   $0x20727564,0x8(%rsp)
20
lea    0x8(%rsp),%rdi
call   1030 <strlen@plt>
test   %eax,%eax
jle    1252 <main+0x132>
lea    0xe14(%rip),%r14
lea    0x8(%rsp),%r15
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movsbl 0x8(%rsp,%rbx,1),%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%rbx
mov    %r15,%rdi
call   1030 <strlen@plt>
cltq
cmp    %rax,%rbx
jl     1230 <main+0x110>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [31 x i8] c"Am Index %d liegt der Wert %d\0A\00"
@__const.main.arr = [10 x i32] [i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 12, i32 13, i32 42, i32 10]
@.str.1 = [18 x i8] c"Durchschnitt: %f\0A\00"
@__const.main.arr3 = [6 x i8] c"dur tt"
@.str.2 = [3 x i8] c"%c\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [10 x i32]
%4 = alloca [10 x i32]
%5 = alloca i32
%6 = alloca [6 x i8]
store i32 0, i32* %1
store i32 0, i32* %2
%7 = bitcast [10 x i32]* %3 to i8*
%8 = bitcast i8* %7 to [10 x i32]*
%9 = getelementptr inbounds [10 x i32], [10 x i32]* %8, i32 0, i32 0
store i32 1, i32* %9
%10 = getelementptr inbounds [10 x i32], [10 x i32]* %8, i32 0, i32 1
store i32 2, i32* %10
%11 = getelementptr inbounds [10 x i32], [10 x i32]* %8, i32 0, i32 2
store i32 3, i32* %11
%12 = getelementptr inbounds [10 x i32], [10 x i32]* %8, i32 0, i32 3
store i32 4, i32* %12
%13 = getelementptr inbounds [10 x i32], [10 x i32]* %8, i32 0, i32 4
store i32 5, i32* %13
store i32 0, i32* %2
br label %14
14: ; preds = %25, %0
%15 = load i32, i32* %2
%16 = icmp slt i32 %15, 10
br i1 %16, label %17, label %28
17: ; preds = %14
%18 = load i32, i32* %2
%19 = trunc i32 %18 to i8
%20 = load i32, i32* %2
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds [10 x i32], [10 x i32]* %3, i64 0, i64 %21
%23 = load i32, i32* %22
%24 = call i32 (i8*, i8, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), i8 signext %19, i32 %23)
br label %25
25: ; preds = %17
%26 = load i32, i32* %2
%27 = add nsw i32 %26, 1
store i32 %27, i32* %2
br label %14
28: ; preds = %14
%29 = bitcast [10 x i32]* %4 to i8*
store i32 0, i32* %5
store i32 0, i32* %2
br label %30
30: ; preds = %40, %28
%31 = load i32, i32* %2
%32 = icmp slt i32 %31, 10
br i1 %32, label %33, label %43
33: ; preds = %30
%34 = load i32, i32* %5
%35 = load i32, i32* %2
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds [10 x i32], [10 x i32]* %4, i64 0, i64 %36
%38 = load i32, i32* %37
%39 = add nsw i32 %34, %38
store i32 %39, i32* %5
br label %40
40: ; preds = %33
%41 = load i32, i32* %2
%42 = add nsw i32 %41, 1
store i32 %42, i32* %2
br label %30
43: ; preds = %30
%44 = load i32, i32* %5
%45 = sitofp i32 %44 to double
%46 = fdiv double %45, 1.000000e+01
%47 = fptosi double %46 to i8
%48 = call i32 (i8*, i8, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i8 signext %47)
%49 = bitcast [6 x i8]* %6 to i8*
store i32 0, i32* %2
br label %50
50: ; preds = %61, %43
%51 = load i32, i32* %2
%52 = getelementptr inbounds [6 x i8], [6 x i8]* %6, i64 0, i64 0
%53 = call i32 @strlen(i8* %52)
%54 = icmp slt i32 %51, %53
br i1 %54, label %55, label %64
55: ; preds = %50
%56 = load i32, i32* %2
%57 = sext i32 %56 to i64
%58 = getelementptr inbounds [6 x i8], [6 x i8]* %6, i64 0, i64 %57
%59 = load i8, i8* %58
%60 = call i32 (i8*, i8, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8 signext %59)
br label %61
61: ; preds = %55
%62 = load i32, i32* %2
%63 = add nsw i32 %62, 1
store i32 %63, i32* %2
br label %50
64: ; preds = %50
ret i32 0
}

LLVM IR (-O2):
@.str = [31 x i8] c"Am Index %d liegt der Wert %d\0A\00"
@.str.1 = [18 x i8] c"Durchschnitt: %f\0A\00"
@__const.main.arr3 = [6 x i8] c"dur tt"
@.str.2 = [3 x i8] c"%c\00"
define i32 @main() {
%1 = alloca [6 x i8]
%2 = tail call i32 (i8*, i8, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), i8 signext 0, i32 1)
%3 = tail call i32 (i8*, i8, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), i8 signext 1, i32 2)
%4 = tail call i32 (i8*, i8, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), i8 signext 2, i32 3)
%5 = tail call i32 (i8*, i8, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), i8 signext 3, i32 4)
%6 = tail call i32 (i8*, i8, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), i8 signext 4, i32 5)
%7 = tail call i32 (i8*, i8, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), i8 signext 5, i32 0)
%8 = tail call i32 (i8*, i8, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), i8 signext 6, i32 0)
%9 = tail call i32 (i8*, i8, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), i8 signext 7, i32 0)
%10 = tail call i32 (i8*, i8, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), i8 signext 8, i32 0)
%11 = tail call i32 (i8*, i8, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), i8 signext 9, i32 0)
%12 = tail call i32 (i8*, i8, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i8 signext 9)
%13 = getelementptr inbounds [6 x i8], [6 x i8]* %1, i64 0, i64 0
%14 = call i32 @strlen(i8* %13)
%15 = icmp sgt i32 %14, 0
br i1 %15, label %16, label %25
16: ; preds = %0, %16
%17 = phi i64 [ %21, %16 ], [ 0, %0 ]
%18 = getelementptr inbounds [6 x i8], [6 x i8]* %1, i64 0, i64 %17
%19 = load i8, i8* %18
%20 = call i32 (i8*, i8, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i8 signext %19)
%21 = add nuw nsw i64 %17, 1
%22 = call i32 @strlen(i8* %13)
%23 = sext i32 %22 to i64
%24 = icmp slt i64 %21, %23
br i1 %24, label %16, label %25
25: ; preds = %16, %0
ret i32 0
}