#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*/ printf(char *, int, int);
int /*<<< orphan*/ scanf(char *, ...);
int main() {
  int seats = 2, i;
  float p_SEAT, p, pval;
  int N;
  scanf("%d", &N);
  while (N--) {
    p_SEAT = 0;
    scanf("%f", &p);
    p = 1 - p;
    pval = 1;
    i = 0;
    do {
      pval = pval * p;
      p_SEAT = 1 - pval;
      i++;
    } while (p_SEAT != 1);
    printf("\np_SEAT =1 after %d seats for p=%f\n", i, 1 - p);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x2,-0x8(%rbp)
lea    0xec7(%rip),%rdi
lea    -0x1c(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
mov    -0x1c(%rbp),%eax
mov    %eax,%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x1c(%rbp)
cmp    $0x0,%eax
je     1207 <main+0xe7>
xorps  %xmm0,%xmm0
movss  %xmm0,-0x10(%rbp)
lea    0xe9c(%rip),%rdi
lea    -0x14(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
movss  0xe82(%rip),%xmm0
subss  -0x14(%rbp),%xmm0
movss  %xmm0,-0x14(%rbp)
movss  0xe70(%rip),%xmm0
movss  %xmm0,-0x18(%rbp)
movl   $0x0,-0xc(%rbp)
movss  -0x18(%rbp),%xmm0
mulss  -0x14(%rbp),%xmm0
movss  %xmm0,-0x18(%rbp)
movss  0xe4d(%rip),%xmm0
subss  -0x18(%rbp),%xmm0
movss  %xmm0,-0x10(%rbp)
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
movss  -0x10(%rbp),%xmm0
movss  0xe2d(%rip),%xmm1
ucomiss %xmm1,%xmm0
jne    119c <main+0x7c>
jp     119c <main+0x7c>
mov    -0xc(%rbp),%esi
movss  0xe13(%rip),%xmm0
subss  -0x14(%rbp),%xmm0
cvttss2si %xmm0,%edx
lea    0xe0d(%rip),%rdi
call   1030 <printf@plt>
jmp    1148 <main+0x28>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
lea    0xed6(%rip),%rdi
mov    %rsp,%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
subl   $0x1,(%rsp)
jb     11c0 <main+0xa0>
lea    0xebe(%rip),%r14
lea    0x4(%rsp),%r15
lea    0xeb5(%rip),%rbx
cs nopw 0x0(%rax,%rax,1)
nop
xor    %ebp,%ebp
mov    %r14,%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
movss  0xe89(%rip),%xmm3
movaps %xmm3,%xmm0
subss  0x4(%rsp),%xmm0
movss  %xmm0,0x4(%rsp)
movaps %xmm3,%xmm1
nopl   0x0(%rax)
mulss  %xmm0,%xmm1
movaps %xmm3,%xmm2
subss  %xmm1,%xmm2
add    $0x1,%ebp
ucomiss %xmm3,%xmm2
jne    1190 <main+0x70>
jp     1190 <main+0x70>
movaps %xmm3,%xmm1
subss  %xmm0,%xmm1
cvttss2si %xmm1,%edx
mov    %rbx,%rdi
mov    %ebp,%esi
call   1030 <printf@plt>
subl   $0x1,(%rsp)
jae    1160 <main+0x40>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@.str.1 = [3 x i8] c"%f\00"
@.str.2 = [36 x i8] c"\0Ap_SEAT =1 after %d seats for p=%f\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca float
%5 = alloca float
%6 = alloca float
%7 = alloca i32
store i32 0, i32* %1
store i32 2, i32* %2
%8 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %7)
br label %9
9: ; preds = %28, %0
%10 = load i32, i32* %7
%11 = add nsw i32 %10, -1
store i32 %11, i32* %7
%12 = icmp ne i32 %10, 0
br i1 %12, label %13, label %34
13: ; preds = %9
store float 0.000000e+00, float* %4
%14 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %5)
%15 = load float, float* %5
%16 = fsub float 1.000000e+00, %15
store float %16, float* %5
store float 1.000000e+00, float* %6
store i32 0, i32* %3
br label %17
17: ; preds = %25, %13
%18 = load float, float* %6
%19 = load float, float* %5
%20 = fmul float %18, %19
store float %20, float* %6
%21 = load float, float* %6
%22 = fsub float 1.000000e+00, %21
store float %22, float* %4
%23 = load i32, i32* %3
%24 = add nsw i32 %23, 1
store i32 %24, i32* %3
br label %25
25: ; preds = %17
%26 = load float, float* %4
%27 = fcmp une float %26, 1.000000e+00
br i1 %27, label %17, label %28
28: ; preds = %25
%29 = load i32, i32* %3
%30 = load float, float* %5
%31 = fsub float 1.000000e+00, %30
%32 = fptosi float %31 to i32
%33 = call i32 @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.2, i64 0, i64 0), i32 %29, i32 %32)
br label %9
34: ; preds = %9
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@.str.1 = [3 x i8] c"%f\00"
@.str.2 = [36 x i8] c"\0Ap_SEAT =1 after %d seats for p=%f\0A\00"
define i32 @main() {
%1 = alloca float
%2 = alloca i32
%3 = bitcast float* %1 to i8*
%4 = bitcast i32* %2 to i8*
%5 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
%6 = load i32, i32* %2
%7 = add nsw i32 %6, -1
store i32 %7, i32* %2
%8 = icmp eq i32 %6, 0
br i1 %8, label %27, label %9
9: ; preds = %0, %20
%10 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %1)
%11 = load float, float* %1
%12 = fsub float 1.000000e+00, %11
store float %12, float* %1
br label %13
13: ; preds = %13, %9
%14 = phi i32 [ 0, %9 ], [ %18, %13 ]
%15 = phi float [ 1.000000e+00, %9 ], [ %16, %13 ]
%16 = fmul float %12, %15
%17 = fsub float 1.000000e+00, %16
%18 = add nuw nsw i32 %14, 1
%19 = fcmp une float %17, 1.000000e+00
br i1 %19, label %13, label %20
20: ; preds = %13
%21 = fsub float 1.000000e+00, %12
%22 = fptosi float %21 to i32
%23 = call i32 @printf(i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.2, i64 0, i64 0), i32 %18, i32 %22)
%24 = load i32, i32* %2
%25 = add nsw i32 %24, -1
store i32 %25, i32* %2
%26 = icmp eq i32 %24, 0
br i1 %26, label %27, label %9
27: ; preds = %20, %0
ret i32 0
}