#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 */

/* Variables and functions */
int /*<<< orphan*/ TOR_ISPRINT(char const);
int /*<<< orphan*/ TOR_ISSPACE(char const);
int /*<<< orphan*/ strcmpstart(char const *, char *);
int body_is_plausible(const char *body, size_t len, int purpose) {
  int i;
  if (len == 0)
    return 1;
  if (len < 32)
    return 0;
  if (purpose == 19) {
    return (!strcmpstart(body, "onion-key"));
  }
  if (purpose != 3) {
    if (!strcmpstart(body, "router") ||
        !strcmpstart(body, "signed-directory") ||
        !strcmpstart(body, "network-status") ||
        !strcmpstart(body, "running-routers"))
      return 1;
    for (i = 0; i < 32; ++i) {
      if (!TOR_ISPRINT(body[i]) && !TOR_ISSPACE(body[i]))
        return 0;
    }
    return 1;
  } else {
    return 1;
  }
}


x86 assembly (clang, -O0):
<body_is_plausible>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    115a <body_is_plausible+0x2a>
movl   $0x1,-0x4(%rbp)
jmp    1291 <body_is_plausible+0x161>
cmpq   $0x20,-0x18(%rbp)
jae    1171 <body_is_plausible+0x41>
movl   $0x0,-0x4(%rbp)
jmp    1291 <body_is_plausible+0x161>
cmpl   $0x13,-0x1c(%rbp)
jne    11a0 <body_is_plausible+0x70>
mov    -0x10(%rbp),%rdi
lea    0xe7a(%rip),%rsi
call   1040 <strcmpstart@plt>
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x4(%rbp)
jmp    1291 <body_is_plausible+0x161>
cmpl   $0x3,-0x1c(%rbp)
je     128a <body_is_plausible+0x15a>
mov    -0x10(%rbp),%rdi
lea    0xe55(%rip),%rsi
call   1040 <strcmpstart@plt>
cmp    $0x0,%eax
je     120e <body_is_plausible+0xde>
mov    -0x10(%rbp),%rdi
lea    0xe43(%rip),%rsi
call   1040 <strcmpstart@plt>
cmp    $0x0,%eax
je     120e <body_is_plausible+0xde>
mov    -0x10(%rbp),%rdi
lea    0xe3b(%rip),%rsi
call   1040 <strcmpstart@plt>
cmp    $0x0,%eax
je     120e <body_is_plausible+0xde>
mov    -0x10(%rbp),%rdi
lea    0xe31(%rip),%rsi
call   1040 <strcmpstart@plt>
cmp    $0x0,%eax
jne    121a <body_is_plausible+0xea>
movl   $0x1,-0x4(%rbp)
jmp    1291 <body_is_plausible+0x161>
movl   $0x0,-0x20(%rbp)
cmpl   $0x20,-0x20(%rbp)
jge    127e <body_is_plausible+0x14e>
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1050 <TOR_ISPRINT@plt>
cmp    $0x0,%eax
jne    126b <body_is_plausible+0x13b>
mov    -0x10(%rbp),%rax
movslq -0x20(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1030 <TOR_ISSPACE@plt>
cmp    $0x0,%eax
jne    126b <body_is_plausible+0x13b>
movl   $0x0,-0x4(%rbp)
jmp    1291 <body_is_plausible+0x161>
jmp    1270 <body_is_plausible+0x140>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1221 <body_is_plausible+0xf1>
movl   $0x1,-0x4(%rbp)
jmp    1291 <body_is_plausible+0x161>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<body_is_plausible>:
push   %r14
push   %rbx
push   %rax
test   %rsi,%rsi
je     11fa <body_is_plausible+0xca>
xor    %eax,%eax
cmp    $0x20,%rsi
jb     11ff <body_is_plausible+0xcf>
cmp    $0x3,%edx
je     11fa <body_is_plausible+0xca>
mov    %rdi,%r14
cmp    $0x13,%edx
jne    1177 <body_is_plausible+0x47>
lea    0xe9f(%rip),%rsi
mov    %r14,%rdi
call   1040 <strcmpstart@plt>
mov    %eax,%ecx
xor    %eax,%eax
test   %ecx,%ecx
sete   %al
jmp    11ff <body_is_plausible+0xcf>
lea    0xe8c(%rip),%rsi
mov    %r14,%rdi
call   1040 <strcmpstart@plt>
test   %eax,%eax
je     11fa <body_is_plausible+0xca>
lea    0xe80(%rip),%rsi
mov    %r14,%rdi
call   1040 <strcmpstart@plt>
test   %eax,%eax
je     11fa <body_is_plausible+0xca>
lea    0xe7e(%rip),%rsi
mov    %r14,%rdi
call   1040 <strcmpstart@plt>
test   %eax,%eax
je     11fa <body_is_plausible+0xca>
lea    0xe7a(%rip),%rsi
mov    %r14,%rdi
call   1040 <strcmpstart@plt>
test   %eax,%eax
je     11fa <body_is_plausible+0xca>
xor    %ebx,%ebx
jmp    11da <body_is_plausible+0xaa>
nopw   0x0(%rax,%rax,1)
add    $0x1,%rbx
cmp    $0x20,%rbx
je     11fa <body_is_plausible+0xca>
movsbl (%r14,%rbx,1),%edi
call   1050 <TOR_ISPRINT@plt>
test   %eax,%eax
jne    11d0 <body_is_plausible+0xa0>
movsbl (%r14,%rbx,1),%edi
call   1030 <TOR_ISSPACE@plt>
test   %eax,%eax
jne    11d0 <body_is_plausible+0xa0>
xor    %eax,%eax
jmp    11ff <body_is_plausible+0xcf>
mov    $0x1,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [10 x i8] c"onion-key\00"
@.str.1 = [7 x i8] c"router\00"
@.str.2 = [17 x i8] c"signed-directory\00"
@.str.3 = [15 x i8] c"network-status\00"
@.str.4 = [16 x i8] c"running-routers\00"
define i32 @body_is_plausible(i8* %0, i64 %1, i32 %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i64
%7 = alloca i32
%8 = alloca i32
store i8* %0, i8** %5
store i64 %1, i64* %6
store i32 %2, i32* %7
%9 = load i64, i64* %6
%10 = icmp eq i64 %9, 0
br i1 %10, label %11, label %12
11: ; preds = %3
store i32 1, i32* %4
br label %72
12: ; preds = %3
%13 = load i64, i64* %6
%14 = icmp ult i64 %13, 32
br i1 %14, label %15, label %16
15: ; preds = %12
store i32 0, i32* %4
br label %72
16: ; preds = %12
%17 = load i32, i32* %7
%18 = icmp eq i32 %17, 19
br i1 %18, label %19, label %25
19: ; preds = %16
%20 = load i8*, i8** %5
%21 = call i32 @strcmpstart(i8* %20, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%22 = icmp ne i32 %21, 0
%23 = xor i1 %22, true
%24 = zext i1 %23 to i32
store i32 %24, i32* %4
br label %72
25: ; preds = %16
%26 = load i32, i32* %7
%27 = icmp ne i32 %26, 3
br i1 %27, label %28, label %71
28: ; preds = %25
%29 = load i8*, i8** %5
%30 = call i32 @strcmpstart(i8* %29, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%31 = icmp ne i32 %30, 0
br i1 %31, label %32, label %44
32: ; preds = %28
%33 = load i8*, i8** %5
%34 = call i32 @strcmpstart(i8* %33, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0))
%35 = icmp ne i32 %34, 0
br i1 %35, label %36, label %44
36: ; preds = %32
%37 = load i8*, i8** %5
%38 = call i32 @strcmpstart(i8* %37, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0))
%39 = icmp ne i32 %38, 0
br i1 %39, label %40, label %44
40: ; preds = %36
%41 = load i8*, i8** %5
%42 = call i32 @strcmpstart(i8* %41, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0))
%43 = icmp ne i32 %42, 0
br i1 %43, label %45, label %44
44: ; preds = %40, %36, %32, %28
store i32 1, i32* %4
br label %72
45: ; preds = %40
store i32 0, i32* %8
br label %46
46: ; preds = %67, %45
%47 = load i32, i32* %8
%48 = icmp slt i32 %47, 32
br i1 %48, label %49, label %70
49: ; preds = %46
%50 = load i8*, i8** %5
%51 = load i32, i32* %8
%52 = sext i32 %51 to i64
%53 = getelementptr inbounds i8, i8* %50, i64 %52
%54 = load i8, i8* %53
%55 = call i32 @TOR_ISPRINT(i8 signext %54)
%56 = icmp ne i32 %55, 0
br i1 %56, label %66, label %57
57: ; preds = %49
%58 = load i8*, i8** %5
%59 = load i32, i32* %8
%60 = sext i32 %59 to i64
%61 = getelementptr inbounds i8, i8* %58, i64 %60
%62 = load i8, i8* %61
%63 = call i32 @TOR_ISSPACE(i8 signext %62)
%64 = icmp ne i32 %63, 0
br i1 %64, label %66, label %65
65: ; preds = %57
store i32 0, i32* %4
br label %72
66: ; preds = %57, %49
br label %67
67: ; preds = %66
%68 = load i32, i32* %8
%69 = add nsw i32 %68, 1
store i32 %69, i32* %8
br label %46
70: ; preds = %46
store i32 1, i32* %4
br label %72
71: ; preds = %25
store i32 1, i32* %4
br label %72
72: ; preds = %71, %70, %65, %44, %19, %15, %11
%73 = load i32, i32* %4
ret i32 %73
}

