#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 */

/* Variables and functions */
scalar_t__ isalpha(char);
scalar_t__ isspace(char);
int /*<<< orphan*/ sscanf(char *, char *, ...);
scalar_t__ strcmp(char *, char *);
char *parse_header(char *grid, int *ncols, int *nrows, double *xllcorner,
                   double *yllcorner, double *cellsize, double *NODATA_value) {
  char key[32];
  int bytes;
  while (isalpha(grid[0])) {
    sscanf(grid, "%s%n", key, &bytes);
    grid += bytes;
    if ((strcmp((key), ("ncols")) == 0))
      sscanf(grid, "%d%n", ncols, &bytes);
    else if ((strcmp((key), ("nrows")) == 0))
      sscanf(grid, "%d%n", nrows, &bytes);
    else if ((strcmp((key), ("xllcorner")) == 0))
      sscanf(grid, "%lf%n", xllcorner, &bytes);
    else if ((strcmp((key), ("yllcorner")) == 0))
      sscanf(grid, "%lf%n", yllcorner, &bytes);
    else if ((strcmp((key), ("cellsize")) == 0))
      sscanf(grid, "%lf%n", cellsize, &bytes);
    else if ((strcmp((key), ("NODATA_value")) == 0))
      sscanf(grid, "%lf%n", NODATA_value, &bytes);
    grid += bytes;
    while (isspace(grid[0]))
      ++grid;
  }
  return grid;
}


