#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*/ exit(int);
int /*<<< orphan*/ *fopen(char *, char *);
int libpdex_verify_model(int /*<<< orphan*/ *, int /*<<< orphan*/ *, int);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ print_usage(char *);
int /*<<< orphan*/ printf(char *);
scalar_t__ strcmp(char *, char *);
int main(int argc, char *argv[]) {
  FILE *problem, *solver_out;
  bool model_is_sat = false;
  if (argc < 3) {
    print_usage(argv[0]);
  }
  if (strcmp(argv[1], "SAT") == 0) {
    model_is_sat = true;
  } else if (strcmp(argv[1], "UNSAT")) {
    print_usage(argv[0]);
  }
  if ((model_is_sat) && (argc < 4)) {
    print_usage(argv[0]);
  }
  solver_out = fopen(argv[2], "r");
  if (solver_out == NULL) {
    perror("Can't open solver output.");
    exit(-1);
  }
  if (model_is_sat) {
    problem = fopen(argv[3], "r");
    if (problem == NULL) {
      perror("Can't open problem output.");
      exit(-1);
    }
  } else {
    problem = NULL;
  }
  switch (libpdex_verify_model(problem, solver_out, model_is_sat)) {
  case -1:
    perror("I/O or parser error. System I/O state");
    return -1;
  case 0:
    printf("Invalid model.\n");
    return 0;
  case 1:
    printf("Model valid.\n");
    return 1;
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x24(%rbp)
cmpl   $0x3,-0x8(%rbp)
jge    11a3 <main+0x33>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1090 <print_usage@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe50(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    11cd <main+0x5d>
movl   $0x1,-0x24(%rbp)
jmp    11fc <main+0x8c>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe24(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
je     11f7 <main+0x87>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1090 <print_usage@plt>
jmp    11fc <main+0x8c>
cmpl   $0x0,-0x24(%rbp)
je     121c <main+0xac>
cmpl   $0x4,-0x8(%rbp)
jge    121c <main+0xac>
mov    -0x10(%rbp),%rax
mov    (%rax),%rdi
call   1090 <print_usage@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xddb(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    1255 <main+0xe5>
lea    0xdc2(%rip),%rdi
call   1070 <perror@plt>
mov    $0xffffffff,%edi
call   1080 <exit@plt>
cmpl   $0x0,-0x24(%rbp)
je     129d <main+0x12d>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
lea    0xd98(%rip),%rsi
call   1060 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1298 <main+0x128>
lea    0xd99(%rip),%rdi
call   1070 <perror@plt>
mov    $0xffffffff,%edi
call   1080 <exit@plt>
jmp    12a5 <main+0x135>
movq   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%rsi
mov    -0x24(%rbp),%edx
call   1050 <libpdex_verify_model@plt>
mov    %eax,%ecx
mov    %ecx,-0x28(%rbp)
sub    $0xffffffff,%eax
je     12e9 <main+0x179>
jmp    12c8 <main+0x158>
mov    -0x28(%rbp),%eax
test   %eax,%eax
je     1301 <main+0x191>
jmp    12d8 <main+0x168>
mov    -0x28(%rbp),%eax
sub    $0x1,%eax
je     1319 <main+0x1a9>
jmp    132c <main+0x1bc>
lea    0xd4d(%rip),%rdi
call   1070 <perror@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    132c <main+0x1bc>
lea    0xd5b(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    132c <main+0x1bc>
lea    0xd53(%rip),%rdi
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%rbx
mov    %edi,%ebp
cmp    $0x2,%edi
jg     1186 <main+0x16>
mov    (%rbx),%rdi
call   1090 <print_usage@plt>
mov    0x8(%rbx),%rdi
lea    0xe71(%rip),%rsi
call   1040 <strcmp@plt>
test   %rax,%rax
je     11da <main+0x6a>
mov    0x8(%rbx),%rdi
lea    0xe5a(%rip),%rsi
call   1040 <strcmp@plt>
test   %rax,%rax
je     11b8 <main+0x48>
mov    (%rbx),%rdi
call   1090 <print_usage@plt>
mov    0x10(%rbx),%rdi
lea    0xe43(%rip),%rsi
call   1060 <fopen@plt>
test   %rax,%rax
je     126d <main+0xfd>
mov    %rax,%r14
xor    %edx,%edx
xor    %edi,%edi
jmp    121c <main+0xac>
cmp    $0x3,%ebp
jg     11e7 <main+0x77>
mov    (%rbx),%rdi
call   1090 <print_usage@plt>
mov    0x10(%rbx),%rdi
lea    0xe14(%rip),%rsi
call   1060 <fopen@plt>
test   %rax,%rax
je     126d <main+0xfd>
mov    %rax,%r14
mov    0x18(%rbx),%rdi
lea    0xdfc(%rip),%rsi
call   1060 <fopen@plt>
test   %rax,%rax
je     1276 <main+0x106>
mov    %rax,%rdi
mov    $0x1,%edx
mov    %r14,%rsi
call   1050 <libpdex_verify_model@plt>
xor    %ebx,%ebx
test   %eax,%eax
je     1247 <main+0xd7>
cmp    $0x1,%eax
je     1255 <main+0xe5>
cmp    $0xffffffff,%eax
jne    1266 <main+0xf6>
lea    0xe02(%rip),%rdi
call   1070 <perror@plt>
mov    $0xffffffff,%ebx
jmp    1266 <main+0xf6>
lea    0xe22(%rip),%rdi
call   1030 <puts@plt>
jmp    1266 <main+0xf6>
lea    0xe07(%rip),%rdi
call   1030 <puts@plt>
mov    $0x1,%ebx
mov    %ebx,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret
lea    0xd94(%rip),%rdi
jmp    127d <main+0x10d>
lea    0xda5(%rip),%rdi
call   1070 <perror@plt>
mov    $0xffffffff,%edi
call   1080 <exit@plt>

LLVM IR (-O0):
@.str = [4 x i8] c"SAT\00"
@.str.1 = [6 x i8] c"UNSAT\00"
@.str.2 = [2 x i8] c"r\00"
@.str.3 = [26 x i8] c"Can't open solver output.\00"
@.str.4 = [27 x i8] c"Can't open problem output.\00"
@.str.5 = [38 x i8] c"I/O or parser error. System I/O state\00"
@.str.6 = [16 x i8] c"Invalid model.\0A\00"
@.str.7 = [14 x i8] c"Model valid.\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca i32*
%8 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %8
%9 = load i32, i32* %4
%10 = icmp slt i32 %9, 3
br i1 %10, label %11, label %16
11: ; preds = %2
%12 = load i8**, i8*** %5
%13 = getelementptr inbounds i8*, i8** %12, i64 0
%14 = load i8*, i8** %13
%15 = call i32 @print_usage(i8* %14)
br label %16
16: ; preds = %11, %2
%17 = load i8**, i8*** %5
%18 = getelementptr inbounds i8*, i8** %17, i64 1
%19 = load i8*, i8** %18
%20 = call i64 @strcmp(i8* %19, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%21 = icmp eq i64 %20, 0
br i1 %21, label %22, label %23
22: ; preds = %16
store i32 1, i32* %8
br label %35
23: ; preds = %16
%24 = load i8**, i8*** %5
%25 = getelementptr inbounds i8*, i8** %24, i64 1
%26 = load i8*, i8** %25
%27 = call i64 @strcmp(i8* %26, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%28 = icmp ne i64 %27, 0
br i1 %28, label %29, label %34
29: ; preds = %23
%30 = load i8**, i8*** %5
%31 = getelementptr inbounds i8*, i8** %30, i64 0
%32 = load i8*, i8** %31
%33 = call i32 @print_usage(i8* %32)
br label %34
34: ; preds = %29, %23
br label %35
35: ; preds = %34, %22
%36 = load i32, i32* %8
%37 = icmp ne i32 %36, 0
br i1 %37, label %38, label %46
38: ; preds = %35
%39 = load i32, i32* %4
%40 = icmp slt i32 %39, 4
br i1 %40, label %41, label %46
41: ; preds = %38
%42 = load i8**, i8*** %5
%43 = getelementptr inbounds i8*, i8** %42, i64 0
%44 = load i8*, i8** %43
%45 = call i32 @print_usage(i8* %44)
br label %46
46: ; preds = %41, %38, %35
%47 = load i8**, i8*** %5
%48 = getelementptr inbounds i8*, i8** %47, i64 2
%49 = load i8*, i8** %48
%50 = call i32* @fopen(i8* %49, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32* %50, i32** %7
%51 = load i32*, i32** %7
%52 = icmp eq i32* %51, null
br i1 %52, label %53, label %56
53: ; preds = %46
%54 = call i32 @perror(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0))
%55 = call i32 @exit(i32 -1)
unreachable
56: ; preds = %46
%57 = load i32, i32* %8
%58 = icmp ne i32 %57, 0
br i1 %58, label %59, label %70
59: ; preds = %56
%60 = load i8**, i8*** %5
%61 = getelementptr inbounds i8*, i8** %60, i64 3
%62 = load i8*, i8** %61
%63 = call i32* @fopen(i8* %62, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32* %63, i32** %6
%64 = load i32*, i32** %6
%65 = icmp eq i32* %64, null
br i1 %65, label %66, label %69
66: ; preds = %59
%67 = call i32 @perror(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.4, i64 0, i64 0))
%68 = call i32 @exit(i32 -1)
unreachable
69: ; preds = %59
br label %71
70: ; preds = %56
store i32* null, i32** %6
br label %71
71: ; preds = %70, %69
%72 = load i32*, i32** %6
%73 = load i32*, i32** %7
%74 = load i32, i32* %8
%75 = call i32 @libpdex_verify_model(i32* %72, i32* %73, i32 %74)
switch i32 %75, label %82 [
i32 -1, label %76
i32 0, label %78
i32 1, label %80
]
76: ; preds = %71
%77 = call i32 @perror(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.5, i64 0, i64 0))
store i32 -1, i32* %3
br label %82
78: ; preds = %71
%79 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.6, i64 0, i64 0))
store i32 0, i32* %3
br label %82
80: ; preds = %71
%81 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.7, i64 0, i64 0))
store i32 1, i32* %3
br label %82
82: ; preds = %76, %78, %80, %71
%83 = load i32, i32* %3
ret i32 %83
}

LLVM IR (-O2):
@.str = [4 x i8] c"SAT\00"
@.str.1 = [6 x i8] c"UNSAT\00"
@.str.2 = [2 x i8] c"r\00"
@.str.3 = [26 x i8] c"Can't open solver output.\00"
@.str.4 = [27 x i8] c"Can't open problem output.\00"
@.str.5 = [38 x i8] c"I/O or parser error. System I/O state\00"
@str = [13 x i8] c"Model valid.\00"
@str.8 = [15 x i8] c"Invalid model.\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp slt i32 %0, 3
br i1 %3, label %4, label %7
4: ; preds = %2
%5 = load i8*, i8** %1
%6 = tail call i32 @print_usage(i8* %5)
br label %7
7: ; preds = %4, %2
%8 = getelementptr inbounds i8*, i8** %1, i64 1
%9 = load i8*, i8** %8
%10 = tail call i64 @strcmp(i8* %9, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0))
%11 = icmp eq i64 %10, 0
br i1 %11, label %19, label %12
12: ; preds = %7
%13 = load i8*, i8** %8
%14 = tail call i64 @strcmp(i8* %13, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%15 = icmp eq i64 %14, 0
br i1 %15, label %29, label %16
16: ; preds = %12
%17 = load i8*, i8** %1
%18 = tail call i32 @print_usage(i8* %17)
br label %29
19: ; preds = %7
%20 = icmp slt i32 %0, 4
br i1 %20, label %21, label %24
21: ; preds = %19
%22 = load i8*, i8** %1
%23 = tail call i32 @print_usage(i8* %22)
br label %24
24: ; preds = %21, %19
%25 = getelementptr inbounds i8*, i8** %1, i64 2
%26 = load i8*, i8** %25
%27 = tail call i32* @fopen(i8* %26, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%28 = icmp eq i32* %27, null
br i1 %28, label %34, label %37
29: ; preds = %16, %12
%30 = getelementptr inbounds i8*, i8** %1, i64 2
%31 = load i8*, i8** %30
%32 = tail call i32* @fopen(i8* %31, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%33 = icmp eq i32* %32, null
br i1 %33, label %34, label %45
34: ; preds = %29, %24
%35 = tail call i32 @perror(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0))
%36 = tail call i32 @exit(i32 -1)
unreachable
37: ; preds = %24
%38 = getelementptr inbounds i8*, i8** %1, i64 3
%39 = load i8*, i8** %38
%40 = tail call i32* @fopen(i8* %39, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%41 = icmp eq i32* %40, null
br i1 %41, label %42, label %45
42: ; preds = %37
%43 = tail call i32 @perror(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.4, i64 0, i64 0))
%44 = tail call i32 @exit(i32 -1)
unreachable
45: ; preds = %29, %37
%46 = phi i32 [ 1, %37 ], [ 0, %29 ]
%47 = phi i32* [ %27, %37 ], [ %32, %29 ]
%48 = phi i32* [ %40, %37 ], [ null, %29 ]
%49 = tail call i32 @libpdex_verify_model(i32* %48, i32* %47, i32 %46)
switch i32 %49, label %56 [
i32 -1, label %50
i32 0, label %52
i32 1, label %54
]
50: ; preds = %45
%51 = tail call i32 @perror(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.5, i64 0, i64 0))
br label %56
52: ; preds = %45
%53 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @str.8, i64 0, i64 0))
br label %56
54: ; preds = %45
%55 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @str, i64 0, i64 0))
br label %56
56: ; preds = %45, %54, %52, %50
%57 = phi i32 [ 1, %54 ], [ 0, %52 ], [ -1, %50 ], [ 0, %45 ]
ret i32 %57
}