#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 */
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, int);
int getc(int /*<<< orphan*/ *);
int /*<<< orphan*/ stderr;
void eat_expected_string(FILE *in, char *str) {
  int c;
  while (*str != '\0') {
    c = getc(in);
    if (c != *str) {
      fprintf(stderr, "unexpected character '%c'\n", c);
      exit(1);
    }
    str++;
  }
}


x86 assembly (clang, -O0):
<eat_expected_string>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     11a1 <eat_expected_string+0x71>
mov    -0x8(%rbp),%rdi
call   1050 <getc@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    -0x10(%rbp),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
je     1190 <eat_expected_string+0x60>
mov    0x2e6b(%rip),%rax
mov    (%rax),%edi
mov    -0x14(%rbp),%edx
lea    0xe7f(%rip),%rsi
call   1030 <fprintf@plt>
mov    $0x1,%edi
call   1040 <exit@plt>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    1140 <eat_expected_string+0x10>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<eat_expected_string>:
push   %r14
push   %rbx
push   %rax
cmpb   $0x0,(%rsi)
je     1169 <eat_expected_string+0x39>
mov    %rsi,%rbx
mov    %rdi,%r14
add    $0x1,%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %r14,%rdi
call   1050 <getc@plt>
movsbl -0x1(%rbx),%ecx
cmp    %ecx,%eax
jne    1171 <eat_expected_string+0x41>
cmpb   $0x0,(%rbx)
lea    0x1(%rbx),%rbx
jne    1150 <eat_expected_string+0x20>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
mov    0x2e68(%rip),%rcx
mov    (%rcx),%edi
lea    0xe7f(%rip),%rsi
mov    %eax,%edx
call   1030 <fprintf@plt>
mov    $0x1,%edi
call   1040 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [27 x i8] c"unexpected character '%c'\0A\00"
define void @eat_expected_string(i32* %0, i8* %1) {
%3 = alloca i32*
%4 = alloca i8*
%5 = alloca i32
store i32* %0, i32** %3
store i8* %1, i8** %4
br label %6
6: ; preds = %24, %2
%7 = load i8*, i8** %4
%8 = load i8, i8* %7
%9 = sext i8 %8 to i32
%10 = icmp ne i32 %9, 0
br i1 %10, label %11, label %27
11: ; preds = %6
%12 = load i32*, i32** %3
%13 = call i32 @getc(i32* %12)
store i32 %13, i32* %5
%14 = load i32, i32* %5
%15 = load i8*, i8** %4
%16 = load i8, i8* %15
%17 = sext i8 %16 to i32
%18 = icmp ne i32 %14, %17
br i1 %18, label %19, label %24
19: ; preds = %11
%20 = load i32, i32* @stderr
%21 = load i32, i32* %5
%22 = call i32 @fprintf(i32 %20, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i32 %21)
%23 = call i32 @exit(i32 1)
unreachable
24: ; preds = %11
%25 = load i8*, i8** %4
%26 = getelementptr inbounds i8, i8* %25, i32 1
store i8* %26, i8** %4
br label %6
27: ; preds = %6
ret void
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [27 x i8] c"unexpected character '%c'\0A\00"
define void @eat_expected_string(i32* nocapture %0, i8* nocapture %1) {
%3 = load i8, i8* %1
%4 = icmp eq i8 %3, 0
br i1 %4, label %19, label %8
5: ; preds = %8
%6 = load i8, i8* %14
%7 = icmp eq i8 %6, 0
br i1 %7, label %19, label %8
8: ; preds = %2, %5
%9 = phi i8* [ %14, %5 ], [ %1, %2 ]
%10 = tail call i32 @getc(i32* %0)
%11 = load i8, i8* %9
%12 = sext i8 %11 to i32
%13 = icmp eq i32 %10, %12
%14 = getelementptr inbounds i8, i8* %9, i64 1
br i1 %13, label %5, label %15
15: ; preds = %8
%16 = load i32, i32* @stderr
%17 = tail call i32 @fprintf(i32 %16, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i32 %10)
%18 = tail call i32 @exit(i32 1)
unreachable
19: ; preds = %5, %2
ret void
}