#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 strlen(char const *);
int check_viewport(const char *document) {
  if (strlen(document) < 3)
    return 0;
  if (document[0] != '%')
    return 0;
  if (document[1] != 'V')
    return 0;
  if (document[2] != '(' && document[2] != 'l' && document[2] != 'i')
    return 0;
  return 1;
}


x86 assembly (clang, -O0):
<check_viewport>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
cmp    $0x3,%eax
jge    113a <check_viewport+0x2a>
movl   $0x0,-0x4(%rbp)
jmp    11b9 <check_viewport+0xa9>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x25,%eax
je     1156 <check_viewport+0x46>
movl   $0x0,-0x4(%rbp)
jmp    11b9 <check_viewport+0xa9>
mov    -0x10(%rbp),%rax
movsbl 0x1(%rax),%eax
cmp    $0x56,%eax
je     1173 <check_viewport+0x63>
movl   $0x0,-0x4(%rbp)
jmp    11b9 <check_viewport+0xa9>
mov    -0x10(%rbp),%rax
movsbl 0x2(%rax),%eax
cmp    $0x28,%eax
je     11b2 <check_viewport+0xa2>
mov    -0x10(%rbp),%rax
movsbl 0x2(%rax),%eax
cmp    $0x6c,%eax
je     11b2 <check_viewport+0xa2>
mov    -0x10(%rbp),%rax
movsbl 0x2(%rax),%eax
cmp    $0x69,%eax
je     11b2 <check_viewport+0xa2>
movl   $0x0,-0x4(%rbp)
jmp    11b9 <check_viewport+0xa9>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<check_viewport>:
push   %rbx
mov    %rdi,%rbx
call   1030 <strlen@plt>
mov    %eax,%ecx
xor    %eax,%eax
cmp    $0x3,%ecx
jl     1144 <check_viewport+0x34>
cmpb   $0x25,(%rbx)
jne    1144 <check_viewport+0x34>
cmpb   $0x56,0x1(%rbx)
jne    1144 <check_viewport+0x34>
mov    0x2(%rbx),%cl
cmp    $0x28,%cl
je     113f <check_viewport+0x2f>
cmp    $0x6c,%cl
je     113f <check_viewport+0x2f>
cmp    $0x69,%cl
jne    1144 <check_viewport+0x34>
mov    $0x1,%eax
pop    %rbx
ret

LLVM IR (-O0):
define i32 @check_viewport(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
store i8* %0, i8** %3
%4 = load i8*, i8** %3
%5 = call i32 @strlen(i8* %4)
%6 = icmp slt i32 %5, 3
br i1 %6, label %7, label %8
7: ; preds = %1
store i32 0, i32* %2
br label %42
8: ; preds = %1
%9 = load i8*, i8** %3
%10 = getelementptr inbounds i8, i8* %9, i64 0
%11 = load i8, i8* %10
%12 = sext i8 %11 to i32
%13 = icmp ne i32 %12, 37
br i1 %13, label %14, label %15
14: ; preds = %8
store i32 0, i32* %2
br label %42
15: ; preds = %8
%16 = load i8*, i8** %3
%17 = getelementptr inbounds i8, i8* %16, i64 1
%18 = load i8, i8* %17
%19 = sext i8 %18 to i32
%20 = icmp ne i32 %19, 86
br i1 %20, label %21, label %22
21: ; preds = %15
store i32 0, i32* %2
br label %42
22: ; preds = %15
%23 = load i8*, i8** %3
%24 = getelementptr inbounds i8, i8* %23, i64 2
%25 = load i8, i8* %24
%26 = sext i8 %25 to i32
%27 = icmp ne i32 %26, 40
br i1 %27, label %28, label %41
28: ; preds = %22
%29 = load i8*, i8** %3
%30 = getelementptr inbounds i8, i8* %29, i64 2
%31 = load i8, i8* %30
%32 = sext i8 %31 to i32
%33 = icmp ne i32 %32, 108
br i1 %33, label %34, label %41
34: ; preds = %28
%35 = load i8*, i8** %3
%36 = getelementptr inbounds i8, i8* %35, i64 2
%37 = load i8, i8* %36
%38 = sext i8 %37 to i32
%39 = icmp ne i32 %38, 105
br i1 %39, label %40, label %41
40: ; preds = %34
store i32 0, i32* %2
br label %42
41: ; preds = %34, %28, %22
store i32 1, i32* %2
br label %42
42: ; preds = %41, %40, %21, %14, %7
%43 = load i32, i32* %2
ret i32 %43
}

LLVM IR (-O2):
define i32 @check_viewport(i8* %0) {
%2 = tail call i32 @strlen(i8* %0)
%3 = icmp slt i32 %2, 3
br i1 %3, label %15, label %4
4: ; preds = %1
%5 = load i8, i8* %0
%6 = icmp eq i8 %5, 37
br i1 %6, label %7, label %15
7: ; preds = %4
%8 = getelementptr inbounds i8, i8* %0, i64 1
%9 = load i8, i8* %8
%10 = icmp eq i8 %9, 86
br i1 %10, label %11, label %15
11: ; preds = %7
%12 = getelementptr inbounds i8, i8* %0, i64 2
%13 = load i8, i8* %12
switch i8 %13, label %15 [
i8 40, label %14
i8 108, label %14
i8 105, label %14
]
14: ; preds = %11, %11, %11
br label %15
15: ; preds = %11, %7, %4, %1, %14
%16 = phi i32 [ 1, %14 ], [ 0, %1 ], [ 0, %4 ], [ 0, %7 ], [ 0, %11 ]
ret i32 %16
}