#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 EOF;
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int getc(int /*<<< orphan*/ *const);
int /*<<< orphan*/ stderr;
int readmagicnumber(FILE *const ifP) {
  int ich1, ich2;
  ich1 = getc(ifP);
  ich2 = getc(ifP);
  if (ich1 == EOF || ich2 == EOF) {
    fprintf(stderr,
            "Error reading magic number from Netpbm image stream.\nMost often, "
            "this means your input file is empty.\n");
    exit(-1);
  }
  return ich1 * 256 + ich2;
}


x86 assembly (clang, -O0):
<readmagicnumber>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <getc@plt>
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <getc@plt>
mov    %eax,-0x10(%rbp)
mov    -0xc(%rbp),%eax
mov    0x2e8a(%rip),%rcx
cmp    (%rcx),%eax
je     1178 <readmagicnumber+0x48>
mov    -0x10(%rbp),%eax
mov    0x2e78(%rip),%rcx
cmp    (%rcx),%eax
jne    1197 <readmagicnumber+0x67>
mov    0x2e59(%rip),%rax
mov    (%rax),%edi
lea    0xe78(%rip),%rsi
call   1030 <fprintf@plt>
mov    $0xffffffff,%edi
call   1040 <exit@plt>
mov    -0xc(%rbp),%eax
shl    $0x8,%eax
add    -0x10(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<readmagicnumber>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%r14
call   1050 <getc@plt>
mov    %eax,%ebx
mov    %r14,%rdi
call   1050 <getc@plt>
mov    0x2e9b(%rip),%rcx
mov    (%rcx),%ecx
cmp    %ecx,%ebx
je     1166 <readmagicnumber+0x36>
cmp    %ecx,%eax
je     1166 <readmagicnumber+0x36>
shl    $0x8,%ebx
add    %eax,%ebx
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
mov    0x2e6b(%rip),%rax
mov    (%rax),%edi
lea    0xe8a(%rip),%rsi
call   1030 <fprintf@plt>
mov    $0xffffffff,%edi
call   1040 <exit@plt>

LLVM IR (-O0):
@EOF = global i32 0
@stderr = global i32 0
@.str = [103 x i8] c"Error reading magic number from Netpbm image stream.\0AMost often, this means your input file is empty.\0A\00"
define i32 @readmagicnumber(i32* %0) {
%2 = alloca i32*
%3 = alloca i32
%4 = alloca i32
store i32* %0, i32** %2
%5 = load i32*, i32** %2
%6 = call i32 @getc(i32* %5)
store i32 %6, i32* %3
%7 = load i32*, i32** %2
%8 = call i32 @getc(i32* %7)
store i32 %8, i32* %4
%9 = load i32, i32* %3
%10 = load i32, i32* @EOF
%11 = icmp eq i32 %9, %10
br i1 %11, label %16, label %12
12: ; preds = %1
%13 = load i32, i32* %4
%14 = load i32, i32* @EOF
%15 = icmp eq i32 %13, %14
br i1 %15, label %16, label %20
16: ; preds = %12, %1
%17 = load i32, i32* @stderr
%18 = call i32 @fprintf(i32 %17, i8* getelementptr inbounds ([103 x i8], [103 x i8]* @.str, i64 0, i64 0))
%19 = call i32 @exit(i32 -1)
unreachable
20: ; preds = %12
%21 = load i32, i32* %3
%22 = mul nsw i32 %21, 256
%23 = load i32, i32* %4
%24 = add nsw i32 %22, %23
ret i32 %24
}

LLVM IR (-O2):
@EOF = global i32 0
@stderr = global i32 0
@.str = [103 x i8] c"Error reading magic number from Netpbm image stream.\0AMost often, this means your input file is empty.\0A\00"
define i32 @readmagicnumber(i32* nocapture %0) {
%2 = tail call i32 @getc(i32* %0)
%3 = tail call i32 @getc(i32* %0)
%4 = load i32, i32* @EOF
%5 = icmp eq i32 %2, %4
%6 = icmp eq i32 %3, %4
%7 = or i1 %5, %6
br i1 %7, label %8, label %12
8: ; preds = %1
%9 = load i32, i32* @stderr
%10 = tail call i32 @fprintf(i32 %9, i8* getelementptr inbounds ([103 x i8], [103 x i8]* @.str, i64 0, i64 0))
%11 = tail call i32 @exit(i32 -1)
unreachable
12: ; preds = %1
%13 = shl nsw i32 %2, 8
%14 = add nsw i32 %13, %3
ret i32 %14
}