#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 */
size_t strlen(char const *);
int validate_source(const char *source) {
  size_t i;
  if (source == NULL) {
    return -1;
  }
  if (strlen(source) > 250) {
    return -1;
  }
  for (i = 0; i < strlen(source); i++) {
    if (source[i] == ' ') {
      return -1;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<validate_source>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1133 <validate_source+0x23>
movl   $0xffffffff,-0x4(%rbp)
jmp    11bb <validate_source+0xab>
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
cmp    $0xfa,%rax
jbe    1154 <validate_source+0x44>
movl   $0xffffffff,-0x4(%rbp)
jmp    11bb <validate_source+0xab>
movq   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %rax,%rcx
mov    -0x20(%rbp),%rax
cmp    %rcx,%rax
jae    11b4 <validate_source+0xa4>
mov    -0x10(%rbp),%rax
mov    -0x18(%rbp),%rcx
movsbl (%rax,%rcx,1),%eax
cmp    $0x20,%eax
jne    119e <validate_source+0x8e>
movl   $0xffffffff,-0x4(%rbp)
jmp    11bb <validate_source+0xab>
jmp    11a3 <validate_source+0x93>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    115c <validate_source+0x4c>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<validate_source>:
push   %rbp
push   %rbx
push   %rax
mov    $0xffffffff,%ebp
test   %rdi,%rdi
je     1151 <validate_source+0x41>
mov    %rdi,%rbx
call   1030 <strlen@plt>
cmp    $0xfa,%rax
ja     1151 <validate_source+0x41>
test   %rax,%rax
je     114f <validate_source+0x3f>
xor    %ecx,%ecx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
cmpb   $0x20,(%rbx,%rcx,1)
je     1151 <validate_source+0x41>
add    $0x1,%rcx
cmp    %rcx,%rax
jne    1140 <validate_source+0x30>
xor    %ebp,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
define i32 @validate_source(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i64
store i8* %0, i8** %3
%5 = load i8*, i8** %3
%6 = icmp eq i8* %5, null
br i1 %6, label %7, label %8
7: ; preds = %1
store i32 -1, i32* %2
br label %32
8: ; preds = %1
%9 = load i8*, i8** %3
%10 = call i64 @strlen(i8* %9)
%11 = icmp ugt i64 %10, 250
br i1 %11, label %12, label %13
12: ; preds = %8
store i32 -1, i32* %2
br label %32
13: ; preds = %8
store i64 0, i64* %4
br label %14
14: ; preds = %28, %13
%15 = load i64, i64* %4
%16 = load i8*, i8** %3
%17 = call i64 @strlen(i8* %16)
%18 = icmp ult i64 %15, %17
br i1 %18, label %19, label %31
19: ; preds = %14
%20 = load i8*, i8** %3
%21 = load i64, i64* %4
%22 = getelementptr inbounds i8, i8* %20, i64 %21
%23 = load i8, i8* %22
%24 = sext i8 %23 to i32
%25 = icmp eq i32 %24, 32
br i1 %25, label %26, label %27
26: ; preds = %19
store i32 -1, i32* %2
br label %32
27: ; preds = %19
br label %28
28: ; preds = %27
%29 = load i64, i64* %4
%30 = add i64 %29, 1
store i64 %30, i64* %4
br label %14
31: ; preds = %14
store i32 0, i32* %2
br label %32
32: ; preds = %31, %26, %12, %7
%33 = load i32, i32* %2
ret i32 %33
}

LLVM IR (-O2):
define i32 @validate_source(i8* %0) {
%2 = icmp eq i8* %0, null
br i1 %2, label %16, label %3
3: ; preds = %1
%4 = tail call i64 @strlen(i8* %0)
%5 = icmp ugt i64 %4, 250
br i1 %5, label %16, label %6
6: ; preds = %3
%7 = icmp eq i64 %4, 0
br i1 %7, label %16, label %10
8: ; preds = %10
%9 = icmp eq i64 %15, %4
br i1 %9, label %16, label %10
10: ; preds = %6, %8
%11 = phi i64 [ %15, %8 ], [ 0, %6 ]
%12 = getelementptr inbounds i8, i8* %0, i64 %11
%13 = load i8, i8* %12
%14 = icmp eq i8 %13, 32
%15 = add nuw i64 %11, 1
br i1 %14, label %16, label %8
16: ; preds = %10, %8, %6, %3, %1
%17 = phi i32 [ -1, %1 ], [ -1, %3 ], [ 0, %6 ], [ -1, %10 ], [ 0, %8 ]
ret i32 %17
}