#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*/ d;
typedef int /*<<< orphan*/ c;
typedef int /*<<< orphan*/ b;
typedef int /*<<< orphan*/ a;

/* Variables and functions */
int EXIT_SUCCESS;
int getMaxElement(int *, int);
int /*<<< orphan*/ printf(char *, ...);
int main(int argc, char **argv) {
  printf("= Aufgabe 13 =\n");
  int a[3] = {0, 2, 1};
  int b[5] = {0, 1, 4, 3, 2};
  int c[9] = {0, 7, 2, 3, 8, 5, 6, 1, 4};
  int d[4] = {3, 1, 2, 0};
  printf("Größtes Element des Arrays a => %d\n",
         getMaxElement(a, sizeof(a) / 4));
  printf("Größtes Element des Arrays b => %d\n",
         getMaxElement(b, sizeof(b) / 4));
  printf("Größtes Element des Arrays c => %d\n",
         getMaxElement(c, sizeof(c) / 4));
  printf("Größtes Element des Arrays d => %d\n",
         getMaxElement(d, sizeof(d) / 4));
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xeb3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    0xf55(%rip),%rax
mov    %rax,-0x1c(%rbp)
mov    0xf53(%rip),%eax
mov    %eax,-0x14(%rbp)
mov    0xf51(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    0xf4e(%rip),%rax
mov    %rax,-0x28(%rbp)
mov    0xf4c(%rip),%eax
mov    %eax,-0x20(%rbp)
lea    -0x60(%rbp),%rdi
lea    0xf4e(%rip),%rsi
mov    $0x24,%edx
call   1040 <memcpy@plt>
mov    0xf6d(%rip),%rax
mov    %rax,-0x70(%rbp)
mov    0xf6a(%rip),%rax
mov    %rax,-0x68(%rbp)
lea    -0x1c(%rbp),%rdi
mov    $0x3,%esi
call   1050 <getMaxElement@plt>
mov    %eax,%esi
lea    0xe47(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x30(%rbp),%rdi
mov    $0x5,%esi
call   1050 <getMaxElement@plt>
mov    %eax,%esi
lea    0xe4f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x60(%rbp),%rdi
mov    $0x9,%esi
call   1050 <getMaxElement@plt>
mov    %eax,%esi
lea    0xe57(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x70(%rbp),%rdi
mov    $0x4,%esi
call   1050 <getMaxElement@plt>
mov    %eax,%esi
lea    0xe5f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    0x2daf(%rip),%rax
mov    (%rax),%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x68,%rsp
lea    0xfcd(%rip),%rdi
call   1030 <puts@plt>
mov    0xec2(%rip),%eax
mov    %eax,0x8(%rsp)
mov    0xeaf(%rip),%rax
mov    %rax,(%rsp)
mov    0xec5(%rip),%eax
mov    %eax,0x20(%rsp)
movaps 0xeaa(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
mov    0xedf(%rip),%eax
mov    %eax,0x60(%rsp)
movaps 0xec4(%rip),%xmm0
movaps %xmm0,0x50(%rsp)
movaps 0xea8(%rip),%xmm0
movaps %xmm0,0x40(%rsp)
movaps 0xecc(%rip),%xmm0
movaps %xmm0,0x30(%rsp)
mov    %rsp,%rdi
mov    $0x3,%esi
call   1050 <getMaxElement@plt>
lea    0xec3(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0x10(%rsp),%rdi
mov    $0x5,%esi
call   1050 <getMaxElement@plt>
lea    0xeca(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0x40(%rsp),%rdi
mov    $0x9,%esi
call   1050 <getMaxElement@plt>
lea    0xed1(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0x30(%rsp),%rdi
mov    $0x4,%esi
call   1050 <getMaxElement@plt>
lea    0xed8(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x2dc6(%rip),%rax
mov    (%rax),%eax
add    $0x68,%rsp
ret

LLVM IR (-O0):
@.str = [16 x i8] c"= Aufgabe 13 =\0A\00"
@__const.main.a = [3 x i32] [i32 0, i32 2, i32 1]
@__const.main.b = [5 x i32] [i32 0, i32 1, i32 4, i32 3, i32 2]
@__const.main.c = [9 x i32] [i32 0, i32 7, i32 2, i32 3, i32 8, i32 5, i32 6, i32 1, i32 4]
@__const.main.d = [4 x i32] [i32 3, i32 1, i32 2, i32 0]
@.str.1 = [38 x i8] c"Gr\C3\B6\C3\9Ftes Element des Arrays a => %d\0A\00"
@.str.2 = [38 x i8] c"Gr\C3\B6\C3\9Ftes Element des Arrays b => %d\0A\00"
@.str.3 = [38 x i8] c"Gr\C3\B6\C3\9Ftes Element des Arrays c => %d\0A\00"
@.str.4 = [38 x i8] c"Gr\C3\B6\C3\9Ftes Element des Arrays d => %d\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [3 x i32]
%7 = alloca [5 x i32]
%8 = alloca [9 x i32]
%9 = alloca [4 x i32]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
%11 = bitcast [3 x i32]* %6 to i8*
%12 = bitcast [5 x i32]* %7 to i8*
%13 = bitcast [9 x i32]* %8 to i8*
%14 = bitcast [4 x i32]* %9 to i8*
%15 = getelementptr inbounds [3 x i32], [3 x i32]* %6, i64 0, i64 0
%16 = call i32 @getMaxElement(i32* %15, i32 3)
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.1, i64 0, i64 0), i32 %16)
%18 = getelementptr inbounds [5 x i32], [5 x i32]* %7, i64 0, i64 0
%19 = call i32 @getMaxElement(i32* %18, i32 5)
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.2, i64 0, i64 0), i32 %19)
%21 = getelementptr inbounds [9 x i32], [9 x i32]* %8, i64 0, i64 0
%22 = call i32 @getMaxElement(i32* %21, i32 9)
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.3, i64 0, i64 0), i32 %22)
%24 = getelementptr inbounds [4 x i32], [4 x i32]* %9, i64 0, i64 0
%25 = call i32 @getMaxElement(i32* %24, i32 4)
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.4, i64 0, i64 0), i32 %25)
%27 = load i32, i32* @EXIT_SUCCESS
ret i32 %27
}

