#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*/ error(int, char *);
int getc(int /*<<< orphan*/ *);
int getint(int /*<<< orphan*/ *);
int /*<<< orphan*/ skip_to_nl(int /*<<< orphan*/ *);
int pbm_header(FILE *ifp, int *p4eatenp, int *wp, int *hp) {
  int c1, c2;
  if (*p4eatenp)
    *p4eatenp = 0;
  else {
    c1 = getc(ifp);
    if (c1 == EOF)
      return 0;
    c2 = getc(ifp);
    if (c1 != 'P' || c2 != '4')
      error(1, "Not a pbmraw data stream\n");
  }
  skip_to_nl(ifp);
  *wp = getint(ifp);
  *hp = getint(ifp);
  skip_to_nl(ifp);
  return 1;
}


x86 assembly (clang, -O0):
<pbm_header>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    -0x18(%rbp),%rax
cmpl   $0x0,(%rax)
je     1174 <pbm_header+0x34>
mov    -0x18(%rbp),%rax
movl   $0x0,(%rax)
jmp    11d4 <pbm_header+0x94>
mov    -0x10(%rbp),%rdi
call   1060 <getc@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
mov    0x2e5e(%rip),%rcx
cmp    (%rcx),%eax
jne    119e <pbm_header+0x5e>
movl   $0x0,-0x4(%rbp)
jmp    120f <pbm_header+0xcf>
mov    -0x10(%rbp),%rdi
call   1060 <getc@plt>
mov    %eax,-0x30(%rbp)
cmpl   $0x50,-0x2c(%rbp)
jne    11be <pbm_header+0x7e>
cmpl   $0x34,-0x30(%rbp)
je     11cf <pbm_header+0x8f>
mov    $0x1,%edi
lea    0xe36(%rip),%rsi
call   1050 <error@plt>
jmp    11d4 <pbm_header+0x94>
mov    -0x10(%rbp),%rdi
call   1030 <skip_to_nl@plt>
mov    -0x10(%rbp),%rdi
call   1040 <getint@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x10(%rbp),%rdi
call   1040 <getint@plt>
mov    %eax,%ecx
mov    -0x28(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x10(%rbp),%rdi
call   1030 <skip_to_nl@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pbm_header>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rcx,%r14
mov    %rdx,%r15
mov    %rdi,%rbx
cmpl   $0x0,(%rsi)
je     1191 <pbm_header+0x51>
movl   $0x0,(%rsi)
mov    %rbx,%rdi
call   1030 <skip_to_nl@plt>
mov    %rbx,%rdi
call   1040 <getint@plt>
mov    %eax,(%r15)
mov    %rbx,%rdi
call   1040 <getint@plt>
mov    %eax,(%r14)
mov    %rbx,%rdi
call   1030 <skip_to_nl@plt>
mov    $0x1,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %rbx,%rdi
call   1060 <getc@plt>
mov    %eax,%ebp
mov    0x2e46(%rip),%rcx
xor    %eax,%eax
cmp    (%rcx),%ebp
je     1186 <pbm_header+0x46>
mov    %rbx,%rdi
call   1060 <getc@plt>
cmp    $0x50,%ebp
jne    11ba <pbm_header+0x7a>
cmp    $0x34,%eax
je     115b <pbm_header+0x1b>
lea    0xe3f(%rip),%rsi
mov    $0x1,%edi
call   1050 <error@plt>
jmp    115b <pbm_header+0x1b>

LLVM IR (-O0):
@EOF = global i32 0
@.str = [26 x i8] c"Not a pbmraw data stream\0A\00"
define i32 @pbm_header(i32* %0, i32* %1, i32* %2, i32* %3) {
%5 = alloca i32
%6 = alloca i32*
%7 = alloca i32*
%8 = alloca i32*
%9 = alloca i32*
%10 = alloca i32
%11 = alloca i32
store i32* %0, i32** %6
store i32* %1, i32** %7
store i32* %2, i32** %8
store i32* %3, i32** %9
%12 = load i32*, i32** %7
%13 = load i32, i32* %12
%14 = icmp ne i32 %13, 0
br i1 %14, label %15, label %17
15: ; preds = %4
%16 = load i32*, i32** %7
store i32 0, i32* %16
br label %35
17: ; preds = %4
%18 = load i32*, i32** %6
%19 = call i32 @getc(i32* %18)
store i32 %19, i32* %10
%20 = load i32, i32* %10
%21 = load i32, i32* @EOF
%22 = icmp eq i32 %20, %21
br i1 %22, label %23, label %24
23: ; preds = %17
store i32 0, i32* %5
br label %46
24: ; preds = %17
%25 = load i32*, i32** %6
%26 = call i32 @getc(i32* %25)
store i32 %26, i32* %11
%27 = load i32, i32* %10
%28 = icmp ne i32 %27, 80
br i1 %28, label %32, label %29
29: ; preds = %24
%30 = load i32, i32* %11
%31 = icmp ne i32 %30, 52
br i1 %31, label %32, label %34
32: ; preds = %29, %24
%33 = call i32 @error(i32 1, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
br label %34
34: ; preds = %32, %29
br label %35
35: ; preds = %34, %15
%36 = load i32*, i32** %6
%37 = call i32 @skip_to_nl(i32* %36)
%38 = load i32*, i32** %6
%39 = call i32 @getint(i32* %38)
%40 = load i32*, i32** %8
store i32 %39, i32* %40
%41 = load i32*, i32** %6
%42 = call i32 @getint(i32* %41)
%43 = load i32*, i32** %9
store i32 %42, i32* %43
%44 = load i32*, i32** %6
%45 = call i32 @skip_to_nl(i32* %44)
store i32 1, i32* %5
br label %46
46: ; preds = %35, %23
%47 = load i32, i32* %5
ret i32 %47
}

LLVM IR (-O2):
@EOF = global i32 0
@.str = [26 x i8] c"Not a pbmraw data stream\0A\00"
define i32 @pbm_header(i32* %0, i32* nocapture %1, i32* nocapture writeonly %2, i32* nocapture writeonly %3) {
%5 = load i32, i32* %1
%6 = icmp eq i32 %5, 0
br i1 %6, label %8, label %7
7: ; preds = %4
store i32 0, i32* %1
br label %19
8: ; preds = %4
%9 = tail call i32 @getc(i32* %0)
%10 = load i32, i32* @EOF
%11 = icmp eq i32 %9, %10
br i1 %11, label %24, label %12
12: ; preds = %8
%13 = tail call i32 @getc(i32* %0)
%14 = icmp ne i32 %9, 80
%15 = icmp ne i32 %13, 52
%16 = or i1 %14, %15
br i1 %16, label %17, label %19
17: ; preds = %12
%18 = tail call i32 @error(i32 1, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
br label %19
19: ; preds = %17, %12, %7
%20 = tail call i32 @skip_to_nl(i32* %0)
%21 = tail call i32 @getint(i32* %0)
store i32 %21, i32* %2
%22 = tail call i32 @getint(i32* %0)
store i32 %22, i32* %3
%23 = tail call i32 @skip_to_nl(i32* %0)
br label %24
24: ; preds = %8, %19
%25 = phi i32 [ 1, %19 ], [ 0, %8 ]
ret i32 %25
}