#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 /*<<< orphan*/ check_executed(int /*<<< orphan*/ *, int, int);
int /*<<< orphan*/ check_for_done(int /*<<< orphan*/ *);
int /*<<< orphan*/ compute_queue_size(int /*<<< orphan*/ *, int *, int *, int *,
                                      int *);
int /*<<< orphan*/ read_header(int /*<<< orphan*/ *, int *, int *, int *);
int /*<<< orphan*/ rewind(int /*<<< orphan*/ *);
int check_rudimentary(FILE *in, int workers, int queue_size, int iterations) {
  int final_threads, threads_max, threads_min, admitted_threads;
  int actual_workers, actual_queue_size, actual_iterations;
  rewind(in);
  read_header(in, &actual_workers, &actual_queue_size, &actual_iterations);
  if (!((workers == actual_workers) && (queue_size == actual_queue_size) &&
        (iterations == actual_iterations)))
    return 0;
  rewind(in);
  if (!check_for_done(in))
    return 0;
  rewind(in);
  compute_queue_size(in, &final_threads, &threads_max, &threads_min,
                     &admitted_threads);
  if (!((threads_min == 0) && (threads_max <= queue_size) &&
        (final_threads == 0) && (admitted_threads == workers)))
    return 0;
  rewind(in);
  if (!check_executed(in, workers, iterations))
    return 0;
  return 1;
}


x86 assembly (clang, -O0):
<check_rudimentary>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %edx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <rewind@plt>
mov    -0x10(%rbp),%rdi
lea    -0x30(%rbp),%rsi
lea    -0x34(%rbp),%rdx
lea    -0x38(%rbp),%rcx
call   1060 <read_header@plt>
mov    -0x14(%rbp),%eax
cmp    -0x30(%rbp),%eax
jne    11a7 <check_rudimentary+0x57>
mov    -0x18(%rbp),%eax
cmp    -0x34(%rbp),%eax
jne    11a7 <check_rudimentary+0x57>
mov    -0x1c(%rbp),%eax
cmp    -0x38(%rbp),%eax
je     11b3 <check_rudimentary+0x63>
movl   $0x0,-0x4(%rbp)
jmp    1268 <check_rudimentary+0x118>
mov    -0x10(%rbp),%rdi
call   1030 <rewind@plt>
mov    -0x10(%rbp),%rdi
call   1070 <check_for_done@plt>
cmp    $0x0,%eax
jne    11da <check_rudimentary+0x8a>
movl   $0x0,-0x4(%rbp)
jmp    1268 <check_rudimentary+0x118>
mov    -0x10(%rbp),%rdi
call   1030 <rewind@plt>
mov    -0x10(%rbp),%rdi
lea    -0x20(%rbp),%rsi
lea    -0x24(%rbp),%rdx
lea    -0x28(%rbp),%rcx
lea    -0x2c(%rbp),%r8
call   1040 <compute_queue_size@plt>
cmpl   $0x0,-0x28(%rbp)
jne    1228 <check_rudimentary+0xd8>
mov    -0x24(%rbp),%eax
cmp    -0x18(%rbp),%eax
jg     1228 <check_rudimentary+0xd8>
cmpl   $0x0,-0x20(%rbp)
jne    1228 <check_rudimentary+0xd8>
mov    -0x2c(%rbp),%eax
cmp    -0x14(%rbp),%eax
je     1234 <check_rudimentary+0xe4>
movl   $0x0,-0x4(%rbp)
jmp    1268 <check_rudimentary+0x118>
mov    -0x10(%rbp),%rdi
call   1030 <rewind@plt>
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x1c(%rbp),%edx
call   1050 <check_executed@plt>
cmp    $0x0,%eax
jne    1261 <check_rudimentary+0x111>
movl   $0x0,-0x4(%rbp)
jmp    1268 <check_rudimentary+0x118>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<check_rudimentary>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x20,%rsp
mov    %ecx,%r14d
mov    %edx,%ebp
mov    %esi,%r12d
mov    %rdi,%rbx
call   1030 <rewind@plt>
lea    0xc(%rsp),%rsi
lea    0x8(%rsp),%rdx
lea    0x4(%rsp),%rcx
mov    %rbx,%rdi
call   1060 <read_header@plt>
xor    %r15d,%r15d
cmp    %r12d,0xc(%rsp)
jne    120c <check_rudimentary+0xbc>
cmp    %ebp,0x8(%rsp)
jne    120c <check_rudimentary+0xbc>
cmp    %r14d,0x4(%rsp)
jne    120c <check_rudimentary+0xbc>
mov    %rbx,%rdi
call   1030 <rewind@plt>
mov    %rbx,%rdi
call   1070 <check_for_done@plt>
test   %eax,%eax
je     120c <check_rudimentary+0xbc>
mov    %rbx,%rdi
call   1030 <rewind@plt>
lea    0x1c(%rsp),%rsi
lea    0x18(%rsp),%rdx
lea    0x14(%rsp),%rcx
lea    0x10(%rsp),%r8
mov    %rbx,%rdi
call   1040 <compute_queue_size@plt>
cmpl   $0x0,0x14(%rsp)
jne    120c <check_rudimentary+0xbc>
cmp    %ebp,0x18(%rsp)
jg     120c <check_rudimentary+0xbc>
cmpl   $0x0,0x1c(%rsp)
jne    120c <check_rudimentary+0xbc>
cmp    %r12d,0x10(%rsp)
jne    120c <check_rudimentary+0xbc>
mov    %rbx,%rdi
call   1030 <rewind@plt>
mov    %rbx,%rdi
mov    %r12d,%esi
mov    %r14d,%edx
call   1050 <check_executed@plt>
xor    %r15d,%r15d
test   %eax,%eax
setne  %r15b
mov    %r15d,%eax
add    $0x20,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @check_rudimentary(i32* %0, i32 %1, i32 %2, i32 %3) {
%5 = alloca i32
%6 = alloca i32*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
store i32* %0, i32** %6
store i32 %1, i32* %7
store i32 %2, i32* %8
store i32 %3, i32* %9
%17 = load i32*, i32** %6
%18 = call i32 @rewind(i32* %17)
%19 = load i32*, i32** %6
%20 = call i32 @read_header(i32* %19, i32* %14, i32* %15, i32* %16)
%21 = load i32, i32* %7
%22 = load i32, i32* %14
%23 = icmp eq i32 %21, %22
br i1 %23, label %24, label %32
24: ; preds = %4
%25 = load i32, i32* %8
%26 = load i32, i32* %15
%27 = icmp eq i32 %25, %26
br i1 %27, label %28, label %32
28: ; preds = %24
%29 = load i32, i32* %9
%30 = load i32, i32* %16
%31 = icmp eq i32 %29, %30
br i1 %31, label %33, label %32
32: ; preds = %28, %24, %4
store i32 0, i32* %5
br label %69
33: ; preds = %28
%34 = load i32*, i32** %6
%35 = call i32 @rewind(i32* %34)
%36 = load i32*, i32** %6
%37 = call i32 @check_for_done(i32* %36)
%38 = icmp ne i32 %37, 0
br i1 %38, label %40, label %39
39: ; preds = %33
store i32 0, i32* %5
br label %69
40: ; preds = %33
%41 = load i32*, i32** %6
%42 = call i32 @rewind(i32* %41)
%43 = load i32*, i32** %6
%44 = call i32 @compute_queue_size(i32* %43, i32* %10, i32* %11, i32* %12, i32* %13)
%45 = load i32, i32* %12
%46 = icmp eq i32 %45, 0
br i1 %46, label %47, label %58
47: ; preds = %40
%48 = load i32, i32* %11
%49 = load i32, i32* %8
%50 = icmp sle i32 %48, %49
br i1 %50, label %51, label %58
51: ; preds = %47
%52 = load i32, i32* %10
%53 = icmp eq i32 %52, 0
br i1 %53, label %54, label %58
54: ; preds = %51
%55 = load i32, i32* %13
%56 = load i32, i32* %7
%57 = icmp eq i32 %55, %56
br i1 %57, label %59, label %58
58: ; preds = %54, %51, %47, %40
store i32 0, i32* %5
br label %69
59: ; preds = %54
%60 = load i32*, i32** %6
%61 = call i32 @rewind(i32* %60)
%62 = load i32*, i32** %6
%63 = load i32, i32* %7
%64 = load i32, i32* %9
%65 = call i32 @check_executed(i32* %62, i32 %63, i32 %64)
%66 = icmp ne i32 %65, 0
br i1 %66, label %68, label %67
67: ; preds = %59
store i32 0, i32* %5
br label %69
68: ; preds = %59
store i32 1, i32* %5
br label %69
69: ; preds = %68, %67, %58, %39, %32
%70 = load i32, i32* %5
ret i32 %70
}

