void compareGrids(int gridID1, int gridID2) {
  int xsize, ysize;
  if (gridInqType(gridID1) == gridInqType(gridID2)) {
    if (gridInqType(gridID1) == 2 || gridInqType(gridID1) == 4) {
      xsize = gridInqXsize(gridID1);
      ysize = gridInqYsize(gridID1);
      if (ysize == gridInqYsize(gridID2))
        compare_lat_reg2d(ysize, gridID1, gridID2);
      else
        cdoWarning("ysize of input grids differ!");
      if (xsize == gridInqXsize(gridID2))
        compare_lon_reg2d(xsize, gridID1, gridID2);
      else
        cdoWarning("xsize of input grids differ!");
    } else if (gridInqType(gridID1) == 10 || gridInqType(gridID1) == 9) {
      compare_grid_unstructured(gridID1, gridID2);
    }
  } else {
    cdoWarning("Grids have different types! First grid: %s; second grid: %s",
               gridNamePtr(gridInqType(gridID1)),
               gridNamePtr(gridInqType(gridID2)));
  }
}


x86 assembly (clang, -O0):
<compareGrids>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    -0x4(%rbp),%edi
mov    $0x0,%al
call   1090 <gridInqType@plt>
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%edi
mov    $0x0,%al
call   1090 <gridInqType@plt>
mov    %eax,%ecx
mov    -0x14(%rbp),%eax
cmp    %ecx,%eax
jne    12b4 <compareGrids+0x134>
mov    -0x4(%rbp),%edi
mov    $0x0,%al
call   1090 <gridInqType@plt>
cmp    $0x2,%eax
je     11d8 <compareGrids+0x58>
mov    -0x4(%rbp),%edi
mov    $0x0,%al
call   1090 <gridInqType@plt>
cmp    $0x4,%eax
jne    1277 <compareGrids+0xf7>
mov    -0x4(%rbp),%edi
mov    $0x0,%al
call   1070 <gridInqXsize@plt>
mov    %eax,-0xc(%rbp)
mov    -0x4(%rbp),%edi
mov    $0x0,%al
call   1060 <gridInqYsize@plt>
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x8(%rbp),%edi
mov    $0x0,%al
call   1060 <gridInqYsize@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%eax
cmp    %ecx,%eax
jne    1224 <compareGrids+0xa4>
mov    -0x10(%rbp),%edi
mov    -0x4(%rbp),%esi
mov    -0x8(%rbp),%edx
mov    $0x0,%al
call   1050 <compare_lat_reg2d@plt>
jmp    1232 <compareGrids+0xb2>
lea    0xdd5(%rip),%rdi
mov    $0x0,%al
call   10a0 <cdoWarning@plt>
mov    -0xc(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x8(%rbp),%edi
mov    $0x0,%al
call   1070 <gridInqXsize@plt>
mov    %eax,%ecx
mov    -0x1c(%rbp),%eax
cmp    %ecx,%eax
jne    1264 <compareGrids+0xe4>
mov    -0xc(%rbp),%edi
mov    -0x4(%rbp),%esi
mov    -0x8(%rbp),%edx
mov    $0x0,%al
call   1030 <compare_lon_reg2d@plt>
jmp    1272 <compareGrids+0xf2>
lea    0xdb2(%rip),%rdi
mov    $0x0,%al
call   10a0 <cdoWarning@plt>
jmp    12af <compareGrids+0x12f>
mov    -0x4(%rbp),%edi
mov    $0x0,%al
call   1090 <gridInqType@plt>
cmp    $0xa,%eax
je     129d <compareGrids+0x11d>
mov    -0x4(%rbp),%edi
mov    $0x0,%al
call   1090 <gridInqType@plt>
cmp    $0x9,%eax
jne    12aa <compareGrids+0x12a>
mov    -0x4(%rbp),%edi
mov    -0x8(%rbp),%esi
mov    $0x0,%al
call   1040 <compare_grid_unstructured@plt>
jmp    12af <compareGrids+0x12f>
jmp    12f0 <compareGrids+0x170>
mov    -0x4(%rbp),%edi
mov    $0x0,%al
call   1090 <gridInqType@plt>
mov    %eax,%edi
mov    $0x0,%al
call   1080 <gridNamePtr@plt>
mov    %eax,-0x20(%rbp)
mov    -0x8(%rbp),%edi
mov    $0x0,%al
call   1090 <gridInqType@plt>
mov    %eax,%edi
mov    $0x0,%al
call   1080 <gridNamePtr@plt>
mov    -0x20(%rbp),%esi
mov    %eax,%edx
lea    0xd51(%rip),%rdi
mov    $0x0,%al
call   10a0 <cdoWarning@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<compareGrids>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %esi,%r15d
mov    %edi,%r12d
xor    %eax,%eax
call   1090 <gridInqType@plt>
mov    %eax,%ebx
mov    %r15d,%edi
xor    %eax,%eax
call   1090 <gridInqType@plt>
mov    %eax,%ebp
mov    %r12d,%edi
xor    %eax,%eax
call   1090 <gridInqType@plt>
cmp    %ebp,%ebx
jne    1201 <compareGrids+0x81>
cmp    $0x2,%eax
je     11c9 <compareGrids+0x49>
mov    %r12d,%edi
xor    %eax,%eax
call   1090 <gridInqType@plt>
cmp    $0x4,%eax
jne    1284 <compareGrids+0x104>
mov    %r12d,%edi
xor    %eax,%eax
call   1070 <gridInqXsize@plt>
mov    %eax,%r14d
mov    %r12d,%edi
xor    %eax,%eax
call   1060 <gridInqYsize@plt>
mov    %eax,%ebx
mov    %r15d,%edi
xor    %eax,%eax
call   1060 <gridInqYsize@plt>
cmp    %eax,%ebx
jne    1239 <compareGrids+0xb9>
mov    %ebx,%edi
mov    %r12d,%esi
mov    %r15d,%edx
xor    %eax,%eax
call   1050 <compare_lat_reg2d@plt>
jmp    1247 <compareGrids+0xc7>
mov    %eax,%edi
xor    %eax,%eax
call   1080 <gridNamePtr@plt>
mov    %eax,%ebx
mov    %r15d,%edi
xor    %eax,%eax
call   1090 <gridInqType@plt>
mov    %eax,%edi
xor    %eax,%eax
call   1080 <gridNamePtr@plt>
lea    0xe14(%rip),%rdi
mov    %ebx,%esi
mov    %eax,%edx
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    10a0 <cdoWarning@plt>
lea    0xdc0(%rip),%rdi
xor    %eax,%eax
call   10a0 <cdoWarning@plt>
mov    %r15d,%edi
xor    %eax,%eax
call   1070 <gridInqXsize@plt>
cmp    %eax,%r14d
jne    126e <compareGrids+0xee>
mov    %r14d,%edi
mov    %r12d,%esi
mov    %r15d,%edx
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <compare_lon_reg2d@plt>
lea    0xda8(%rip),%rdi
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    10a0 <cdoWarning@plt>
mov    %r12d,%edi
xor    %eax,%eax
call   1090 <gridInqType@plt>
cmp    $0xa,%eax
je     12a2 <compareGrids+0x122>
mov    %r12d,%edi
xor    %eax,%eax
call   1090 <gridInqType@plt>
cmp    $0x9,%eax
jne    12b7 <compareGrids+0x137>
mov    %r12d,%edi
mov    %r15d,%esi
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1040 <compare_grid_unstructured@plt>
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [29 x i8] c"ysize of input grids differ!\00"
@.str.1 = [29 x i8] c"xsize of input grids differ!\00"
@.str.2 = [60 x i8] c"Grids have different types! First grid: %s; second grid: %s\00"
define void @compareGrids(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
%7 = load i32, i32* %3
%8 = call i32 (i32, ...) bitcast (i32 (...)* @gridInqType to i32 (i32, ...)*)(i32 %7)
%9 = load i32, i32* %4
%10 = call i32 (i32, ...) bitcast (i32 (...)* @gridInqType to i32 (i32, ...)*)(i32 %9)
%11 = icmp eq i32 %8, %10
br i1 %11, label %12, label %63
12: ; preds = %2
%13 = load i32, i32* %3
%14 = call i32 (i32, ...) bitcast (i32 (...)* @gridInqType to i32 (i32, ...)*)(i32 %13)
%15 = icmp eq i32 %14, 2
br i1 %15, label %20, label %16
16: ; preds = %12
%17 = load i32, i32* %3
%18 = call i32 (i32, ...) bitcast (i32 (...)* @gridInqType to i32 (i32, ...)*)(i32 %17)
%19 = icmp eq i32 %18, 4
br i1 %19, label %20, label %49
20: ; preds = %16, %12
%21 = load i32, i32* %3
%22 = call i32 (i32, ...) bitcast (i32 (...)* @gridInqXsize to i32 (i32, ...)*)(i32 %21)
store i32 %22, i32* %5
%23 = load i32, i32* %3
%24 = call i32 (i32, ...) bitcast (i32 (...)* @gridInqYsize to i32 (i32, ...)*)(i32 %23)
store i32 %24, i32* %6
%25 = load i32, i32* %6
%26 = load i32, i32* %4
%27 = call i32 (i32, ...) bitcast (i32 (...)* @gridInqYsize to i32 (i32, ...)*)(i32 %26)
%28 = icmp eq i32 %25, %27
br i1 %28, label %29, label %34
29: ; preds = %20
%30 = load i32, i32* %6
%31 = load i32, i32* %3
%32 = load i32, i32* %4
%33 = call i32 (i32, i32, i32, ...) bitcast (i32 (...)* @compare_lat_reg2d to i32 (i32, i32, i32, ...)*)(i32 %30, i32 %31, i32 %32)
br label %36
34: ; preds = %20
%35 = call i32 (i8*, ...) bitcast (i32 (...)* @cdoWarning to i32 (i8*, ...)*)(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
br label %36
36: ; preds = %34, %29
%37 = load i32, i32* %5
%38 = load i32, i32* %4
%39 = call i32 (i32, ...) bitcast (i32 (...)* @gridInqXsize to i32 (i32, ...)*)(i32 %38)
%40 = icmp eq i32 %37, %39
br i1 %40, label %41, label %46
41: ; preds = %36
%42 = load i32, i32* %5
%43 = load i32, i32* %3
%44 = load i32, i32* %4
%45 = call i32 (i32, i32, i32, ...) bitcast (i32 (...)* @compare_lon_reg2d to i32 (i32, i32, i32, ...)*)(i32 %42, i32 %43, i32 %44)
br label %48
46: ; preds = %36
%47 = call i32 (i8*, ...) bitcast (i32 (...)* @cdoWarning to i32 (i8*, ...)*)(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0))
br label %48
48: ; preds = %46, %41
br label %62
49: ; preds = %16
%50 = load i32, i32* %3
%51 = call i32 (i32, ...) bitcast (i32 (...)* @gridInqType to i32 (i32, ...)*)(i32 %50)
%52 = icmp eq i32 %51, 10
br i1 %52, label %57, label %53
53: ; preds = %49
%54 = load i32, i32* %3
%55 = call i32 (i32, ...) bitcast (i32 (...)* @gridInqType to i32 (i32, ...)*)(i32 %54)
%56 = icmp eq i32 %55, 9
br i1 %56, label %57, label %61
57: ; preds = %53, %49
%58 = load i32, i32* %3
%59 = load i32, i32* %4
%60 = call i32 (i32, i32, ...) bitcast (i32 (...)* @compare_grid_unstructured to i32 (i32, i32, ...)*)(i32 %58, i32 %59)
br label %61
61: ; preds = %57, %53
br label %62
62: ; preds = %61, %48
br label %71
63: ; preds = %2
%64 = load i32, i32* %3
%65 = call i32 (i32, ...) bitcast (i32 (...)* @gridInqType to i32 (i32, ...)*)(i32 %64)
%66 = call i32 (i32, ...) bitcast (i32 (...)* @gridNamePtr to i32 (i32, ...)*)(i32 %65)
%67 = load i32, i32* %4
%68 = call i32 (i32, ...) bitcast (i32 (...)* @gridInqType to i32 (i32, ...)*)(i32 %67)
%69 = call i32 (i32, ...) bitcast (i32 (...)* @gridNamePtr to i32 (i32, ...)*)(i32 %68)
%70 = call i32 (i8*, i32, i32, ...) bitcast (i32 (...)* @cdoWarning to i32 (i8*, i32, i32, ...)*)(i8* getelementptr inbounds ([60 x i8], [60 x i8]* @.str.2, i64 0, i64 0), i32 %66, i32 %69)
br label %71
71: ; preds = %63, %62
ret void
}

LLVM IR (-O2):
@.str = [29 x i8] c"ysize of input grids differ!\00"
@.str.1 = [29 x i8] c"xsize of input grids differ!\00"
@.str.2 = [60 x i8] c"Grids have different types! First grid: %s; second grid: %s\00"
define void @compareGrids(i32 %0, i32 %1) {
%3 = tail call i32 (i32, ...) bitcast (i32 (...)* @gridInqType to i32 (i32, ...)*)(i32 %0)
%4 = tail call i32 (i32, ...) bitcast (i32 (...)* @gridInqType to i32 (i32, ...)*)(i32 %1)
%5 = icmp eq i32 %3, %4
%6 = tail call i32 (i32, ...) bitcast (i32 (...)* @gridInqType to i32 (i32, ...)*)(i32 %0)
br i1 %5, label %7, label %36
7: ; preds = %2
%8 = icmp eq i32 %6, 2
br i1 %8, label %12, label %9
9: ; preds = %7
%10 = tail call i32 (i32, ...) bitcast (i32 (...)* @gridInqType to i32 (i32, ...)*)(i32 %0)
%11 = icmp eq i32 %10, 4
br i1 %11, label %12, label %28
12: ; preds = %9, %7
%13 = tail call i32 (i32, ...) bitcast (i32 (...)* @gridInqXsize to i32 (i32, ...)*)(i32 %0)
%14 = tail call i32 (i32, ...) bitcast (i32 (...)* @gridInqYsize to i32 (i32, ...)*)(i32 %0)
%15 = tail call i32 (i32, ...) bitcast (i32 (...)* @gridInqYsize to i32 (i32, ...)*)(i32 %1)
%16 = icmp eq i32 %14, %15
br i1 %16, label %17, label %19
17: ; preds = %12
%18 = tail call i32 (i32, i32, i32, ...) bitcast (i32 (...)* @compare_lat_reg2d to i32 (i32, i32, i32, ...)*)(i32 %14, i32 %0, i32 %1)
br label %21
19: ; preds = %12
%20 = tail call i32 (i8*, ...) bitcast (i32 (...)* @cdoWarning to i32 (i8*, ...)*)(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
br label %21
21: ; preds = %19, %17
%22 = tail call i32 (i32, ...) bitcast (i32 (...)* @gridInqXsize to i32 (i32, ...)*)(i32 %1)
%23 = icmp eq i32 %13, %22
br i1 %23, label %24, label %26
24: ; preds = %21
%25 = tail call i32 (i32, i32, i32, ...) bitcast (i32 (...)* @compare_lon_reg2d to i32 (i32, i32, i32, ...)*)(i32 %13, i32 %0, i32 %1)
br label %41
26: ; preds = %21
%27 = tail call i32 (i8*, ...) bitcast (i32 (...)* @cdoWarning to i32 (i8*, ...)*)(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0))
br label %41
28: ; preds = %9
%29 = tail call i32 (i32, ...) bitcast (i32 (...)* @gridInqType to i32 (i32, ...)*)(i32 %0)
%30 = icmp eq i32 %29, 10
br i1 %30, label %34, label %31
31: ; preds = %28
%32 = tail call i32 (i32, ...) bitcast (i32 (...)* @gridInqType to i32 (i32, ...)*)(i32 %0)
%33 = icmp eq i32 %32, 9
br i1 %33, label %34, label %41
34: ; preds = %31, %28
%35 = tail call i32 (i32, i32, ...) bitcast (i32 (...)* @compare_grid_unstructured to i32 (i32, i32, ...)*)(i32 %0, i32 %1)
br label %41
36: ; preds = %2
%37 = tail call i32 (i32, ...) bitcast (i32 (...)* @gridNamePtr to i32 (i32, ...)*)(i32 %6)
%38 = tail call i32 (i32, ...) bitcast (i32 (...)* @gridInqType to i32 (i32, ...)*)(i32 %1)
%39 = tail call i32 (i32, ...) bitcast (i32 (...)* @gridNamePtr to i32 (i32, ...)*)(i32 %38)
%40 = tail call i32 (i8*, i32, i32, ...) bitcast (i32 (...)* @cdoWarning to i32 (i8*, i32, i32, ...)*)(i8* getelementptr inbounds ([60 x i8], [60 x i8]* @.str.2, i64 0, i64 0), i32 %37, i32 %39)
br label %41
41: ; preds = %26, %24, %34, %31, %36
ret void
}