#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 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    -0x18(%rbp),%rdx
call   1090 <nc_open@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%edi
call   1070 <check@plt>
mov    -0x18(%rbp),%edi
mov    -0x30(%rbp),%rsi
lea    -0x1c(%rbp),%rdx
call   1030 <nc_inq_grp_full_ncid@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%edi
call   1070 <check@plt>
mov    -0x1c(%rbp),%edi
mov    -0x38(%rbp),%rsi
call   10a0 <nc_rename_grp@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%edi
call   1070 <check@plt>
mov    -0x18(%rbp),%edi
call   1040 <nc_close@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%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 i8*
%10 = alloca i8*
%11 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%12 = load i32, i32* %4
switch i32 %12, label %18 [
i32 0, label %13
i32 1, label %13
i32 2, label %15
i32 3, label %17
]
13: ; preds = %2, %2
%14 = call i32 @usage(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
br label %28
15: ; preds = %2
%16 = call i32 @usage(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0))
br label %28
17: ; preds = %2
br label %18
18: ; preds = %2, %17
%19 = load i8**, i8*** %5
%20 = getelementptr inbounds i8*, i8** %19, i64 1
%21 = load i8*, i8** %20
store i8* %21, i8** %9
%22 = load i8**, i8*** %5
%23 = getelementptr inbounds i8*, i8** %22, i64 2
%24 = load i8*, i8** %23
store i8* %24, i8** %10
%25 = load i8**, i8*** %5
%26 = getelementptr inbounds i8*, i8** %25, i64 3
%27 = load i8*, i8** %26
store i8* %27, i8** %11
br label %28
28: ; preds = %18, %15, %13
%29 = load i8*, i8** %9
%30 = call i64 @strlen(i8* %29)
%31 = icmp eq i64 %30, 0
br i1 %31, label %32, label %34
32: ; preds = %28
%33 = call i32 @usage(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.2, i64 0, i64 0))
br label %34
34: ; preds = %32, %28
%35 = load i8*, i8** %10
%36 = call i64 @strlen(i8* %35)
%37 = icmp eq i64 %36, 0
br i1 %37, label %38, label %40
38: ; preds = %34
%39 = call i32 @usage(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0))
br label %40
40: ; preds = %38, %34
%41 = load i8*, i8** %11
%42 = call i64 @strlen(i8* %41)
%43 = icmp eq i64 %42, 0
br i1 %43, label %44, label %46
44: ; preds = %40
%45 = call i32 @usage(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.4, i64 0, i64 0))
br label %46
46: ; preds = %44, %40
%47 = load i8*, i8** %9
%48 = call i32 @nc_open(i8* %47, i32 1, i32* %7)
store i32 %48, i32* %6
%49 = load i32, i32* %6
%50 = call i32 @check(i32 %49)
%51 = load i32, i32* %7
%52 = load i8*, i8** %10
%53 = call i32 @nc_inq_grp_full_ncid(i32 %51, i8* %52, i32* %8)
store i32 %53, i32* %6
%54 = load i32, i32* %6
%55 = call i32 @check(i32 %54)
%56 = load i32, i32* %8
%57 = load i8*, i8** %11
%58 = call i32 @nc_rename_grp(i32 %56, i8* %57)
store i32 %58, i32* %6
%59 = load i32, i32* %6
%60 = call i32 @check(i32 %59)
%61 = load i32, i32* %7
%62 = call i32 @nc_close(i32 %61)
store i32 %62, i32* %6
%63 = load i32, i32* %6
%64 = call i32 @check(i32 %63)
%65 = 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
}