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


x86 assembly (clang, -O0):
<benoetigten_kaeufe>:
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)
movl   $0x0,-0x20(%rbp)
mov    -0x4(%rbp),%esi
mov    $0xffffffff,%edx
call   1030 <initialisiere_int_array@plt>
movl   $0x0,-0x24(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x4(%rbp),%eax
jge    11df <benoetigten_kaeufe+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 <benoetigten_kaeufe+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 <benoetigten_kaeufe+0xb1>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1182 <benoetigten_kaeufe+0x62>
mov    -0x24(%rbp),%eax
mov    -0x10(%rbp),%rcx
mov    %rcx,%rsp
mov    %rbp,%rsp
pop    %rbp
ret

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

LLVM IR (-O0):
define i32 @benoetigten_kaeufe(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
store i32 0, i32* %6
%12 = load i32, i32* %2
%13 = call i32 @initialisiere_int_array(i32* %11, i32 %12, i32 -1)
store i32 0, i32* %7
br label %14
14: ; preds = %36, %1
%15 = load i32, i32* %6
%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* %7
%41 = load i8*, i8** %3
ret i32 %40
}

LLVM IR (-O2):
define i32 @benoetigten_kaeufe(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 slt i32 %18, %0
br i1 %20, label %6, label %21
21: ; preds = %17, %1
%22 = phi i32 [ 0, %1 ], [ %19, %17 ]
ret i32 %22
}