#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 */
char *malloc(int);
scalar_t__ strcmp(char *, char *);
int words(char *);
int checkHost(char *ligne) {
  char *buffer = malloc(6 * sizeof(char));
  int i;
  for (i = 0; i < 6; ++i) {
    buffer[i] = ligne[i];
  }
  if (strcmp(buffer, "Host: ") != 0) {
    return -1;
  }
  if (words(ligne) != 2) {
    return -1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<checkHost>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    $0x6,%edi
call   1050 <malloc@plt>
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
cmpl   $0x6,-0x1c(%rbp)
jge    117f <checkHost+0x4f>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,1),%dl
mov    -0x18(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1151 <checkHost+0x21>
mov    -0x18(%rbp),%rdi
lea    0xe76(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
je     11a5 <checkHost+0x75>
movl   $0xffffffff,-0x4(%rbp)
jmp    11ca <checkHost+0x9a>
mov    -0x10(%rbp),%rdi
call   1040 <words@plt>
cmp    $0x2,%eax
je     11c3 <checkHost+0x93>
movl   $0xffffffff,-0x4(%rbp)
jmp    11ca <checkHost+0x9a>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<checkHost>:
push   %rbx
mov    %rdi,%rbx
mov    $0x6,%edi
call   1050 <malloc@plt>
mov    (%rbx),%ecx
mov    %ecx,(%rax)
movzwl 0x4(%rbx),%ecx
mov    %cx,0x4(%rax)
lea    0xeaf(%rip),%rsi
mov    %rax,%rdi
call   1030 <strcmp@plt>
mov    %rax,%rcx
mov    $0xffffffff,%eax
test   %rcx,%rcx
je     1168 <checkHost+0x38>
pop    %rbx
ret
mov    %rbx,%rdi
call   1040 <words@plt>
mov    %eax,%ecx
xor    %eax,%eax
cmp    $0x2,%ecx
setne  %al
neg    %eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [7 x i8] c"Host: \00"
define i32 @checkHost(i8* %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i32
store i8* %0, i8** %3
%6 = call i8* @malloc(i32 6)
store i8* %6, i8** %4
store i32 0, i32* %5
br label %7
7: ; preds = %20, %1
%8 = load i32, i32* %5
%9 = icmp slt i32 %8, 6
br i1 %9, label %10, label %23
10: ; preds = %7
%11 = load i8*, i8** %3
%12 = load i32, i32* %5
%13 = sext i32 %12 to i64
%14 = getelementptr inbounds i8, i8* %11, i64 %13
%15 = load i8, i8* %14
%16 = load i8*, i8** %4
%17 = load i32, i32* %5
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds i8, i8* %16, i64 %18
store i8 %15, i8* %19
br label %20
20: ; preds = %10
%21 = load i32, i32* %5
%22 = add nsw i32 %21, 1
store i32 %22, i32* %5
br label %7
23: ; preds = %7
%24 = load i8*, i8** %4
%25 = call i64 @strcmp(i8* %24, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%26 = icmp ne i64 %25, 0
br i1 %26, label %27, label %28
27: ; preds = %23
store i32 -1, i32* %2
br label %34
28: ; preds = %23
%29 = load i8*, i8** %3
%30 = call i32 @words(i8* %29)
%31 = icmp ne i32 %30, 2
br i1 %31, label %32, label %33
32: ; preds = %28
store i32 -1, i32* %2
br label %34
33: ; preds = %28
store i32 0, i32* %2
br label %34
34: ; preds = %33, %32, %27
%35 = load i32, i32* %2
ret i32 %35
}

LLVM IR (-O2):
@.str = [7 x i8] c"Host: \00"
define i32 @checkHost(i8* %0) {
%2 = tail call dereferenceable_or_null(6) i8* @malloc(i32 6)
%3 = tail call i64 @strcmp(i8* %2, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%4 = icmp eq i64 %3, 0
br i1 %4, label %5, label %9
5: ; preds = %1
%6 = tail call i32 @words(i8* %0)
%7 = icmp ne i32 %6, 2
%8 = sext i1 %7 to i32
br label %9
9: ; preds = %5, %1
%10 = phi i32 [ -1, %1 ], [ %8, %5 ]
ret i32 %10
}