#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 */
char get8();
int hdr_test(void) {
  char *signature = "#?RADIANCE\n";
  int i;
  for (i = 0; signature[i]; ++i)
    if (get8() != signature[i])
      return 0;
  return 1;
}


x86 assembly (clang, -O0):
<hdr_test>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
lea    0xee1(%rip),%rax
mov    %rax,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x14(%rbp),%rcx
cmpb   $0x0,(%rax,%rcx,1)
je     1179 <hdr_test+0x69>
mov    $0x0,%al
call   1030 <get8@plt>
movsbl %al,%eax
mov    -0x10(%rbp),%rcx
movslq -0x14(%rbp),%rdx
movsbl (%rcx,%rdx,1),%ecx
cmp    %ecx,%eax
je     1166 <hdr_test+0x56>
movl   $0x0,-0x4(%rbp)
jmp    1180 <hdr_test+0x70>
jmp    116b <hdr_test+0x5b>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    112a <hdr_test+0x1a>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<hdr_test>:
push   %rbx
xor    %ebx,%ebx
xor    %eax,%eax
call   1030 <get8@plt>
cmp    $0x23,%al
jne    11a5 <hdr_test+0x95>
xor    %ebx,%ebx
xor    %eax,%eax
call   1030 <get8@plt>
cmp    $0x3f,%al
jne    11a5 <hdr_test+0x95>
xor    %ebx,%ebx
xor    %eax,%eax
call   1030 <get8@plt>
cmp    $0x52,%al
jne    11a5 <hdr_test+0x95>
xor    %ebx,%ebx
xor    %eax,%eax
call   1030 <get8@plt>
cmp    $0x41,%al
jne    11a5 <hdr_test+0x95>
xor    %ebx,%ebx
xor    %eax,%eax
call   1030 <get8@plt>
cmp    $0x44,%al
jne    11a5 <hdr_test+0x95>
xor    %ebx,%ebx
xor    %eax,%eax
call   1030 <get8@plt>
cmp    $0x49,%al
jne    11a5 <hdr_test+0x95>
xor    %ebx,%ebx
xor    %eax,%eax
call   1030 <get8@plt>
cmp    $0x41,%al
jne    11a5 <hdr_test+0x95>
xor    %ebx,%ebx
xor    %eax,%eax
call   1030 <get8@plt>
cmp    $0x4e,%al
jne    11a5 <hdr_test+0x95>
xor    %ebx,%ebx
xor    %eax,%eax
call   1030 <get8@plt>
cmp    $0x43,%al
jne    11a5 <hdr_test+0x95>
xor    %ebx,%ebx
xor    %eax,%eax
call   1030 <get8@plt>
cmp    $0x45,%al
jne    11a5 <hdr_test+0x95>
xor    %eax,%eax
call   1030 <get8@plt>
xor    %ebx,%ebx
cmp    $0xa,%al
sete   %bl
mov    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [12 x i8] c"#?RADIANCE\0A\00"
define i32 @hdr_test() {
%1 = alloca i32
%2 = alloca i8*
%3 = alloca i32
store i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i8** %2
store i32 0, i32* %3
br label %4
4: ; preds = %23, %0
%5 = load i8*, i8** %2
%6 = load i32, i32* %3
%7 = sext i32 %6 to i64
%8 = getelementptr inbounds i8, i8* %5, i64 %7
%9 = load i8, i8* %8
%10 = icmp ne i8 %9, 0
br i1 %10, label %11, label %26
11: ; preds = %4
%12 = call signext i8 (...) @get8()
%13 = sext i8 %12 to i32
%14 = load i8*, i8** %2
%15 = load i32, i32* %3
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds i8, i8* %14, i64 %16
%18 = load i8, i8* %17
%19 = sext i8 %18 to i32
%20 = icmp ne i32 %13, %19
br i1 %20, label %21, label %22
21: ; preds = %11
store i32 0, i32* %1
br label %27
22: ; preds = %11
br label %23
23: ; preds = %22
%24 = load i32, i32* %3
%25 = add nsw i32 %24, 1
store i32 %25, i32* %3
br label %4
26: ; preds = %4
store i32 1, i32* %1
br label %27
27: ; preds = %26, %21
%28 = load i32, i32* %1
ret i32 %28
}

LLVM IR (-O2):
define i32 @hdr_test() {
%1 = tail call signext i8 (...) @get8()
%2 = icmp eq i8 %1, 35
br i1 %2, label %3, label %34
3: ; preds = %0
%4 = tail call signext i8 (...) @get8()
%5 = icmp eq i8 %4, 63
br i1 %5, label %6, label %34
6: ; preds = %3
%7 = tail call signext i8 (...) @get8()
%8 = icmp eq i8 %7, 82
br i1 %8, label %9, label %34
9: ; preds = %6
%10 = tail call signext i8 (...) @get8()
%11 = icmp eq i8 %10, 65
br i1 %11, label %12, label %34
12: ; preds = %9
%13 = tail call signext i8 (...) @get8()
%14 = icmp eq i8 %13, 68
br i1 %14, label %15, label %34
15: ; preds = %12
%16 = tail call signext i8 (...) @get8()
%17 = icmp eq i8 %16, 73
br i1 %17, label %18, label %34
18: ; preds = %15
%19 = tail call signext i8 (...) @get8()
%20 = icmp eq i8 %19, 65
br i1 %20, label %21, label %34
21: ; preds = %18
%22 = tail call signext i8 (...) @get8()
%23 = icmp eq i8 %22, 78
br i1 %23, label %24, label %34
24: ; preds = %21
%25 = tail call signext i8 (...) @get8()
%26 = icmp eq i8 %25, 67
br i1 %26, label %27, label %34
27: ; preds = %24
%28 = tail call signext i8 (...) @get8()
%29 = icmp eq i8 %28, 69
br i1 %29, label %30, label %34
30: ; preds = %27
%31 = tail call signext i8 (...) @get8()
%32 = icmp eq i8 %31, 10
%33 = zext i1 %32 to i32
br label %34
34: ; preds = %30, %27, %24, %21, %18, %15, %12, %9, %6, %3, %0
%35 = phi i32 [ 0, %0 ], [ 0, %3 ], [ 0, %6 ], [ 0, %9 ], [ 0, %12 ], [ 0, %15 ], [ 0, %18 ], [ 0, %21 ], [ 0, %24 ], [ 0, %27 ], [ %33, %30 ]
ret i32 %35
}