#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 EIO;
int createQueryURL(char const *, int, char const *, char *, int, char const **,
                   char const **, char **);
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
int snprintf(char *, int, char *, size_t);
int createUrlForReadFromDatanode(const char *dnHost, int dnPort,
                                 const char *path, size_t offset, size_t length,
                                 const char *user, const char *namenodeRpcAddr,
                                 char **url) {
  char offsetStr[21], lengthStr[21];
  const char *paraNames[4], *paraValues[4];
  int strlength;
  memset(offsetStr, 0, 21);
  memset(lengthStr, 0, 21);
  if (offset > 0) {
    strlength = snprintf(offsetStr, 21, "%lu", offset);
    if (strlength < 0 || strlength >= 21) {
      return EIO;
    }
  }
  if (length > 0) {
    strlength = snprintf(lengthStr, 21, "%lu", length);
    if (strlength < 0 || strlength >= 21) {
      return EIO;
    }
  }
  paraNames[0] = "offset";
  paraNames[1] = "length";
  paraNames[2] = "user.name";
  paraNames[3] = "namenoderpcaddress";
  paraValues[0] = offsetStr;
  paraValues[1] = lengthStr;
  paraValues[2] = user;
  paraValues[3] = namenodeRpcAddr;
  return createQueryURL(dnHost, dnPort, path, "OPEN", 4, paraNames, paraValues,
                        url);
}


