#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*/ fflush(int /*<<< orphan*/);
int getIterations();
int /*<<< orphan*/ getchar();
int /*<<< orphan*/ printf(char *, ...);
int rand();
int /*<<< orphan*/ srand(int /*<<< orphan*/);
int /*<<< orphan*/ stdin;
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int main(void) {
  int iterations = getIterations(), i, changed = 0, stayed = 0;
  srand(time(NULL));
  for (i = 0; i < iterations; i++) {
    int doors[3] = {0, 0, 0};
    doors[rand() % 3] = 1;
    int pick = rand() % 3;
    int tip;
    do
      tip = rand() % 3;
    while (tip == pick && doors[tip]);
    int change;
    for (change = 0; change < 3; change++)
      if (change != tip && change != pick)
        break;
    if (doors[change])
      changed++;
    if (doors[pick])
      stayed++;
  }
  printf("\n");
  printf("----------------------------------------------------\n");
  printf("Der Moderator darf weder Rate- noch Auto-Tuer oeffnen\n");
  printf("   Gewinnchance beim Wechseln:       ..... %.2lf%%\n",
         (double)changed / iterations * 100);
  printf("                beim Nicht-Wechseln: ..... %.2lf%%\n\n",
         (double)stayed / iterations * 100);
  printf("----------------------------------------------------\n");
  fflush(stdin);
  getchar();
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1080 <getIterations@plt>
mov    %eax,-0x8(%rbp)
movl   $0x0,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1070 <time@plt>
mov    %eax,%edi
call   1050 <srand@plt>
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    12c7 <main+0x147>
lea    -0x20(%rbp),%rdi
xor    %esi,%esi
mov    $0xc,%edx
call   1040 <memset@plt>
mov    $0x0,%al
call   10a0 <rand@plt>
mov    $0x3,%ecx
cltd
idiv   %ecx
movslq %edx,%rax
movl   $0x1,-0x20(%rbp,%rax,4)
mov    $0x0,%al
call   10a0 <rand@plt>
mov    $0x3,%ecx
cltd
idiv   %ecx
mov    %edx,-0x24(%rbp)
mov    $0x0,%al
call   10a0 <rand@plt>
mov    $0x3,%ecx
cltd
idiv   %ecx
mov    %edx,-0x28(%rbp)
mov    -0x28(%rbp),%ecx
xor    %eax,%eax
cmp    -0x24(%rbp),%ecx
mov    %al,-0x2d(%rbp)
jne    1238 <main+0xb8>
movslq -0x28(%rbp),%rax
cmpl   $0x0,-0x20(%rbp,%rax,4)
setne  %al
mov    %al,-0x2d(%rbp)
mov    -0x2d(%rbp),%al
test   $0x1,%al
jne    1206 <main+0x86>
movl   $0x0,-0x2c(%rbp)
cmpl   $0x3,-0x2c(%rbp)
jge    1284 <main+0x104>
mov    -0x2c(%rbp),%eax
cmp    -0x28(%rbp),%eax
je     1271 <main+0xf1>
mov    -0x2c(%rbp),%eax
cmp    -0x24(%rbp),%eax
je     1271 <main+0xf1>
jmp    1284 <main+0x104>
jmp    1276 <main+0xf6>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    124a <main+0xca>
movslq -0x2c(%rbp),%rax
cmpl   $0x0,-0x20(%rbp,%rax,4)
je     129c <main+0x11c>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
movslq -0x24(%rbp),%rax
cmpl   $0x0,-0x20(%rbp,%rax,4)
je     12b4 <main+0x134>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    12b9 <main+0x139>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    11be <main+0x3e>
lea    0xe0e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xd2c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xd54(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
cvtsi2sdl -0x10(%rbp),%xmm0
cvtsi2sdl -0x8(%rbp),%xmm1
divsd  %xmm1,%xmm0
movsd  0xcf9(%rip),%xmm1
mulsd  %xmm1,%xmm0
lea    0xd63(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
cvtsi2sdl -0x14(%rbp),%xmm0
cvtsi2sdl -0x8(%rbp),%xmm1
divsd  %xmm1,%xmm0
movsd  0xcd1(%rip),%xmm1
mulsd  %xmm1,%xmm0
lea    0xd6f(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
lea    0xcc0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    0x2c92(%rip),%rax
mov    (%rax),%edi
call   1090 <fflush@plt>
mov    $0x0,%al
call   1060 <getchar@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
xor    %eax,%eax
call   1090 <getIterations@plt>
mov    %eax,%r15d
xor    %edi,%edi
call   1080 <time@plt>
mov    %eax,%edi
call   1060 <srand@plt>
test   %r15d,%r15d
jle    12d2 <main+0x142>
xor    %r13d,%r13d
xor    %r12d,%r12d
xor    %r14d,%r14d
jmp    11ef <main+0x5f>
nopw   0x0(%rax,%rax,1)
xor    %ecx,%ecx
cmpl   $0x1,(%rsp,%rcx,4)
sbb    $0xffffffff,%r12d
cmpl   $0x1,(%rsp,%rbp,4)
sbb    $0xffffffff,%r14d
add    $0x1,%r13d
cmp    %r15d,%r13d
je     12b7 <main+0x127>
movl   $0x0,0x8(%rsp)
movq   $0x0,(%rsp)
xor    %eax,%eax
call   10b0 <rand@plt>
cltq
imul   $0x55555556,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
shr    $0x20,%rcx
add    %edx,%ecx
lea    (%rcx,%rcx,2),%ecx
sub    %ecx,%eax
cltq
movl   $0x1,(%rsp,%rax,4)
xor    %eax,%eax
call   10b0 <rand@plt>
movslq %eax,%rbx
imul   $0x55555556,%rbx,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
shr    $0x20,%rax
add    %ecx,%eax
lea    (%rax,%rax,2),%eax
sub    %eax,%ebx
movslq %ebx,%rbp
xor    %eax,%eax
call   10b0 <rand@plt>
cltq
imul   $0x55555556,%rax,%rcx
mov    %rcx,%rdx
shr    $0x3f,%rdx
shr    $0x20,%rcx
add    %edx,%ecx
lea    (%rcx,%rcx,2),%ecx
sub    %ecx,%eax
cmp    %ebx,%eax
jne    127e <main+0xee>
cmpl   $0x0,(%rsp,%rbp,4)
jne    1250 <main+0xc0>
mov    %ebx,%eax
test   %eax,%eax
je     128a <main+0xfa>
test   %ebx,%ebx
jne    11d0 <main+0x40>
cmp    $0x1,%eax
je     129d <main+0x10d>
mov    $0x1,%ecx
cmp    $0x1,%ebx
jne    11d2 <main+0x42>
cmp    $0x2,%eax
sete   %al
cmp    $0x2,%ebx
sete   %cl
or     %al,%cl
movzbl %cl,%ecx
or     $0x2,%rcx
jmp    11d2 <main+0x42>
cvtsi2sd %r12d,%xmm0
movsd  %xmm0,0x10(%rsp)
xorps  %xmm0,%xmm0
cvtsi2sd %r14d,%xmm0
movsd  %xmm0,0x18(%rsp)
jmp    12e6 <main+0x156>
xorpd  %xmm0,%xmm0
movsd  %xmm0,0x18(%rsp)
xorpd  %xmm0,%xmm0
movsd  %xmm0,0x10(%rsp)
mov    $0xa,%edi
call   1030 <putchar@plt>
lea    0xdb0(%rip),%r14
mov    %r14,%rdi
call   1040 <puts@plt>
lea    0xd6b(%rip),%rdi
call   1040 <puts@plt>
cvtsi2sd %r15d,%xmm1
movsd  %xmm1,0x20(%rsp)
movsd  0x10(%rsp),%xmm0
divsd  %xmm1,%xmm0
mulsd  0xcd8(%rip),%xmm0
lea    0xcd9(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
movsd  0x18(%rsp),%xmm0
divsd  0x20(%rsp),%xmm0
mulsd  0xcb6(%rip),%xmm0
lea    0xceb(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
mov    %r14,%rdi
call   1040 <puts@plt>
mov    0x2c81(%rip),%rax
mov    (%rax),%edi
call   10a0 <fflush@plt>
xor    %eax,%eax
call   1070 <getchar@plt>
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c"\0A\00"
@.str.1 = [54 x i8] c"----------------------------------------------------\0A\00"
@.str.2 = [55 x i8] c"Der Moderator darf weder Rate- noch Auto-Tuer oeffnen\0A\00"
@.str.3 = [52 x i8] c" Gewinnchance beim Wechseln: ..... %.2lf%%\0A\00"
@.str.4 = [53 x i8] c" beim Nicht-Wechseln: ..... %.2lf%%\0A\0A\00"
@stdin = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca [3 x i32]
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i32 0, i32* %1
%10 = call i32 (...) @getIterations()
store i32 %10, i32* %2
store i32 0, i32* %4
store i32 0, i32* %5
%11 = call i32 @time(i32* null)
%12 = call i32 @srand(i32 %11)
store i32 0, i32* %3
br label %13
13: ; preds = %76, %0
%14 = load i32, i32* %3
%15 = load i32, i32* %2
%16 = icmp slt i32 %14, %15
br i1 %16, label %17, label %79
17: ; preds = %13
%18 = bitcast [3 x i32]* %6 to i8*
%19 = call i32 (...) @rand()
%20 = srem i32 %19, 3
%21 = sext i32 %20 to i64
%22 = getelementptr inbounds [3 x i32], [3 x i32]* %6, i64 0, i64 %21
store i32 1, i32* %22
%23 = call i32 (...) @rand()
%24 = srem i32 %23, 3
store i32 %24, i32* %7
br label %25
25: ; preds = %38, %17
%26 = call i32 (...) @rand()
%27 = srem i32 %26, 3
store i32 %27, i32* %8
br label %28
28: ; preds = %25
%29 = load i32, i32* %8
%30 = load i32, i32* %7
%31 = icmp eq i32 %29, %30
br i1 %31, label %32, label %38
32: ; preds = %28
%33 = load i32, i32* %8
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds [3 x i32], [3 x i32]* %6, i64 0, i64 %34
%36 = load i32, i32* %35
%37 = icmp ne i32 %36, 0
br label %38
38: ; preds = %32, %28
%39 = phi i1 [ false, %28 ], [ %37, %32 ]
br i1 %39, label %25, label %40
40: ; preds = %38
store i32 0, i32* %9
br label %41
41: ; preds = %54, %40
%42 = load i32, i32* %9
%43 = icmp slt i32 %42, 3
br i1 %43, label %44, label %57
44: ; preds = %41
%45 = load i32, i32* %9
%46 = load i32, i32* %8
%47 = icmp ne i32 %45, %46
br i1 %47, label %48, label %53
48: ; preds = %44
%49 = load i32, i32* %9
%50 = load i32, i32* %7
%51 = icmp ne i32 %49, %50
br i1 %51, label %52, label %53
52: ; preds = %48
br label %57
53: ; preds = %48, %44
br label %54
54: ; preds = %53
%55 = load i32, i32* %9
%56 = add nsw i32 %55, 1
store i32 %56, i32* %9
br label %41
57: ; preds = %52, %41
%58 = load i32, i32* %9
%59 = sext i32 %58 to i64
%60 = getelementptr inbounds [3 x i32], [3 x i32]* %6, i64 0, i64 %59
%61 = load i32, i32* %60
%62 = icmp ne i32 %61, 0
br i1 %62, label %63, label %66
63: ; preds = %57
%64 = load i32, i32* %4
%65 = add nsw i32 %64, 1
store i32 %65, i32* %4
br label %66
66: ; preds = %63, %57
%67 = load i32, i32* %7
%68 = sext i32 %67 to i64
%69 = getelementptr inbounds [3 x i32], [3 x i32]* %6, i64 0, i64 %68
%70 = load i32, i32* %69
%71 = icmp ne i32 %70, 0
br i1 %71, label %72, label %75
72: ; preds = %66
%73 = load i32, i32* %5
%74 = add nsw i32 %73, 1
store i32 %74, i32* %5
br label %75
75: ; preds = %72, %66
br label %76
76: ; preds = %75
%77 = load i32, i32* %3
%78 = add nsw i32 %77, 1
store i32 %78, i32* %3
br label %13
79: ; preds = %13
%80 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%81 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.1, i64 0, i64 0))
%82 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str.2, i64 0, i64 0))
%83 = load i32, i32* %4
%84 = sitofp i32 %83 to double
%85 = load i32, i32* %2
%86 = sitofp i32 %85 to double
%87 = fdiv double %84, %86
%88 = fmul double %87, 1.000000e+02
%89 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.3, i64 0, i64 0), double %88)
%90 = load i32, i32* %5
%91 = sitofp i32 %90 to double
%92 = load i32, i32* %2
%93 = sitofp i32 %92 to double
%94 = fdiv double %91, %93
%95 = fmul double %94, 1.000000e+02
%96 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([53 x i8], [53 x i8]* @.str.4, i64 0, i64 0), double %95)
%97 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.1, i64 0, i64 0))
%98 = load i32, i32* @stdin
%99 = call i32 @fflush(i32 %98)
%100 = call i32 (...) @getchar()
ret i32 0
}