x86 assembly (clang, -O0):
<parse_header>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    0x10(%rbp),%rax
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
mov    -0x8(%rbp),%rax
movsbl (%rax),%edi
call   1060 <isalpha@plt>
cmp    $0x0,%rax
je     134c <parse_header+0x20c>
mov    -0x8(%rbp),%rdi
lea    -0x50(%rbp),%rdx
lea    0xe77(%rip),%rsi
lea    -0x54(%rbp),%rcx
mov    $0x0,%al
call   1050 <sscanf@plt>
mov    -0x54(%rbp),%ecx
mov    -0x8(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x8(%rbp)
lea    -0x50(%rbp),%rdi
lea    0xe55(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    11de <parse_header+0x9e>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rdx
lea    0xe3d(%rip),%rsi
lea    -0x54(%rbp),%rcx
mov    $0x0,%al
call   1050 <sscanf@plt>
jmp    130f <parse_header+0x1cf>
lea    -0x50(%rbp),%rdi
lea    0xe27(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    1217 <parse_header+0xd7>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rdx
lea    0xe04(%rip),%rsi
lea    -0x54(%rbp),%rcx
mov    $0x0,%al
call   1050 <sscanf@plt>
jmp    130a <parse_header+0x1ca>
lea    -0x50(%rbp),%rdi
lea    0xdf4(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    1250 <parse_header+0x110>
mov    -0x8(%rbp),%rdi
mov    -0x20(%rbp),%rdx
lea    0xde0(%rip),%rsi
lea    -0x54(%rbp),%rcx
mov    $0x0,%al
call   1050 <sscanf@plt>
jmp    1305 <parse_header+0x1c5>
lea    -0x50(%rbp),%rdi
lea    0xdcb(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    1289 <parse_header+0x149>
mov    -0x8(%rbp),%rdi
mov    -0x28(%rbp),%rdx
lea    0xda7(%rip),%rsi
lea    -0x54(%rbp),%rcx
mov    $0x0,%al
call   1050 <sscanf@plt>
jmp    1300 <parse_header+0x1c0>
lea    -0x50(%rbp),%rdi
lea    0xd9c(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    12c2 <parse_header+0x182>
mov    -0x8(%rbp),%rdi
mov    -0x30(%rbp),%rdx
lea    0xd6e(%rip),%rsi
lea    -0x54(%rbp),%rcx
mov    $0x0,%al
call   1050 <sscanf@plt>
jmp    12fb <parse_header+0x1bb>
lea    -0x50(%rbp),%rdi
lea    0xd6c(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    12f6 <parse_header+0x1b6>
mov    -0x8(%rbp),%rdi
mov    0x10(%rbp),%rdx
lea    0xd35(%rip),%rsi
lea    -0x54(%rbp),%rcx
mov    $0x0,%al
call   1050 <sscanf@plt>
jmp    12fb <parse_header+0x1bb>
jmp    1300 <parse_header+0x1c0>
jmp    1305 <parse_header+0x1c5>
jmp    130a <parse_header+0x1ca>
jmp    130f <parse_header+0x1cf>
mov    -0x54(%rbp),%ecx
mov    -0x8(%rbp),%rax
movslq %ecx,%rcx
add    %rcx,%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
movsbl (%rax),%edi
call   1030 <isspace@plt>
cmp    $0x0,%rax
je     1347 <parse_header+0x207>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    1320 <parse_header+0x1e0>
jmp    1164 <parse_header+0x24>
mov    -0x8(%rbp),%rax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<parse_header>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x58,%rsp
mov    %r9,0x8(%rsp)
mov    %r8,0x10(%rsp)
mov    %rcx,0x18(%rsp)
mov    %rdx,0x20(%rsp)
mov    %rsi,0x28(%rsp)
mov    %rdi,%rbx
movsbl (%rdi),%edi
call   1060 <isalpha@plt>
test   %rax,%rax
je     1303 <parse_header+0x1c3>
lea    0x30(%rsp),%r15
lea    0x4(%rsp),%r12
lea    0xe79(%rip),%r13
nopl   0x0(%rax)
mov    %rbx,%rdi
lea    0xe66(%rip),%rsi
mov    %r15,%rdx
mov    %r12,%rcx
xor    %eax,%eax
call   1050 <sscanf@plt>
movslq 0x4(%rsp),%r14
lea    (%rbx,%r14,1),%rbp
mov    %r15,%rdi
mov    %r13,%rsi
call   1040 <strcmp@plt>
test   %rax,%rax
je     1250 <parse_header+0x110>
mov    %r15,%rdi
lea    0xe42(%rip),%rsi
call   1040 <strcmp@plt>
test   %rax,%rax
je     1270 <parse_header+0x130>
mov    %r15,%rdi
lea    0xe30(%rip),%rsi
call   1040 <strcmp@plt>
test   %rax,%rax
je     1281 <parse_header+0x141>
mov    %r15,%rdi
lea    0xe28(%rip),%rsi
call   1040 <strcmp@plt>
test   %rax,%rax
je     1292 <parse_header+0x152>
mov    %r15,%rdi
lea    0xe1a(%rip),%rsi
call   1040 <strcmp@plt>
test   %rax,%rax
je     12a3 <parse_header+0x163>
mov    %r15,%rdi
lea    0xe0b(%rip),%rsi
call   1040 <strcmp@plt>
test   %rax,%rax
jne    12ca <parse_header+0x18a>
mov    %rbp,%rdi
lea    0xdda(%rip),%rsi
mov    0x90(%rsp),%rdx
jmp    12c0 <parse_header+0x180>
mov    %rbp,%rdi
lea    0xdb1(%rip),%rsi
mov    0x28(%rsp),%rdx
jmp    12c0 <parse_header+0x180>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %rbp,%rdi
lea    0xd91(%rip),%rsi
mov    0x20(%rsp),%rdx
jmp    12c0 <parse_header+0x180>
mov    %rbp,%rdi
lea    0xd95(%rip),%rsi
mov    0x18(%rsp),%rdx
jmp    12c0 <parse_header+0x180>
mov    %rbp,%rdi
lea    0xd84(%rip),%rsi
mov    0x10(%rsp),%rdx
jmp    12c0 <parse_header+0x180>
mov    %rbp,%rdi
lea    0xd73(%rip),%rsi
mov    0x8(%rsp),%rdx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r12,%rcx
xor    %eax,%eax
call   1050 <sscanf@plt>
movslq 0x4(%rsp),%rax
add    %r14,%rax
add    %rax,%rbx
add    $0xffffffffffffffff,%rbx
nopl   0x0(%rax)
movsbl 0x1(%rbx),%edi
add    $0x1,%rbx
call   1030 <isspace@plt>
test   %rax,%rax
jne    12e0 <parse_header+0x1a0>
movsbl (%rbx),%edi
call   1060 <isalpha@plt>
test   %rax,%rax
jne    1190 <parse_header+0x50>
mov    %rbx,%rax
add    $0x58,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [5 x i8] c"%s%n\00"
@.str.1 = [6 x i8] c"ncols\00"
@.str.2 = [5 x i8] c"%d%n\00"
@.str.3 = [6 x i8] c"nrows\00"
@.str.4 = [10 x i8] c"xllcorner\00"
@.str.5 = [6 x i8] c"%lf%n\00"
@.str.6 = [10 x i8] c"yllcorner\00"
@.str.7 = [9 x i8] c"cellsize\00"
@.str.8 = [13 x i8] c"NODATA_value\00"
define i8* @parse_header(i8* %0, i32* %1, i32* %2, double* %3, double* %4, double* %5, double* %6) {
%8 = alloca i8*
%9 = alloca i32*
%10 = alloca i32*
%11 = alloca double*
%12 = alloca double*
%13 = alloca double*
%14 = alloca double*
%15 = alloca [32 x i8]
%16 = alloca i32
store i8* %0, i8** %8
store i32* %1, i32** %9
store i32* %2, i32** %10
store double* %3, double** %11
store double* %4, double** %12
store double* %5, double** %13
store double* %6, double** %14
br label %17
17: ; preds = %97, %7
%18 = load i8*, i8** %8
%19 = getelementptr inbounds i8, i8* %18, i64 0
%20 = load i8, i8* %19
%21 = call i64 @isalpha(i8 signext %20)
%22 = icmp ne i64 %21, 0
br i1 %22, label %23, label %98
23: ; preds = %17
%24 = load i8*, i8** %8
%25 = getelementptr inbounds [32 x i8], [32 x i8]* %15, i64 0, i64 0
%26 = call i32 (i8*, i8*, ...) @sscanf(i8* %24, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %25, i32* %16)
%27 = load i32, i32* %16
%28 = load i8*, i8** %8
%29 = sext i32 %27 to i64
%30 = getelementptr inbounds i8, i8* %28, i64 %29
store i8* %30, i8** %8
%31 = getelementptr inbounds [32 x i8], [32 x i8]* %15, i64 0, i64 0
%32 = call i64 @strcmp(i8* %31, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%33 = icmp eq i64 %32, 0
br i1 %33, label %34, label %38
34: ; preds = %23
%35 = load i8*, i8** %8
%36 = load i32*, i32** %9
%37 = call i32 (i8*, i8*, ...) @sscanf(i8* %35, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32* %36, i32* %16)
br label %83
38: ; preds = %23
%39 = getelementptr inbounds [32 x i8], [32 x i8]* %15, i64 0, i64 0
%40 = call i64 @strcmp(i8* %39, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
%41 = icmp eq i64 %40, 0
br i1 %41, label %42, label %46
42: ; preds = %38
%43 = load i8*, i8** %8
%44 = load i32*, i32** %10
%45 = call i32 (i8*, i8*, ...) @sscanf(i8* %43, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32* %44, i32* %16)
br label %82
46: ; preds = %38
%47 = getelementptr inbounds [32 x i8], [32 x i8]* %15, i64 0, i64 0
%48 = call i64 @strcmp(i8* %47, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0))
%49 = icmp eq i64 %48, 0
br i1 %49, label %50, label %54
50: ; preds = %46
%51 = load i8*, i8** %8
%52 = load double*, double** %11
%53 = call i32 (i8*, i8*, ...) @sscanf(i8* %51, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0), double* %52, i32* %16)
br label %81
54: ; preds = %46
%55 = getelementptr inbounds [32 x i8], [32 x i8]* %15, i64 0, i64 0
%56 = call i64 @strcmp(i8* %55, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i64 0, i64 0))
%57 = icmp eq i64 %56, 0
br i1 %57, label %58, label %62
58: ; preds = %54
%59 = load i8*, i8** %8
%60 = load double*, double** %12
%61 = call i32 (i8*, i8*, ...) @sscanf(i8* %59, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0), double* %60, i32* %16)
br label %80
62: ; preds = %54
%63 = getelementptr inbounds [32 x i8], [32 x i8]* %15, i64 0, i64 0
%64 = call i64 @strcmp(i8* %63, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.7, i64 0, i64 0))
%65 = icmp eq i64 %64, 0
br i1 %65, label %66, label %70
66: ; preds = %62
%67 = load i8*, i8** %8
%68 = load double*, double** %13
%69 = call i32 (i8*, i8*, ...) @sscanf(i8* %67, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0), double* %68, i32* %16)
br label %79
70: ; preds = %62
%71 = getelementptr inbounds [32 x i8], [32 x i8]* %15, i64 0, i64 0
%72 = call i64 @strcmp(i8* %71, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.8, i64 0, i64 0))
%73 = icmp eq i64 %72, 0
br i1 %73, label %74, label %78
74: ; preds = %70
%75 = load i8*, i8** %8
%76 = load double*, double** %14
%77 = call i32 (i8*, i8*, ...) @sscanf(i8* %75, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0), double* %76, i32* %16)
br label %78
78: ; preds = %74, %70
br label %79
79: ; preds = %78, %66
br label %80
80: ; preds = %79, %58
br label %81
81: ; preds = %80, %50
br label %82
82: ; preds = %81, %42
br label %83
83: ; preds = %82, %34
%84 = load i32, i32* %16
%85 = load i8*, i8** %8
%86 = sext i32 %84 to i64
%87 = getelementptr inbounds i8, i8* %85, i64 %86
store i8* %87, i8** %8
br label %88
88: ; preds = %94, %83
%89 = load i8*, i8** %8
%90 = getelementptr inbounds i8, i8* %89, i64 0
%91 = load i8, i8* %90
%92 = call i64 @isspace(i8 signext %91)
%93 = icmp ne i64 %92, 0
br i1 %93, label %94, label %97
94: ; preds = %88
%95 = load i8*, i8** %8
%96 = getelementptr inbounds i8, i8* %95, i32 1
store i8* %96, i8** %8
br label %88
97: ; preds = %88
br label %17
98: ; preds = %17
%99 = load i8*, i8** %8
ret i8* %99
}

LLVM IR (-O2):
@.str = [5 x i8] c"%s%n\00"
@.str.1 = [6 x i8] c"ncols\00"
@.str.2 = [5 x i8] c"%d%n\00"
@.str.3 = [6 x i8] c"nrows\00"
@.str.4 = [10 x i8] c"xllcorner\00"
@.str.5 = [6 x i8] c"%lf%n\00"
@.str.6 = [10 x i8] c"yllcorner\00"
@.str.7 = [9 x i8] c"cellsize\00"
@.str.8 = [13 x i8] c"NODATA_value\00"
define i8* @parse_header(i8* %0, i32* %1, i32* %2, double* %3, double* %4, double* %5, double* %6) {
%8 = alloca [32 x i8]
%9 = alloca i32
%10 = getelementptr inbounds [32 x i8], [32 x i8]* %8, i64 0, i64 0
%11 = bitcast i32* %9 to i8*
%12 = load i8, i8* %0
%13 = call i64 @isalpha(i8 signext %12)
%14 = icmp eq i64 %13, 0
br i1 %14, label %64, label %19
15: ; preds = %58
%16 = load i8, i8* %59
%17 = call i64 @isalpha(i8 signext %16)
%18 = icmp eq i64 %17, 0
br i1 %18, label %64, label %19
19: ; preds = %7, %15
%20 = phi i8* [ %59, %15 ], [ %0, %7 ]
%21 = call i32 (i8*, i8*, ...) @sscanf(i8* %20, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i8* %10, i32* %9)
%22 = load i32, i32* %9
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds i8, i8* %20, i64 %23
%25 = call i64 @strcmp(i8* %10, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%26 = icmp eq i64 %25, 0
br i1 %26, label %27, label %29
27: ; preds = %19
%28 = call i32 (i8*, i8*, ...) @sscanf(i8* %24, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32* %1, i32* %9)
br label %54
29: ; preds = %19
%30 = call i64 @strcmp(i8* %10, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.3, i64 0, i64 0))
%31 = icmp eq i64 %30, 0
br i1 %31, label %32, label %34
32: ; preds = %29
%33 = call i32 (i8*, i8*, ...) @sscanf(i8* %24, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32* %2, i32* %9)
br label %54
34: ; preds = %29
%35 = call i64 @strcmp(i8* %10, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.4, i64 0, i64 0))
%36 = icmp eq i64 %35, 0
br i1 %36, label %37, label %39
37: ; preds = %34
%38 = call i32 (i8*, i8*, ...) @sscanf(i8* %24, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0), double* %3, i32* %9)
br label %54
39: ; preds = %34
%40 = call i64 @strcmp(i8* %10, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.6, i64 0, i64 0))
%41 = icmp eq i64 %40, 0
br i1 %41, label %42, label %44
42: ; preds = %39
%43 = call i32 (i8*, i8*, ...) @sscanf(i8* %24, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0), double* %4, i32* %9)
br label %54
44: ; preds = %39
%45 = call i64 @strcmp(i8* %10, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.7, i64 0, i64 0))
%46 = icmp eq i64 %45, 0
br i1 %46, label %47, label %49
47: ; preds = %44
%48 = call i32 (i8*, i8*, ...) @sscanf(i8* %24, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0), double* %5, i32* %9)
br label %54
49: ; preds = %44
%50 = call i64 @strcmp(i8* %10, i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.8, i64 0, i64 0))
%51 = icmp eq i64 %50, 0
br i1 %51, label %52, label %54
52: ; preds = %49
%53 = call i32 (i8*, i8*, ...) @sscanf(i8* %24, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0), double* %6, i32* %9)
br label %54
54: ; preds = %32, %42, %49, %52, %47, %37, %27
%55 = load i32, i32* %9
%56 = sext i32 %55 to i64
%57 = getelementptr inbounds i8, i8* %24, i64 %56
br label %58
58: ; preds = %58, %54
%59 = phi i8* [ %57, %54 ], [ %63, %58 ]
%60 = load i8, i8* %59
%61 = call i64 @isspace(i8 signext %60)
%62 = icmp eq i64 %61, 0
%63 = getelementptr inbounds i8, i8* %59, i64 1
br i1 %62, label %15, label %58
64: ; preds = %15, %7
%65 = phi i8* [ %0, %7 ], [ %59, %15 ]
ret i8* %65
}