#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*/ fprintf(int /*<<< orphan*/, char *);
int getc(int /*<<< orphan*/ *const);
int /*<<< orphan*/ stderr;
int pm_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.  "
                    "Most often, this "
                    "means your input file is empty.\n");
  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   1040 <getc@plt>
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <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    117d <pm_readmagicnumber+0x5d>
mov    0x2e69(%rip),%rax
mov    (%rax),%edi
lea    0xe88(%rip),%rsi
call   1030 <fprintf@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   1040 <getc@plt>
mov    %eax,%ebx
mov    %rbp,%rdi
call   1040 <getc@plt>
mov    %eax,%ebp
mov    0x2eaa(%rip),%rax
mov    (%rax),%eax
cmp    %eax,%ebx
je     1148 <pm_readmagicnumber+0x28>
cmp    %eax,%ebp
jne    115d <pm_readmagicnumber+0x3d>
mov    0x2e89(%rip),%rax
mov    (%rax),%edi
lea    0xea8(%rip),%rsi
call   1030 <fprintf@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
@stderr = global i32 0
@.str = [104 x i8] c"Error reading magic number from Netpbm image stream. Most often, this means your input file is empty.\0A\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 %19
16: ; preds = %12, %1
%17 = load i32, i32* @stderr
%18 = call i32 @fprintf(i32 %17, i8* getelementptr inbounds ([104 x i8], [104 x i8]* @.str, i64 0, i64 0))
br label %19
19: ; preds = %16, %12
%20 = load i32, i32* %3
%21 = mul nsw i32 %20, 256
%22 = load i32, i32* %4
%23 = add nsw i32 %21, %22
ret i32 %23
}

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