#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_FAILURE;
int EXIT_SUCCESS;
int *calloc(int, int);
int /*<<< orphan*/ printf(char *, ...);
int *realloc(int *, int);
int /*<<< orphan*/ scanf(char *, int *);
int main(void) {
  int n = 0, max = 8, z, i;
  int *zahlen;
  zahlen = calloc(8, sizeof(int));
  if (zahlen == NULL) {
    printf("Kein virtueller RAM mehr vorhanden");
    return EXIT_FAILURE;
  }
  printf("Zahlen eingeben --- Beenden mit 0\n");
  while (1) {
    printf("Zahl (%d) eingeben : ", n + 1);
    scanf("%d", &z);
    if (z == 0)
      break;
    if (n >= max - 1) {
      max += 8;
      zahlen = realloc(zahlen, max * sizeof(int));
      if (NULL == zahlen) {
        printf("Kein virtueller RAM mehr vorhanden !");
        return EXIT_FAILURE;
      }
      printf("Neuer Speicher 	: %d Bytes\n", 8);
      printf("Insgesamt	: %d Bytes\n", sizeof(int) * max);
      printf("Platz für 	: %d Elemente\n", max);
    }
    *(zahlen + n++) = z;
  }
  printf("Folgende Zahlen wurden eingegeben -> \n\n");
  for (i = 0; i < n; i++)
    printf("%d ", *(zahlen + i));
  printf("\n");
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0x8,-0xc(%rbp)
mov    $0x8,%edi
mov    $0x4,%esi
call   1040 <calloc@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    119a <main+0x5a>
lea    0xe7e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    0x2e50(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    12f0 <main+0x1b0>
lea    0xe82(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%esi
add    $0x1,%esi
lea    0xe91(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xe99(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1060 <scanf@plt>
cmpl   $0x0,-0x10(%rbp)
jne    11db <main+0x9b>
jmp    128e <main+0x14e>
mov    -0x8(%rbp),%eax
mov    -0xc(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jl     1271 <main+0x131>
mov    -0xc(%rbp),%eax
add    $0x8,%eax
mov    %eax,-0xc(%rbp)
mov    -0x20(%rbp),%rdi
movslq -0xc(%rbp),%rax
shl    $0x2,%rax
mov    %eax,%esi
call   1050 <realloc@plt>
mov    %rax,-0x20(%rbp)
xor    %eax,%eax
cmp    -0x20(%rbp),%rax
jne    1237 <main+0xf7>
lea    0xe40(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    0x2db3(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    12f0 <main+0x1b0>
lea    0xe46(%rip),%rdi
mov    $0x8,%esi
mov    $0x0,%al
call   1030 <printf@plt>
movslq -0xc(%rbp),%rsi
shl    $0x2,%rsi
lea    0xe47(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0xc(%rbp),%esi
lea    0xe4c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%edx
mov    -0x20(%rbp),%rax
mov    -0x8(%rbp),%ecx
mov    %ecx,%esi
add    $0x1,%esi
mov    %esi,-0x8(%rbp)
movslq %ecx,%rcx
mov    %edx,(%rax,%rcx,4)
jmp    11a8 <main+0x68>
lea    0xe3c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    12d6 <main+0x196>
mov    -0x20(%rbp),%rax
movslq -0x14(%rbp),%rcx
mov    (%rax,%rcx,4),%esi
lea    0xe38(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    12a3 <main+0x163>
lea    0xe1a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    0x2ced(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    $0x8,%edi
mov    $0x4,%esi
call   1060 <calloc@plt>
test   %rax,%rax
je     128c <main+0x12c>
mov    %rax,%r14
lea    0xf25(%rip),%rdi
call   1040 <puts@plt>
lea    0xe8a(%rip),%rdi
mov    $0x1,%esi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe8d(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1080 <scanf@plt>
mov    0x4(%rsp),%eax
test   %eax,%eax
je     12c9 <main+0x169>
mov    $0x8,%r12d
lea    0xe54(%rip),%r15
lea    0x4(%rsp),%r13
xor    %ebp,%ebp
jmp    1215 <main+0xb5>
nopl   0x0(%rax,%rax,1)
lea    0x1(%rbp),%rbx
mov    %eax,(%r14,%rbp,4)
add    $0x2,%ebp
mov    %r15,%rdi
mov    %ebp,%esi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe3b(%rip),%rdi
mov    %r13,%rsi
call   1080 <scanf@plt>
mov    0x4(%rsp),%eax
mov    %rbx,%rbp
test   %eax,%eax
je     1295 <main+0x135>
lea    -0x1(%r12),%ecx
movslq %ecx,%rcx
cmp    %rcx,%rbp
jl     11e0 <main+0x80>
mov    %r15,%rbx
movslq %r12d,%rax
lea    0x20(,%rax,4),%r15
mov    %r14,%rdi
mov    %r15d,%esi
call   1070 <realloc@plt>
test   %rax,%rax
je     12e8 <main+0x188>
mov    %rax,%r14
add    $0x8,%r12d
lea    0xe0f(%rip),%rdi
mov    $0x8,%esi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe18(%rip),%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe1d(%rip),%rdi
mov    %r12d,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x4(%rsp),%eax
mov    %rbx,%r15
jmp    11e0 <main+0x80>
lea    0xd6d(%rip),%rdi
jmp    12ef <main+0x18f>
lea    0xe38(%rip),%rdi
call   1040 <puts@plt>
test   %ebx,%ebx
je     12d5 <main+0x175>
mov    %ebx,%ebp
lea    0xe00(%rip),%r15
xor    %ebx,%ebx
mov    (%r14,%rbx,4),%esi
mov    %r15,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
add    $0x1,%rbx
cmp    %rbx,%rbp
jne    12b0 <main+0x150>
jmp    12d5 <main+0x175>
lea    0xe04(%rip),%rdi
call   1040 <puts@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    0x2cf2(%rip),%rax
jmp    12fd <main+0x19d>
lea    0xd4d(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x2ce3(%rip),%rax
mov    (%rax),%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [35 x i8] c"Kein virtueller RAM mehr vorhanden\00"
@EXIT_FAILURE = global i32 0
@.str.1 = [35 x i8] c"Zahlen eingeben --- Beenden mit 0\0A\00"
@.str.2 = [22 x i8] c"Zahl (%d) eingeben : \00"
@.str.3 = [3 x i8] c"%d\00"
@.str.4 = [37 x i8] c"Kein virtueller RAM mehr vorhanden !\00"
@.str.5 = [28 x i8] c"Neuer Speicher \09: %d Bytes\0A\00"
@.str.6 = [22 x i8] c"Insgesamt\09: %d Bytes\0A\00"
@.str.7 = [27 x i8] c"Platz f\C3\BCr \09: %d Elemente\0A\00"
@.str.8 = [40 x i8] c"Folgende Zahlen wurden eingegeben -> \0A\0A\00"
@.str.9 = [4 x i8] c"%d \00"
@.str.10 = [2 x i8] c"\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32*
store i32 0, i32* %1
store i32 0, i32* %2
store i32 8, i32* %3
%7 = call i32* @calloc(i32 8, i32 4)
store i32* %7, i32** %6
%8 = load i32*, i32** %6
%9 = icmp eq i32* %8, null
br i1 %9, label %10, label %13
10: ; preds = %0
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0))
%12 = load i32, i32* @EXIT_FAILURE
store i32 %12, i32* %1
br label %76
13: ; preds = %0
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.1, i64 0, i64 0))
br label %15
15: ; preds = %13, %50
%16 = load i32, i32* %2
%17 = add nsw i32 %16, 1
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0), i32 %17)
%19 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %4)
%20 = load i32, i32* %4
%21 = icmp eq i32 %20, 0
br i1 %21, label %22, label %23
22: ; preds = %15
br label %57
23: ; preds = %15
%24 = load i32, i32* %2
%25 = load i32, i32* %3
%26 = sub nsw i32 %25, 1
%27 = icmp sge i32 %24, %26
br i1 %27, label %28, label %50
28: ; preds = %23
%29 = load i32, i32* %3
%30 = add nsw i32 %29, 8
store i32 %30, i32* %3
%31 = load i32*, i32** %6
%32 = load i32, i32* %3
%33 = sext i32 %32 to i64
%34 = mul i64 %33, 4
%35 = trunc i64 %34 to i32
%36 = call i32* @realloc(i32* %31, i32 %35)
store i32* %36, i32** %6
%37 = load i32*, i32** %6
%38 = icmp eq i32* null, %37
br i1 %38, label %39, label %42
39: ; preds = %28
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.4, i64 0, i64 0))
%41 = load i32, i32* @EXIT_FAILURE
store i32 %41, i32* %1
br label %76
42: ; preds = %28
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.5, i64 0, i64 0), i32 8)
%44 = load i32, i32* %3
%45 = sext i32 %44 to i64
%46 = mul i64 4, %45
%47 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.6, i64 0, i64 0), i64 %46)
%48 = load i32, i32* %3
%49 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.7, i64 0, i64 0), i32 %48)
br label %50
50: ; preds = %42, %23
%51 = load i32, i32* %4
%52 = load i32*, i32** %6
%53 = load i32, i32* %2
%54 = add nsw i32 %53, 1
store i32 %54, i32* %2
%55 = sext i32 %53 to i64
%56 = getelementptr inbounds i32, i32* %52, i64 %55
store i32 %51, i32* %56
br label %15
57: ; preds = %22
%58 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.8, i64 0, i64 0))
store i32 0, i32* %5
br label %59
59: ; preds = %70, %57
%60 = load i32, i32* %5
%61 = load i32, i32* %2
%62 = icmp slt i32 %60, %61
br i1 %62, label %63, label %73
63: ; preds = %59
%64 = load i32*, i32** %6
%65 = load i32, i32* %5
%66 = sext i32 %65 to i64
%67 = getelementptr inbounds i32, i32* %64, i64 %66
%68 = load i32, i32* %67
%69 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.9, i64 0, i64 0), i32 %68)
br label %70
70: ; preds = %63
%71 = load i32, i32* %5
%72 = add nsw i32 %71, 1
store i32 %72, i32* %5
br label %59
73: ; preds = %59
%74 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.10, i64 0, i64 0))
%75 = load i32, i32* @EXIT_SUCCESS
store i32 %75, i32* %1
br label %76
76: ; preds = %73, %39, %10
%77 = load i32, i32* %1
ret i32 %77
}

