#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 */
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
char getc(int /*<<< orphan*/ *);
int /*<<< orphan*/ skip_spaces(int /*<<< orphan*/ *);
int match_string(FILE *inf, char *s) {
  skip_spaces(inf);
  while (*s && *s == getc(inf))
    s++;
  return (*s == 0);
}


x86 assembly (clang, -O0):
<match_string>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <skip_spaces@plt>
mov    -0x10(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x11(%rbp)
je     1171 <match_string+0x51>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
mov    %eax,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <getc@plt>
mov    %al,%cl
mov    -0x18(%rbp),%eax
movsbl %cl,%ecx
cmp    %ecx,%eax
sete   %al
mov    %al,-0x11(%rbp)
mov    -0x11(%rbp),%al
test   $0x1,%al
jne    1181 <match_string+0x61>
jmp    1192 <match_string+0x72>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    1139 <match_string+0x19>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
sete   %al
and    $0x1,%al
movzbl %al,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<match_string>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %rdi,%rbp
call   1030 <skip_spaces@plt>
mov    (%rbx),%r15b
mov    $0x1,%r14d
test   %r15b,%r15b
je     1177 <match_string+0x57>
add    $0x1,%rbx
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
mov    %rbp,%rdi
call   1040 <getc@plt>
cmp    %al,%r15b
jne    116c <match_string+0x4c>
movzbl (%rbx),%r15d
add    $0x1,%rbx
test   %r15b,%r15b
jne    1150 <match_string+0x30>
jmp    1177 <match_string+0x57>
xor    %r14d,%r14d
cmpb   $0x0,-0x1(%rbx)
sete   %r14b
mov    %r14d,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

LLVM IR (-O2):
define i32 @match_string(i32* %0, i8* nocapture %1) {
%3 = tail call i32 @skip_spaces(i32* %0)
%4 = load i8, i8* %1
%5 = icmp eq i8 %4, 0
br i1 %5, label %19, label %6
6: ; preds = %2, %15
%7 = phi i8 [ %17, %15 ], [ %4, %2 ]
%8 = phi i8* [ %16, %15 ], [ %1, %2 ]
%9 = tail call signext i8 @getc(i32* %0)
%10 = icmp eq i8 %7, %9
br i1 %10, label %15, label %11
11: ; preds = %6
%12 = load i8, i8* %8
%13 = icmp eq i8 %12, 0
%14 = zext i1 %13 to i32
br label %19
15: ; preds = %6
%16 = getelementptr inbounds i8, i8* %8, i64 1
%17 = load i8, i8* %16
%18 = icmp eq i8 %17, 0
br i1 %18, label %19, label %6
19: ; preds = %15, %11, %2
%20 = phi i32 [ 1, %2 ], [ %14, %11 ], [ 1, %15 ]
ret i32 %20
}