#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 int16_t;

/* 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 createUrlForNnWRITE(const char *host, int nnPort, const char *path,
                        const char *user, int16_t replication, size_t blockSize,
                        char **url) {
  int strlength;
  char repStr[6], blockSizeStr[21];
  const char *paraNames[4], *paraValues[4];
  memset(repStr, 0, 6);
  memset(blockSizeStr, 0, 21);
  if (replication > 0) {
    strlength = snprintf(repStr, 6, "%u", replication);
    if (strlength < 0 || strlength >= 6) {
      return EIO;
    }
  }
  if (blockSize > 0) {
    strlength = snprintf(blockSizeStr, 21, "%lu", blockSize);
    if (strlength < 0 || strlength >= 21) {
      return EIO;
    }
  }
  paraNames[0] = "overwrite";
  paraNames[1] = "replication";
  paraNames[2] = "blocksize";
  paraNames[3] = "user.name";
  paraValues[0] = "true";
  paraValues[1] = repStr;
  paraValues[2] = blockSizeStr;
  paraValues[3] = user;
  return createQueryURL(host, nnPort, path, "CREATE", 4, paraNames, paraValues,
                        url);
}


x86 assembly (clang, -O0):
<createUrlForNnWRITE>:
push   %rbp
mov    %rsp,%rbp
sub    $0xb0,%rsp
mov    0x10(%rbp),%rax
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    %r8d,-0x2c(%rbp)
mov    %r9,-0x38(%rbp)
lea    -0x42(%rbp),%rdi
xor    %esi,%esi
mov    $0x6,%edx
call   1050 <memset@plt>
lea    -0x60(%rbp),%rdi
xor    %esi,%esi
mov    $0x15,%edx
call   1050 <memset@plt>
cmpl   $0x0,-0x2c(%rbp)
jle    11c6 <createUrlForNnWRITE+0x96>
lea    -0x42(%rbp),%rdi
movslq -0x2c(%rbp),%rcx
mov    $0x6,%esi
lea    0xe6c(%rip),%rdx
call   1030 <snprintf@plt>
mov    %eax,-0x3c(%rbp)
cmpl   $0x0,-0x3c(%rbp)
jl     11b0 <createUrlForNnWRITE+0x80>
cmpl   $0x6,-0x3c(%rbp)
jl     11c1 <createUrlForNnWRITE+0x91>
mov    0x2e29(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    12aa <createUrlForNnWRITE+0x17a>
jmp    11c6 <createUrlForNnWRITE+0x96>
cmpq   $0x0,-0x38(%rbp)
jbe    1217 <createUrlForNnWRITE+0xe7>
lea    -0x60(%rbp),%rdi
mov    -0x38(%rbp),%rcx
mov    $0x15,%esi
lea    0xe1e(%rip),%rdx
call   1030 <snprintf@plt>
mov    %eax,-0x3c(%rbp)
cmpl   $0x0,-0x3c(%rbp)
jl     1201 <createUrlForNnWRITE+0xd1>
cmpl   $0x15,-0x3c(%rbp)
jl     1212 <createUrlForNnWRITE+0xe2>
mov    0x2dd8(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    12aa <createUrlForNnWRITE+0x17a>
jmp    1217 <createUrlForNnWRITE+0xe7>
lea    0xde9(%rip),%rax
mov    %rax,-0x80(%rbp)
lea    0xde8(%rip),%rax
mov    %rax,-0x78(%rbp)
lea    0xde9(%rip),%rax
mov    %rax,-0x70(%rbp)
lea    0xde8(%rip),%rax
mov    %rax,-0x68(%rbp)
lea    0xde7(%rip),%rax
mov    %rax,-0xa0(%rbp)
lea    -0x42(%rbp),%rax
mov    %rax,-0x98(%rbp)
lea    -0x60(%rbp),%rax
mov    %rax,-0x90(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,-0x88(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x20(%rbp),%rdx
lea    -0x80(%rbp),%r9
lea    -0xa0(%rbp),%r10
mov    0x10(%rbp),%rax
lea    0xda3(%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    $0xb0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<createUrlForNnWRITE>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x68,%rsp
mov    %r9,%r12
mov    %r8d,%r14d
mov    %rcx,%rbp
mov    %rdx,0x8(%rsp)
mov    %esi,%r15d
mov    %rdi,%r13
lea    0x2(%rsp),%rdi
xor    %esi,%esi
mov    $0x6,%edx
call   1050 <memset@plt>
lea    0x50(%rsp),%rbx
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x15,%edx
call   1050 <memset@plt>
test   %r14d,%r14d
jle    119a <createUrlForNnWRITE+0x6a>
mov    %r14d,%ecx
lea    0xe7a(%rip),%rdx
lea    0x2(%rsp),%rdi
mov    $0x6,%esi
call   1030 <snprintf@plt>
cmp    $0x6,%eax
jae    11bd <createUrlForNnWRITE+0x8d>
test   %r12,%r12
je     11cb <createUrlForNnWRITE+0x9b>
lea    0xe5d(%rip),%rdx
lea    0x50(%rsp),%rdi
mov    $0x15,%esi
mov    %r12,%rcx
call   1030 <snprintf@plt>
cmp    $0x15,%eax
jb     11cb <createUrlForNnWRITE+0x9b>
mov    0x2e1c(%rip),%rax
mov    (%rax),%eax
jmp    1250 <createUrlForNnWRITE+0x120>
mov    0xa0(%rsp),%rax
lea    0xe2d(%rip),%rcx
mov    %rcx,0x30(%rsp)
lea    0xe2b(%rip),%rcx
mov    %rcx,0x38(%rsp)
lea    0xe2b(%rip),%rcx
mov    %rcx,0x40(%rsp)
lea    0xe29(%rip),%rcx
mov    %rcx,0x48(%rsp)
lea    0xe27(%rip),%rcx
mov    %rcx,0x10(%rsp)
lea    0x2(%rsp),%rcx
mov    %rcx,0x18(%rsp)
mov    %rbx,0x20(%rsp)
mov    %rbp,0x28(%rsp)
lea    0x10(%rsp),%rbp
lea    0xe07(%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    $0x68,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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