#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*/ printf(char *);
int /*<<< orphan*/ sscanf(char *, char *, char *, char *, int *, int *);
scalar_t__ strcmp(char *, char *);
int verif(char buf[], char get[], char slash[], int M, int m) {
  sscanf(buf, "%s %s HTTP/%d.%d", get, slash, &M, &m);
  if (strcmp(get, "GET") == 0) {
    if (M == 1 && (m == 1 || m == 0)) {
      if (strcmp(slash, "/") == 0) {
        printf("OK \n");
        return 0;
      } else {
        return -2;
      }
    } else {
      return -1;
    }
  } else {
    return -1;
  }
}


x86 assembly (clang, -O0):
<verif>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %ecx,-0x24(%rbp)
mov    %r8d,-0x28(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rcx
lea    0xea2(%rip),%rsi
lea    -0x24(%rbp),%r8
lea    -0x28(%rbp),%r9
call   1050 <sscanf@plt>
mov    -0x18(%rbp),%rdi
lea    0xe9b(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    11ed <verif+0xbd>
cmpl   $0x1,-0x24(%rbp)
jne    11e1 <verif+0xb1>
cmpl   $0x1,-0x28(%rbp)
je     11a3 <verif+0x73>
cmpl   $0x0,-0x28(%rbp)
jne    11e1 <verif+0xb1>
mov    -0x20(%rbp),%rdi
lea    0xe67(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    11d5 <verif+0xa5>
lea    0xe53(%rip),%rdi
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    11f4 <verif+0xc4>
movl   $0xfffffffe,-0x4(%rbp)
jmp    11f4 <verif+0xc4>
movl   $0xffffffff,-0x4(%rbp)
jmp    11f4 <verif+0xc4>
movl   $0xffffffff,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<verif>:
push   %r14
push   %rbx
push   %rax
mov    %rdx,%r14
mov    %rsi,%rbx
mov    %ecx,0x4(%rsp)
mov    %r8d,(%rsp)
lea    0xeb7(%rip),%rsi
lea    0x4(%rsp),%r8
mov    %rsp,%r9
mov    %rbx,%rdx
mov    %r14,%rcx
call   1050 <sscanf@plt>
lea    0xeae(%rip),%rsi
mov    %rbx,%rdi
call   1040 <strcmp@plt>
mov    %rax,%rcx
mov    $0xffffffff,%eax
test   %rcx,%rcx
je     1180 <verif+0x50>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
cmpl   $0x1,0x4(%rsp)
jne    1178 <verif+0x48>
cmpl   $0x1,(%rsp)
ja     1178 <verif+0x48>
lea    0xe81(%rip),%rsi
mov    %r14,%rdi
call   1040 <strcmp@plt>
mov    %rax,%rcx
mov    $0xfffffffe,%eax
test   %rcx,%rcx
jne    1178 <verif+0x48>
lea    0xe67(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
jmp    1178 <verif+0x48>

LLVM IR (-O0):
@.str = [17 x i8] c"%s %s HTTP/%d.%d\00"
@.str.1 = [4 x i8] c"GET\00"
@.str.2 = [2 x i8] c"/\00"
@.str.3 = [5 x i8] c"OK \0A\00"
define i32 @verif(i8* %0, i8* %1, i8* %2, i32 %3, i32 %4) {
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i32
%11 = alloca i32
store i8* %0, i8** %7
store i8* %1, i8** %8
store i8* %2, i8** %9
store i32 %3, i32* %10
store i32 %4, i32* %11
%12 = load i8*, i8** %7
%13 = load i8*, i8** %8
%14 = load i8*, i8** %9
%15 = call i32 @sscanf(i8* %12, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8* %13, i8* %14, i32* %10, i32* %11)
%16 = load i8*, i8** %8
%17 = call i64 @strcmp(i8* %16, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%18 = icmp eq i64 %17, 0
br i1 %18, label %19, label %36
19: ; preds = %5
%20 = load i32, i32* %10
%21 = icmp eq i32 %20, 1
br i1 %21, label %22, label %35
22: ; preds = %19
%23 = load i32, i32* %11
%24 = icmp eq i32 %23, 1
br i1 %24, label %28, label %25
25: ; preds = %22
%26 = load i32, i32* %11
%27 = icmp eq i32 %26, 0
br i1 %27, label %28, label %35
28: ; preds = %25, %22
%29 = load i8*, i8** %9
%30 = call i64 @strcmp(i8* %29, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%31 = icmp eq i64 %30, 0
br i1 %31, label %32, label %34
32: ; preds = %28
%33 = call i32 @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.3, i64 0, i64 0))
store i32 0, i32* %6
br label %37
34: ; preds = %28
store i32 -2, i32* %6
br label %37
35: ; preds = %25, %19
store i32 -1, i32* %6
br label %37
36: ; preds = %5
store i32 -1, i32* %6
br label %37
37: ; preds = %36, %35, %34, %32
%38 = load i32, i32* %6
ret i32 %38
}

LLVM IR (-O2):
@.str = [17 x i8] c"%s %s HTTP/%d.%d\00"
@.str.1 = [4 x i8] c"GET\00"
@.str.2 = [2 x i8] c"/\00"
@str = [4 x i8] c"OK \00"
define i32 @verif(i8* nocapture %0, i8* %1, i8* %2, i32 %3, i32 %4) {
%6 = alloca i32
%7 = alloca i32
store i32 %3, i32* %6
store i32 %4, i32* %7
%8 = call i32 @sscanf(i8* %0, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str, i64 0, i64 0), i8* %1, i8* %2, i32* %6, i32* %7)
%9 = call i64 @strcmp(i8* %1, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%10 = icmp eq i64 %9, 0
br i1 %10, label %11, label %22
11: ; preds = %5
%12 = load i32, i32* %6
%13 = icmp eq i32 %12, 1
%14 = load i32, i32* %7
%15 = icmp ult i32 %14, 2
%16 = select i1 %13, i1 %15, i1 false
br i1 %16, label %17, label %22
17: ; preds = %11
%18 = call i64 @strcmp(i8* %2, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%19 = icmp eq i64 %18, 0
br i1 %19, label %20, label %22
20: ; preds = %17
%21 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @str, i64 0, i64 0))
br label %22
22: ; preds = %5, %11, %17, %20
%23 = phi i32 [ 0, %20 ], [ -2, %17 ], [ -1, %11 ], [ -1, %5 ]
ret i32 %23
}