LLVM IR (-O2):
@.str = [35 x i8] c"Kein virtueller RAM mehr vorhanden\00"
@EXIT_FAILURE = global i32 0
@.str.2 = [22 x i8] c"Zahl (%d) eingeben : \00"
@.str.3 = [3 x i8] c"%d\00"
@.str.4 = [37 x i8] c"Kein virtueller RAM mehr vorhanden !\00"
@.str.5 = [28 x i8] c"Neuer Speicher \09: %d Bytes\0A\00"
@.str.6 = [22 x i8] c"Insgesamt\09: %d Bytes\0A\00"
@.str.7 = [27 x i8] c"Platz f\C3\BCr \09: %d Elemente\0A\00"
@.str.9 = [4 x i8] c"%d \00"
@EXIT_SUCCESS = global i32 0
@str = [34 x i8] c"Zahlen eingeben --- Beenden mit 0\00"
@str.11 = [39 x i8] c"Folgende Zahlen wurden eingegeben -> \0A\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32* @calloc(i32 8, i32 4)
%4 = icmp eq i32* %3, null
br i1 %4, label %5, label %7
5: ; preds = %0
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0))
br label %65
7: ; preds = %0
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @str, i64 0, i64 0))
%9 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0), i32 1)
%10 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %1)
%11 = load i32, i32* %1
%12 = icmp eq i32 %11, 0
br i1 %12, label %13, label %15
13: ; preds = %7
%14 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @str.11, i64 0, i64 0))
br label %63
15: ; preds = %7, %39
%16 = phi i32 [ %48, %39 ], [ %11, %7 ]
%17 = phi i64 [ %21, %39 ], [ 0, %7 ]
%18 = phi i64 [ %44, %39 ], [ 1, %7 ]
%19 = phi i32* [ %42, %39 ], [ %3, %7 ]
%20 = phi i32 [ %41, %39 ], [ 8, %7 ]
%21 = add nuw nsw i64 %17, 1
%22 = add nsw i32 %20, -1
%23 = sext i32 %22 to i64
%24 = icmp slt i64 %17, %23
br i1 %24, label %39, label %25
25: ; preds = %15
%26 = add nsw i32 %20, 8
%27 = sext i32 %26 to i64
%28 = shl nsw i64 %27, 2
%29 = trunc i64 %28 to i32
%30 = call i32* @realloc(i32* %19, i32 %29)
%31 = icmp eq i32* %30, null
br i1 %31, label %32, label %34
32: ; preds = %25
%33 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str.4, i64 0, i64 0))
br label %65
34: ; preds = %25
%35 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.5, i64 0, i64 0), i32 8)
%36 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.6, i64 0, i64 0), i64 %28)
%37 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.7, i64 0, i64 0), i32 %26)
%38 = load i32, i32* %1
br label %39
39: ; preds = %34, %15
%40 = phi i32 [ %38, %34 ], [ %16, %15 ]
%41 = phi i32 [ %26, %34 ], [ %20, %15 ]
%42 = phi i32* [ %30, %34 ], [ %19, %15 ]
%43 = getelementptr inbounds i32, i32* %42, i64 %17
store i32 %40, i32* %43
%44 = add nuw i64 %18, 1
%45 = trunc i64 %44 to i32
%46 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0), i32 %45)
%47 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %1)
%48 = load i32, i32* %1
%49 = icmp eq i32 %48, 0
br i1 %49, label %50, label %15
50: ; preds = %39
%51 = trunc i64 %18 to i32
%52 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @str.11, i64 0, i64 0))
%53 = icmp eq i32 %51, 0
br i1 %53, label %63, label %54
54: ; preds = %50
%55 = and i64 %18, 4294967295
br label %56
56: ; preds = %54, %56
%57 = phi i64 [ 0, %54 ], [ %61, %56 ]
%58 = getelementptr inbounds i32, i32* %42, i64 %57
%59 = load i32, i32* %58
%60 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.9, i64 0, i64 0), i32 %59)
%61 = add nuw nsw i64 %57, 1
%62 = icmp eq i64 %61, %55
br i1 %62, label %63, label %56
63: ; preds = %56, %13, %50
%64 = call i32 @putchar(i32 10)
br label %65
65: ; preds = %63, %32, %5
%66 = phi i32* [ @EXIT_FAILURE, %5 ], [ @EXIT_SUCCESS, %63 ], [ @EXIT_FAILURE, %32 ]
%67 = load i32, i32* %66
ret i32 %67
}