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


x86 assembly (clang, -O0):
<createUrlForOPEN>:
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    0xea3(%rip),%rax
mov    %rax,-0xa0(%rbp)
lea    0xe9c(%rip),%rax
mov    %rax,-0x98(%rbp)
lea    0xe95(%rip),%rax
mov    %rax,-0x90(%rbp)
lea    -0x60(%rbp),%rdi
xor    %esi,%esi
mov    $0x15,%edx
call   1050 <memset@plt>
lea    -0x80(%rbp),%rdi
xor    %esi,%esi
mov    $0x15,%edx
call   1050 <memset@plt>
lea    -0x60(%rbp),%rdi
mov    -0x30(%rbp),%rcx
mov    $0x15,%esi
lea    0xe64(%rip),%rdx
call   1030 <snprintf@plt>
mov    %eax,-0x3c(%rbp)
cmpl   $0x0,-0x3c(%rbp)
jl     11d0 <createUrlForOPEN+0xa0>
cmpl   $0x15,-0x3c(%rbp)
jl     11e1 <createUrlForOPEN+0xb1>
mov    0x2e09(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    127e <createUrlForOPEN+0x14e>
lea    -0x80(%rbp),%rdi
mov    -0x38(%rbp),%rcx
mov    $0x15,%esi
lea    0xe23(%rip),%rdx
call   1030 <snprintf@plt>
mov    %eax,-0x3c(%rbp)
cmpl   $0x0,-0x3c(%rbp)
jl     1211 <createUrlForOPEN+0xe1>
cmpl   $0x15,-0x3c(%rbp)
jl     1222 <createUrlForOPEN+0xf2>
mov    0x2dc8(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    127e <createUrlForOPEN+0x14e>
lea    -0x60(%rbp),%rax
mov    %rax,-0xc0(%rbp)
lea    -0x80(%rbp),%rax
mov    %rax,-0xb8(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,-0xb0(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x14(%rbp),%esi
mov    -0x20(%rbp),%rdx
lea    -0xa0(%rbp),%r9
lea    -0xc0(%rbp),%r10
mov    0x10(%rbp),%rax
lea    0xdb5(%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):
<createUrlForOPEN>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x88,%rsp
mov    %r9,%rbx
mov    %r8,%r14
mov    %rcx,%r13
mov    %rdx,0x8(%rsp)
mov    %esi,%r15d
mov    %rdi,%r12
lea    0xea4(%rip),%rax
mov    %rax,0x30(%rsp)
lea    0xe9f(%rip),%rax
mov    %rax,0x38(%rsp)
lea    0xe9a(%rip),%rax
mov    %rax,0x40(%rsp)
lea    0x70(%rsp),%rbp
mov    %rbp,%rdi
xor    %esi,%esi
mov    $0x15,%edx
call   1050 <memset@plt>
lea    0x50(%rsp),%rdi
xor    %esi,%esi
mov    $0x15,%edx
call   1050 <memset@plt>
lea    0xe73(%rip),%rdx
mov    %rbp,%rdi
mov    $0x15,%esi
mov    %r14,%rcx
call   1030 <snprintf@plt>
cmp    $0x15,%eax
jae    11db <createUrlForOPEN+0xab>
lea    0xe57(%rip),%rdx
lea    0x50(%rsp),%r14
mov    %r14,%rdi
mov    $0x15,%esi
mov    %rbx,%rcx
call   1030 <snprintf@plt>
cmp    $0x15,%eax
jb     11e6 <createUrlForOPEN+0xb6>
mov    0x2dfe(%rip),%rax
mov    (%rax),%eax
jmp    122a <createUrlForOPEN+0xfa>
mov    0xc0(%rsp),%rax
mov    %rbp,0x10(%rsp)
mov    %r14,0x18(%rsp)
mov    %r13,0x20(%rsp)
lea    0x10(%rsp),%rbp
lea    0xe13(%rip),%rcx
lea    0x30(%rsp),%r9
mov    %r12,%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 = [7 x i8] c"offset\00"
@.str.1 = [7 x i8] c"length\00"
@.str.2 = [10 x i8] c"user.name\00"
@.str.3 = [4 x i8] c"%lu\00"
@EIO = global i32 0
@.str.4 = [5 x i8] c"OPEN\00"
define i32 @createUrlForOPEN(i8* %0, i32 %1, i8* %2, i8* %3, i64 %4, i64 %5, i8** %6) {
%8 = alloca i32
%9 = alloca i8*
%10 = alloca i32
%11 = alloca i8*
%12 = alloca i8*
%13 = alloca i64
%14 = alloca i64
%15 = alloca i8**
%16 = alloca i32
%17 = alloca [21 x i8]
%18 = alloca [21 x i8]
%19 = alloca [3 x i8*]
%20 = alloca [3 x i8*]
store i8* %0, i8** %9
store i32 %1, i32* %10
store i8* %2, i8** %11
store i8* %3, i8** %12
store i64 %4, i64* %13
store i64 %5, i64* %14
store i8** %6, i8*** %15
%21 = getelementptr inbounds [3 x i8*], [3 x i8*]* %19, i64 0, i64 0
store i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8** %21
%22 = getelementptr inbounds [3 x i8*], [3 x i8*]* %19, i64 0, i64 1
store i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8** %22
%23 = getelementptr inbounds [3 x i8*], [3 x i8*]* %19, i64 0, i64 2
store i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8** %23
%24 = getelementptr inbounds [21 x i8], [21 x i8]* %17, i64 0, i64 0
%25 = call i32 @memset(i8* %24, i32 0, i32 21)
%26 = getelementptr inbounds [21 x i8], [21 x i8]* %18, i64 0, i64 0
%27 = call i32 @memset(i8* %26, i32 0, i32 21)
%28 = getelementptr inbounds [21 x i8], [21 x i8]* %17, i64 0, i64 0
%29 = load i64, i64* %13
%30 = call i32 @snprintf(i8* %28, i32 21, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i64 %29)
store i32 %30, i32* %16
%31 = load i32, i32* %16
%32 = icmp slt i32 %31, 0
br i1 %32, label %36, label %33
33: ; preds = %7
%34 = load i32, i32* %16
%35 = icmp sge i32 %34, 21
br i1 %35, label %36, label %38
36: ; preds = %33, %7
%37 = load i32, i32* @EIO
store i32 %37, i32* %8
br label %63
38: ; preds = %33
%39 = getelementptr inbounds [21 x i8], [21 x i8]* %18, i64 0, i64 0
%40 = load i64, i64* %14
%41 = call i32 @snprintf(i8* %39, i32 21, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i64 %40)
store i32 %41, i32* %16
%42 = load i32, i32* %16
%43 = icmp slt i32 %42, 0
br i1 %43, label %47, label %44
44: ; preds = %38
%45 = load i32, i32* %16
%46 = icmp sge i32 %45, 21
br i1 %46, label %47, label %49
47: ; preds = %44, %38
%48 = load i32, i32* @EIO
store i32 %48, i32* %8
br label %63
49: ; preds = %44
%50 = getelementptr inbounds [21 x i8], [21 x i8]* %17, i64 0, i64 0
%51 = getelementptr inbounds [3 x i8*], [3 x i8*]* %20, i64 0, i64 0
store i8* %50, i8** %51
%52 = getelementptr inbounds [21 x i8], [21 x i8]* %18, i64 0, i64 0
%53 = getelementptr inbounds [3 x i8*], [3 x i8*]* %20, i64 0, i64 1
store i8* %52, i8** %53
%54 = load i8*, i8** %12
%55 = getelementptr inbounds [3 x i8*], [3 x i8*]* %20, i64 0, i64 2
store i8* %54, i8** %55
%56 = load i8*, i8** %9
%57 = load i32, i32* %10
%58 = load i8*, i8** %11
%59 = getelementptr inbounds [3 x i8*], [3 x i8*]* %19, i64 0, i64 0
%60 = getelementptr inbounds [3 x i8*], [3 x i8*]* %20, i64 0, i64 0
%61 = load i8**, i8*** %15
%62 = call i32 @createQueryURL(i8* %56, i32 %57, i8* %58, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i32 3, i8** %59, i8** %60, i8** %61)
store i32 %62, i32* %8
br label %63
63: ; preds = %49, %47, %36
%64 = load i32, i32* %8
ret i32 %64
}

LLVM IR (-O2):
@.str = [7 x i8] c"offset\00"
@.str.1 = [7 x i8] c"length\00"
@.str.2 = [10 x i8] c"user.name\00"
@.str.3 = [4 x i8] c"%lu\00"
@EIO = global i32 0
@.str.4 = [5 x i8] c"OPEN\00"
define i32 @createUrlForOPEN(i8* %0, i32 %1, i8* %2, i8* %3, i64 %4, i64 %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 = getelementptr inbounds [3 x i8*], [3 x i8*]* %10, i64 0, i64 0
store i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8** %16
%17 = getelementptr inbounds [3 x i8*], [3 x i8*]* %10, i64 0, i64 1
store i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8** %17
%18 = getelementptr inbounds [3 x i8*], [3 x i8*]* %10, i64 0, i64 2
store i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0), i8** %18
%19 = call i32 @memset(i8* %12, i32 0, i32 21)
%20 = call i32 @memset(i8* %13, i32 0, i32 21)
%21 = call i32 @snprintf(i8* %12, i32 21, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i64 %4)
%22 = icmp ugt i32 %21, 20
br i1 %22, label %23, label %25
23: ; preds = %7
%24 = load i32, i32* @EIO
br label %35
25: ; preds = %7
%26 = call i32 @snprintf(i8* %13, i32 21, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i64 %5)
%27 = icmp ugt i32 %26, 20
br i1 %27, label %28, label %30
28: ; preds = %25
%29 = load i32, i32* @EIO
br label %35
30: ; preds = %25
%31 = getelementptr inbounds [3 x i8*], [3 x i8*]* %11, i64 0, i64 0
store i8* %12, i8** %31
%32 = getelementptr inbounds [3 x i8*], [3 x i8*]* %11, i64 0, i64 1
store i8* %13, i8** %32
%33 = getelementptr inbounds [3 x i8*], [3 x i8*]* %11, i64 0, i64 2
store i8* %3, i8** %33
%34 = call i32 @createQueryURL(i8* %0, i32 %1, i8* %2, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.4, i64 0, i64 0), i32 3, i8** %16, i8** %31, i8** %6)
br label %35
35: ; preds = %30, %28, %23
%36 = phi i32 [ %24, %23 ], [ %29, %28 ], [ %34, %30 ]
ret i32 %36
}