#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*/ initialisiere_int_array(int *, int, int);
int liefere_ganze_zufallszahl(int, int);
int simuliere_einkauf_bilder(int anzahl_gekaufter_bilder) {
  int gefunden[anzahl_gekaufter_bilder];
  int zufallsbild = 0;
  int funde = 0;
  int kaeufe = 0;
  initialisiere_int_array(gefunden, anzahl_gekaufter_bilder, -1);
  funde = 0;
  for (kaeufe = 0; kaeufe < anzahl_gekaufter_bilder; kaeufe++) {
    zufallsbild = liefere_ganze_zufallszahl(1, anzahl_gekaufter_bilder) - 1;
    if (zufallsbild != gefunden[zufallsbild]) {
      gefunden[zufallsbild] = zufallsbild;
      funde = funde + 1;
    }
  }
  return funde;
}


x86 assembly (clang, -O0):
<simuliere_einkauf_bilder>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x10(%rbp)
lea    0xf(,%rax,4),%rcx
and    $0xfffffffffffffff0,%rcx
mov    %rsp,%rdi
sub    %rcx,%rdi
mov    %rdi,-0x30(%rbp)
mov    %rdi,%rsp
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x4(%rbp),%esi
mov    $0xffffffff,%edx
call   1030 <initialisiere_int_array@plt>
movl   $0x0,-0x20(%rbp)
movl   $0x0,-0x24(%rbp)
mov    -0x24(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    11df <simuliere_einkauf_bilder+0xbf>
mov    -0x4(%rbp),%esi
mov    $0x1,%edi
call   1040 <liefere_ganze_zufallszahl@plt>
mov    -0x30(%rbp),%rcx
sub    $0x1,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
movslq -0x1c(%rbp),%rdx
cmp    (%rcx,%rdx,4),%eax
je     11cc <simuliere_einkauf_bilder+0xac>
mov    -0x30(%rbp),%rax
mov    -0x1c(%rbp),%edx
movslq -0x1c(%rbp),%rcx
mov    %edx,(%rax,%rcx,4)
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    11d1 <simuliere_einkauf_bilder+0xb1>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1182 <simuliere_einkauf_bilder+0x62>
mov    -0x20(%rbp),%eax
mov    -0x10(%rbp),%rcx
mov    %rcx,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<simuliere_einkauf_bilder>:
push   %rbp
mov    %rsp,%rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %edi,%r14d
mov    %edi,%eax
mov    %rsp,%r12
lea    0xf(,%rax,4),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%r12
mov    %r12,%rsp
mov    %r12,%rdi
mov    %r14d,%esi
mov    $0xffffffff,%edx
call   1030 <initialisiere_int_array@plt>
xor    %r15d,%r15d
test   %r14d,%r14d
jle    119c <simuliere_einkauf_bilder+0x7c>
mov    %r14d,%ebx
jmp    1175 <simuliere_einkauf_bilder+0x55>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
add    $0xffffffff,%ebx
je     119c <simuliere_einkauf_bilder+0x7c>
mov    $0x1,%edi
mov    %r14d,%esi
call   1040 <liefere_ganze_zufallszahl@plt>
cltq
lea    -0x1(%rax),%ecx
cmp    -0x4(%r12,%rax,4),%ecx
je     1170 <simuliere_einkauf_bilder+0x50>
add    $0xffffffffffffffff,%rax
mov    %ecx,(%r12,%rax,4)
add    $0x1,%r15d
jmp    1170 <simuliere_einkauf_bilder+0x50>
mov    %r15d,%eax
lea    -0x20(%rbp),%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @simuliere_einkauf_bilder(i32 %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i64
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
store i32 %0, i32* %2
%8 = load i32, i32* %2
%9 = zext i32 %8 to i64
%10 = call i8* @llvm.stacksave()
store i8* %10, i8** %3
%11 = alloca i32, i64 %9
store i64 %9, i64* %4
store i32 0, i32* %5
store i32 0, i32* %6
store i32 0, i32* %7
%12 = load i32, i32* %2
%13 = call i32 @initialisiere_int_array(i32* %11, i32 %12, i32 -1)
store i32 0, i32* %6
store i32 0, i32* %7
br label %14
14: ; preds = %36, %1
%15 = load i32, i32* %7
%16 = load i32, i32* %2
%17 = icmp slt i32 %15, %16
br i1 %17, label %18, label %39
18: ; preds = %14
%19 = load i32, i32* %2
%20 = call i32 @liefere_ganze_zufallszahl(i32 1, i32 %19)
%21 = sub nsw i32 %20, 1
store i32 %21, i32* %5
%22 = load i32, i32* %5
%23 = load i32, i32* %5
%24 = sext i32 %23 to i64
%25 = getelementptr inbounds i32, i32* %11, i64 %24
%26 = load i32, i32* %25
%27 = icmp ne i32 %22, %26
br i1 %27, label %28, label %35
28: ; preds = %18
%29 = load i32, i32* %5
%30 = load i32, i32* %5
%31 = sext i32 %30 to i64
%32 = getelementptr inbounds i32, i32* %11, i64 %31
store i32 %29, i32* %32
%33 = load i32, i32* %6
%34 = add nsw i32 %33, 1
store i32 %34, i32* %6
br label %35
35: ; preds = %28, %18
br label %36
36: ; preds = %35
%37 = load i32, i32* %7
%38 = add nsw i32 %37, 1
store i32 %38, i32* %7
br label %14
39: ; preds = %14
%40 = load i32, i32* %6
%41 = load i8*, i8** %3
ret i32 %40
}

LLVM IR (-O2):
define i32 @simuliere_einkauf_bilder(i32 %0) {
%2 = zext i32 %0 to i64
%3 = alloca i32, i64 %2
%4 = call i32 @initialisiere_int_array(i32* %3, i32 %0, i32 -1)
%5 = icmp sgt i32 %0, 0
br i1 %5, label %6, label %21
6: ; preds = %1, %17
%7 = phi i32 [ %19, %17 ], [ 0, %1 ]
%8 = phi i32 [ %18, %17 ], [ 0, %1 ]
%9 = call i32 @liefere_ganze_zufallszahl(i32 1, i32 %0)
%10 = add nsw i32 %9, -1
%11 = sext i32 %10 to i64
%12 = getelementptr inbounds i32, i32* %3, i64 %11
%13 = load i32, i32* %12
%14 = icmp eq i32 %10, %13
br i1 %14, label %17, label %15
15: ; preds = %6
store i32 %10, i32* %12
%16 = add nsw i32 %8, 1
br label %17
17: ; preds = %6, %15
%18 = phi i32 [ %16, %15 ], [ %8, %6 ]
%19 = add nuw nsw i32 %7, 1
%20 = icmp eq i32 %19, %0
br i1 %20, label %21, label %6
21: ; preds = %17, %1
%22 = phi i32 [ 0, %1 ], [ %18, %17 ]
ret i32 %22
}