#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 EXIT_SUCCESS;
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ swap(int *, int *);
int main(int argc, char **argv) {
  printf("= Aufgabe 15.1 =\n");
  int loc_variable = 10;
  printf("Adresse der Funktion (main) @ %p\n", &main);
  printf("Adresse der Variable (loc_variable) @ %p\n", &loc_variable);
  printf("= Aufgabe 15.2 =\n");
  int a = 10;
  int b = 20;
  printf("Inhalte von a und b (vorher) => (%d, %d) ", a, b);
  swap(&a, &b);
  printf("und (nacher) => (%d, %d)\n", a, b);
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xec3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0xa,-0x14(%rbp)
lea    0xec0(%rip),%rdi
mov    0x2e8f(%rip),%rsi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xecd(%rip),%rdi
lea    -0x14(%rbp),%rsi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xee5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0xa,-0x18(%rbp)
movl   $0x14,-0x1c(%rbp)
mov    -0x18(%rbp),%esi
mov    -0x1c(%rbp),%edx
lea    0xed5(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x18(%rbp),%rdi
lea    -0x1c(%rbp),%rsi
call   1040 <swap@plt>
mov    -0x18(%rbp),%esi
mov    -0x1c(%rbp),%edx
lea    0xede(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    0x2e0e(%rip),%rax
mov    (%rax),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
sub    $0x18,%rsp
lea    0xf55(%rip),%rdi
call   1030 <puts@plt>
movl   $0xa,0x14(%rsp)
lea    0xeb1(%rip),%rdi
mov    0x2e92(%rip),%rsi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xebe(%rip),%rdi
lea    0x14(%rsp),%rsi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xf2a(%rip),%rdi
call   1030 <puts@plt>
movl   $0xa,0x10(%rsp)
movl   $0x14,0xc(%rsp)
lea    0xeb9(%rip),%rdi
mov    $0xa,%esi
mov    $0x14,%edx
xor    %eax,%eax
call   1040 <printf@plt>
lea    0x10(%rsp),%rdi
lea    0xc(%rsp),%rsi
call   1050 <swap@plt>
mov    0x10(%rsp),%esi
mov    0xc(%rsp),%edx
lea    0xeb4(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x2e08(%rip),%rax
mov    (%rax),%eax
add    $0x18,%rsp
ret

LLVM IR (-O0):
@.str = [18 x i8] c"= Aufgabe 15.1 =\0A\00"
@.str.1 = [34 x i8] c"Adresse der Funktion (main) @ %p\0A\00"
@.str.2 = [42 x i8] c"Adresse der Variable (loc_variable) @ %p\0A\00"
@.str.3 = [18 x i8] c"= Aufgabe 15.2 =\0A\00"
@.str.4 = [42 x i8] c"Inhalte von a und b (vorher) => (%d, %d) \00"
@.str.5 = [26 x i8] c"und (nacher) => (%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 i32
%7 = alloca i32
%8 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
store i32 10, i32* %6
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0), i32 (i32, i8**)* @main)
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.2, i64 0, i64 0), i32* %6)
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0))
store i32 10, i32* %7
store i32 20, i32* %8
%13 = load i32, i32* %7
%14 = load i32, i32* %8
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str.4, i64 0, i64 0), i32 %13, i32 %14)
%16 = call i32 @swap(i32* %7, i32* %8)
%17 = load i32, i32* %7
%18 = load i32, i32* %8
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.5, i64 0, i64 0), i32 %17, i32 %18)
%20 = load i32, i32* @EXIT_SUCCESS
ret i32 %20
}

LLVM IR (-O2):
@.str.1 = [34 x i8] c"Adresse der Funktion (main) @ %p\0A\00"
@.str.2 = [42 x i8] c"Adresse der Variable (loc_variable) @ %p\0A\00"
@.str.4 = [42 x i8] c"Inhalte von a und b (vorher) => (%d, %d) \00"
@.str.5 = [26 x i8] c"und (nacher) => (%d, %d)\0A\00"
@EXIT_SUCCESS = global i32 0
@str = [17 x i8] c"= Aufgabe 15.1 =\00"
@str.6 = [17 x i8] c"= Aufgabe 15.2 =\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str, i64 0, i64 0))
%7 = bitcast i32* %3 to i8*
store i32 10, i32* %3
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0), i32 (i32, i8**)* @main)
%9 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @.str.2, i64 0, i64 0), i32* %3)
%10 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str.6, i64 0, i64 0))
%11 = bitcast i32* %4 to i8*
store i32 10, i32* %4
%12 = bitcast i32* %5 to i8*
store i32 20, i32* %5
%13 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([42 x i8], [42 x i8]* @.str.4, i64 0, i64 0), i32 10, i32 20)
%14 = call i32 @swap(i32* %4, i32* %5)
%15 = load i32, i32* %4
%16 = load i32, i32* %5
%17 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.5, i64 0, i64 0), i32 %15, i32 %16)
%18 = load i32, i32* @EXIT_SUCCESS
ret i32 %18
}