#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 scalar_t__ pid_t;

/* Variables and functions */
int /*<<< orphan*/ fflush(int /*<<< orphan*/);
scalar_t__ fork();
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ stdout;
float work(int);
int main() {
  int a = 3.14;
  float out;
  pid_t p;
  p = fork();
  if (p)
    a = 3.14;
  else
    a = 2.42;
  while (1) {
    out = work(a);
    if (out != a)
      printf("Wrong value: %f\n", out);
    else {
      if (p)
        printf(".");
      else
        printf("!");
      fflush(stdout);
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x3,-0x8(%rbp)
mov    $0x0,%al
call   1060 <fork@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
je     1178 <main+0x38>
movl   $0x3,-0x8(%rbp)
jmp    117f <main+0x3f>
movl   $0x2,-0x8(%rbp)
jmp    1184 <main+0x44>
mov    -0x8(%rbp),%edi
call   1030 <work@plt>
movss  %xmm0,-0xc(%rbp)
movss  -0xc(%rbp),%xmm0
cvtsi2ssl -0x8(%rbp),%xmm1
ucomiss %xmm1,%xmm0
jne    11af <main+0x6f>
jp     11af <main+0x6f>
jmp    11cb <main+0x8b>
movss  -0xc(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe41(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
jmp    1205 <main+0xc5>
cmpq   $0x0,-0x18(%rbp)
je     11e9 <main+0xa9>
lea    0xe34(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11f7 <main+0xb7>
lea    0xe23(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    0x2de2(%rip),%rax
mov    (%rax),%edi
call   1050 <fflush@plt>
jmp    1184 <main+0x44>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
xor    %eax,%eax
call   1070 <fork@plt>
xor    %ebx,%ebx
test   %rax,%rax
sete   %bl
mov    $0x21,%eax
mov    $0x2e,%ebp
cmove  %eax,%ebp
xor    $0x3,%ebx
cvtsi2ss %ebx,%xmm0
movss  %xmm0,0x4(%rsp)
lea    0xe79(%rip),%r14
mov    0x2e52(%rip),%r15
jmp    119f <main+0x4f>
mov    %ebp,%edi
call   1030 <putchar@plt>
mov    (%r15),%edi
call   1060 <fflush@plt>
mov    %ebx,%edi
call   1040 <work@plt>
ucomiss 0x4(%rsp),%xmm0
jne    11af <main+0x5f>
jnp    1190 <main+0x40>
cvtss2sd %xmm0,%xmm0
mov    %r14,%rdi
mov    $0x1,%al
call   1050 <printf@plt>
jmp    119f <main+0x4f>

LLVM IR (-O0):
@.str = [17 x i8] c"Wrong value: %f\0A\00"
@.str.1 = [2 x i8] c".\00"
@.str.2 = [2 x i8] c"!\00"
@stdout = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca float
%4 = alloca i64
store i32 0, i32* %1
store i32 3, i32* %2
%5 = call i64 (...) @fork()
store i64 %5, i64* %4
%6 = load i64, i64* %4
%7 = icmp ne i64 %6, 0
br i1 %7, label %8, label %9
8: ; preds = %0
store i32 3, i32* %2
br label %10
9: ; preds = %0
store i32 2, i32* %2
br label %10
10: ; preds = %9, %8
br label %11
11: ; preds = %10, %32
%12 = load i32, i32* %2
%13 = call float @work(i32 %12)
store float %13, float* %3
%14 = load float, float* %3
%15 = load i32, i32* %2
%16 = sitofp i32 %15 to float
%17 = fcmp une float %14, %16
br i1 %17, label %18, label %22
18: ; preds = %11
%19 = load float, float* %3
%20 = fpext float %19 to double
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), double %20)
br label %32
22: ; preds = %11
%23 = load i64, i64* %4
%24 = icmp ne i64 %23, 0
br i1 %24, label %25, label %27
25: ; preds = %22
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
br label %29
27: ; preds = %22
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %29
29: ; preds = %27, %25
%30 = load i32, i32* @stdout
%31 = call i32 @fflush(i32 %30)
br label %32
32: ; preds = %29, %18
br label %11
}

LLVM IR (-O2):
@.str = [17 x i8] c"Wrong value: %f\0A\00"
@stdout = global i32 0
define i32 @main() {
%1 = tail call i64 (...) @fork()
%2 = icmp eq i64 %1, 0
%3 = select i1 %2, i32 2, i32 3
%4 = sitofp i32 %3 to float
%5 = select i1 %2, i32 33, i32 46
br label %6
6: ; preds = %16, %0
%7 = tail call float @work(i32 %3)
%8 = fcmp une float %7, %4
br i1 %8, label %9, label %12
9: ; preds = %6
%10 = fpext float %7 to double
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), double %10)
br label %16
12: ; preds = %6
%13 = tail call i32 @putchar(i32 %5)
%14 = load i32, i32* @stdout
%15 = tail call i32 @fflush(i32 %14)
br label %16
16: ; preds = %12, %9
br label %6
}