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

/* Variables and functions */
int /*<<< orphan*/ FAIL_IF(int);
int /*<<< orphan*/ exit(int);
int fork();
int syscall_fpu();
int /*<<< orphan*/ waitpid(int, int *, int /*<<< orphan*/);
int test_syscall_fpu(void) {
  pid_t pid2;
  pid_t pid = fork();
  int ret;
  int child_ret;
  FAIL_IF(pid == -1);
  pid2 = fork();
  if (pid2 == -1) {
    child_ret = ret = 1;
  } else {
    ret = syscall_fpu();
    if (pid2)
      waitpid(pid2, &child_ret, 0);
    else
      exit(ret);
  }
  ret |= child_ret;
  if (pid)
    waitpid(pid, &child_ret, 0);
  else
    exit(ret);
  FAIL_IF(ret || child_ret);
  return 0;
}


x86 assembly (clang, -O0):
<test_syscall_fpu>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    $0x0,%al
call   1070 <fork@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0xffffffff,-0x8(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <FAIL_IF@plt>
mov    $0x0,%al
call   1070 <fork@plt>
mov    %eax,-0x4(%rbp)
cmpl   $0xffffffff,-0x4(%rbp)
jne    119a <test_syscall_fpu+0x4a>
movl   $0x1,-0xc(%rbp)
movl   $0x1,-0x10(%rbp)
jmp    11ce <test_syscall_fpu+0x7e>
mov    $0x0,%al
call   1040 <syscall_fpu@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0x4(%rbp)
je     11c1 <test_syscall_fpu+0x71>
mov    -0x4(%rbp),%edi
lea    -0x10(%rbp),%rsi
xor    %edx,%edx
call   1050 <waitpid@plt>
jmp    11c9 <test_syscall_fpu+0x79>
mov    -0xc(%rbp),%edi
call   1060 <exit@plt>
jmp    11ce <test_syscall_fpu+0x7e>
mov    -0x10(%rbp),%eax
or     -0xc(%rbp),%eax
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0x8(%rbp)
je     11f4 <test_syscall_fpu+0xa4>
mov    -0x8(%rbp),%edi
lea    -0x10(%rbp),%rsi
xor    %edx,%edx
call   1050 <waitpid@plt>
jmp    11fc <test_syscall_fpu+0xac>
mov    -0xc(%rbp),%edi
call   1060 <exit@plt>
mov    $0x1,%al
cmpl   $0x0,-0xc(%rbp)
mov    %al,-0x11(%rbp)
jne    1215 <test_syscall_fpu+0xc5>
cmpl   $0x0,-0x10(%rbp)
setne  %al
mov    %al,-0x11(%rbp)
mov    -0x11(%rbp),%al
and    $0x1,%al
movzbl %al,%edi
call   1030 <FAIL_IF@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_syscall_fpu>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
xor    %eax,%eax
call   1070 <fork@plt>
mov    %eax,%r14d
xor    %edi,%edi
cmp    $0xffffffff,%eax
sete   %dil
call   1030 <FAIL_IF@plt>
xor    %eax,%eax
call   1070 <fork@plt>
cmp    $0xffffffff,%eax
je     11cb <test_syscall_fpu+0x7b>
mov    %eax,%ebx
xor    %eax,%eax
call   1040 <syscall_fpu@plt>
mov    %eax,%ebp
test   %ebx,%ebx
je     11dd <test_syscall_fpu+0x8d>
lea    0xc(%rsp),%rsi
mov    %ebx,%edi
xor    %edx,%edx
call   1050 <waitpid@plt>
or     0xc(%rsp),%ebp
test   %r14d,%r14d
je     11dd <test_syscall_fpu+0x8d>
lea    0xc(%rsp),%rsi
mov    %r14d,%edi
xor    %edx,%edx
call   1050 <waitpid@plt>
xor    %edi,%edi
or     0xc(%rsp),%ebp
setne  %dil
call   1030 <FAIL_IF@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret
movl   $0x1,0xc(%rsp)
mov    $0x1,%ebp
test   %r14d,%r14d
jne    11a2 <test_syscall_fpu+0x52>
mov    %ebp,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
define i32 @test_syscall_fpu() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = call i32 (...) @fork()
store i32 %5, i32* %2
%6 = load i32, i32* %2
%7 = icmp eq i32 %6, -1
%8 = zext i1 %7 to i32
%9 = call i32 @FAIL_IF(i32 %8)
%10 = call i32 (...) @fork()
store i32 %10, i32* %1
%11 = load i32, i32* %1
%12 = icmp eq i32 %11, -1
br i1 %12, label %13, label %14
13: ; preds = %0
store i32 1, i32* %3
store i32 1, i32* %4
br label %25
14: ; preds = %0
%15 = call i32 (...) @syscall_fpu()
store i32 %15, i32* %3
%16 = load i32, i32* %1
%17 = icmp ne i32 %16, 0
br i1 %17, label %18, label %21
18: ; preds = %14
%19 = load i32, i32* %1
%20 = call i32 @waitpid(i32 %19, i32* %4, i32 0)
br label %24
21: ; preds = %14
%22 = load i32, i32* %3
%23 = call i32 @exit(i32 %22)
unreachable
24: ; preds = %18
br label %25
25: ; preds = %24, %13
%26 = load i32, i32* %4
%27 = load i32, i32* %3
%28 = or i32 %27, %26
store i32 %28, i32* %3
%29 = load i32, i32* %2
%30 = icmp ne i32 %29, 0
br i1 %30, label %31, label %34
31: ; preds = %25
%32 = load i32, i32* %2
%33 = call i32 @waitpid(i32 %32, i32* %4, i32 0)
br label %37
34: ; preds = %25
%35 = load i32, i32* %3
%36 = call i32 @exit(i32 %35)
unreachable
37: ; preds = %31
%38 = load i32, i32* %3
%39 = icmp ne i32 %38, 0
br i1 %39, label %43, label %40
40: ; preds = %37
%41 = load i32, i32* %4
%42 = icmp ne i32 %41, 0
br label %43
43: ; preds = %40, %37
%44 = phi i1 [ true, %37 ], [ %42, %40 ]
%45 = zext i1 %44 to i32
%46 = call i32 @FAIL_IF(i32 %45)
ret i32 0
}

