#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*/ check(int);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int nc_close(int);
int nc_inq_grp_full_ncid(int, char *, int *);
int nc_open(char *, int, int *);
int nc_rename_grp(int, char *);
scalar_t__ strlen(char *);
int /*<<< orphan*/ usage(char *);
int main(int argc, char **argv) {
  int i, stat;
  int ncid, grpid;
  char *filename;
  char *oldname;
  char *newname;
  switch (argc) {
  case 0:
  case 1:
    usage("No arguments");
    break;
  case 2:
    usage("Too few arguments");
    break;
  case 3:
  default:
    filename = argv[1];
    oldname = argv[2];
    newname = argv[3];
    break;
  }
  if (strlen(filename) == 0)
    usage("bad filename argument");
  if (strlen(oldname) == 0)
    usage("bad old name argument");
  if (strlen(newname) == 0)
    usage("bad new name argument");
  stat = nc_open(filename, 0x0001, &ncid);
  check(stat);
  stat = nc_inq_grp_full_ncid(ncid, oldname, &grpid);
  check(stat);
  stat = nc_rename_grp(grpid, newname);
  check(stat);
  stat = nc_close(ncid);
  check(stat);
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x3c(%rbp)
sub    $0x2,%eax
jb     11cc <main+0x4c>
jmp    11aa <main+0x2a>
mov    -0x3c(%rbp),%eax
sub    $0x2,%eax
je     11dd <main+0x5d>
jmp    11bb <main+0x3b>
mov    -0x3c(%rbp),%eax
sub    $0x3,%eax
je     11ee <main+0x6e>
jmp    11f3 <main+0x73>
lea    0xe2d(%rip),%rdi
call   1060 <usage@plt>
jmp    1217 <main+0x97>
lea    0xe29(%rip),%rdi
call   1060 <usage@plt>
jmp    1217 <main+0x97>
jmp    11f3 <main+0x73>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x28(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rax
mov    %rax,-0x38(%rbp)
mov    -0x28(%rbp),%rdi
call   1050 <strlen@plt>
cmp    $0x0,%rax
jne    1236 <main+0xb6>
lea    0xdee(%rip),%rdi
call   1060 <usage@plt>
mov    -0x30(%rbp),%rdi
call   1050 <strlen@plt>
cmp    $0x0,%rax
jne    1255 <main+0xd5>
lea    0xde5(%rip),%rdi
call   1060 <usage@plt>
mov    -0x38(%rbp),%rdi
call   1050 <strlen@plt>
cmp    $0x0,%rax
jne    1274 <main+0xf4>
lea    0xddc(%rip),%rdi
call   1060 <usage@plt>
mov    -0x28(%rbp),%rdi
mov    $0x1,%esi
lea    -0x1c(%rbp),%rdx
call   1090 <nc_open@plt>
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%edi
call   1070 <check@plt>
mov    -0x1c(%rbp),%edi
mov    -0x30(%rbp),%rsi
lea    -0x20(%rbp),%rdx
call   1030 <nc_inq_grp_full_ncid@plt>
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%edi
call   1070 <check@plt>
mov    -0x20(%rbp),%edi
mov    -0x38(%rbp),%rsi
call   10a0 <nc_rename_grp@plt>
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%edi
call   1070 <check@plt>
mov    -0x1c(%rbp),%edi
call   1040 <nc_close@plt>
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%edi
call   1070 <check@plt>
xor    %edi,%edi
call   1080 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x10,%rsp
cmp    $0x2,%edi
je     1239 <main+0xc9>
jb     1245 <main+0xd5>
mov    0x8(%rsi),%rbx
mov    0x10(%rsi),%r15
mov    0x18(%rsi),%r14
cmpb   $0x0,(%rbx)
je     120c <main+0x9c>
cmpb   $0x0,(%r15)
je     121e <main+0xae>
cmpb   $0x0,(%r14)
jne    11b1 <main+0x41>
lea    0xe9f(%rip),%rdi
call   1050 <usage@plt>
lea    0x8(%rsp),%rdx
mov    %rbx,%rdi
mov    $0x1,%esi
call   1080 <nc_open@plt>
mov    %eax,%edi
call   1060 <check@plt>
mov    0x8(%rsp),%edi
lea    0xc(%rsp),%rdx
mov    %r15,%rsi
call   1030 <nc_inq_grp_full_ncid@plt>
mov    %eax,%edi
call   1060 <check@plt>
mov    0xc(%rsp),%edi
mov    %r14,%rsi
call   1090 <nc_rename_grp@plt>
mov    %eax,%edi
call   1060 <check@plt>
mov    0x8(%rsp),%edi
call   1040 <nc_close@plt>
mov    %eax,%edi
call   1060 <check@plt>
xor    %edi,%edi
call   1070 <exit@plt>
lea    0xe0c(%rip),%rdi
call   1050 <usage@plt>
cmpb   $0x0,(%r15)
jne    119f <main+0x2f>
lea    0xe10(%rip),%rdi
call   1050 <usage@plt>
cmpb   $0x0,(%r14)
je     11a5 <main+0x35>
jmp    11b1 <main+0x41>
lea    0xdcd(%rip),%rdi
call   1050 <usage@plt>
lea    0xdb4(%rip),%rdi
call   1050 <usage@plt>

LLVM IR (-O0):
@.str = [13 x i8] c"No arguments\00"
@.str.1 = [18 x i8] c"Too few arguments\00"
@.str.2 = [22 x i8] c"bad filename argument\00"
@.str.3 = [22 x i8] c"bad old name argument\00"
@.str.4 = [22 x i8] c"bad new name argument\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i8*
%11 = alloca i8*
%12 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%13 = load i32, i32* %4
switch i32 %13, label %19 [
i32 0, label %14
i32 1, label %14
i32 2, label %16
i32 3, label %18
]
14: ; preds = %2, %2
%15 = call i32 @usage(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
br label %29
16: ; preds = %2
%17 = call i32 @usage(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0))
br label %29
18: ; preds = %2
br label %19
19: ; preds = %2, %18
%20 = load i8**, i8*** %5
%21 = getelementptr inbounds i8*, i8** %20, i64 1
%22 = load i8*, i8** %21
store i8* %22, i8** %10
%23 = load i8**, i8*** %5
%24 = getelementptr inbounds i8*, i8** %23, i64 2
%25 = load i8*, i8** %24
store i8* %25, i8** %11
%26 = load i8**, i8*** %5
%27 = getelementptr inbounds i8*, i8** %26, i64 3
%28 = load i8*, i8** %27
store i8* %28, i8** %12
br label %29
29: ; preds = %19, %16, %14
%30 = load i8*, i8** %10
%31 = call i64 @strlen(i8* %30)
%32 = icmp eq i64 %31, 0
br i1 %32, label %33, label %35
33: ; preds = %29
%34 = call i32 @usage(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0))
br label %35
35: ; preds = %33, %29
%36 = load i8*, i8** %11
%37 = call i64 @strlen(i8* %36)
%38 = icmp eq i64 %37, 0
br i1 %38, label %39, label %41
39: ; preds = %35
%40 = call i32 @usage(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0))
br label %41
41: ; preds = %39, %35
%42 = load i8*, i8** %12
%43 = call i64 @strlen(i8* %42)
%44 = icmp eq i64 %43, 0
br i1 %44, label %45, label %47
45: ; preds = %41
%46 = call i32 @usage(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.4, i64 0, i64 0))
br label %47
47: ; preds = %45, %41
%48 = load i8*, i8** %10
%49 = call i32 @nc_open(i8* %48, i32 1, i32* %8)
store i32 %49, i32* %7
%50 = load i32, i32* %7
%51 = call i32 @check(i32 %50)
%52 = load i32, i32* %8
%53 = load i8*, i8** %11
%54 = call i32 @nc_inq_grp_full_ncid(i32 %52, i8* %53, i32* %9)
store i32 %54, i32* %7
%55 = load i32, i32* %7
%56 = call i32 @check(i32 %55)
%57 = load i32, i32* %9
%58 = load i8*, i8** %12
%59 = call i32 @nc_rename_grp(i32 %57, i8* %58)
store i32 %59, i32* %7
%60 = load i32, i32* %7
%61 = call i32 @check(i32 %60)
%62 = load i32, i32* %8
%63 = call i32 @nc_close(i32 %62)
store i32 %63, i32* %7
%64 = load i32, i32* %7
%65 = call i32 @check(i32 %64)
%66 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
@.str = [13 x i8] c"No arguments\00"
@.str.1 = [18 x i8] c"Too few arguments\00"
@.str.2 = [22 x i8] c"bad filename argument\00"
@.str.3 = [22 x i8] c"bad old name argument\00"
@.str.4 = [22 x i8] c"bad new name argument\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = alloca i32
%5 = bitcast i32* %3 to i8*
%6 = bitcast i32* %4 to i8*
switch i32 %0, label %11 [
i32 0, label %7
i32 1, label %7
i32 2, label %9
]
7: ; preds = %2, %2
%8 = tail call i32 @usage(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
unreachable
9: ; preds = %2
%10 = tail call i32 @usage(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0))
unreachable
11: ; preds = %2
%12 = getelementptr inbounds i8*, i8** %1, i64 1
%13 = load i8*, i8** %12
%14 = getelementptr inbounds i8*, i8** %1, i64 2
%15 = load i8*, i8** %14
%16 = getelementptr inbounds i8*, i8** %1, i64 3
%17 = load i8*, i8** %16
%18 = load i8, i8* %13
%19 = icmp eq i8 %18, 0
br i1 %19, label %20, label %22
20: ; preds = %11
%21 = tail call i32 @usage(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0))
br label %22
22: ; preds = %20, %11
%23 = load i8, i8* %15
%24 = icmp eq i8 %23, 0
br i1 %24, label %25, label %27
25: ; preds = %22
%26 = tail call i32 @usage(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0))
br label %27
27: ; preds = %25, %22
%28 = load i8, i8* %17
%29 = icmp eq i8 %28, 0
br i1 %29, label %30, label %32
30: ; preds = %27
%31 = tail call i32 @usage(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.4, i64 0, i64 0))
br label %32
32: ; preds = %30, %27
%33 = call i32 @nc_open(i8* %13, i32 1, i32* %3)
%34 = call i32 @check(i32 %33)
%35 = load i32, i32* %3
%36 = call i32 @nc_inq_grp_full_ncid(i32 %35, i8* %15, i32* %4)
%37 = call i32 @check(i32 %36)
%38 = load i32, i32* %4
%39 = call i32 @nc_rename_grp(i32 %38, i8* %17)
%40 = call i32 @check(i32 %39)
%41 = load i32, i32* %3
%42 = call i32 @nc_close(i32 %41)
%43 = call i32 @check(i32 %42)
%44 = call i32 @exit(i32 0)
unreachable
}