#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 /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int pbm_readmagicnumber(int /*<<< orphan*/ *);
int /*<<< orphan*/ pbm_readpbminitrest(int /*<<< orphan*/ *, int *, int *);
int /*<<< orphan*/ stderr;
void pbm_readpbminit(FILE *file, int *colsP, int *rowsP, int *formatP) {
  *formatP = pbm_readmagicnumber(file);
  switch (((*formatP) == ('P' * 256 + '1') || (*formatP) == ('P' * 256 + '4')
               ? ('P' * 256 + '1')
               : -1)) {
  case ('P' * 256 + '1'):
    pbm_readpbminitrest(file, colsP, rowsP);
    break;
  default:
    fprintf(stderr, "bad magic number - not a pbm file\n");
    exit(-1);
  }
}


x86 assembly (clang, -O0):
<pbm_readpbminit>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <pbm_readmagicnumber@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x20(%rbp),%rcx
mov    $0x1,%al
cmpl   $0x5031,(%rcx)
mov    %al,-0x21(%rbp)
je     118e <pbm_readpbminit+0x4e>
mov    -0x20(%rbp),%rax
cmpl   $0x5034,(%rax)
sete   %al
mov    %al,-0x21(%rbp)
mov    -0x21(%rbp),%al
test   $0x1,%al
mov    $0x5031,%ecx
mov    $0xffffffff,%eax
cmovne %ecx,%eax
sub    $0x5031,%eax
jne    11c6 <pbm_readpbminit+0x86>
jmp    11b0 <pbm_readpbminit+0x70>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
call   1050 <pbm_readpbminitrest@plt>
jmp    11e5 <pbm_readpbminit+0xa5>
mov    0x2e13(%rip),%rax
mov    (%rax),%edi
lea    0xe2a(%rip),%rsi
call   1030 <fprintf@plt>
mov    $0xffffffff,%edi
call   1060 <exit@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pbm_readpbminit>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
mov    %rcx,%r12
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%rbx
call   1040 <pbm_readmagicnumber@plt>
mov    %eax,(%r12)
cmp    $0x5034,%eax
je     116b <pbm_readpbminit+0x2b>
cmp    $0x5031,%eax
jne    1184 <pbm_readpbminit+0x44>
mov    %rbx,%rdi
mov    %r15,%rsi
mov    %r14,%rdx
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
jmp    1050 <pbm_readpbminitrest@plt>
mov    0x2e55(%rip),%rax
mov    (%rax),%edi
lea    0xe6c(%rip),%rsi
call   1030 <fprintf@plt>
mov    $0xffffffff,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [35 x i8] c"bad magic number - not a pbm file\0A\00"
define void @pbm_readpbminit(i32* %0, i32* %1, i32* %2, i32* %3) {
%5 = alloca i32*
%6 = alloca i32*
%7 = alloca i32*
%8 = alloca i32*
store i32* %0, i32** %5
store i32* %1, i32** %6
store i32* %2, i32** %7
store i32* %3, i32** %8
%9 = load i32*, i32** %5
%10 = call i32 @pbm_readmagicnumber(i32* %9)
%11 = load i32*, i32** %8
store i32 %10, i32* %11
%12 = load i32*, i32** %8
%13 = load i32, i32* %12
%14 = icmp eq i32 %13, 20529
br i1 %14, label %19, label %15
15: ; preds = %4
%16 = load i32*, i32** %8
%17 = load i32, i32* %16
%18 = icmp eq i32 %17, 20532
br label %19
19: ; preds = %15, %4
%20 = phi i1 [ true, %4 ], [ %18, %15 ]
%21 = zext i1 %20 to i64
%22 = select i1 %20, i32 20529, i32 -1
switch i32 %22, label %28 [
i32 20529, label %23
]
23: ; preds = %19
%24 = load i32*, i32** %5
%25 = load i32*, i32** %6
%26 = load i32*, i32** %7
%27 = call i32 @pbm_readpbminitrest(i32* %24, i32* %25, i32* %26)
br label %32
28: ; preds = %19
%29 = load i32, i32* @stderr
%30 = call i32 @fprintf(i32 %29, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0))
%31 = call i32 @exit(i32 -1)
unreachable
32: ; preds = %23
ret void
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [35 x i8] c"bad magic number - not a pbm file\0A\00"
define void @pbm_readpbminit(i32* %0, i32* %1, i32* %2, i32* nocapture writeonly %3) {
%5 = tail call i32 @pbm_readmagicnumber(i32* %0)
store i32 %5, i32* %3
switch i32 %5, label %8 [
i32 20532, label %6
i32 20529, label %6
]
6: ; preds = %4, %4
%7 = tail call i32 @pbm_readpbminitrest(i32* %0, i32* %1, i32* %2)
ret void
8: ; preds = %4
%9 = load i32, i32* @stderr
%10 = tail call i32 @fprintf(i32 %9, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str, i64 0, i64 0))
%11 = tail call i32 @exit(i32 -1)
unreachable
}