LLVM IR (-O2):
define i32 @check_rudimentary(i32* %0, i32 %1, i32 %2, i32 %3) {
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = bitcast i32* %5 to i8*
%13 = bitcast i32* %6 to i8*
%14 = bitcast i32* %7 to i8*
%15 = bitcast i32* %8 to i8*
%16 = bitcast i32* %9 to i8*
%17 = bitcast i32* %10 to i8*
%18 = bitcast i32* %11 to i8*
%19 = tail call i32 @rewind(i32* %0)
%20 = call i32 @read_header(i32* %0, i32* %9, i32* %10, i32* %11)
%21 = load i32, i32* %9
%22 = icmp eq i32 %21, %1
%23 = load i32, i32* %10
%24 = icmp eq i32 %23, %2
%25 = select i1 %22, i1 %24, i1 false
%26 = load i32, i32* %11
%27 = icmp eq i32 %26, %3
%28 = select i1 %25, i1 %27, i1 false
br i1 %28, label %29, label %52
29: ; preds = %4
%30 = call i32 @rewind(i32* %0)
%31 = call i32 @check_for_done(i32* %0)
%32 = icmp eq i32 %31, 0
br i1 %32, label %52, label %33
33: ; preds = %29
%34 = call i32 @rewind(i32* %0)
%35 = call i32 @compute_queue_size(i32* %0, i32* %5, i32* %6, i32* %7, i32* %8)
%36 = load i32, i32* %7
%37 = icmp eq i32 %36, 0
br i1 %37, label %38, label %52
38: ; preds = %33
%39 = load i32, i32* %6
%40 = icmp sle i32 %39, %2
%41 = load i32, i32* %5
%42 = icmp eq i32 %41, 0
%43 = select i1 %40, i1 %42, i1 false
%44 = load i32, i32* %8
%45 = icmp eq i32 %44, %1
%46 = select i1 %43, i1 %45, i1 false
br i1 %46, label %47, label %52
47: ; preds = %38
%48 = call i32 @rewind(i32* %0)
%49 = call i32 @check_executed(i32* %0, i32 %1, i32 %3)
%50 = icmp ne i32 %49, 0
%51 = zext i1 %50 to i32
br label %52
52: ; preds = %47, %33, %38, %29, %4
%53 = phi i32 [ 0, %4 ], [ 0, %29 ], [ 0, %38 ], [ 0, %33 ], [ %51, %47 ]
ret i32 %53
}