#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int EXIT_SUCCESS;
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fscanf(int /*<<< orphan*/ *, char *, int *);
int /*<<< orphan*/ printf(char *, int, int);
int main(void) {
  FILE *fp;
  fp = fopen("cosmic.in", "r");
  int numScenarios;
  int i, j, k;
  fscanf(fp, "%d", &numScenarios);
  for (i = 0; i < numScenarios; i++) {
    int a;
    int b;
    fscanf(fp, "%d", &a);
    fscanf(fp, "%d", &b);
    int planetsSurviving = 1;
    int planetsChecked = 1;
    while (planetsChecked % a != 0 || planetsChecked % b != 0) {
      if (planetsChecked % a != 0 && planetsChecked % b != 0) {
        planetsSurviving++;
      }
      planetsChecked++;
    }
    printf("Universe #%d: There's a %.4f%% chance we'll survive!\n", i + 1,
           100 * ((double)(planetsSurviving) / (double)(planetsChecked)));
  }
  fclose(fp);
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeb2(%rip),%rdi
lea    0xeb5(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xea3(%rip),%rsi
lea    -0x14(%rbp),%rdx
call   1050 <fscanf@plt>
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    126d <main+0x12d>
mov    -0x10(%rbp),%rdi
lea    0xe7c(%rip),%rsi
lea    -0x24(%rbp),%rdx
call   1050 <fscanf@plt>
mov    -0x10(%rbp),%rdi
lea    0xe68(%rip),%rsi
lea    -0x28(%rbp),%rdx
call   1050 <fscanf@plt>
movl   $0x1,-0x2c(%rbp)
movl   $0x1,-0x30(%rbp)
mov    -0x30(%rbp),%eax
cltd
idivl  -0x24(%rbp)
mov    $0x1,%al
cmp    $0x0,%edx
mov    %al,-0x31(%rbp)
jne    11e8 <main+0xa8>
mov    -0x30(%rbp),%eax
cltd
idivl  -0x28(%rbp)
cmp    $0x0,%edx
setne  %al
mov    %al,-0x31(%rbp)
mov    -0x31(%rbp),%al
test   $0x1,%al
jne    11f8 <main+0xb8>
jmp    122f <main+0xef>
mov    -0x30(%rbp),%eax
cltd
idivl  -0x24(%rbp)
cmp    $0x0,%edx
je     1221 <main+0xe1>
mov    -0x30(%rbp),%eax
cltd
idivl  -0x28(%rbp)
cmp    $0x0,%edx
je     1221 <main+0xe1>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    11c3 <main+0x83>
mov    -0x18(%rbp),%esi
add    $0x1,%esi
cvtsi2sdl -0x2c(%rbp),%xmm1
cvtsi2sdl -0x30(%rbp),%xmm0
divsd  %xmm0,%xmm1
movsd  0xdb5(%rip),%xmm0
mulsd  %xmm1,%xmm0
cvttsd2si %xmm0,%edx
lea    0xdbd(%rip),%rdi
call   1040 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1181 <main+0x41>
mov    -0x10(%rbp),%rdi
call   1030 <fclose@plt>
mov    0x2d63(%rip),%rax
mov    (%rax),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
lea    0xeb3(%rip),%rdi
lea    0xeb6(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,%r15
lea    0xea9(%rip),%rsi
lea    0xc(%rsp),%rdx
mov    %rax,%rdi
call   1050 <fscanf@plt>
cmpl   $0x0,0xc(%rsp)
jle    1235 <main+0xf5>
xor    %r12d,%r12d
lea    0xe87(%rip),%r14
lea    0xe83(%rip),%r13
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %r15,%rdi
mov    %r14,%rsi
lea    0x14(%rsp),%rdx
call   1050 <fscanf@plt>
mov    %r15,%rdi
mov    %r14,%rsi
lea    0x10(%rsp),%rdx
call   1050 <fscanf@plt>
mov    0x14(%rsp),%ebx
mov    $0x1,%edi
mov    0x10(%rsp),%ebp
mov    $0x1,%ecx
jmp    11e9 <main+0xa9>
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
cmp    $0x1,%edx
sbb    $0xffffffff,%edi
add    $0x1,%ecx
mov    %ecx,%eax
cltd
idiv   %ebx
mov    %edx,%esi
mov    %ecx,%eax
cltd
idiv   %ebp
test   %esi,%esi
jne    11e0 <main+0xa0>
test   %edx,%edx
jne    11e6 <main+0xa6>
add    $0x1,%r12d
xorps  %xmm0,%xmm0
cvtsi2sd %edi,%xmm0
xorps  %xmm1,%xmm1
cvtsi2sd %ecx,%xmm1
divsd  %xmm1,%xmm0
mulsd  0xde5(%rip),%xmm0
cvttsd2si %xmm0,%edx
mov    %r13,%rdi
mov    %r12d,%esi
call   1040 <printf@plt>
cmp    0xc(%rsp),%r12d
jl     11a0 <main+0x60>
mov    %r15,%rdi
call   1030 <fclose@plt>
mov    0x2d9c(%rip),%rax
mov    (%rax),%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [10 x i8] c"cosmic.in\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [54 x i8] c"Universe #%d: There's a %.4f%% chance we'll survive!\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
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
store i32 0, i32* %1
%11 = call i32* @fopen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %11, i32** %2
%12 = load i32*, i32** %2
%13 = call i32 @fscanf(i32* %12, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %3)
store i32 0, i32* %4
br label %14
14: ; preds = %62, %0
%15 = load i32, i32* %4
%16 = load i32, i32* %3
%17 = icmp slt i32 %15, %16
br i1 %17, label %18, label %65
18: ; preds = %14
%19 = load i32*, i32** %2
%20 = call i32 @fscanf(i32* %19, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %7)
%21 = load i32*, i32** %2
%22 = call i32 @fscanf(i32* %21, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %8)
store i32 1, i32* %9
store i32 1, i32* %10
br label %23
23: ; preds = %48, %18
%24 = load i32, i32* %10
%25 = load i32, i32* %7
%26 = srem i32 %24, %25
%27 = icmp ne i32 %26, 0
br i1 %27, label %33, label %28
28: ; preds = %23
%29 = load i32, i32* %10
%30 = load i32, i32* %8
%31 = srem i32 %29, %30
%32 = icmp ne i32 %31, 0
br label %33
33: ; preds = %28, %23
%34 = phi i1 [ true, %23 ], [ %32, %28 ]
br i1 %34, label %35, label %51
35: ; preds = %33
%36 = load i32, i32* %10
%37 = load i32, i32* %7
%38 = srem i32 %36, %37
%39 = icmp ne i32 %38, 0
br i1 %39, label %40, label %48
40: ; preds = %35
%41 = load i32, i32* %10
%42 = load i32, i32* %8
%43 = srem i32 %41, %42
%44 = icmp ne i32 %43, 0
br i1 %44, label %45, label %48
45: ; preds = %40
%46 = load i32, i32* %9
%47 = add nsw i32 %46, 1
store i32 %47, i32* %9
br label %48
48: ; preds = %45, %40, %35
%49 = load i32, i32* %10
%50 = add nsw i32 %49, 1
store i32 %50, i32* %10
br label %23
51: ; preds = %33
%52 = load i32, i32* %4
%53 = add nsw i32 %52, 1
%54 = load i32, i32* %9
%55 = sitofp i32 %54 to double
%56 = load i32, i32* %10
%57 = sitofp i32 %56 to double
%58 = fdiv double %55, %57
%59 = fmul double 1.000000e+02, %58
%60 = fptosi double %59 to i32
%61 = call i32 @printf(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.3, i64 0, i64 0), i32 %53, i32 %60)
br label %62
62: ; preds = %51
%63 = load i32, i32* %4
%64 = add nsw i32 %63, 1
store i32 %64, i32* %4
br label %14
65: ; preds = %14
%66 = load i32*, i32** %2
%67 = call i32 @fclose(i32* %66)
%68 = load i32, i32* @EXIT_SUCCESS
ret i32 %68
}

LLVM IR (-O2):
@.str = [10 x i8] c"cosmic.in\00"
@.str.1 = [2 x i8] c"r\00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [54 x i8] c"Universe #%d: There's a %.4f%% chance we'll survive!\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = tail call i32* @fopen(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%5 = bitcast i32* %1 to i8*
%6 = call i32 @fscanf(i32* %4, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %1)
%7 = load i32, i32* %1
%8 = icmp sgt i32 %7, 0
br i1 %8, label %9, label %43
9: ; preds = %0
%10 = bitcast i32* %2 to i8*
%11 = bitcast i32* %3 to i8*
br label %12
12: ; preds = %9, %33
%13 = phi i32 [ 0, %9 ], [ %34, %33 ]
%14 = call i32 @fscanf(i32* %4, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %2)
%15 = call i32 @fscanf(i32* %4, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %3)
%16 = load i32, i32* %2
%17 = load i32, i32* %3
br label %18
18: ; preds = %30, %12
%19 = phi i32 [ 1, %12 ], [ %31, %30 ]
%20 = phi i32 [ 1, %12 ], [ %32, %30 ]
%21 = srem i32 %20, %16
%22 = icmp eq i32 %21, 0
%23 = srem i32 %20, %17
br i1 %22, label %24, label %26
24: ; preds = %18
%25 = icmp eq i32 %23, 0
br i1 %25, label %33, label %30
26: ; preds = %18
%27 = icmp ne i32 %23, 0
%28 = zext i1 %27 to i32
%29 = add nsw i32 %19, %28
br label %30
30: ; preds = %24, %26
%31 = phi i32 [ %29, %26 ], [ %19, %24 ]
%32 = add nuw nsw i32 %20, 1
br label %18
33: ; preds = %24
%34 = add nuw nsw i32 %13, 1
%35 = sitofp i32 %19 to double
%36 = sitofp i32 %20 to double
%37 = fdiv double %35, %36
%38 = fmul double %37, 1.000000e+02
%39 = fptosi double %38 to i32
%40 = call i32 @printf(i8* getelementptr inbounds ([54 x i8], [54 x i8]* @.str.3, i64 0, i64 0), i32 %34, i32 %39)
%41 = load i32, i32* %1
%42 = icmp slt i32 %34, %41
br i1 %42, label %12, label %43
43: ; preds = %33, %0
%44 = call i32 @fclose(i32* %4)
%45 = load i32, i32* @EXIT_SUCCESS
ret i32 %45
}