#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 *, ...);
int gen_med_auxinput_in_closes(FILE *fp) {
  char *aux, *streamtype, streamno[5];
  int i;
  for (i = 1; i < 12; i++) {
    fprintf(fp, " CASE ( AUXINPUT%d_ALARM )\n", i);
    fprintf(fp,
            "     IF ( grid%%nframes(stream) >= "
            "config_flags%%frames_per_auxinput%d ) THEN\n",
            i);
    fprintf(fp,
            "       CALL close_dataset ( grid%%auxinput%d_oid , config_flags , "
            "\"DATASET=AUXINPUT%d\" )\n",
            i, i);
    fprintf(fp, "       grid%%auxinput%d_oid = 0\n", i);
    fprintf(fp, "       grid%%nframes(stream) = 0\n");
    fprintf(fp, "     ENDIF\n");
  }
  return 0;
}


x86 assembly (clang, -O0):
<gen_med_auxinput_in_closes>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x1,-0x24(%rbp)
cmpl   $0xc,-0x24(%rbp)
jge    11b6 <gen_med_auxinput_in_closes+0xa6>
mov    -0x8(%rbp),%rdi
mov    -0x24(%rbp),%edx
lea    0xec5(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    -0x8(%rbp),%rdi
mov    -0x24(%rbp),%edx
lea    0xecc(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    -0x8(%rbp),%rdi
mov    -0x24(%rbp),%edx
mov    -0x24(%rbp),%ecx
lea    0xf03(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    -0x8(%rbp),%rdi
mov    -0x24(%rbp),%edx
lea    0xf48(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    -0x8(%rbp),%rdi
lea    0xf57(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    -0x8(%rbp),%rdi
lea    0xf67(%rip),%rsi
mov    $0x0,%al
call   1030 <fprintf@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1123 <gen_med_auxinput_in_closes+0x13>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gen_med_auxinput_in_closes>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rdi,%rbx
mov    $0x1,%ebp
lea    0xf31(%rip),%r12
lea    0xf84(%rip),%r13
lea    0xf9e(%rip),%r14
lea    0xfb9(%rip),%r15
nop
mov    %rbx,%rdi
lea    0xea6(%rip),%rsi
mov    %ebp,%edx
xor    %eax,%eax
call   1030 <fprintf@plt>
mov    %rbx,%rdi
lea    0xeaf(%rip),%rsi
mov    %ebp,%edx
xor    %eax,%eax
call   1030 <fprintf@plt>
mov    %rbx,%rdi
mov    %r12,%rsi
mov    %ebp,%edx
mov    %ebp,%ecx
xor    %eax,%eax
call   1030 <fprintf@plt>
mov    %rbx,%rdi
mov    %r13,%rsi
mov    %ebp,%edx
xor    %eax,%eax
call   1030 <fprintf@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1030 <fprintf@plt>
mov    $0xb,%esi
mov    $0x1,%edx
mov    %r15,%rdi
mov    %rbx,%rcx
call   1040 <fwrite@plt>
add    $0x1,%ebp
cmp    $0xc,%ebp
jne    1150 <gen_med_auxinput_in_closes+0x30>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [28 x i8] c" CASE ( AUXINPUT%d_ALARM )\0A\00"
@.str.1 = [79 x i8] c" IF ( grid%%nframes(stream) >= config_flags%%frames_per_auxinput%d ) THEN\0A\00"
@.str.2 = [90 x i8] c" CALL close_dataset ( grid%%auxinput%d_oid , config_flags , \22DATASET=AUXINPUT%d\22 )\0A\00"
@.str.3 = [33 x i8] c" grid%%auxinput%d_oid = 0\0A\00"
@.str.4 = [34 x i8] c" grid%%nframes(stream) = 0\0A\00"
@.str.5 = [12 x i8] c" ENDIF\0A\00"
define i32 @gen_med_auxinput_in_closes(i32* %0) {
%2 = alloca i32*
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca [5 x i8]
%6 = alloca i32
store i32* %0, i32** %2
store i32 1, i32* %6
br label %7
7: ; preds = %28, %1
%8 = load i32, i32* %6
%9 = icmp slt i32 %8, 12
br i1 %9, label %10, label %31
10: ; preds = %7
%11 = load i32*, i32** %2
%12 = load i32, i32* %6
%13 = call i32 (i32*, i8*, ...) @fprintf(i32* %11, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), i32 %12)
%14 = load i32*, i32** %2
%15 = load i32, i32* %6
%16 = call i32 (i32*, i8*, ...) @fprintf(i32* %14, i8* getelementptr inbounds ([79 x i8], [79 x i8]* @.str.1, i64 0, i64 0), i32 %15)
%17 = load i32*, i32** %2
%18 = load i32, i32* %6
%19 = load i32, i32* %6
%20 = call i32 (i32*, i8*, ...) @fprintf(i32* %17, i8* getelementptr inbounds ([90 x i8], [90 x i8]* @.str.2, i64 0, i64 0), i32 %18, i32 %19)
%21 = load i32*, i32** %2
%22 = load i32, i32* %6
%23 = call i32 (i32*, i8*, ...) @fprintf(i32* %21, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.3, i64 0, i64 0), i32 %22)
%24 = load i32*, i32** %2
%25 = call i32 (i32*, i8*, ...) @fprintf(i32* %24, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.4, i64 0, i64 0))
%26 = load i32*, i32** %2
%27 = call i32 (i32*, i8*, ...) @fprintf(i32* %26, i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0))
br label %28
28: ; preds = %10
%29 = load i32, i32* %6
%30 = add nsw i32 %29, 1
store i32 %30, i32* %6
br label %7
31: ; preds = %7
ret i32 0
}

LLVM IR (-O2):
@.str = [28 x i8] c" CASE ( AUXINPUT%d_ALARM )\0A\00"
@.str.1 = [79 x i8] c" IF ( grid%%nframes(stream) >= config_flags%%frames_per_auxinput%d ) THEN\0A\00"
@.str.2 = [90 x i8] c" CALL close_dataset ( grid%%auxinput%d_oid , config_flags , \22DATASET=AUXINPUT%d\22 )\0A\00"
@.str.3 = [33 x i8] c" grid%%auxinput%d_oid = 0\0A\00"
@.str.4 = [34 x i8] c" grid%%nframes(stream) = 0\0A\00"
@.str.5 = [12 x i8] c" ENDIF\0A\00"
define i32 @gen_med_auxinput_in_closes(i32* nocapture %0) {
br label %2
2: ; preds = %1, %2
%3 = phi i32 [ 1, %1 ], [ %10, %2 ]
%4 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), i32 %3)
%5 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([79 x i8], [79 x i8]* @.str.1, i64 0, i64 0), i32 %3)
%6 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([90 x i8], [90 x i8]* @.str.2, i64 0, i64 0), i32 %3, i32 %3)
%7 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.3, i64 0, i64 0), i32 %3)
%8 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.4, i64 0, i64 0))
%9 = tail call i64 @fwrite(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0), i64 11, i64 1, i32* %0)
%10 = add nuw nsw i32 %3, 1
%11 = icmp eq i32 %10, 12
br i1 %11, label %12, label %2
12: ; preds = %2
ret i32 0
}