#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 */

/* Variables and functions */
int /*<<< orphan*/ nc_close(int);
int /*<<< orphan*/ nc_create(char *, int, int *);
int nc_def_dim(int, char *, int, int *);
int nc_def_var(int, char *, int, int, int *, int *);
int /*<<< orphan*/ nc_open(char *, int, int *);
int /*<<< orphan*/ nc_redef(int);
int /*<<< orphan*/ nc_rename_dim(int, int, char *);
int /*<<< orphan*/ nc_rename_var(int, int, char *);
int main() {
  int status;
  int id;
  int rh_id, varid, v1, v2, v3, v4;
  int dimids[2];
  nc_create("tst_rehash.nc", 0x0000, &id);
  nc_redef(id);
  status = nc_def_dim(id, "dim1", 10, &dimids[0]);
  status = nc_def_var(id, "dim1", 5, 1, dimids, &v1);
  status = nc_def_var(id, "var1", 5, 1, dimids, &v2);
  nc_close(id);
  nc_open("tst_rehash.nc", 0x0001, &id);
  nc_redef(id);
  nc_rename_var(id, v1, "dim_new1");
  nc_rename_dim(id, dimids[0], "dim_new1");
  status = nc_def_dim(id, "dim2", 20, &dimids[1]);
  nc_def_var(id, "dim2", 5, 1, &dimids[1], &v3);
  nc_def_var(id, "var2", 5, 2, dimids, &v4);
  nc_close(id);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
lea    0xe71(%rip),%rdi
xor    %esi,%esi
lea    -0x8(%rbp),%rdx
call   1050 <nc_create@plt>
mov    -0x8(%rbp),%edi
call   1040 <nc_redef@plt>
mov    -0x8(%rbp),%edi
lea    -0x28(%rbp),%rcx
lea    0xe5e(%rip),%rsi
mov    $0xa,%edx
call   1090 <nc_def_dim@plt>
mov    %eax,-0x4(%rbp)
mov    -0x8(%rbp),%edi
lea    -0x28(%rbp),%r8
lea    0xe43(%rip),%rsi
mov    $0x5,%edx
mov    $0x1,%ecx
lea    -0x14(%rbp),%r9
call   1080 <nc_def_var@plt>
mov    %eax,-0x4(%rbp)
mov    -0x8(%rbp),%edi
lea    -0x28(%rbp),%r8
lea    0xe24(%rip),%rsi
mov    $0x5,%edx
mov    $0x1,%ecx
lea    -0x18(%rbp),%r9
call   1080 <nc_def_var@plt>
mov    %eax,-0x4(%rbp)
mov    -0x8(%rbp),%edi
call   1030 <nc_close@plt>
lea    0xdec(%rip),%rdi
mov    $0x1,%esi
lea    -0x8(%rbp),%rdx
call   10a0 <nc_open@plt>
mov    -0x8(%rbp),%edi
call   1040 <nc_redef@plt>
mov    -0x8(%rbp),%edi
mov    -0x14(%rbp),%esi
lea    0xde1(%rip),%rdx
call   1070 <nc_rename_var@plt>
mov    -0x8(%rbp),%edi
mov    -0x28(%rbp),%esi
lea    0xdcf(%rip),%rdx
call   1060 <nc_rename_dim@plt>
mov    -0x8(%rbp),%edi
lea    -0x28(%rbp),%rcx
add    $0x4,%rcx
lea    0xdc1(%rip),%rsi
mov    $0x14,%edx
call   1090 <nc_def_dim@plt>
mov    %eax,-0x4(%rbp)
mov    -0x8(%rbp),%edi
lea    -0x28(%rbp),%r8
add    $0x4,%r8
lea    0xda2(%rip),%rsi
mov    $0x5,%edx
mov    $0x1,%ecx
lea    -0x1c(%rbp),%r9
call   1080 <nc_def_var@plt>
mov    -0x8(%rbp),%edi
lea    -0x28(%rbp),%r8
lea    0xd86(%rip),%rsi
mov    $0x5,%edx
mov    $0x2,%ecx
lea    -0x20(%rbp),%r9
call   1080 <nc_def_var@plt>
mov    -0x8(%rbp),%edi
call   1030 <nc_close@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x28,%rsp
lea    0xe6e(%rip),%r14
lea    0xc(%rsp),%r15
mov    %r14,%rdi
xor    %esi,%esi
mov    %r15,%rdx
call   1050 <nc_create@plt>
mov    0xc(%rsp),%edi
call   1040 <nc_redef@plt>
mov    0xc(%rsp),%edi
lea    0xe56(%rip),%rbx
lea    0x14(%rsp),%r12
mov    %rbx,%rsi
mov    $0xa,%edx
mov    %r12,%rcx
call   1090 <nc_def_dim@plt>
mov    0xc(%rsp),%edi
lea    0x10(%rsp),%r9
mov    %rbx,%rsi
mov    $0x5,%edx
mov    $0x1,%ecx
mov    %r12,%r8
call   1080 <nc_def_var@plt>
mov    0xc(%rsp),%edi
lea    0xe1d(%rip),%rsi
lea    0x24(%rsp),%r9
mov    $0x5,%edx
mov    $0x1,%ecx
mov    %r12,%r8
call   1080 <nc_def_var@plt>
mov    0xc(%rsp),%edi
call   1030 <nc_close@plt>
mov    %r14,%rdi
mov    $0x1,%esi
mov    %r15,%rdx
call   10a0 <nc_open@plt>
mov    0xc(%rsp),%edi
call   1040 <nc_redef@plt>
mov    0xc(%rsp),%edi
mov    0x10(%rsp),%esi
lea    0xdda(%rip),%rbx
mov    %rbx,%rdx
call   1070 <nc_rename_var@plt>
mov    0xc(%rsp),%edi
mov    0x14(%rsp),%esi
mov    %rbx,%rdx
call   1060 <nc_rename_dim@plt>
mov    0xc(%rsp),%edi
lea    0x18(%rsp),%r14
lea    0xdbb(%rip),%rbx
mov    %rbx,%rsi
mov    $0x14,%edx
mov    %r14,%rcx
call   1090 <nc_def_dim@plt>
mov    0xc(%rsp),%edi
lea    0x20(%rsp),%r9
mov    %rbx,%rsi
mov    $0x5,%edx
mov    $0x1,%ecx
mov    %r14,%r8
call   1080 <nc_def_var@plt>
mov    0xc(%rsp),%edi
lea    0xd87(%rip),%rsi
lea    0x1c(%rsp),%r9
mov    $0x5,%edx
mov    $0x2,%ecx
mov    %r12,%r8
call   1080 <nc_def_var@plt>
mov    0xc(%rsp),%edi
call   1030 <nc_close@plt>
xor    %eax,%eax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [14 x i8] c"tst_rehash.nc\00"
@.str.1 = [5 x i8] c"dim1\00"
@.str.2 = [5 x i8] c"var1\00"
@.str.3 = [9 x i8] c"dim_new1\00"
@.str.4 = [5 x i8] c"dim2\00"
@.str.5 = [5 x i8] c"var2\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca [2 x i32]
%10 = call i32 @nc_create(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i32 0, i32* %2)
%11 = load i32, i32* %2
%12 = call i32 @nc_redef(i32 %11)
%13 = load i32, i32* %2
%14 = getelementptr inbounds [2 x i32], [2 x i32]* %9, i64 0, i64 0
%15 = call i32 @nc_def_dim(i32 %13, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 10, i32* %14)
store i32 %15, i32* %1
%16 = load i32, i32* %2
%17 = getelementptr inbounds [2 x i32], [2 x i32]* %9, i64 0, i64 0
%18 = call i32 @nc_def_var(i32 %16, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 5, i32 1, i32* %17, i32* %5)
store i32 %18, i32* %1
%19 = load i32, i32* %2
%20 = getelementptr inbounds [2 x i32], [2 x i32]* %9, i64 0, i64 0
%21 = call i32 @nc_def_var(i32 %19, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 5, i32 1, i32* %20, i32* %6)
store i32 %21, i32* %1
%22 = load i32, i32* %2
%23 = call i32 @nc_close(i32 %22)
%24 = call i32 @nc_open(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i32 1, i32* %2)
%25 = load i32, i32* %2
%26 = call i32 @nc_redef(i32 %25)
%27 = load i32, i32* %2
%28 = load i32, i32* %5
%29 = call i32 @nc_rename_var(i32 %27, i32 %28, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0))
%30 = load i32, i32* %2
%31 = getelementptr inbounds [2 x i32], [2 x i32]* %9, i64 0, i64 0
%32 = load i32, i32* %31
%33 = call i32 @nc_rename_dim(i32 %30, i32 %32, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0))
%34 = load i32, i32* %2
%35 = getelementptr inbounds [2 x i32], [2 x i32]* %9, i64 0, i64 1
%36 = call i32 @nc_def_dim(i32 %34, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i32 20, i32* %35)
store i32 %36, i32* %1
%37 = load i32, i32* %2
%38 = getelementptr inbounds [2 x i32], [2 x i32]* %9, i64 0, i64 1
%39 = call i32 @nc_def_var(i32 %37, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i32 5, i32 1, i32* %38, i32* %7)
%40 = load i32, i32* %2
%41 = getelementptr inbounds [2 x i32], [2 x i32]* %9, i64 0, i64 0
%42 = call i32 @nc_def_var(i32 %40, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), i32 5, i32 2, i32* %41, i32* %8)
%43 = load i32, i32* %2
%44 = call i32 @nc_close(i32 %43)
ret i32 0
}