LLVM IR (-O2):
@.str = [10 x i8] c"onion-key\00"
@.str.1 = [7 x i8] c"router\00"
@.str.2 = [17 x i8] c"signed-directory\00"
@.str.3 = [15 x i8] c"network-status\00"
@.str.4 = [16 x i8] c"running-routers\00"
define i32 @body_is_plausible(i8* %0, i64 %1, i32 %2) {
%4 = icmp eq i64 %1, 0
br i1 %4, label %37, label %5
5: ; preds = %3
%6 = icmp ult i64 %1, 32
br i1 %6, label %37, label %7
7: ; preds = %5
switch i32 %2, label %12 [
i32 19, label %8
i32 3, label %37
]
8: ; preds = %7
%9 = tail call i32 @strcmpstart(i8* %0, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%10 = icmp eq i32 %9, 0
%11 = zext i1 %10 to i32
br label %37
12: ; preds = %7
%13 = tail call i32 @strcmpstart(i8* %0, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
%14 = icmp eq i32 %13, 0
br i1 %14, label %37, label %15
15: ; preds = %12
%16 = tail call i32 @strcmpstart(i8* %0, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0))
%17 = icmp eq i32 %16, 0
br i1 %17, label %37, label %18
18: ; preds = %15
%19 = tail call i32 @strcmpstart(i8* %0, i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0))
%20 = icmp eq i32 %19, 0
br i1 %20, label %37, label %21
21: ; preds = %18
%22 = tail call i32 @strcmpstart(i8* %0, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.4, i64 0, i64 0))
%23 = icmp eq i32 %22, 0
br i1 %23, label %37, label %24
24: ; preds = %21, %34
%25 = phi i64 [ %35, %34 ], [ 0, %21 ]
%26 = getelementptr inbounds i8, i8* %0, i64 %25
%27 = load i8, i8* %26
%28 = tail call i32 @TOR_ISPRINT(i8 signext %27)
%29 = icmp eq i32 %28, 0
br i1 %29, label %30, label %34
30: ; preds = %24
%31 = load i8, i8* %26
%32 = tail call i32 @TOR_ISSPACE(i8 signext %31)
%33 = icmp eq i32 %32, 0
br i1 %33, label %37, label %34
34: ; preds = %24, %30
%35 = add nuw nsw i64 %25, 1
%36 = icmp eq i64 %35, 32
br i1 %36, label %37, label %24
37: ; preds = %34, %30, %7, %12, %15, %18, %21, %5, %3, %8
%38 = phi i32 [ %11, %8 ], [ 1, %3 ], [ 0, %5 ], [ 1, %21 ], [ 1, %18 ], [ 1, %15 ], [ 1, %12 ], [ 1, %7 ], [ 1, %34 ], [ 0, %30 ]
ret i32 %38
}