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

/* Variables and functions */
int /*<<< orphan*/ fail(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int nc_close(int);
int nc_open(char *, int, int *);
int /*<<< orphan*/ snprintf(char *, int, char *, char *, char *);
int /*<<< orphan*/ stderr;
int main(int argc, char **argv) {
  int ret = 0;
  char url[4096];
  int ncid;
  argc++;
  argv++;
  if (argc < 2) {
    fprintf(stderr, "too few arguments: t_dmrdata.c <infile> <outfile>\n");
    fail(0);
  }
  snprintf(url, sizeof(url), "file://%s#dap4&debug=copy&substratename=%s",
           argv[0], argv[1]);
  if ((ret = nc_open(url, 0x1000, &ncid)))
    goto done;
  if ((ret = nc_close(ncid)))
    goto done;
done:
  return (ret ? 1 : 0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1030,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
mov    -0x10(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    11ab <main+0x5b>
mov    0x2e4a(%rip),%rax
mov    (%rax),%edi
lea    0xe61(%rip),%rsi
call   1060 <fprintf@plt>
xor    %edi,%edi
call   1030 <fail@plt>
lea    -0x1020(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    (%rax),%rcx
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%r8
mov    $0x1000,%esi
lea    0xe66(%rip),%rdx
call   1050 <snprintf@plt>
lea    -0x1020(%rbp),%rdi
mov    $0x1000,%esi
lea    -0x1024(%rbp),%rdx
call   1070 <nc_open@plt>
mov    %eax,-0x14(%rbp)
cmp    $0x0,%eax
je     11fb <main+0xab>
jmp    121c <main+0xcc>
mov    -0x1024(%rbp),%edi
call   1040 <nc_close@plt>
mov    %eax,-0x14(%rbp)
cmp    $0x0,%eax
je     1217 <main+0xc7>
jmp    121c <main+0xcc>
jmp    121c <main+0xcc>
mov    -0x14(%rbp),%edx
xor    %eax,%eax
mov    $0x1,%ecx
cmp    $0x0,%edx
cmovne %ecx,%eax
add    $0x1030,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x1010,%rsp
mov    %rsi,%rbx
test   %edi,%edi
jg     117b <main+0x2b>
mov    0x2e7a(%rip),%rax
mov    (%rax),%edi
lea    0xe91(%rip),%rsi
call   1060 <fprintf@plt>
xor    %edi,%edi
call   1030 <fail@plt>
mov    0x8(%rbx),%rcx
mov    0x10(%rbx),%r8
lea    0xea9(%rip),%rdx
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x1000,%esi
call   1050 <snprintf@plt>
lea    0xc(%rsp),%rdx
mov    %rbx,%rdi
mov    $0x1000,%esi
call   1070 <nc_open@plt>
test   %eax,%eax
jne    11bb <main+0x6b>
mov    0xc(%rsp),%edi
call   1040 <nc_close@plt>
xor    %ecx,%ecx
test   %eax,%eax
setne  %cl
mov    %ecx,%eax
add    $0x1010,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [51 x i8] c"too few arguments: t_dmrdata.c <infile> <outfile>\0A\00"
@.str.1 = [43 x i8] c"file://%s#dap4&debug=copy&substratename=%s\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca [4096 x i8]
%8 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %6
%9 = load i32, i32* %4
%10 = add nsw i32 %9, 1
store i32 %10, i32* %4
%11 = load i8**, i8*** %5
%12 = getelementptr inbounds i8*, i8** %11, i32 1
store i8** %12, i8*** %5
%13 = load i32, i32* %4
%14 = icmp slt i32 %13, 2
br i1 %14, label %15, label %19
15: ; preds = %2
%16 = load i32, i32* @stderr
%17 = call i32 @fprintf(i32 %16, i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str, i64 0, i64 0))
%18 = call i32 @fail(i32 0)
br label %19
19: ; preds = %15, %2
%20 = getelementptr inbounds [4096 x i8], [4096 x i8]* %7, i64 0, i64 0
%21 = load i8**, i8*** %5
%22 = getelementptr inbounds i8*, i8** %21, i64 0
%23 = load i8*, i8** %22
%24 = load i8**, i8*** %5
%25 = getelementptr inbounds i8*, i8** %24, i64 1
%26 = load i8*, i8** %25
%27 = call i32 @snprintf(i8* %20, i32 4096, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.1, i64 0, i64 0), i8* %23, i8* %26)
%28 = getelementptr inbounds [4096 x i8], [4096 x i8]* %7, i64 0, i64 0
%29 = call i32 @nc_open(i8* %28, i32 4096, i32* %8)
store i32 %29, i32* %6
%30 = icmp ne i32 %29, 0
br i1 %30, label %31, label %32
31: ; preds = %19
br label %38
32: ; preds = %19
%33 = load i32, i32* %8
%34 = call i32 @nc_close(i32 %33)
store i32 %34, i32* %6
%35 = icmp ne i32 %34, 0
br i1 %35, label %36, label %37
36: ; preds = %32
br label %38
37: ; preds = %32
br label %38
38: ; preds = %37, %36, %31
%39 = load i32, i32* %6
%40 = icmp ne i32 %39, 0
%41 = zext i1 %40 to i64
%42 = select i1 %40, i32 1, i32 0
ret i32 %42
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [51 x i8] c"too few arguments: t_dmrdata.c <infile> <outfile>\0A\00"
@.str.1 = [43 x i8] c"file://%s#dap4&debug=copy&substratename=%s\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [4096 x i8]
%4 = alloca i32
%5 = getelementptr inbounds [4096 x i8], [4096 x i8]* %3, i64 0, i64 0
%6 = bitcast i32* %4 to i8*
%7 = getelementptr inbounds i8*, i8** %1, i64 1
%8 = icmp slt i32 %0, 1
br i1 %8, label %9, label %13
9: ; preds = %2
%10 = load i32, i32* @stderr
%11 = tail call i32 @fprintf(i32 %10, i8* getelementptr inbounds ([51 x i8], [51 x i8]* @.str, i64 0, i64 0))
%12 = tail call i32 @fail(i32 0)
br label %13
13: ; preds = %9, %2
%14 = load i8*, i8** %7
%15 = getelementptr inbounds i8*, i8** %1, i64 2
%16 = load i8*, i8** %15
%17 = call i32 @snprintf(i8* %5, i32 4096, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.1, i64 0, i64 0), i8* %14, i8* %16)
%18 = call i32 @nc_open(i8* %5, i32 4096, i32* %4)
%19 = icmp eq i32 %18, 0
br i1 %19, label %20, label %23
20: ; preds = %13
%21 = load i32, i32* %4
%22 = call i32 @nc_close(i32 %21)
br label %23
23: ; preds = %20, %13
%24 = phi i32 [ %18, %13 ], [ %22, %20 ]
%25 = icmp ne i32 %24, 0
%26 = zext i1 %25 to i32
ret i32 %26
}