#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 */
struct lrg_get_args {
  int dummy;
};
struct low_res_grid_cell {
  int dummy;
};
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
void lrg_print_val(struct low_res_grid_cell **grid, int xcnt, int ycnt,
                   const struct lrg_get_args *a, FILE *f,
                   const char *section_label,
                   double (*get_field)(struct low_res_grid_cell **, int, int,
                                       const struct lrg_get_args *)) {
  int i, j;
  fprintf(f, "# %s\n", section_label);
  for (j = 0; j < ycnt; j++) {
    for (i = 0; i < xcnt; i++)
      fprintf(f, "%5.2f ", get_field(grid, i, j, a));
    fprintf(f, "\n");
  }
  fprintf(f, "\n");
}


x86 assembly (clang, -O0):
<lrg_print_val>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    0x10(%rbp),%rax
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %rcx,-0x18(%rbp)
mov    %r8,-0x20(%rbp)
mov    %r9,-0x28(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x28(%rbp),%rdx
lea    0xebf(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
movl   $0x0,-0x30(%rbp)
mov    -0x30(%rbp),%eax
cmp    -0x10(%rbp),%eax
jge    11ca <lrg_print_val+0xba>
movl   $0x0,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11aa <lrg_print_val+0x9a>
mov    -0x20(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    0x10(%rbp),%rax
mov    -0x8(%rbp),%rdi
mov    -0x2c(%rbp),%esi
mov    -0x30(%rbp),%edx
mov    -0x18(%rbp),%rcx
call   *%rax
mov    -0x38(%rbp),%rdi
lea    0xe71(%rip),%rsi
mov    $0x1,%al
call   1030 <fprintf@plt>
mov    -0x2c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x2c(%rbp)
jmp    1162 <lrg_print_val+0x52>
mov    -0x20(%rbp),%rdi
lea    0xe4f(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    114f <lrg_print_val+0x3f>
mov    -0x20(%rbp),%rdi
lea    0xe2f(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<lrg_print_val>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %r8,%r13
mov    %rcx,0x20(%rsp)
mov    %edx,%r15d
mov    %esi,%ebp
mov    %rdi,0x18(%rsp)
mov    0x60(%rsp),%rax
mov    %rax,0x10(%rsp)
lea    0xeaf(%rip),%rsi
xor    %ebx,%ebx
mov    %r8,%rdi
mov    %r9,%rdx
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    %r15d,0xc(%rsp)
test   %r15d,%r15d
jle    11db <lrg_print_val+0xbb>
mov    %ebp,0x8(%rsp)
mov    0x20(%rsp),%r12
mov    0x18(%rsp),%r14
jmp    119a <lrg_print_val+0x7a>
nopw   0x0(%rax,%rax,1)
mov    $0xa,%edi
mov    %r13,%rsi
call   1030 <fputc@plt>
add    $0x1,%ebx
cmp    0xc(%rsp),%ebx
mov    0x8(%rsp),%ebp
je     11db <lrg_print_val+0xbb>
test   %ebp,%ebp
mov    0x10(%rsp),%rbp
jle    1180 <lrg_print_val+0x60>
xor    %r15d,%r15d
cs nopw 0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    %r15d,%esi
mov    %ebx,%edx
mov    %r12,%rcx
call   *%rbp
mov    %r13,%rdi
lea    0xe3f(%rip),%rsi
mov    $0x1,%al
call   1040 <fprintf@plt>
add    $0x1,%r15d
cmp    %r15d,0x8(%rsp)
jne    11b0 <lrg_print_val+0x90>
jmp    1180 <lrg_print_val+0x60>
mov    $0xa,%edi
mov    %r13,%rsi
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <fputc@plt>

LLVM IR (-O0):
%struct.low_res_grid_cell = type { i32 }
%struct.lrg_get_args = type { i32 }
@.str = [6 x i8] c"# %s\0A\00"
@.str.1 = [7 x i8] c"%5.2f \00"
@.str.2 = [2 x i8] c"\0A\00"
define void @lrg_print_val(%struct.low_res_grid_cell** %0, i32 %1, i32 %2, %struct.lrg_get_args* %3, i32* %4, i8* %5, double (%struct.low_res_grid_cell**, i32, i32, %struct.lrg_get_args*)* %6) {
%8 = alloca %struct.low_res_grid_cell**
%9 = alloca i32
%10 = alloca i32
%11 = alloca %struct.lrg_get_args*
%12 = alloca i32*
%13 = alloca i8*
%14 = alloca double (%struct.low_res_grid_cell**, i32, i32, %struct.lrg_get_args*)*
%15 = alloca i32
%16 = alloca i32
store %struct.low_res_grid_cell** %0, %struct.low_res_grid_cell*** %8
store i32 %1, i32* %9
store i32 %2, i32* %10
store %struct.lrg_get_args* %3, %struct.lrg_get_args** %11
store i32* %4, i32** %12
store i8* %5, i8** %13
store double (%struct.low_res_grid_cell**, i32, i32, %struct.lrg_get_args*)* %6, double (%struct.low_res_grid_cell**, i32, i32, %struct.lrg_get_args*)** %14
%17 = load i32*, i32** %12
%18 = load i8*, i8** %13
%19 = call i32 (i32*, i8*, ...) @fprintf(i32* %17, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %18)
store i32 0, i32* %16
br label %20
20: ; preds = %44, %7
%21 = load i32, i32* %16
%22 = load i32, i32* %10
%23 = icmp slt i32 %21, %22
br i1 %23, label %24, label %47
24: ; preds = %20
store i32 0, i32* %15
br label %25
25: ; preds = %38, %24
%26 = load i32, i32* %15
%27 = load i32, i32* %9
%28 = icmp slt i32 %26, %27
br i1 %28, label %29, label %41
29: ; preds = %25
%30 = load i32*, i32** %12
%31 = load double (%struct.low_res_grid_cell**, i32, i32, %struct.lrg_get_args*)*, double (%struct.low_res_grid_cell**, i32, i32, %struct.lrg_get_args*)** %14
%32 = load %struct.low_res_grid_cell**, %struct.low_res_grid_cell*** %8
%33 = load i32, i32* %15
%34 = load i32, i32* %16
%35 = load %struct.lrg_get_args*, %struct.lrg_get_args** %11
%36 = call double %31(%struct.low_res_grid_cell** %32, i32 %33, i32 %34, %struct.lrg_get_args* %35)
%37 = call i32 (i32*, i8*, ...) @fprintf(i32* %30, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), double %36)
br label %38
38: ; preds = %29
%39 = load i32, i32* %15
%40 = add nsw i32 %39, 1
store i32 %40, i32* %15
br label %25
41: ; preds = %25
%42 = load i32*, i32** %12
%43 = call i32 (i32*, i8*, ...) @fprintf(i32* %42, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
br label %44
44: ; preds = %41
%45 = load i32, i32* %16
%46 = add nsw i32 %45, 1
store i32 %46, i32* %16
br label %20
47: ; preds = %20
%48 = load i32*, i32** %12
%49 = call i32 (i32*, i8*, ...) @fprintf(i32* %48, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
%struct.low_res_grid_cell = type { i32 }
%struct.lrg_get_args = type { i32 }
@.str = [6 x i8] c"# %s\0A\00"
@.str.1 = [7 x i8] c"%5.2f \00"
define void @lrg_print_val(%struct.low_res_grid_cell** %0, i32 %1, i32 %2, %struct.lrg_get_args* %3, i32* nocapture %4, i8* %5, double (%struct.low_res_grid_cell**, i32, i32, %struct.lrg_get_args*)* nocapture %6) {
%8 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %4, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %5)
%9 = icmp sgt i32 %2, 0
br i1 %9, label %10, label %24
10: ; preds = %7
%11 = icmp sgt i32 %1, 0
br label %12
12: ; preds = %10, %20
%13 = phi i32 [ 0, %10 ], [ %22, %20 ]
br i1 %11, label %14, label %20
14: ; preds = %12, %14
%15 = phi i32 [ %18, %14 ], [ 0, %12 ]
%16 = tail call double %6(%struct.low_res_grid_cell** %0, i32 %15, i32 %13, %struct.lrg_get_args* %3)
%17 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %4, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), double %16)
%18 = add nuw nsw i32 %15, 1
%19 = icmp eq i32 %18, %1
br i1 %19, label %20, label %14
20: ; preds = %14, %12
%21 = tail call i32 @fputc(i32 10, i32* %4)
%22 = add nuw nsw i32 %13, 1
%23 = icmp eq i32 %22, %2
br i1 %23, label %24, label %12
24: ; preds = %20, %7
%25 = tail call i32 @fputc(i32 10, i32* %4)
ret void
}