#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 *, char *);
int com_response_ok(char *response, unsigned int len) {
  char first_token[len];
  int i = 0;
  for (; response[i] != ' ' && i < 256; i++) {
    first_token[i] = response[i];
  }
  first_token[i + 1] = 0;
  if (strcmp(first_token, "ok") == 0) {
    return 1;
  } else {
    return 0;
  }
}


x86 assembly (clang, -O0):
<com_response_ok>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x20(%rbp)
mov    %rax,%rdx
add    $0xf,%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x38(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x28(%rbp)
movl   $0x0,-0x2c(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x2c(%rbp),%rcx
movsbl (%rax,%rcx,1),%ecx
xor    %eax,%eax
cmp    $0x20,%ecx
mov    %al,-0x39(%rbp)
je     1173 <com_response_ok+0x63>
cmpl   $0x100,-0x2c(%rbp)
setl   %al
mov    %al,-0x39(%rbp)
mov    -0x39(%rbp),%al
test   $0x1,%al
jne    1183 <com_response_ok+0x73>
jmp    11a7 <com_response_ok+0x97>
mov    -0x38(%rbp),%rax
mov    -0x10(%rbp),%rcx
movslq -0x2c(%rbp),%rdx
mov    (%rcx,%rdx,1),%dl
movslq -0x2c(%rbp),%rcx
mov    %dl,(%rax,%rcx,1)
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    114c <com_response_ok+0x3c>
mov    -0x38(%rbp),%rdi
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
cltq
movb   $0x0,(%rdi,%rax,1)
lea    0xe42(%rip),%rsi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    11e0 <com_response_ok+0xd0>
movl   $0x1,-0x4(%rbp)
movl   $0x1,-0x30(%rbp)
jmp    11ee <com_response_ok+0xde>
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x30(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<com_response_ok>:
push   %rbp
mov    %rsp,%rbp
mov    %rdi,%rax
mov    %esi,%ecx
mov    %rsp,%rdi
add    $0xf,%rcx
and    $0xfffffffffffffff0,%rcx
sub    %rcx,%rdi
mov    %rdi,%rsp
mov    (%rax),%cl
mov    $0x1,%edx
cmp    $0x20,%cl
je     1161 <com_response_ok+0x51>
xor    %esi,%esi
nopl   0x0(%rax,%rax,1)
mov    %cl,(%rdi,%rsi,1)
lea    0x1(%rsi),%rdx
movzbl 0x1(%rax,%rsi,1),%ecx
cmp    $0x20,%cl
je     115d <com_response_ok+0x4d>
cmp    $0xff,%rsi
mov    %rdx,%rsi
jb     1140 <com_response_ok+0x30>
add    $0x1,%rdx
movb   $0x0,(%rdi,%rdx,1)
lea    0xe94(%rip),%rsi
call   1030 <strcmp@plt>
xor    %ecx,%ecx
test   %rax,%rax
sete   %cl
mov    %ecx,%eax
mov    %rbp,%rsp
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"ok\00"
define i32 @com_response_ok(i8* %0, i32 %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i32
%6 = alloca i8*
%7 = alloca i64
%8 = alloca i32
%9 = alloca i32
store i8* %0, i8** %4
store i32 %1, i32* %5
%10 = load i32, i32* %5
%11 = zext i32 %10 to i64
%12 = call i8* @llvm.stacksave()
store i8* %12, i8** %6
%13 = alloca i8, i64 %11
store i64 %11, i64* %7
store i32 0, i32* %8
br label %14
14: ; preds = %36, %2
%15 = load i8*, i8** %4
%16 = load i32, i32* %8
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds i8, i8* %15, i64 %17
%19 = load i8, i8* %18
%20 = sext i8 %19 to i32
%21 = icmp ne i32 %20, 32
br i1 %21, label %22, label %25
22: ; preds = %14
%23 = load i32, i32* %8
%24 = icmp slt i32 %23, 256
br label %25
25: ; preds = %22, %14
%26 = phi i1 [ false, %14 ], [ %24, %22 ]
br i1 %26, label %27, label %39
27: ; preds = %25
%28 = load i8*, i8** %4
%29 = load i32, i32* %8
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds i8, i8* %28, i64 %30
%32 = load i8, i8* %31
%33 = load i32, i32* %8
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds i8, i8* %13, i64 %34
store i8 %32, i8* %35
br label %36
36: ; preds = %27
%37 = load i32, i32* %8
%38 = add nsw i32 %37, 1
store i32 %38, i32* %8
br label %14
39: ; preds = %25
%40 = load i32, i32* %8
%41 = add nsw i32 %40, 1
%42 = sext i32 %41 to i64
%43 = getelementptr inbounds i8, i8* %13, i64 %42
store i8 0, i8* %43
%44 = call i64 @strcmp(i8* %13, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%45 = icmp eq i64 %44, 0
br i1 %45, label %46, label %47
46: ; preds = %39
store i32 1, i32* %3
store i32 1, i32* %9
br label %48
47: ; preds = %39
store i32 0, i32* %3
store i32 1, i32* %9
br label %48
48: ; preds = %47, %46
%49 = load i8*, i8** %6
%50 = load i32, i32* %3
ret i32 %50
}

LLVM IR (-O2):
@.str = [3 x i8] c"ok\00"
define i32 @com_response_ok(i8* nocapture %0, i32 %1) {
%3 = zext i32 %1 to i64
%4 = alloca i8, i64 %3
%5 = load i8, i8* %0
%6 = icmp eq i8 %5, 32
br i1 %6, label %19, label %7
7: ; preds = %2, %7
%8 = phi i64 [ %11, %7 ], [ 0, %2 ]
%9 = phi i8 [ %13, %7 ], [ %5, %2 ]
%10 = getelementptr inbounds i8, i8* %4, i64 %8
store i8 %9, i8* %10
%11 = add nuw nsw i64 %8, 1
%12 = getelementptr inbounds i8, i8* %0, i64 %11
%13 = load i8, i8* %12
%14 = icmp ne i8 %13, 32
%15 = icmp ult i64 %8, 255
%16 = select i1 %14, i1 %15, i1 false
br i1 %16, label %7, label %17
17: ; preds = %7
%18 = add nuw nsw i64 %8, 2
br label %19
19: ; preds = %17, %2
%20 = phi i64 [ 1, %2 ], [ %18, %17 ]
%21 = getelementptr inbounds i8, i8* %4, i64 %20
store i8 0, i8* %21
%22 = call i64 @strcmp(i8* %4, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0))
%23 = icmp eq i64 %22, 0
%24 = zext i1 %23 to i32
ret i32 %24
}