LLVM IR (-O2):
@__const.main.a = [3 x i32] [i32 0, i32 2, i32 1]
@__const.main.b = [5 x i32] [i32 0, i32 1, i32 4, i32 3, i32 2]
@__const.main.c = [9 x i32] [i32 0, i32 7, i32 2, i32 3, i32 8, i32 5, i32 6, i32 1, i32 4]
@__const.main.d = [4 x i32] [i32 3, i32 1, i32 2, i32 0]
@.str.1 = [38 x i8] c"Gr\C3\B6\C3\9Ftes Element des Arrays a => %d\0A\00"
@.str.2 = [38 x i8] c"Gr\C3\B6\C3\9Ftes Element des Arrays b => %d\0A\00"
@.str.3 = [38 x i8] c"Gr\C3\B6\C3\9Ftes Element des Arrays c => %d\0A\00"
@.str.4 = [38 x i8] c"Gr\C3\B6\C3\9Ftes Element des Arrays d => %d\0A\00"
@EXIT_SUCCESS = global i32 0
@str = [15 x i8] c"= Aufgabe 13 =\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [3 x i32]
%4 = alloca [5 x i32]
%5 = alloca [9 x i32]
%6 = alloca [4 x i32]
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str, i64 0, i64 0))
%8 = bitcast [3 x i32]* %3 to i8*
%9 = bitcast [5 x i32]* %4 to i8*
%10 = bitcast [9 x i32]* %5 to i8*
%11 = bitcast [4 x i32]* %6 to i8*
%12 = getelementptr inbounds [3 x i32], [3 x i32]* %3, i64 0, i64 0
%13 = call i32 @getMaxElement(i32* %12, i32 3)
%14 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @.str.1, i64 0, i64 0), i32 %13)
%15 = getelementptr inbounds [5 x i32], [5 x i32]* %4, i64 0, i64 0
%16 = call i32 @getMaxElement(i32* %15, i32 5)
%17 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @.str.2, i64 0, i64 0), i32 %16)
%18 = getelementptr inbounds [9 x i32], [9 x i32]* %5, i64 0, i64 0
%19 = call i32 @getMaxElement(i32* %18, i32 9)
%20 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @.str.3, i64 0, i64 0), i32 %19)
%21 = getelementptr inbounds [4 x i32], [4 x i32]* %6, i64 0, i64 0
%22 = call i32 @getMaxElement(i32* %21, i32 4)
%23 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @.str.4, i64 0, i64 0), i32 %22)
%24 = load i32, i32* @EXIT_SUCCESS
ret i32 %24
}