LLVM IR (-O2):
define i32 @test_syscall_fpu() {
%1 = alloca i32
%2 = tail call i32 (...) @fork()
%3 = bitcast i32* %1 to i8*
%4 = icmp eq i32 %2, -1
%5 = zext i1 %4 to i32
%6 = tail call i32 @FAIL_IF(i32 %5)
%7 = tail call i32 (...) @fork()
%8 = icmp eq i32 %7, -1
br i1 %8, label %9, label %10
9: ; preds = %0
store i32 1, i32* %1
br label %19
10: ; preds = %0
%11 = tail call i32 (...) @syscall_fpu()
%12 = icmp eq i32 %7, 0
br i1 %12, label %17, label %13
13: ; preds = %10
%14 = call i32 @waitpid(i32 %7, i32* %1, i32 0)
%15 = load i32, i32* %1
%16 = or i32 %15, %11
br label %19
17: ; preds = %10
%18 = tail call i32 @exit(i32 %11)
unreachable
19: ; preds = %13, %9
%20 = phi i32 [ %16, %13 ], [ 1, %9 ]
%21 = icmp eq i32 %2, 0
br i1 %21, label %30, label %22
22: ; preds = %19
%23 = call i32 @waitpid(i32 %2, i32* %1, i32 0)
%24 = icmp ne i32 %20, 0
%25 = load i32, i32* %1
%26 = icmp ne i32 %25, 0
%27 = select i1 %24, i1 true, i1 %26
%28 = zext i1 %27 to i32
%29 = call i32 @FAIL_IF(i32 %28)
ret i32 0
30: ; preds = %19
%31 = call i32 @exit(i32 %20)
unreachable
}