x86 assembly (clang, -O0):
<createUrlForReadFromDatanode>:
push   %rbp
mov    %rsp,%rbp
sub    $0xd0,%rsp
mov    0x18(%rbp),%rax
mov    0x10(%rbp),%rax
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    %r8,-0x30(%rbp)
mov    %r9,-0x38(%rbp)
lea    -0x50(%rbp),%rdi
xor    %esi,%esi
mov    $0x15,%edx
call   1050 <memset@plt>
lea    -0x70(%rbp),%rdi
xor    %esi,%esi
mov    $0x15,%edx
call   1050 <memset@plt>
cmpq   $0x0,-0x28(%rbp)
jbe    11d4 <createUrlForReadFromDatanode+0xa4>
lea    -0x50(%rbp),%rdi
mov    -0x28(%rbp),%rcx
mov    $0x15,%esi
lea    0xe67(%rip),%rdx
call   1030 <snprintf@plt>
mov    %eax,-0xb4(%rbp)
cmpl   $0x0,-0xb4(%rbp)
jl     11be <createUrlForReadFromDatanode+0x8e>
cmpl   $0x15,-0xb4(%rbp)
jl     11cf <createUrlForReadFromDatanode+0x9f>
mov    0x2e1b(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    12c7 <createUrlForReadFromDatanode+0x197>
jmp    11d4 <createUrlForReadFromDatanode+0xa4>
cmpq   $0x0,-0x30(%rbp)
jbe    122e <createUrlForReadFromDatanode+0xfe>
lea    -0x70(%rbp),%rdi
mov    -0x30(%rbp),%rcx
mov    $0x15,%esi
lea    0xe0d(%rip),%rdx
call   1030 <snprintf@plt>
mov    %eax,-0xb4(%rbp)
cmpl   $0x0,-0xb4(%rbp)
jl     1218 <createUrlForReadFromDatanode+0xe8>
cmpl   $0x15,-0xb4(%rbp)
jl     1229 <createUrlForReadFromDatanode+0xf9>
mov    0x2dc1(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    12c7 <createUrlForReadFromDatanode+0x197>
jmp    122e <createUrlForReadFromDatanode+0xfe>
lea    0xdcf(%rip),%rax
mov    %rax,-0x90(%rbp)
lea    0xdc8(%rip),%rax
mov    %rax,-0x88(%rbp)
lea    0xdc1(%rip),%rax
mov    %rax,-0x80(%rbp)
lea    0xdc0(%rip),%rax
mov    %rax,-0x78(%rbp)
lea    -0x50(%rbp),%rax
mov    %rax,-0xb0(%rbp)
lea    -0x70(%rbp),%rax
mov    %rax,-0xa8(%rbp)
mov    -0x38(%rbp),%rax
mov    %rax,-0xa0(%rbp)
mov    0x10(%rbp),%rax
mov    %rax,-0x98(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x20(%rbp),%rdx
lea    -0x90(%rbp),%r9
lea    -0xb0(%rbp),%r10
mov    0x18(%rbp),%rax
lea    0xd7f(%rip),%rcx
mov    $0x4,%r8d
mov    %r10,(%rsp)
mov    %rax,0x8(%rsp)
call   1040 <createQueryURL@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0xd0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<createUrlForReadFromDatanode>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x88,%rsp
mov    %r9,%rbp
mov    %r8,%r12
mov    %rcx,%r14
mov    %rdx,0x8(%rsp)
mov    %esi,%r15d
mov    %rdi,%r13
lea    0x50(%rsp),%rdi
xor    %esi,%esi
mov    $0x15,%edx
call   1050 <memset@plt>
lea    0x70(%rsp),%rbx
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x15,%edx
call   1050 <memset@plt>
test   %r14,%r14
je     119d <createUrlForReadFromDatanode+0x6d>
lea    0xe7a(%rip),%rdx
lea    0x50(%rsp),%rdi
mov    $0x15,%esi
mov    %r14,%rcx
call   1030 <snprintf@plt>
cmp    $0x15,%eax
jae    11c0 <createUrlForReadFromDatanode+0x90>
test   %r12,%r12
je     11ce <createUrlForReadFromDatanode+0x9e>
lea    0xe57(%rip),%rdx
lea    0x70(%rsp),%rdi
mov    $0x15,%esi
mov    %r12,%rcx
call   1030 <snprintf@plt>
cmp    $0x15,%eax
jb     11ce <createUrlForReadFromDatanode+0x9e>
mov    0x2e19(%rip),%rax
mov    (%rax),%eax
jmp    1254 <createUrlForReadFromDatanode+0x124>
mov    0xc8(%rsp),%rax
mov    0xc0(%rsp),%rcx
lea    0xe1f(%rip),%rdx
mov    %rdx,0x30(%rsp)
lea    0xe1a(%rip),%rdx
mov    %rdx,0x38(%rsp)
lea    0xe15(%rip),%rdx
mov    %rdx,0x40(%rsp)
lea    0xe13(%rip),%rdx
mov    %rdx,0x48(%rsp)
lea    0x50(%rsp),%rdx
mov    %rdx,0x10(%rsp)
mov    %rbx,0x18(%rsp)
mov    %rbp,0x20(%rsp)
mov    %rcx,0x28(%rsp)
lea    0x10(%rsp),%rbp
lea    0xdfc(%rip),%rcx
lea    0x30(%rsp),%r9
mov    %r13,%rdi
mov    %r15d,%esi
mov    0x8(%rsp),%rdx
mov    $0x4,%r8d
push   %rax
push   %rbp
call   1040 <createQueryURL@plt>
add    $0x10,%rsp
add    $0x88,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%lu\00"
@EIO = global i32 0
@.str.1 = [7 x i8] c"offset\00"
@.str.2 = [7 x i8] c"length\00"
@.str.3 = [10 x i8] c"user.name\00"
@.str.4 = [19 x i8] c"namenoderpcaddress\00"
@.str.5 = [5 x i8] c"OPEN\00"
define i32 @createUrlForReadFromDatanode(i8* %0, i32 %1, i8* %2, i64 %3, i64 %4, i8* %5, i8* %6, i8** %7) {
%9 = alloca i32
%10 = alloca i8*
%11 = alloca i32
%12 = alloca i8*
%13 = alloca i64
%14 = alloca i64
%15 = alloca i8*
%16 = alloca i8*
%17 = alloca i8**
%18 = alloca [21 x i8]
%19 = alloca [21 x i8]
%20 = alloca [4 x i8*]
%21 = alloca [4 x i8*]
%22 = alloca i32
store i8* %0, i8** %10
store i32 %1, i32* %11
store i8* %2, i8** %12
store i64 %3, i64* %13
store i64 %4, i64* %14
store i8* %5, i8** %15
store i8* %6, i8** %16
store i8** %7, i8*** %17
%23 = getelementptr inbounds [21 x i8], [21 x i8]* %18, i64 0, i64 0
%24 = call i32 @memset(i8* %23, i32 0, i32 21)
%25 = getelementptr inbounds [21 x i8], [21 x i8]* %19, i64 0, i64 0
%26 = call i32 @memset(i8* %25, i32 0, i32 21)
%27 = load i64, i64* %13
%28 = icmp ugt i64 %27, 0
br i1 %28, label %29, label %41
29: ; preds = %8
%30 = getelementptr inbounds [21 x i8], [21 x i8]* %18, i64 0, i64 0
%31 = load i64, i64* %13
%32 = call i32 @snprintf(i8* %30, i32 21, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i64 %31)
store i32 %32, i32* %22
%33 = load i32, i32* %22
%34 = icmp slt i32 %33, 0
br i1 %34, label %38, label %35
35: ; preds = %29
%36 = load i32, i32* %22
%37 = icmp sge i32 %36, 21
br i1 %37, label %38, label %40
38: ; preds = %35, %29
%39 = load i32, i32* @EIO
store i32 %39, i32* %9
br label %76
40: ; preds = %35
br label %41
41: ; preds = %40, %8
%42 = load i64, i64* %14
%43 = icmp ugt i64 %42, 0
br i1 %43, label %44, label %56
44: ; preds = %41
%45 = getelementptr inbounds [21 x i8], [21 x i8]* %19, i64 0, i64 0
%46 = load i64, i64* %14
%47 = call i32 @snprintf(i8* %45, i32 21, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i64 %46)
store i32 %47, i32* %22
%48 = load i32, i32* %22
%49 = icmp slt i32 %48, 0
br i1 %49, label %53, label %50
50: ; preds = %44
%51 = load i32, i32* %22
%52 = icmp sge i32 %51, 21
br i1 %52, label %53, label %55
53: ; preds = %50, %44
%54 = load i32, i32* @EIO
store i32 %54, i32* %9
br label %76
55: ; preds = %50
br label %56
56: ; preds = %55, %41
%57 = getelementptr inbounds [4 x i8*], [4 x i8*]* %20, i64 0, i64 0
store i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8** %57
%58 = getelementptr inbounds [4 x i8*], [4 x i8*]* %20, i64 0, i64 1
store i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i8** %58
%59 = getelementptr inbounds [4 x i8*], [4 x i8*]* %20, i64 0, i64 2
store i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i8** %59
%60 = getelementptr inbounds [4 x i8*], [4 x i8*]* %20, i64 0, i64 3
store i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0), i8** %60
%61 = getelementptr inbounds [21 x i8], [21 x i8]* %18, i64 0, i64 0
%62 = getelementptr inbounds [4 x i8*], [4 x i8*]* %21, i64 0, i64 0
store i8* %61, i8** %62
%63 = getelementptr inbounds [21 x i8], [21 x i8]* %19, i64 0, i64 0
%64 = getelementptr inbounds [4 x i8*], [4 x i8*]* %21, i64 0, i64 1
store i8* %63, i8** %64
%65 = load i8*, i8** %15
%66 = getelementptr inbounds [4 x i8*], [4 x i8*]* %21, i64 0, i64 2
store i8* %65, i8** %66
%67 = load i8*, i8** %16
%68 = getelementptr inbounds [4 x i8*], [4 x i8*]* %21, i64 0, i64 3
store i8* %67, i8** %68
%69 = load i8*, i8** %10
%70 = load i32, i32* %11
%71 = load i8*, i8** %12
%72 = getelementptr inbounds [4 x i8*], [4 x i8*]* %20, i64 0, i64 0
%73 = getelementptr inbounds [4 x i8*], [4 x i8*]* %21, i64 0, i64 0
%74 = load i8**, i8*** %17
%75 = call i32 @createQueryURL(i8* %69, i32 %70, i8* %71, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), i32 4, i8** %72, i8** %73, i8** %74)
store i32 %75, i32* %9
br label %76
76: ; preds = %56, %53, %38
%77 = load i32, i32* %9
ret i32 %77
}

LLVM IR (-O2):
@.str = [4 x i8] c"%lu\00"
@EIO = global i32 0
@.str.1 = [7 x i8] c"offset\00"
@.str.2 = [7 x i8] c"length\00"
@.str.3 = [10 x i8] c"user.name\00"
@.str.4 = [19 x i8] c"namenoderpcaddress\00"
@.str.5 = [5 x i8] c"OPEN\00"
define i32 @createUrlForReadFromDatanode(i8* %0, i32 %1, i8* %2, i64 %3, i64 %4, i8* %5, i8* %6, i8** %7) {
%9 = alloca [21 x i8]
%10 = alloca [21 x i8]
%11 = alloca [4 x i8*]
%12 = alloca [4 x i8*]
%13 = getelementptr inbounds [21 x i8], [21 x i8]* %9, i64 0, i64 0
%14 = getelementptr inbounds [21 x i8], [21 x i8]* %10, i64 0, i64 0
%15 = bitcast [4 x i8*]* %11 to i8*
%16 = bitcast [4 x i8*]* %12 to i8*
%17 = call i32 @memset(i8* %13, i32 0, i32 21)
%18 = call i32 @memset(i8* %14, i32 0, i32 21)
%19 = icmp eq i64 %3, 0
br i1 %19, label %25, label %20
20: ; preds = %8
%21 = call i32 @snprintf(i8* %13, i32 21, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i64 %3)
%22 = icmp ugt i32 %21, 20
br i1 %22, label %23, label %25
23: ; preds = %20
%24 = load i32, i32* @EIO
br label %42
25: ; preds = %20, %8
%26 = icmp eq i64 %4, 0
br i1 %26, label %32, label %27
27: ; preds = %25
%28 = call i32 @snprintf(i8* %14, i32 21, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i64 %4)
%29 = icmp ugt i32 %28, 20
br i1 %29, label %30, label %32
30: ; preds = %27
%31 = load i32, i32* @EIO
br label %42
32: ; preds = %27, %25
%33 = getelementptr inbounds [4 x i8*], [4 x i8*]* %11, i64 0, i64 0
store i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8** %33
%34 = getelementptr inbounds [4 x i8*], [4 x i8*]* %11, i64 0, i64 1
store i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i8** %34
%35 = getelementptr inbounds [4 x i8*], [4 x i8*]* %11, i64 0, i64 2
store i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i8** %35
%36 = getelementptr inbounds [4 x i8*], [4 x i8*]* %11, i64 0, i64 3
store i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.4, i64 0, i64 0), i8** %36
%37 = getelementptr inbounds [4 x i8*], [4 x i8*]* %12, i64 0, i64 0
store i8* %13, i8** %37
%38 = getelementptr inbounds [4 x i8*], [4 x i8*]* %12, i64 0, i64 1
store i8* %14, i8** %38
%39 = getelementptr inbounds [4 x i8*], [4 x i8*]* %12, i64 0, i64 2
store i8* %5, i8** %39
%40 = getelementptr inbounds [4 x i8*], [4 x i8*]* %12, i64 0, i64 3
store i8* %6, i8** %40
%41 = call i32 @createQueryURL(i8* %0, i32 %1, i8* %2, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0), i32 4, i8** %33, i8** %37, i8** %7)
br label %42
42: ; preds = %32, %30, %23
%43 = phi i32 [ %24, %23 ], [ %31, %30 ], [ %41, %32 ]
ret i32 %43
}