LLVM IR (-O2):
@.str = [14 x i8] c"tst_rehash.nc\00"
@.str.1 = [5 x i8] c"dim1\00"
@.str.2 = [5 x i8] c"var1\00"
@.str.3 = [9 x i8] c"dim_new1\00"
@.str.4 = [5 x i8] c"dim2\00"
@.str.5 = [5 x i8] c"var2\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca [2 x i32]
%7 = bitcast i32* %1 to i8*
%8 = bitcast i32* %2 to i8*
%9 = bitcast i32* %3 to i8*
%10 = bitcast i32* %4 to i8*
%11 = bitcast i32* %5 to i8*
%12 = bitcast [2 x i32]* %6 to i8*
%13 = call i32 @nc_create(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i32 0, i32* %1)
%14 = load i32, i32* %1
%15 = call i32 @nc_redef(i32 %14)
%16 = load i32, i32* %1
%17 = getelementptr inbounds [2 x i32], [2 x i32]* %6, i64 0, i64 0
%18 = call i32 @nc_def_dim(i32 %16, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 10, i32* %17)
%19 = load i32, i32* %1
%20 = call i32 @nc_def_var(i32 %19, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i32 5, i32 1, i32* %17, i32* %2)
%21 = load i32, i32* %1
%22 = call i32 @nc_def_var(i32 %21, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 5, i32 1, i32* %17, i32* %3)
%23 = load i32, i32* %1
%24 = call i32 @nc_close(i32 %23)
%25 = call i32 @nc_open(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0), i32 1, i32* %1)
%26 = load i32, i32* %1
%27 = call i32 @nc_redef(i32 %26)
%28 = load i32, i32* %1
%29 = load i32, i32* %2
%30 = call i32 @nc_rename_var(i32 %28, i32 %29, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0))
%31 = load i32, i32* %1
%32 = load i32, i32* %17
%33 = call i32 @nc_rename_dim(i32 %31, i32 %32, i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.3, i64 0, i64 0))
%34 = load i32, i32* %1
%35 = getelementptr inbounds [2 x i32], [2 x i32]* %6, i64 0, i64 1
%36 = call i32 @nc_def_dim(i32 %34, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i32 20, i32* %35)
%37 = load i32, i32* %1
%38 = call i32 @nc_def_var(i32 %37, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i32 5, i32 1, i32* %35, i32* %4)
%39 = load i32, i32* %1
%40 = call i32 @nc_def_var(i32 %39, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), i32 5, i32 2, i32* %17, i32* %5)
%41 = load i32, i32* %1
%42 = call i32 @nc_close(i32 %41)
ret i32 0
}