#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 */
scalar_t__ strcmp(char const *, char *);
int check_order_by(const char *s) {
  size_t i;
  char *valid[] = {"package", "version", "description", "rating"};
  size_t num = sizeof valid / sizeof valid[0];
  for (i = 0; i < num; i++)
    if (strcmp(s, valid[i]) == 0)
      return 1;
  return 0;
}


x86 assembly (clang, -O0):
<check_order_by>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x10(%rbp)
mov    0x2cdd(%rip),%rax
mov    %rax,-0x40(%rbp)
mov    0x2cda(%rip),%rax
mov    %rax,-0x38(%rbp)
mov    0x2cd7(%rip),%rax
mov    %rax,-0x30(%rbp)
mov    0x2cd4(%rip),%rax
mov    %rax,-0x28(%rbp)
movq   $0x4,-0x48(%rbp)
movq   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%rax
cmp    -0x48(%rbp),%rax
jae    11a4 <check_order_by+0x94>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rax
mov    -0x40(%rbp,%rax,8),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    118e <check_order_by+0x7e>
movl   $0x1,-0x4(%rbp)
jmp    11ab <check_order_by+0x9b>
jmp    1193 <check_order_by+0x83>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    1158 <check_order_by+0x48>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<check_order_by>:
push   %rbp
push   %rbx
push   %rax
mov    %rdi,%rbx
lea    0xee3(%rip),%rsi
call   1030 <strcmp@plt>
mov    $0x1,%ebp
test   %rax,%rax
je     116c <check_order_by+0x5c>
lea    0xed5(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     116c <check_order_by+0x5c>
lea    0xec9(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     116c <check_order_by+0x5c>
lea    0xec1(%rip),%rsi
mov    %rbx,%rdi
call   1030 <strcmp@plt>
xor    %ebp,%ebp
test   %rax,%rax
sete   %bpl
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [8 x i8] c"package\00"
@.str.1 = [8 x i8] c"version\00"
@.str.2 = [12 x i8] c"description\00"
@.str.3 = [7 x i8] c"rating\00"
@__const.check_order_by.valid = [4 x i8*] [i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i32 0, i32 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i32 0, i32 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i32 0, i32 0)]
define i32 @check_order_by(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i64
%5 = alloca [4 x i8*]
%6 = alloca i64
store i8* %0, i8** %3
%7 = bitcast [4 x i8*]* %5 to i8*
store i64 4, i64* %6
store i64 0, i64* %4
br label %8
8: ; preds = %21, %1
%9 = load i64, i64* %4
%10 = load i64, i64* %6
%11 = icmp ult i64 %9, %10
br i1 %11, label %12, label %24
12: ; preds = %8
%13 = load i8*, i8** %3
%14 = load i64, i64* %4
%15 = getelementptr inbounds [4 x i8*], [4 x i8*]* %5, i64 0, i64 %14
%16 = load i8*, i8** %15
%17 = call i64 @strcmp(i8* %13, i8* %16)
%18 = icmp eq i64 %17, 0
br i1 %18, label %19, label %20
19: ; preds = %12
store i32 1, i32* %2
br label %25
20: ; preds = %12
br label %21
21: ; preds = %20
%22 = load i64, i64* %4
%23 = add i64 %22, 1
store i64 %23, i64* %4
br label %8
24: ; preds = %8
store i32 0, i32* %2
br label %25
25: ; preds = %24, %19
%26 = load i32, i32* %2
ret i32 %26
}

LLVM IR (-O2):
@.str = [8 x i8] c"package\00"
@.str.1 = [8 x i8] c"version\00"
@.str.2 = [12 x i8] c"description\00"
@.str.3 = [7 x i8] c"rating\00"
define i32 @check_order_by(i8* %0) {
%2 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%3 = icmp eq i64 %2, 0
br i1 %3, label %14, label %4
4: ; preds = %1
%5 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0))
%6 = icmp eq i64 %5, 0
br i1 %6, label %14, label %7
7: ; preds = %4
%8 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0))
%9 = icmp eq i64 %8, 0
br i1 %9, label %14, label %10
10: ; preds = %7
%11 = tail call i64 @strcmp(i8* %0, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
%12 = icmp eq i64 %11, 0
%13 = zext i1 %12 to i32
br label %14
14: ; preds = %10, %7, %4, %1
%15 = phi i32 [ 1, %1 ], [ 1, %4 ], [ 1, %7 ], [ %13, %10 ]
ret i32 %15
}