#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*/ fgets(char *, int, int /*<<< orphan*/ *);
scalar_t__ libpdex_search_for(int /*<<< orphan*/ *, char);
scalar_t__ strcmp(char *, char *);
size_t strlen(char *);
int libpdex_get_sat_state(FILE *file) {
  if (libpdex_search_for(file, 's')) {
    char buffer[100];
    int is_sat;
    size_t buf_len;
    fgets(buffer, 100, file);
    buf_len = strlen(buffer);
    while (buf_len--) {
      if ((buffer[buf_len] == ' ') || (buffer[buf_len] == '\n')) {
        buffer[buf_len] = 0;
      } else {
        break;
      }
    }
    is_sat = (strcmp(buffer, " SATISFIABLE") == 0);
    if ((!is_sat) && (strcmp(buffer, " UNSATISFIABLE") != 0)) {
      return -1;
    }
    return is_sat;
  }
  return -1;
}


x86 assembly (clang, -O0):
<libpdex_get_sat_state>:
push   %rbp
mov    %rsp,%rbp
sub    $0x90,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
mov    $0x73,%esi
call   1060 <libpdex_search_for@plt>
cmp    $0x0,%rax
je     1250 <libpdex_get_sat_state+0x110>
lea    -0x80(%rbp),%rdi
mov    -0x10(%rbp),%rdx
mov    $0x64,%esi
call   1040 <fgets@plt>
lea    -0x80(%rbp),%rdi
call   1030 <strlen@plt>
mov    %rax,-0x90(%rbp)
mov    -0x90(%rbp),%rax
mov    %rax,%rcx
add    $0xffffffffffffffff,%rcx
mov    %rcx,-0x90(%rbp)
cmp    $0x0,%rax
je     11ed <libpdex_get_sat_state+0xad>
mov    -0x90(%rbp),%rax
movsbl -0x80(%rbp,%rax,1),%eax
cmp    $0x20,%eax
je     11d2 <libpdex_get_sat_state+0x92>
mov    -0x90(%rbp),%rax
movsbl -0x80(%rbp,%rax,1),%eax
cmp    $0xa,%eax
jne    11e3 <libpdex_get_sat_state+0xa3>
mov    -0x90(%rbp),%rax
movb   $0x0,-0x80(%rbp,%rax,1)
jmp    11e8 <libpdex_get_sat_state+0xa8>
jmp    11ed <libpdex_get_sat_state+0xad>
jmp    1189 <libpdex_get_sat_state+0x49>
lea    -0x80(%rbp),%rdi
lea    0xe08(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
sete   %al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x84(%rbp)
cmpl   $0x0,-0x84(%rbp)
jne    1242 <libpdex_get_sat_state+0x102>
lea    -0x80(%rbp),%rdi
lea    0xde6(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
je     1242 <libpdex_get_sat_state+0x102>
movl   $0xffffffff,-0x4(%rbp)
jmp    1257 <libpdex_get_sat_state+0x117>
mov    -0x84(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    1257 <libpdex_get_sat_state+0x117>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x90,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<libpdex_get_sat_state>:
push   %rbp
push   %r14
push   %rbx
sub    $0x70,%rsp
mov    %rdi,%rbx
mov    $0x73,%esi
call   1060 <libpdex_search_for@plt>
test   %rax,%rax
je     11d7 <libpdex_get_sat_state+0x97>
mov    %rsp,%r14
mov    %r14,%rdi
mov    $0x64,%esi
mov    %rbx,%rdx
call   1040 <fgets@plt>
mov    %r14,%rdi
call   1030 <strlen@plt>
test   %rax,%rax
jne    118b <libpdex_get_sat_state+0x4b>
jmp    119a <libpdex_get_sat_state+0x5a>
nopl   0x0(%rax)
movb   $0x0,-0x1(%rsp,%rax,1)
add    $0xffffffffffffffff,%rax
je     119a <libpdex_get_sat_state+0x5a>
movzbl -0x1(%rsp,%rax,1),%ecx
cmp    $0x20,%cl
je     1180 <libpdex_get_sat_state+0x40>
cmp    $0xa,%cl
je     1180 <libpdex_get_sat_state+0x40>
lea    0xe5f(%rip),%rsi
mov    %rsp,%rdi
call   1050 <strcmp@plt>
xor    %ebx,%ebx
test   %rax,%rax
sete   %bpl
je     11d0 <libpdex_get_sat_state+0x90>
lea    0xe52(%rip),%rsi
mov    %rsp,%rdi
call   1050 <strcmp@plt>
mov    %rax,%rcx
mov    $0xffffffff,%eax
test   %rcx,%rcx
jne    11dc <libpdex_get_sat_state+0x9c>
mov    %bpl,%bl
mov    %ebx,%eax
jmp    11dc <libpdex_get_sat_state+0x9c>
mov    $0xffffffff,%eax
add    $0x70,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [13 x i8] c" SATISFIABLE\00"
@.str.1 = [15 x i8] c" UNSATISFIABLE\00"
define i32 @libpdex_get_sat_state(i32* %0) {
%2 = alloca i32
%3 = alloca i32*
%4 = alloca [100 x i8]
%5 = alloca i32
%6 = alloca i64
store i32* %0, i32** %3
%7 = load i32*, i32** %3
%8 = call i64 @libpdex_search_for(i32* %7, i8 signext 115)
%9 = icmp ne i64 %8, 0
br i1 %9, label %10, label %51
10: ; preds = %1
%11 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 0
%12 = load i32*, i32** %3
%13 = call i32 @fgets(i8* %11, i32 100, i32* %12)
%14 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 0
%15 = call i64 @strlen(i8* %14)
store i64 %15, i64* %6
br label %16
16: ; preds = %36, %10
%17 = load i64, i64* %6
%18 = add i64 %17, -1
store i64 %18, i64* %6
%19 = icmp ne i64 %17, 0
br i1 %19, label %20, label %37
20: ; preds = %16
%21 = load i64, i64* %6
%22 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 %21
%23 = load i8, i8* %22
%24 = sext i8 %23 to i32
%25 = icmp eq i32 %24, 32
br i1 %25, label %32, label %26
26: ; preds = %20
%27 = load i64, i64* %6
%28 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 %27
%29 = load i8, i8* %28
%30 = sext i8 %29 to i32
%31 = icmp eq i32 %30, 10
br i1 %31, label %32, label %35
32: ; preds = %26, %20
%33 = load i64, i64* %6
%34 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 %33
store i8 0, i8* %34
br label %36
35: ; preds = %26
br label %37
36: ; preds = %32
br label %16
37: ; preds = %35, %16
%38 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 0
%39 = call i64 @strcmp(i8* %38, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
%40 = icmp eq i64 %39, 0
%41 = zext i1 %40 to i32
store i32 %41, i32* %5
%42 = load i32, i32* %5
%43 = icmp ne i32 %42, 0
br i1 %43, label %49, label %44
44: ; preds = %37
%45 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 0
%46 = call i64 @strcmp(i8* %45, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0))
%47 = icmp ne i64 %46, 0
br i1 %47, label %48, label %49
48: ; preds = %44
store i32 -1, i32* %2
br label %52
49: ; preds = %44, %37
%50 = load i32, i32* %5
store i32 %50, i32* %2
br label %52
51: ; preds = %1
store i32 -1, i32* %2
br label %52
52: ; preds = %51, %49, %48
%53 = load i32, i32* %2
ret i32 %53
}

LLVM IR (-O2):
@.str = [13 x i8] c" SATISFIABLE\00"
@.str.1 = [15 x i8] c" UNSATISFIABLE\00"
define i32 @libpdex_get_sat_state(i32* %0) {
%2 = alloca [100 x i8]
%3 = tail call i64 @libpdex_search_for(i32* %0, i8 signext 115)
%4 = icmp eq i64 %3, 0
br i1 %4, label %27, label %5
5: ; preds = %1
%6 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%7 = call i32 @fgets(i8* %6, i32 100, i32* %0)
%8 = call i64 @strlen(i8* %6)
%9 = icmp eq i64 %8, 0
br i1 %9, label %17, label %10
10: ; preds = %5, %15
%11 = phi i64 [ %12, %15 ], [ %8, %5 ]
%12 = add i64 %11, -1
%13 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 %12
%14 = load i8, i8* %13
switch i8 %14, label %17 [
i8 32, label %15
i8 10, label %15
]
15: ; preds = %10, %10
store i8 0, i8* %13
%16 = icmp eq i64 %12, 0
br i1 %16, label %17, label %10
17: ; preds = %15, %10, %5
%18 = call i64 @strcmp(i8* %6, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
%19 = icmp eq i64 %18, 0
%20 = zext i1 %19 to i32
br i1 %19, label %24, label %21
21: ; preds = %17
%22 = call i64 @strcmp(i8* %6, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0))
%23 = icmp eq i64 %22, 0
br i1 %23, label %24, label %25
24: ; preds = %21, %17
br label %25
25: ; preds = %21, %24
%26 = phi i32 [ %20, %24 ], [ -1, %21 ]
br label %27
27: ; preds = %1, %25
%28 = phi i32 [ %26, %25 ], [ -1, %1 ]
ret i32 %28
}