#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 createUrlForGetBlockLocations(const char *host, int nnPort,
                                  const char *path, size_t offset,
                                  size_t length, const char *user, char **url) {
  char offsetStr[21], lengthStr[21];
  const char *paraNames[3], *paraValues[3];
  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";
  paraValues[0] = offsetStr;
  paraValues[1] = lengthStr;
  paraValues[2] = user;
  return createQueryURL(host, nnPort, path, "GET_BLOCK_LOCATIONS", 3, paraNames,
                        paraValues, url);
}


x86 assembly (clang, -O0):
<createUrlForGetBlockLocations>:
push   %rbp
mov    %rsp,%rbp
sub    $0xd0,%rsp
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    11d0 <createUrlForGetBlockLocations+0xa0>
lea    -0x50(%rbp),%rdi
mov    -0x28(%rbp),%rcx
mov    $0x15,%esi
lea    0xe6b(%rip),%rdx
call   1030 <snprintf@plt>
mov    %eax,-0xb4(%rbp)
cmpl   $0x0,-0xb4(%rbp)
jl     11ba <createUrlForGetBlockLocations+0x8a>
cmpl   $0x15,-0xb4(%rbp)
jl     11cb <createUrlForGetBlockLocations+0x9b>
mov    0x2e1f(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    12ad <createUrlForGetBlockLocations+0x17d>
jmp    11d0 <createUrlForGetBlockLocations+0xa0>
cmpq   $0x0,-0x30(%rbp)
jbe    122a <createUrlForGetBlockLocations+0xfa>
lea    -0x70(%rbp),%rdi
mov    -0x30(%rbp),%rcx
mov    $0x15,%esi
lea    0xe11(%rip),%rdx
call   1030 <snprintf@plt>
mov    %eax,-0xb4(%rbp)
cmpl   $0x0,-0xb4(%rbp)
jl     1214 <createUrlForGetBlockLocations+0xe4>
cmpl   $0x15,-0xb4(%rbp)
jl     1225 <createUrlForGetBlockLocations+0xf5>
mov    0x2dc5(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    12ad <createUrlForGetBlockLocations+0x17d>
jmp    122a <createUrlForGetBlockLocations+0xfa>
lea    0xdd3(%rip),%rax
mov    %rax,-0x90(%rbp)
lea    0xdcc(%rip),%rax
mov    %rax,-0x88(%rbp)
lea    0xdc5(%rip),%rax
mov    %rax,-0x80(%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),%rdi
mov    -0x14(%rbp),%esi
mov    -0x20(%rbp),%rdx
lea    -0x90(%rbp),%r9
lea    -0xb0(%rbp),%r10
mov    0x10(%rbp),%rax
lea    0xd86(%rip),%rcx
mov    $0x3,%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):
<createUrlForGetBlockLocations>:
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 <createUrlForGetBlockLocations+0x6d>
lea    0xe7a(%rip),%rdx
lea    0x50(%rsp),%rdi
mov    $0x15,%esi
mov    %r14,%rcx
call   1030 <snprintf@plt>
cmp    $0x15,%eax
jae    11c0 <createUrlForGetBlockLocations+0x90>
test   %r12,%r12
je     11cb <createUrlForGetBlockLocations+0x9b>
lea    0xe57(%rip),%rdx
lea    0x70(%rsp),%rdi
mov    $0x15,%esi
mov    %r12,%rcx
call   1030 <snprintf@plt>
cmp    $0x15,%eax
jb     11cb <createUrlForGetBlockLocations+0x9b>
mov    0x2e19(%rip),%rax
mov    (%rax),%eax
jmp    1238 <createUrlForGetBlockLocations+0x108>
mov    0xc0(%rsp),%rax
lea    0xe2a(%rip),%rcx
mov    %rcx,0x30(%rsp)
lea    0xe25(%rip),%rcx
mov    %rcx,0x38(%rsp)
lea    0xe20(%rip),%rcx
mov    %rcx,0x40(%rsp)
lea    0x50(%rsp),%rcx
mov    %rcx,0x10(%rsp)
mov    %rbx,0x18(%rsp)
mov    %rbp,0x20(%rsp)
lea    0x10(%rsp),%rbp
lea    0xe05(%rip),%rcx
lea    0x30(%rsp),%r9
mov    %r13,%rdi
mov    %r15d,%esi
mov    0x8(%rsp),%rdx
mov    $0x3,%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 = [20 x i8] c"GET_BLOCK_LOCATIONS\00"
define i32 @createUrlForGetBlockLocations(i8* %0, i32 %1, i8* %2, i64 %3, i64 %4, i8* %5, i8** %6) {
%8 = alloca i32
%9 = alloca i8*
%10 = alloca i32
%11 = alloca i8*
%12 = alloca i64
%13 = alloca i64
%14 = alloca i8*
%15 = alloca i8**
%16 = alloca [21 x i8]
%17 = alloca [21 x i8]
%18 = alloca [3 x i8*]
%19 = alloca [3 x i8*]
%20 = alloca i32
store i8* %0, i8** %9
store i32 %1, i32* %10
store i8* %2, i8** %11
store i64 %3, i64* %12
store i64 %4, i64* %13
store i8* %5, i8** %14
store i8** %6, i8*** %15
%21 = getelementptr inbounds [21 x i8], [21 x i8]* %16, i64 0, i64 0
%22 = call i32 @memset(i8* %21, i32 0, i32 21)
%23 = getelementptr inbounds [21 x i8], [21 x i8]* %17, i64 0, i64 0
%24 = call i32 @memset(i8* %23, i32 0, i32 21)
%25 = load i64, i64* %12
%26 = icmp ugt i64 %25, 0
br i1 %26, label %27, label %39
27: ; preds = %7
%28 = getelementptr inbounds [21 x i8], [21 x i8]* %16, i64 0, i64 0
%29 = load i64, i64* %12
%30 = call i32 @snprintf(i8* %28, i32 21, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i64 %29)
store i32 %30, i32* %20
%31 = load i32, i32* %20
%32 = icmp slt i32 %31, 0
br i1 %32, label %36, label %33
33: ; preds = %27
%34 = load i32, i32* %20
%35 = icmp sge i32 %34, 21
br i1 %35, label %36, label %38
36: ; preds = %33, %27
%37 = load i32, i32* @EIO
store i32 %37, i32* %8
br label %71
38: ; preds = %33
br label %39
39: ; preds = %38, %7
%40 = load i64, i64* %13
%41 = icmp ugt i64 %40, 0
br i1 %41, label %42, label %54
42: ; preds = %39
%43 = getelementptr inbounds [21 x i8], [21 x i8]* %17, i64 0, i64 0
%44 = load i64, i64* %13
%45 = call i32 @snprintf(i8* %43, i32 21, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i64 %44)
store i32 %45, i32* %20
%46 = load i32, i32* %20
%47 = icmp slt i32 %46, 0
br i1 %47, label %51, label %48
48: ; preds = %42
%49 = load i32, i32* %20
%50 = icmp sge i32 %49, 21
br i1 %50, label %51, label %53
51: ; preds = %48, %42
%52 = load i32, i32* @EIO
store i32 %52, i32* %8
br label %71
53: ; preds = %48
br label %54
54: ; preds = %53, %39
%55 = getelementptr inbounds [3 x i8*], [3 x i8*]* %18, i64 0, i64 0
store i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8** %55
%56 = getelementptr inbounds [3 x i8*], [3 x i8*]* %18, i64 0, i64 1
store i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i8** %56
%57 = getelementptr inbounds [3 x i8*], [3 x i8*]* %18, i64 0, i64 2
store i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i8** %57
%58 = getelementptr inbounds [21 x i8], [21 x i8]* %16, i64 0, i64 0
%59 = getelementptr inbounds [3 x i8*], [3 x i8*]* %19, i64 0, i64 0
store i8* %58, i8** %59
%60 = getelementptr inbounds [21 x i8], [21 x i8]* %17, i64 0, i64 0
%61 = getelementptr inbounds [3 x i8*], [3 x i8*]* %19, i64 0, i64 1
store i8* %60, i8** %61
%62 = load i8*, i8** %14
%63 = getelementptr inbounds [3 x i8*], [3 x i8*]* %19, i64 0, i64 2
store i8* %62, i8** %63
%64 = load i8*, i8** %9
%65 = load i32, i32* %10
%66 = load i8*, i8** %11
%67 = getelementptr inbounds [3 x i8*], [3 x i8*]* %18, i64 0, i64 0
%68 = getelementptr inbounds [3 x i8*], [3 x i8*]* %19, i64 0, i64 0
%69 = load i8**, i8*** %15
%70 = call i32 @createQueryURL(i8* %64, i32 %65, i8* %66, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0), i32 3, i8** %67, i8** %68, i8** %69)
store i32 %70, i32* %8
br label %71
71: ; preds = %54, %51, %36
%72 = load i32, i32* %8
ret i32 %72
}

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 = [20 x i8] c"GET_BLOCK_LOCATIONS\00"
define i32 @createUrlForGetBlockLocations(i8* %0, i32 %1, i8* %2, i64 %3, i64 %4, i8* %5, i8** %6) {
%8 = alloca [21 x i8]
%9 = alloca [21 x i8]
%10 = alloca [3 x i8*]
%11 = alloca [3 x i8*]
%12 = getelementptr inbounds [21 x i8], [21 x i8]* %8, i64 0, i64 0
%13 = getelementptr inbounds [21 x i8], [21 x i8]* %9, i64 0, i64 0
%14 = bitcast [3 x i8*]* %10 to i8*
%15 = bitcast [3 x i8*]* %11 to i8*
%16 = call i32 @memset(i8* %12, i32 0, i32 21)
%17 = call i32 @memset(i8* %13, i32 0, i32 21)
%18 = icmp eq i64 %3, 0
br i1 %18, label %24, label %19
19: ; preds = %7
%20 = call i32 @snprintf(i8* %12, i32 21, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i64 %3)
%21 = icmp ugt i32 %20, 20
br i1 %21, label %22, label %24
22: ; preds = %19
%23 = load i32, i32* @EIO
br label %39
24: ; preds = %19, %7
%25 = icmp eq i64 %4, 0
br i1 %25, label %31, label %26
26: ; preds = %24
%27 = call i32 @snprintf(i8* %13, i32 21, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i64 %4)
%28 = icmp ugt i32 %27, 20
br i1 %28, label %29, label %31
29: ; preds = %26
%30 = load i32, i32* @EIO
br label %39
31: ; preds = %26, %24
%32 = getelementptr inbounds [3 x i8*], [3 x i8*]* %10, i64 0, i64 0
store i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8** %32
%33 = getelementptr inbounds [3 x i8*], [3 x i8*]* %10, i64 0, i64 1
store i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i8** %33
%34 = getelementptr inbounds [3 x i8*], [3 x i8*]* %10, i64 0, i64 2
store i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.3, i64 0, i64 0), i8** %34
%35 = getelementptr inbounds [3 x i8*], [3 x i8*]* %11, i64 0, i64 0
store i8* %12, i8** %35
%36 = getelementptr inbounds [3 x i8*], [3 x i8*]* %11, i64 0, i64 1
store i8* %13, i8** %36
%37 = getelementptr inbounds [3 x i8*], [3 x i8*]* %11, i64 0, i64 2
store i8* %5, i8** %37
%38 = call i32 @createQueryURL(i8* %0, i32 %1, i8* %2, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0), i32 3, i8** %32, i8** %35, i8** %6)
br label %39
39: ; preds = %31, %29, %22
%40 = phi i32 [ %23, %22 ], [ %30, %29 ], [ %38, %31 ]
ret i32 %40
}