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


x86 assembly (clang, -O0):
<pm_readmagicnumber>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <getc@plt>
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <getc@plt>
mov    %eax,-0x10(%rbp)
mov    -0xc(%rbp),%eax
mov    0x2e9a(%rip),%rcx
cmp    (%rcx),%eax
je     1168 <pm_readmagicnumber+0x48>
mov    -0x10(%rbp),%eax
mov    0x2e88(%rip),%rcx
cmp    (%rcx),%eax
jne    1174 <pm_readmagicnumber+0x54>
lea    0xe91(%rip),%rdi
call   1040 <pm_error@plt>
mov    -0xc(%rbp),%eax
shl    $0x8,%eax
add    -0x10(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pm_readmagicnumber>:
push   %rbp
push   %rbx
push   %rax
mov    %rdi,%rbp
call   1030 <getc@plt>
mov    %eax,%ebx
mov    %rbp,%rdi
call   1030 <getc@plt>
mov    %eax,%ebp
mov    0x2eaa(%rip),%rax
mov    (%rax),%eax
cmp    %eax,%ebx
je     1148 <pm_readmagicnumber+0x28>
cmp    %eax,%ebp
jne    1154 <pm_readmagicnumber+0x34>
lea    0xeb1(%rip),%rdi
call   1040 <pm_error@plt>
shl    $0x8,%ebx
add    %ebp,%ebx
mov    %ebx,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@EOF = global i32 0
@.str = [103 x i8] c"Error reading magic number from Netpbm image stream. Most often, this means your input file is empty.\00"
define i32 @pm_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 %18
16: ; preds = %12, %1
%17 = call i32 @pm_error(i8* getelementptr inbounds ([103 x i8], [103 x i8]* @.str, i64 0, i64 0))
br label %18
18: ; preds = %16, %12
%19 = load i32, i32* %3
%20 = mul nsw i32 %19, 256
%21 = load i32, i32* %4
%22 = add nsw i32 %20, %21
ret i32 %22
}

LLVM IR (-O2):
@EOF = global i32 0
@.str = [103 x i8] c"Error reading magic number from Netpbm image stream. Most often, this means your input file is empty.\00"
define i32 @pm_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 %10
8: ; preds = %1
%9 = tail call i32 @pm_error(i8* getelementptr inbounds ([103 x i8], [103 x i8]* @.str, i64 0, i64 0))
br label %10
10: ; preds = %1, %8
%11 = shl nsw i32 %2, 8
%12 = add nsw i32 %11, %3
ret i32 %12
}