#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 /*<<< orphan*/ strncmp(char const *, char const *, int);
const char *looking_at_command(const char *buf, const char *cmd) {
  if (!strncmp(buf, cmd, strlen(cmd))) {
    const char *answer = buf + strlen(cmd);
    if (answer[0] == ':') {
      return (answer + 1);
    }
  }
  return NULL;
}


x86 assembly (clang, -O0):
<looking_at_command>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x30(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    %eax,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%eax
jne    11a8 <looking_at_command+0x88>
mov    -0x10(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x38(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x3a,%eax
jne    11a3 <looking_at_command+0x83>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    11b0 <looking_at_command+0x90>
jmp    11a8 <looking_at_command+0x88>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<looking_at_command>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %rdi,%r14
mov    %rsi,%rdi
call   1040 <strlen@plt>
mov    %r14,%rdi
mov    %rbx,%rsi
mov    %eax,%edx
call   1030 <strncmp@plt>
test   %eax,%eax
jne    115d <looking_at_command+0x3d>
mov    %rbx,%rdi
call   1040 <strlen@plt>
cltq
cmpb   $0x3a,(%r14,%rax,1)
jne    115d <looking_at_command+0x3d>
add    %r14,%rax
add    $0x1,%rax
jmp    115f <looking_at_command+0x3f>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
define i8* @looking_at_command(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i8*
store i8* %0, i8** %4
store i8* %1, i8** %5
%7 = load i8*, i8** %4
%8 = load i8*, i8** %5
%9 = load i8*, i8** %5
%10 = call i32 @strlen(i8* %9)
%11 = call i32 @strncmp(i8* %7, i8* %8, i32 %10)
%12 = icmp ne i32 %11, 0
br i1 %12, label %28, label %13
13: ; preds = %2
%14 = load i8*, i8** %4
%15 = load i8*, i8** %5
%16 = call i32 @strlen(i8* %15)
%17 = sext i32 %16 to i64
%18 = getelementptr inbounds i8, i8* %14, i64 %17
store i8* %18, i8** %6
%19 = load i8*, i8** %6
%20 = getelementptr inbounds i8, i8* %19, i64 0
%21 = load i8, i8* %20
%22 = sext i8 %21 to i32
%23 = icmp eq i32 %22, 58
br i1 %23, label %24, label %27
24: ; preds = %13
%25 = load i8*, i8** %6
%26 = getelementptr inbounds i8, i8* %25, i64 1
store i8* %26, i8** %3
br label %29
27: ; preds = %13
br label %28
28: ; preds = %27, %2
store i8* null, i8** %3
br label %29
29: ; preds = %28, %24
%30 = load i8*, i8** %3
ret i8* %30
}

LLVM IR (-O2):
define i8* @looking_at_command(i8* %0, i8* %1) {
%3 = tail call i32 @strlen(i8* %1)
%4 = tail call i32 @strncmp(i8* %0, i8* %1, i32 %3)
%5 = icmp eq i32 %4, 0
br i1 %5, label %6, label %13
6: ; preds = %2
%7 = tail call i32 @strlen(i8* %1)
%8 = sext i32 %7 to i64
%9 = getelementptr inbounds i8, i8* %0, i64 %8
%10 = load i8, i8* %9
%11 = icmp eq i8 %10, 58
%12 = getelementptr inbounds i8, i8* %9, i64 1
br i1 %11, label %14, label %13
13: ; preds = %6, %2
br label %14
14: ; preds = %6, %13
%15 = phi i8* [ null, %13 ], [ %12, %6 ]
ret i8* %15
}