#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*/ fprintf(int /*<<< orphan*/, char *);
int libpdex_get_sat_state(int /*<<< orphan*/ *);
int libpdex_satisfies_problem_file(int /*<<< orphan*/ *, int /*<<< orphan*/ *);
int /*<<< orphan*/ stderr;
int libpdex_verify_model(FILE *problem_file, FILE *solver_stdout,
                         bool model_is_sat) {
  int solver_is_sat;
  solver_is_sat = libpdex_get_sat_state(solver_stdout);
  if (model_is_sat == -1) {
    fprintf(stderr, "Failed to get model state.\n");
    return -1;
  }
  if (solver_is_sat == -1) {
    fprintf(stderr, "Invalid solver output.\n");
    return 0;
  }
  if (solver_is_sat != model_is_sat) {
    return 0;
  }
  if (solver_is_sat == 0) {
    return (model_is_sat == solver_is_sat) ? (1) : (0);
  }
  if (solver_is_sat == 1) {
    int model_validity;
    model_validity =
        libpdex_satisfies_problem_file(problem_file, solver_stdout);
    if (model_validity == -1) {
      fprintf(stderr, "Can't compare models.\n");
      return -1;
    }
    return model_validity;
  }
}


x86 assembly (clang, -O0):
<libpdex_verify_model>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    -0x18(%rbp),%rdi
call   1050 <libpdex_get_sat_state@plt>
mov    %eax,-0x20(%rbp)
cmpl   $0xffffffff,-0x1c(%rbp)
jne    117a <libpdex_verify_model+0x4a>
mov    0x2e80(%rip),%rax
mov    (%rax),%edi
lea    0xe97(%rip),%rsi
call   1030 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    122c <libpdex_verify_model+0xfc>
cmpl   $0xffffffff,-0x20(%rbp)
jne    11a5 <libpdex_verify_model+0x75>
mov    0x2e55(%rip),%rax
mov    (%rax),%edi
lea    0xe88(%rip),%rsi
call   1030 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
jmp    122c <libpdex_verify_model+0xfc>
mov    -0x20(%rbp),%eax
cmp    -0x1c(%rbp),%eax
je     11bd <libpdex_verify_model+0x8d>
movl   $0x0,-0x4(%rbp)
jmp    122c <libpdex_verify_model+0xfc>
cmpl   $0x0,-0x20(%rbp)
jne    11e1 <libpdex_verify_model+0xb1>
mov    -0x1c(%rbp),%edx
mov    -0x20(%rbp),%esi
xor    %eax,%eax
mov    $0x1,%ecx
cmp    %esi,%edx
cmove  %ecx,%eax
mov    %eax,-0x4(%rbp)
jmp    122c <libpdex_verify_model+0xfc>
cmpl   $0x1,-0x20(%rbp)
jne    122c <libpdex_verify_model+0xfc>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1040 <libpdex_satisfies_problem_file@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0xffffffff,-0x24(%rbp)
jne    1226 <libpdex_verify_model+0xf6>
mov    0x2dd4(%rip),%rax
mov    (%rax),%edi
lea    0xe1f(%rip),%rsi
call   1030 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    122c <libpdex_verify_model+0xfc>
mov    -0x24(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<libpdex_verify_model>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %edx,%ebp
mov    %rsi,%rbx
mov    %rdi,%r14
mov    %rsi,%rdi
call   1050 <libpdex_get_sat_state@plt>
mov    $0xffffffff,%r15d
cmp    $0xffffffff,%ebp
je     1182 <libpdex_verify_model+0x52>
mov    %eax,%ecx
cmp    $0xffffffff,%eax
je     118b <libpdex_verify_model+0x5b>
xor    %eax,%eax
cmp    %ebp,%ecx
jne    11a6 <libpdex_verify_model+0x76>
mov    $0x1,%eax
cmp    $0x1,%ebp
jne    11a6 <libpdex_verify_model+0x76>
mov    %r14,%rdi
mov    %rbx,%rsi
call   1040 <libpdex_satisfies_problem_file@plt>
cmp    $0xffffffff,%eax
jne    11a6 <libpdex_verify_model+0x76>
lea    0xeb4(%rip),%rsi
jmp    1195 <libpdex_verify_model+0x65>
lea    0xe77(%rip),%rsi
jmp    1195 <libpdex_verify_model+0x65>
xor    %r15d,%r15d
lea    0xe87(%rip),%rsi
mov    0x2e44(%rip),%rax
mov    (%rax),%edi
call   1030 <fprintf@plt>
mov    %r15d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [28 x i8] c"Failed to get model state.\0A\00"
@.str.1 = [24 x i8] c"Invalid solver output.\0A\00"
@.str.2 = [23 x i8] c"Can't compare models.\0A\00"
define i32 @libpdex_verify_model(i32* %0, i32* %1, i32 %2) {
%4 = alloca i32
%5 = alloca i32*
%6 = alloca i32*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
store i32* %0, i32** %5
store i32* %1, i32** %6
store i32 %2, i32* %7
%10 = load i32*, i32** %6
%11 = call i32 @libpdex_get_sat_state(i32* %10)
store i32 %11, i32* %8
%12 = load i32, i32* %7
%13 = icmp eq i32 %12, -1
br i1 %13, label %14, label %17
14: ; preds = %3
%15 = load i32, i32* @stderr
%16 = call i32 @fprintf(i32 %15, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0))
store i32 -1, i32* %4
br label %51
17: ; preds = %3
%18 = load i32, i32* %8
%19 = icmp eq i32 %18, -1
br i1 %19, label %20, label %23
20: ; preds = %17
%21 = load i32, i32* @stderr
%22 = call i32 @fprintf(i32 %21, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* %4
br label %51
23: ; preds = %17
%24 = load i32, i32* %8
%25 = load i32, i32* %7
%26 = icmp ne i32 %24, %25
br i1 %26, label %27, label %28
27: ; preds = %23
store i32 0, i32* %4
br label %51
28: ; preds = %23
%29 = load i32, i32* %8
%30 = icmp eq i32 %29, 0
br i1 %30, label %31, label %37
31: ; preds = %28
%32 = load i32, i32* %7
%33 = load i32, i32* %8
%34 = icmp eq i32 %32, %33
%35 = zext i1 %34 to i64
%36 = select i1 %34, i32 1, i32 0
store i32 %36, i32* %4
br label %51
37: ; preds = %28
%38 = load i32, i32* %8
%39 = icmp eq i32 %38, 1
br i1 %39, label %40, label %51
40: ; preds = %37
%41 = load i32*, i32** %5
%42 = load i32*, i32** %6
%43 = call i32 @libpdex_satisfies_problem_file(i32* %41, i32* %42)
store i32 %43, i32* %9
%44 = load i32, i32* %9
%45 = icmp eq i32 %44, -1
br i1 %45, label %46, label %49
46: ; preds = %40
%47 = load i32, i32* @stderr
%48 = call i32 @fprintf(i32 %47, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0))
store i32 -1, i32* %4
br label %51
49: ; preds = %40
%50 = load i32, i32* %9
store i32 %50, i32* %4
br label %51
51: ; preds = %14, %20, %27, %31, %46, %49, %37
%52 = load i32, i32* %4
ret i32 %52
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [28 x i8] c"Failed to get model state.\0A\00"
@.str.1 = [24 x i8] c"Invalid solver output.\0A\00"
@.str.2 = [23 x i8] c"Can't compare models.\0A\00"
define i32 @libpdex_verify_model(i32* %0, i32* %1, i32 %2) {
%4 = tail call i32 @libpdex_get_sat_state(i32* %1)
%5 = icmp eq i32 %2, -1
br i1 %5, label %15, label %6
6: ; preds = %3
%7 = icmp eq i32 %4, -1
br i1 %7, label %15, label %8
8: ; preds = %6
%9 = icmp eq i32 %4, %2
br i1 %9, label %10, label %20
10: ; preds = %8
%11 = icmp eq i32 %2, 1
br i1 %11, label %12, label %20
12: ; preds = %10
%13 = tail call i32 @libpdex_satisfies_problem_file(i32* %0, i32* %1)
%14 = icmp eq i32 %13, -1
br i1 %14, label %15, label %20
15: ; preds = %12, %6, %3
%16 = phi i8* [ getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), %3 ], [ getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), %6 ], [ getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0), %12 ]
%17 = phi i32 [ -1, %3 ], [ 0, %6 ], [ -1, %12 ]
%18 = load i32, i32* @stderr
%19 = tail call i32 @fprintf(i32 %18, i8* %16)
br label %20
20: ; preds = %15, %10, %12, %8
%21 = phi i32 [ 0, %8 ], [ %13, %12 ], [ 1, %10 ], [ %17, %15 ]
ret i32 %21
}