#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*/ fprintf(int /*<<< orphan*/ *, char *, ...);
gen_med_open_esmf_calls(FILE *fp) {
  int i;
  for (i = 1; i < 12; i++) {
    fprintf(fp, "CALL nl_get_io_form_auxinput%d( 1, io_form )\n", i);
    fprintf(fp, "IF ( use_package( io_form ) == IO_ESMF ) THEN\n");
    fprintf(fp, "  stream = first_auxinput + %d\n", i - 1);
    fprintf(fp,
            "  CALL open_aux_u( grid, config_flags, stream, AUXINPUT%d_ALARM,  "
            "     &\n",
            i);
    fprintf(fp,
            "                   config_flags%%auxinput%d_inname, "
            "grid%%auxinput%d_oid, &\n",
            i, i);
    fprintf(fp, "                   input_auxinput%d, ierr )\n", i);
    fprintf(fp, "  IF ( ierr /= 0 ) RETURN\n");
    fprintf(fp, "ENDIF\n");
  }
  for (i = 1; i < 12; i++) {
    fprintf(fp, "CALL nl_get_io_form_auxhist%d( 1, io_form )\n", i);
    fprintf(fp, "IF ( use_package( io_form ) == IO_ESMF ) THEN\n");
    fprintf(fp, "  stream = first_auxhist + %d\n", i - 1);
    fprintf(fp,
            "  CALL open_hist_w( grid, config_flags, stream, AUXHIST%d_ALARM,  "
            "     &\n",
            i);
    fprintf(fp,
            "                    config_flags%%auxhist%d_outname, "
            "grid%%auxhist%d_oid, &\n",
            i, i);
    fprintf(fp, "                    output_auxhist%d, fname, n2, ierr )\n", i);
    fprintf(fp, "  IF ( ierr /= 0 ) RETURN\n");
    fprintf(fp, "ENDIF\n");
  }
  return 0;
}


