#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*/ lua_error(char *);
void LoadSignature(FILE *D) {
  char *s = "Lua";
  while (*s != 0 && getc(D) == *s)
    ++s;
  if (*s != 0)
    lua_error("bad signature");
}


x86 assembly (clang, -O0):
<LoadSignature>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
lea    0xecd(%rip),%rax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%ecx
xor    %eax,%eax
cmp    $0x0,%ecx
mov    %al,-0x11(%rbp)
je     1167 <LoadSignature+0x47>
mov    -0x8(%rbp),%rdi
call   1040 <getc@plt>
movsbl %al,%eax
mov    -0x10(%rbp),%rcx
movsbl (%rcx),%ecx
cmp    %ecx,%eax
sete   %al
mov    %al,-0x11(%rbp)
mov    -0x11(%rbp),%al
test   $0x1,%al
jne    1177 <LoadSignature+0x57>
jmp    1188 <LoadSignature+0x68>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    1137 <LoadSignature+0x17>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     11a4 <LoadSignature+0x84>
lea    0xe65(%rip),%rdi
call   1030 <lua_error@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<LoadSignature>:
push   %rbx
mov    %rdi,%rbx
call   1040 <getc@plt>
cmp    $0x4c,%al
jne    1147 <LoadSignature+0x27>
mov    %rbx,%rdi
call   1040 <getc@plt>
cmp    $0x75,%al
jne    1147 <LoadSignature+0x27>
mov    %rbx,%rdi
call   1040 <getc@plt>
cmp    $0x61,%al
jne    1147 <LoadSignature+0x27>
pop    %rbx
ret
lea    0xeb2(%rip),%rdi
pop    %rbx
jmp    1030 <lua_error@plt>

LLVM IR (-O0):
@.str = [4 x i8] c"Lua\00"
@.str.1 = [14 x i8] c"bad signature\00"
define void @LoadSignature(i32* %0) {
%2 = alloca i32*
%3 = alloca i8*
store i32* %0, i32** %2
store i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8** %3
br label %4
4: ; preds = %19, %1
%5 = load i8*, i8** %3
%6 = load i8, i8* %5
%7 = sext i8 %6 to i32
%8 = icmp ne i32 %7, 0
br i1 %8, label %9, label %17
9: ; preds = %4
%10 = load i32*, i32** %2
%11 = call signext i8 @getc(i32* %10)
%12 = sext i8 %11 to i32
%13 = load i8*, i8** %3
%14 = load i8, i8* %13
%15 = sext i8 %14 to i32
%16 = icmp eq i32 %12, %15
br label %17
17: ; preds = %9, %4
%18 = phi i1 [ false, %4 ], [ %16, %9 ]
br i1 %18, label %19, label %22
19: ; preds = %17
%20 = load i8*, i8** %3
%21 = getelementptr inbounds i8, i8* %20, i32 1
store i8* %21, i8** %3
br label %4
22: ; preds = %17
%23 = load i8*, i8** %3
%24 = load i8, i8* %23
%25 = sext i8 %24 to i32
%26 = icmp ne i32 %25, 0
br i1 %26, label %27, label %29
27: ; preds = %22
%28 = call i32 @lua_error(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
br label %29
29: ; preds = %27, %22
ret void
}

LLVM IR (-O2):
@.str.1 = [14 x i8] c"bad signature\00"
define void @LoadSignature(i32* nocapture %0) {
%2 = tail call signext i8 @getc(i32* %0)
%3 = icmp eq i8 %2, 76
br i1 %3, label %4, label %10
4: ; preds = %1
%5 = tail call signext i8 @getc(i32* %0)
%6 = icmp eq i8 %5, 117
br i1 %6, label %7, label %10
7: ; preds = %4
%8 = tail call signext i8 @getc(i32* %0)
%9 = icmp eq i8 %8, 97
br i1 %9, label %12, label %10
10: ; preds = %1, %4, %7
%11 = tail call i32 @lua_error(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0))
br label %12
12: ; preds = %7, %10
ret void
}