#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 */
struct student {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ add_exam(struct student *, char *, int);
struct student *new_student(char *);
int /*<<< orphan*/ print_student(struct student *);
int main() {
  struct student *db[2];
  db[0] = new_student("Max Mustermann");
  add_exam(db[0], "GTI", 4);
  add_exam(db[0], "SyA", 3);
  db[1] = new_student("Sepp Wurz");
  add_exam(db[1], "GTI", 1);
  add_exam(db[1], "SyA", 1);
  add_exam(db[1], "ThI", 2);
  for (int i = 0; i < 2; ++i)
    print_student(db[i]);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeba(%rip),%rdi
call   1040 <new_student@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
lea    0xeb5(%rip),%rsi
mov    $0x4,%edx
call   1030 <add_exam@plt>
mov    -0x20(%rbp),%rdi
lea    0xea4(%rip),%rsi
mov    $0x3,%edx
call   1030 <add_exam@plt>
lea    0xe97(%rip),%rdi
call   1040 <new_student@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xe7b(%rip),%rsi
mov    $0x1,%edx
call   1030 <add_exam@plt>
mov    -0x18(%rbp),%rdi
lea    0xe6a(%rip),%rsi
mov    $0x1,%edx
call   1030 <add_exam@plt>
mov    -0x18(%rbp),%rdi
lea    0xe63(%rip),%rsi
mov    $0x2,%edx
call   1030 <add_exam@plt>
movl   $0x0,-0x24(%rbp)
cmpl   $0x2,-0x24(%rbp)
jge    11f5 <main+0xc5>
movslq -0x24(%rbp),%rax
mov    -0x20(%rbp,%rax,8),%rdi
call   1050 <print_student@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    11cf <main+0x9f>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
lea    0xec1(%rip),%rdi
call   1040 <new_student@plt>
mov    %rax,%r12
lea    0xec1(%rip),%r14
mov    %rax,%rdi
mov    %r14,%rsi
mov    $0x4,%edx
call   1030 <add_exam@plt>
lea    0xeae(%rip),%r15
mov    %r12,%rdi
mov    %r15,%rsi
mov    $0x3,%edx
call   1030 <add_exam@plt>
lea    0xe9b(%rip),%rdi
call   1040 <new_student@plt>
mov    %rax,%rbx
mov    %rax,%rdi
mov    %r14,%rsi
mov    $0x1,%edx
call   1030 <add_exam@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
mov    $0x1,%edx
call   1030 <add_exam@plt>
lea    0xe76(%rip),%rsi
mov    %rbx,%rdi
mov    $0x2,%edx
call   1030 <add_exam@plt>
mov    %r12,%rdi
call   1050 <print_student@plt>
mov    %rbx,%rdi
call   1050 <print_student@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.student = type { i32 }
@.str = [15 x i8] c"Max Mustermann\00"
@.str.1 = [4 x i8] c"GTI\00"
@.str.2 = [4 x i8] c"SyA\00"
@.str.3 = [10 x i8] c"Sepp Wurz\00"
@.str.4 = [4 x i8] c"ThI\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [2 x %struct.student*]
%3 = alloca i32
store i32 0, i32* %1
%4 = call %struct.student* @new_student(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
%5 = getelementptr inbounds [2 x %struct.student*], [2 x %struct.student*]* %2, i64 0, i64 0
store %struct.student* %4, %struct.student** %5
%6 = getelementptr inbounds [2 x %struct.student*], [2 x %struct.student*]* %2, i64 0, i64 0
%7 = load %struct.student*, %struct.student** %6
%8 = call i32 @add_exam(%struct.student* %7, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 4)
%9 = getelementptr inbounds [2 x %struct.student*], [2 x %struct.student*]* %2, i64 0, i64 0
%10 = load %struct.student*, %struct.student** %9
%11 = call i32 @add_exam(%struct.student* %10, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 3)
%12 = call %struct.student* @new_student(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0))
%13 = getelementptr inbounds [2 x %struct.student*], [2 x %struct.student*]* %2, i64 0, i64 1
store %struct.student* %12, %struct.student** %13
%14 = getelementptr inbounds [2 x %struct.student*], [2 x %struct.student*]* %2, i64 0, i64 1
%15 = load %struct.student*, %struct.student** %14
%16 = call i32 @add_exam(%struct.student* %15, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 1)
%17 = getelementptr inbounds [2 x %struct.student*], [2 x %struct.student*]* %2, i64 0, i64 1
%18 = load %struct.student*, %struct.student** %17
%19 = call i32 @add_exam(%struct.student* %18, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 1)
%20 = getelementptr inbounds [2 x %struct.student*], [2 x %struct.student*]* %2, i64 0, i64 1
%21 = load %struct.student*, %struct.student** %20
%22 = call i32 @add_exam(%struct.student* %21, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 2)
store i32 0, i32* %3
br label %23
23: ; preds = %32, %0
%24 = load i32, i32* %3
%25 = icmp slt i32 %24, 2
br i1 %25, label %26, label %35
26: ; preds = %23
%27 = load i32, i32* %3
%28 = sext i32 %27 to i64
%29 = getelementptr inbounds [2 x %struct.student*], [2 x %struct.student*]* %2, i64 0, i64 %28
%30 = load %struct.student*, %struct.student** %29
%31 = call i32 @print_student(%struct.student* %30)
br label %32
32: ; preds = %26
%33 = load i32, i32* %3
%34 = add nsw i32 %33, 1
store i32 %34, i32* %3
br label %23
35: ; preds = %23
ret i32 0
}

LLVM IR (-O2):
%struct.student = type { i32 }
@.str = [15 x i8] c"Max Mustermann\00"
@.str.1 = [4 x i8] c"GTI\00"
@.str.2 = [4 x i8] c"SyA\00"
@.str.3 = [10 x i8] c"Sepp Wurz\00"
@.str.4 = [4 x i8] c"ThI\00"
define i32 @main() {
%1 = tail call %struct.student* @new_student(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str, i64 0, i64 0))
%2 = tail call i32 @add_exam(%struct.student* %1, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 4)
%3 = tail call i32 @add_exam(%struct.student* %1, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 3)
%4 = tail call %struct.student* @new_student(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0))
%5 = tail call i32 @add_exam(%struct.student* %4, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 1)
%6 = tail call i32 @add_exam(%struct.student* %4, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 1)
%7 = tail call i32 @add_exam(%struct.student* %4, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.4, i64 0, i64 0), i32 2)
%8 = tail call i32 @print_student(%struct.student* %1)
%9 = tail call i32 @print_student(%struct.student* %4)
ret i32 0
}