LLVM IR (-O2):
@.str.3 = [52 x i8] c" Gewinnchance beim Wechseln: ..... %.2lf%%\0A\00"
@.str.4 = [53 x i8] c" beim Nicht-Wechseln: ..... %.2lf%%\0A\0A\00"
@stdin = global i32 0
@str.5 = [54 x i8] c"Der Moderator darf weder Rate- noch Auto-Tuer oeffnen\00"
@str.6 = [53 x i8] c"----------------------------------------------------\00"
define i32 @main() {
%1 = alloca [3 x i32]
%2 = tail call i32 (...) @getIterations()
%3 = tail call i32 @time(i32* null)
%4 = tail call i32 @srand(i32 %3)
%5 = icmp sgt i32 %2, 0
br i1 %5, label %6, label %59
6: ; preds = %0
%7 = bitcast [3 x i32]* %1 to i8*
br label %8
8: ; preds = %6, %41
%9 = phi i32 [ 0, %6 ], [ %54, %41 ]
%10 = phi i32 [ 0, %6 ], [ %47, %41 ]
%11 = phi i32 [ 0, %6 ], [ %53, %41 ]
%12 = tail call i32 (...) @rand()
%13 = srem i32 %12, 3
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds [3 x i32], [3 x i32]* %1, i64 0, i64 %14
store i32 1, i32* %15
%16 = tail call i32 (...) @rand()
%17 = srem i32 %16, 3
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds [3 x i32], [3 x i32]* %1, i64 0, i64 %18
br label %20
20: ; preds = %24, %8
%21 = tail call i32 (...) @rand()
%22 = srem i32 %21, 3
%23 = icmp eq i32 %22, %17
br i1 %23, label %24, label %27
24: ; preds = %20
%25 = load i32, i32* %19
%26 = icmp eq i32 %25, 0
br i1 %26, label %27, label %20
27: ; preds = %20, %24
%28 = phi i32 [ %22, %20 ], [ %17, %24 ]
%29 = icmp eq i32 %28, 0
%30 = icmp eq i32 %17, 0
%31 = select i1 %29, i1 true, i1 %30
br i1 %31, label %32, label %41
32: ; preds = %27
%33 = icmp eq i32 %28, 1
%34 = icmp eq i32 %17, 1
%35 = select i1 %33, i1 true, i1 %34
br i1 %35, label %36, label %41
36: ; preds = %32
%37 = icmp eq i32 %28, 2
%38 = icmp eq i32 %17, 2
%39 = select i1 %37, i1 true, i1 %38
%40 = select i1 %39, i64 3, i64 2
br label %41
41: ; preds = %36, %32, %27
%42 = phi i64 [ 0, %27 ], [ 1, %32 ], [ %40, %36 ]
%43 = getelementptr inbounds [3 x i32], [3 x i32]* %1, i64 0, i64 %42
%44 = load i32, i32* %43
%45 = icmp ne i32 %44, 0
%46 = zext i1 %45 to i32
%47 = add nuw nsw i32 %10, %46
%48 = sext i32 %17 to i64
%49 = getelementptr inbounds [3 x i32], [3 x i32]* %1, i64 0, i64 %48
%50 = load i32, i32* %49
%51 = icmp ne i32 %50, 0
%52 = zext i1 %51 to i32
%53 = add nuw nsw i32 %11, %52
%54 = add nuw nsw i32 %9, 1
%55 = icmp eq i32 %54, %2
br i1 %55, label %56, label %8
56: ; preds = %41
%57 = sitofp i32 %47 to double
%58 = sitofp i32 %53 to double
br label %59
59: ; preds = %56, %0
%60 = phi double [ 0.000000e+00, %0 ], [ %58, %56 ]
%61 = phi double [ 0.000000e+00, %0 ], [ %57, %56 ]
%62 = tail call i32 @putchar(i32 10)
%63 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([53 x i8], [53 x i8]* @str.6, i64 0, i64 0))
%64 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([54 x i8], [54 x i8]* @str.5, i64 0, i64 0))
%65 = sitofp i32 %2 to double
%66 = fdiv double %61, %65
%67 = fmul double %66, 1.000000e+02
%68 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([52 x i8], [52 x i8]* @.str.3, i64 0, i64 0), double %67)
%69 = fdiv double %60, %65
%70 = fmul double %69, 1.000000e+02
%71 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([53 x i8], [53 x i8]* @.str.4, i64 0, i64 0), double %70)
%72 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([53 x i8], [53 x i8]* @str.6, i64 0, i64 0))
%73 = load i32, i32* @stdin
%74 = tail call i32 @fflush(i32 %73)
%75 = tail call i32 (...) @getchar()
ret i32 0
}