#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, int, int);
int gen_shutdown_closes(FILE *fp) {
  char *aux, *streamtype, streamno[5];
  int i;
  for (i = 1; i < 12; i++) {
    fprintf(fp,
            "IF( grid%%auxhist%d_oid > 0 ) CALL close_dataset ( "
            "grid%%auxhist%d_oid, config_flags, 'DATASET=AUXHIST%d' )\n",
            i, i, i);
  }
  return 0;
}


x86 assembly (clang, -O0):
<gen_shutdown_closes>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x1,-0x24(%rbp)
cmpl   $0xc,-0x24(%rbp)
jge    1155 <gen_shutdown_closes+0x45>
mov    -0x8(%rbp),%rdi
mov    -0x24(%rbp),%edx
mov    -0x24(%rbp),%ecx
mov    -0x24(%rbp),%r8d
lea    0xebe(%rip),%rsi
call   1030 <fprintf@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    1123 <gen_shutdown_closes+0x13>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gen_shutdown_closes>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
lea    0xee2(%rip),%r14
mov    %r14,%rsi
mov    $0x1,%edx
mov    $0x1,%ecx
mov    $0x1,%r8d
call   1030 <fprintf@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x2,%edx
mov    $0x2,%ecx
mov    $0x2,%r8d
call   1030 <fprintf@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x3,%edx
mov    $0x3,%ecx
mov    $0x3,%r8d
call   1030 <fprintf@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x4,%edx
mov    $0x4,%ecx
mov    $0x4,%r8d
call   1030 <fprintf@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x5,%edx
mov    $0x5,%ecx
mov    $0x5,%r8d
call   1030 <fprintf@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x6,%edx
mov    $0x6,%ecx
mov    $0x6,%r8d
call   1030 <fprintf@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x7,%edx
mov    $0x7,%ecx
mov    $0x7,%r8d
call   1030 <fprintf@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x8,%edx
mov    $0x8,%ecx
mov    $0x8,%r8d
call   1030 <fprintf@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0x9,%edx
mov    $0x9,%ecx
mov    $0x9,%r8d
call   1030 <fprintf@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0xa,%edx
mov    $0xa,%ecx
mov    $0xa,%r8d
call   1030 <fprintf@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
mov    $0xb,%edx
mov    $0xb,%ecx
mov    $0xb,%r8d
call   1030 <fprintf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [109 x i8] c"IF( grid%%auxhist%d_oid > 0 ) CALL close_dataset ( grid%%auxhist%d_oid, config_flags, 'DATASET=AUXHIST%d' )\0A\00"
define i32 @gen_shutdown_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 = %16, %1
%8 = load i32, i32* %6
%9 = icmp slt i32 %8, 12
br i1 %9, label %10, label %19
10: ; preds = %7
%11 = load i32*, i32** %2
%12 = load i32, i32* %6
%13 = load i32, i32* %6
%14 = load i32, i32* %6
%15 = call i32 @fprintf(i32* %11, i8* getelementptr inbounds ([109 x i8], [109 x i8]* @.str, i64 0, i64 0), i32 %12, i32 %13, i32 %14)
br label %16
16: ; preds = %10
%17 = load i32, i32* %6
%18 = add nsw i32 %17, 1
store i32 %18, i32* %6
br label %7
19: ; preds = %7
ret i32 0
}

LLVM IR (-O2):
@.str = [109 x i8] c"IF( grid%%auxhist%d_oid > 0 ) CALL close_dataset ( grid%%auxhist%d_oid, config_flags, 'DATASET=AUXHIST%d' )\0A\00"
define i32 @gen_shutdown_closes(i32* nocapture %0) {
%2 = tail call i32 @fprintf(i32* %0, i8* getelementptr inbounds ([109 x i8], [109 x i8]* @.str, i64 0, i64 0), i32 1, i32 1, i32 1)
%3 = tail call i32 @fprintf(i32* %0, i8* getelementptr inbounds ([109 x i8], [109 x i8]* @.str, i64 0, i64 0), i32 2, i32 2, i32 2)
%4 = tail call i32 @fprintf(i32* %0, i8* getelementptr inbounds ([109 x i8], [109 x i8]* @.str, i64 0, i64 0), i32 3, i32 3, i32 3)
%5 = tail call i32 @fprintf(i32* %0, i8* getelementptr inbounds ([109 x i8], [109 x i8]* @.str, i64 0, i64 0), i32 4, i32 4, i32 4)
%6 = tail call i32 @fprintf(i32* %0, i8* getelementptr inbounds ([109 x i8], [109 x i8]* @.str, i64 0, i64 0), i32 5, i32 5, i32 5)
%7 = tail call i32 @fprintf(i32* %0, i8* getelementptr inbounds ([109 x i8], [109 x i8]* @.str, i64 0, i64 0), i32 6, i32 6, i32 6)
%8 = tail call i32 @fprintf(i32* %0, i8* getelementptr inbounds ([109 x i8], [109 x i8]* @.str, i64 0, i64 0), i32 7, i32 7, i32 7)
%9 = tail call i32 @fprintf(i32* %0, i8* getelementptr inbounds ([109 x i8], [109 x i8]* @.str, i64 0, i64 0), i32 8, i32 8, i32 8)
%10 = tail call i32 @fprintf(i32* %0, i8* getelementptr inbounds ([109 x i8], [109 x i8]* @.str, i64 0, i64 0), i32 9, i32 9, i32 9)
%11 = tail call i32 @fprintf(i32* %0, i8* getelementptr inbounds ([109 x i8], [109 x i8]* @.str, i64 0, i64 0), i32 10, i32 10, i32 10)
%12 = tail call i32 @fprintf(i32* %0, i8* getelementptr inbounds ([109 x i8], [109 x i8]* @.str, i64 0, i64 0), i32 11, i32 11, i32 11)
ret i32 0
}