x86 assembly (clang, -O0):
<gen_med_open_esmf_calls>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x1,-0xc(%rbp)
cmpl   $0xc,-0xc(%rbp)
jge    11e0 <gen_med_open_esmf_calls+0xd0>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%edx
lea    0xec5(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    -0x8(%rbp),%rdi
lea    0xee1(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%edx
sub    $0x1,%edx
lea    0xef8(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%edx
lea    0xf03(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%edx
mov    -0xc(%rbp),%ecx
lea    0xf35(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%edx
lea    0xf6d(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    -0x8(%rbp),%rdi
lea    0xf88(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    -0x8(%rbp),%rdi
lea    0xf91(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1123 <gen_med_open_esmf_calls+0x13>
movl   $0x1,-0xc(%rbp)
cmpl   $0xc,-0xc(%rbp)
jge    12a4 <gen_med_open_esmf_calls+0x194>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%edx
lea    0xf64(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    -0x8(%rbp),%rdi
lea    0xe1d(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%edx
sub    $0x1,%edx
lea    0xf67(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%edx
lea    0xf71(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%edx
mov    -0xc(%rbp),%ecx
lea    0xfa3(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%edx
lea    0xfdb(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    -0x8(%rbp),%rdi
lea    0xec4(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    -0x8(%rbp),%rdi
lea    0xecd(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    11e7 <gen_med_open_esmf_calls+0xd7>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gen_med_open_esmf_calls>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdi,%r14
mov    $0x1,%ebx
lea    0xf8d(%rip),%r15
lea    0xfd3(%rip),%r12
lea    0xff9(%rip),%r13
lea    0x100d(%rip),%rbp
nop
mov    %r14,%rdi
lea    0xea6(%rip),%rsi
mov    %ebx,%edx
xor    %eax,%eax
call   1030 <fprintf@plt>
mov    $0x2e,%esi
mov    $0x1,%edx
lea    0xeba(%rip),%rdi
mov    %r14,%rcx
call   1040 <fwrite@plt>
lea    -0x1(%rbx),%edx
mov    %r14,%rdi
lea    0xed4(%rip),%rsi
xor    %eax,%eax
call   1030 <fprintf@plt>
mov    %r14,%rdi
lea    0xee3(%rip),%rsi
mov    %ebx,%edx
xor    %eax,%eax
call   1030 <fprintf@plt>
mov    %r14,%rdi
mov    %r15,%rsi
mov    %ebx,%edx
mov    %ebx,%ecx
xor    %eax,%eax
call   1030 <fprintf@plt>
mov    %r14,%rdi
mov    %r12,%rsi
mov    %ebx,%edx
xor    %eax,%eax
call   1030 <fprintf@plt>
mov    $0x1a,%esi
mov    $0x1,%edx
mov    %r13,%rdi
mov    %r14,%rcx
call   1040 <fwrite@plt>
mov    $0x6,%esi
mov    $0x1,%edx
mov    %rbp,%rdi
mov    %r14,%rcx
call   1040 <fwrite@plt>
add    $0x1,%ebx
cmp    $0xc,%ebx
jne    1150 <gen_med_open_esmf_calls+0x30>
mov    $0x1,%ebx
lea    0xff4(%rip),%r15
lea    0x103a(%rip),%r12
lea    0xf2e(%rip),%r13
lea    0xf42(%rip),%rbp
nopw   0x0(%rax,%rax,1)
mov    %r14,%rdi
lea    0xf39(%rip),%rsi
mov    %ebx,%edx
xor    %eax,%eax
call   1030 <fprintf@plt>
mov    $0x2e,%esi
mov    $0x1,%edx
lea    0xdea(%rip),%rdi
mov    %r14,%rcx
call   1040 <fwrite@plt>
lea    -0x1(%rbx),%edx
mov    %r14,%rdi
lea    0xf37(%rip),%rsi
xor    %eax,%eax
call   1030 <fprintf@plt>
mov    %r14,%rdi
lea    0xf45(%rip),%rsi
mov    %ebx,%edx
xor    %eax,%eax
call   1030 <fprintf@plt>
mov    %r14,%rdi
mov    %r15,%rsi
mov    %ebx,%edx
mov    %ebx,%ecx
xor    %eax,%eax
call   1030 <fprintf@plt>
mov    %r14,%rdi
mov    %r12,%rsi
mov    %ebx,%edx
xor    %eax,%eax
call   1030 <fprintf@plt>
mov    $0x1a,%esi
mov    $0x1,%edx
mov    %r13,%rdi
mov    %r14,%rcx
call   1040 <fwrite@plt>
mov    $0x6,%esi
mov    $0x1,%edx
mov    %rbp,%rdi
mov    %r14,%rcx
call   1040 <fwrite@plt>
add    $0x1,%ebx
cmp    $0xc,%ebx
jne    1220 <gen_med_open_esmf_calls+0x100>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [46 x i8] c"CALL nl_get_io_form_auxinput%d( 1, io_form )\0A\00"
@.str.1 = [47 x i8] c"IF ( use_package( io_form ) == IO_ESMF ) THEN\0A\00"
@.str.2 = [32 x i8] c" stream = first_auxinput + %d\0A\00"
@.str.3 = [74 x i8] c" CALL open_aux_u( grid, config_flags, stream, AUXINPUT%d_ALARM, &\0A\00"
@.str.4 = [77 x i8] c" config_flags%%auxinput%d_inname, grid%%auxinput%d_oid, &\0A\00"
@.str.5 = [45 x i8] c" input_auxinput%d, ierr )\0A\00"
@.str.6 = [27 x i8] c" IF ( ierr /= 0 ) RETURN\0A\00"
@.str.7 = [7 x i8] c"ENDIF\0A\00"
@.str.8 = [45 x i8] c"CALL nl_get_io_form_auxhist%d( 1, io_form )\0A\00"
@.str.9 = [31 x i8] c" stream = first_auxhist + %d\0A\00"
@.str.10 = [74 x i8] c" CALL open_hist_w( grid, config_flags, stream, AUXHIST%d_ALARM, &\0A\00"
@.str.11 = [77 x i8] c" config_flags%%auxhist%d_outname, grid%%auxhist%d_oid, &\0A\00"
@.str.12 = [57 x i8] c" output_auxhist%d, fname, n2, ierr )\0A\00"
define i32 @gen_med_open_esmf_calls(i32* %0) {
%2 = alloca i32*
%3 = alloca i32
store i32* %0, i32** %2
store i32 1, i32* %3
br label %4
4: ; preds = %31, %1
%5 = load i32, i32* %3
%6 = icmp slt i32 %5, 12
br i1 %6, label %7, label %34
7: ; preds = %4
%8 = load i32*, i32** %2
%9 = load i32, i32* %3
%10 = call i32 (i32*, i8*, ...) @fprintf(i32* %8, i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str, i64 0, i64 0), i32 %9)
%11 = load i32*, i32** %2
%12 = call i32 (i32*, i8*, ...) @fprintf(i32* %11, i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.1, i64 0, i64 0))
%13 = load i32*, i32** %2
%14 = load i32, i32* %3
%15 = sub nsw i32 %14, 1
%16 = call i32 (i32*, i8*, ...) @fprintf(i32* %13, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0), i32 %15)
%17 = load i32*, i32** %2
%18 = load i32, i32* %3
%19 = call i32 (i32*, i8*, ...) @fprintf(i32* %17, i8* getelementptr inbounds ([74 x i8], [74 x i8]* @.str.3, i64 0, i64 0), i32 %18)
%20 = load i32*, i32** %2
%21 = load i32, i32* %3
%22 = load i32, i32* %3
%23 = call i32 (i32*, i8*, ...) @fprintf(i32* %20, i8* getelementptr inbounds ([77 x i8], [77 x i8]* @.str.4, i64 0, i64 0), i32 %21, i32 %22)
%24 = load i32*, i32** %2
%25 = load i32, i32* %3
%26 = call i32 (i32*, i8*, ...) @fprintf(i32* %24, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.5, i64 0, i64 0), i32 %25)
%27 = load i32*, i32** %2
%28 = call i32 (i32*, i8*, ...) @fprintf(i32* %27, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.6, i64 0, i64 0))
%29 = load i32*, i32** %2
%30 = call i32 (i32*, i8*, ...) @fprintf(i32* %29, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0))
br label %31
31: ; preds = %7
%32 = load i32, i32* %3
%33 = add nsw i32 %32, 1
store i32 %33, i32* %3
br label %4
34: ; preds = %4
store i32 1, i32* %3
br label %35
35: ; preds = %62, %34
%36 = load i32, i32* %3
%37 = icmp slt i32 %36, 12
br i1 %37, label %38, label %65
38: ; preds = %35
%39 = load i32*, i32** %2
%40 = load i32, i32* %3
%41 = call i32 (i32*, i8*, ...) @fprintf(i32* %39, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.8, i64 0, i64 0), i32 %40)
%42 = load i32*, i32** %2
%43 = call i32 (i32*, i8*, ...) @fprintf(i32* %42, i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.1, i64 0, i64 0))
%44 = load i32*, i32** %2
%45 = load i32, i32* %3
%46 = sub nsw i32 %45, 1
%47 = call i32 (i32*, i8*, ...) @fprintf(i32* %44, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.9, i64 0, i64 0), i32 %46)
%48 = load i32*, i32** %2
%49 = load i32, i32* %3
%50 = call i32 (i32*, i8*, ...) @fprintf(i32* %48, i8* getelementptr inbounds ([74 x i8], [74 x i8]* @.str.10, i64 0, i64 0), i32 %49)
%51 = load i32*, i32** %2
%52 = load i32, i32* %3
%53 = load i32, i32* %3
%54 = call i32 (i32*, i8*, ...) @fprintf(i32* %51, i8* getelementptr inbounds ([77 x i8], [77 x i8]* @.str.11, i64 0, i64 0), i32 %52, i32 %53)
%55 = load i32*, i32** %2
%56 = load i32, i32* %3
%57 = call i32 (i32*, i8*, ...) @fprintf(i32* %55, i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str.12, i64 0, i64 0), i32 %56)
%58 = load i32*, i32** %2
%59 = call i32 (i32*, i8*, ...) @fprintf(i32* %58, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.6, i64 0, i64 0))
%60 = load i32*, i32** %2
%61 = call i32 (i32*, i8*, ...) @fprintf(i32* %60, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0))
br label %62
62: ; preds = %38
%63 = load i32, i32* %3
%64 = add nsw i32 %63, 1
store i32 %64, i32* %3
br label %35
65: ; preds = %35
ret i32 0
}

LLVM IR (-O2):
@.str = [46 x i8] c"CALL nl_get_io_form_auxinput%d( 1, io_form )\0A\00"
@.str.1 = [47 x i8] c"IF ( use_package( io_form ) == IO_ESMF ) THEN\0A\00"
@.str.2 = [32 x i8] c" stream = first_auxinput + %d\0A\00"
@.str.3 = [74 x i8] c" CALL open_aux_u( grid, config_flags, stream, AUXINPUT%d_ALARM, &\0A\00"
@.str.4 = [77 x i8] c" config_flags%%auxinput%d_inname, grid%%auxinput%d_oid, &\0A\00"
@.str.5 = [45 x i8] c" input_auxinput%d, ierr )\0A\00"
@.str.6 = [27 x i8] c" IF ( ierr /= 0 ) RETURN\0A\00"
@.str.7 = [7 x i8] c"ENDIF\0A\00"
@.str.8 = [45 x i8] c"CALL nl_get_io_form_auxhist%d( 1, io_form )\0A\00"
@.str.9 = [31 x i8] c" stream = first_auxhist + %d\0A\00"
@.str.10 = [74 x i8] c" CALL open_hist_w( grid, config_flags, stream, AUXHIST%d_ALARM, &\0A\00"
@.str.11 = [77 x i8] c" config_flags%%auxhist%d_outname, grid%%auxhist%d_oid, &\0A\00"
@.str.12 = [57 x i8] c" output_auxhist%d, fname, n2, ierr )\0A\00"
define i32 @gen_med_open_esmf_calls(i32* nocapture %0) {
br label %2
2: ; preds = %1, %2
%3 = phi i32 [ 1, %1 ], [ %13, %2 ]
%4 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str, i64 0, i64 0), i32 %3)
%5 = tail call i64 @fwrite(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.1, i64 0, i64 0), i64 46, i64 1, i32* %0)
%6 = add nsw i32 %3, -1
%7 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0), i32 %6)
%8 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([74 x i8], [74 x i8]* @.str.3, i64 0, i64 0), i32 %3)
%9 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([77 x i8], [77 x i8]* @.str.4, i64 0, i64 0), i32 %3, i32 %3)
%10 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.5, i64 0, i64 0), i32 %3)
%11 = tail call i64 @fwrite(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.6, i64 0, i64 0), i64 26, i64 1, i32* %0)
%12 = tail call i64 @fwrite(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0), i64 6, i64 1, i32* %0)
%13 = add nuw nsw i32 %3, 1
%14 = icmp eq i32 %13, 12
br i1 %14, label %15, label %2
15: ; preds = %2, %15
%16 = phi i32 [ %26, %15 ], [ 1, %2 ]
%17 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.8, i64 0, i64 0), i32 %16)
%18 = tail call i64 @fwrite(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.1, i64 0, i64 0), i64 46, i64 1, i32* %0)
%19 = add nsw i32 %16, -1
%20 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.9, i64 0, i64 0), i32 %19)
%21 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([74 x i8], [74 x i8]* @.str.10, i64 0, i64 0), i32 %16)
%22 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([77 x i8], [77 x i8]* @.str.11, i64 0, i64 0), i32 %16, i32 %16)
%23 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([57 x i8], [57 x i8]* @.str.12, i64 0, i64 0), i32 %16)
%24 = tail call i64 @fwrite(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.6, i64 0, i64 0), i64 26, i64 1, i32* %0)
%25 = tail call i64 @fwrite(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.7, i64 0, i64 0), i64 6, i64 1, i32* %0)
%26 = add nuw nsw i32 %16, 1
%27 = icmp eq i32 %26, 12
br i1 %27, label %28, label %15
28: ; preds = %15
ret i32 0
}