#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 /*<<< orphan*/ free(char *);
int http_get(char *);
scalar_t__ malloc(int);
scalar_t__ read(int, char *, int);
int /*<<< orphan*/ sprintf(char *, char *, char *, char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int strlen(char *);
char *httpsqs_view(char *name, char *pos) {
  char data[3];
  int sock;
  char *query;
  int i = 0, j = 0;
  char queuedata[2000];
  char *fq;
  query = (char *)malloc((strlen(name) + strlen("utf-8") + strlen(pos) + 31) *
                         sizeof(char));
  sprintf(query, "/?charset=%s&name=%s&opt=view&pos=%s", "utf-8", name, pos);
  sock = http_get(query);
  free(query);
  while (read(sock, data, 1) > 0) {
    if (j >= 7) {
      queuedata[i] = data[0];
      i++;
    }
    if (data[0] == '\n') {
      j++;
    }
  }
  if (strlen(queuedata) > 0) {
    queuedata[i] = '\0';
  }
  fq = (char *)malloc(strlen(queuedata) * sizeof(char));
  strcpy(fq, queuedata);
  return fq;
}


x86 assembly (clang, -O0):
<httpsqs_view>:
push   %rbp
mov    %rsp,%rbp
sub    $0x810,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x24(%rbp)
movl   $0x0,-0x28(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,-0x810(%rbp)
lea    0xe59(%rip),%rdi
call   1050 <strlen@plt>
mov    %eax,%ecx
mov    -0x810(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x80c(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,%ecx
mov    -0x80c(%rbp),%eax
add    %ecx,%eax
add    $0x1f,%eax
cltq
shl    $0x0,%rax
mov    %eax,%edi
call   1070 <malloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x8(%rbp),%rcx
mov    -0x10(%rbp),%r8
lea    0xe10(%rip),%rsi
lea    0xe03(%rip),%rdx
call   1090 <sprintf@plt>
mov    -0x20(%rbp),%rdi
call   1080 <http_get@plt>
mov    %eax,-0x18(%rbp)
mov    -0x20(%rbp),%rdi
call   1030 <free@plt>
mov    -0x18(%rbp),%edi
lea    -0x13(%rbp),%rsi
mov    $0x1,%edx
call   1060 <read@plt>
cmp    $0x0,%rax
jle    126e <httpsqs_view+0xfe>
cmpl   $0x7,-0x28(%rbp)
jl     1253 <httpsqs_view+0xe3>
mov    -0x13(%rbp),%cl
movslq -0x24(%rbp),%rax
mov    %cl,-0x800(%rbp,%rax,1)
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
movsbl -0x13(%rbp),%eax
cmp    $0xa,%eax
jne    1269 <httpsqs_view+0xf9>
mov    -0x28(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x28(%rbp)
jmp    1217 <httpsqs_view+0xa7>
lea    -0x800(%rbp),%rdi
call   1050 <strlen@plt>
cmp    $0x0,%eax
jle    128f <httpsqs_view+0x11f>
movslq -0x24(%rbp),%rax
movb   $0x0,-0x800(%rbp,%rax,1)
lea    -0x800(%rbp),%rdi
call   1050 <strlen@plt>
cltq
shl    $0x0,%rax
mov    %eax,%edi
call   1070 <malloc@plt>
mov    %rax,-0x808(%rbp)
mov    -0x808(%rbp),%rdi
lea    -0x800(%rbp),%rsi
call   1040 <strcpy@plt>
mov    -0x808(%rbp),%rax
add    $0x810,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<httpsqs_view>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x7e0,%rsp
mov    %rsi,%r14
mov    %rdi,%r12
call   1050 <strlen@plt>
mov    %eax,%ebp
lea    0xe6d(%rip),%r15
mov    %r15,%rdi
call   1050 <strlen@plt>
mov    %eax,%ebx
mov    %r14,%rdi
call   1050 <strlen@plt>
add    %ebp,%ebx
lea    (%rax,%rbx,1),%edi
add    $0x1f,%edi
call   1070 <malloc@plt>
mov    %rax,%rbp
lea    0xe4a(%rip),%rsi
mov    %rax,%rdi
mov    %r15,%rdx
mov    %r12,%rcx
mov    %r14,%r8
call   1090 <sprintf@plt>
mov    %rbp,%rdi
call   1080 <http_get@plt>
mov    %eax,%r15d
mov    %rbp,%rdi
call   1030 <free@plt>
lea    0xd(%rsp),%rsi
mov    %r15d,%edi
mov    $0x1,%edx
call   1060 <read@plt>
xor    %ebp,%ebp
test   %rax,%rax
jle    1244 <httpsqs_view+0xd4>
lea    0xd(%rsp),%r14
xor    %ebx,%ebx
jmp    122e <httpsqs_view+0xbe>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
xor    %ecx,%ecx
cmp    $0xa,%al
sete   %cl
add    %ecx,%ebx
mov    %r15d,%edi
mov    %r14,%rsi
mov    $0x1,%edx
call   1060 <read@plt>
test   %rax,%rax
jle    1244 <httpsqs_view+0xd4>
movzbl 0xd(%rsp),%eax
cmp    $0x7,%ebx
jb     1210 <httpsqs_view+0xa0>
movslq %ebp,%rbp
mov    %al,0x10(%rsp,%rbp,1)
add    $0x1,%ebp
jmp    1210 <httpsqs_view+0xa0>
lea    0x10(%rsp),%rdi
call   1050 <strlen@plt>
test   %eax,%eax
jle    125a <httpsqs_view+0xea>
movslq %ebp,%rax
movb   $0x0,0x10(%rsp,%rax,1)
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
call   1050 <strlen@plt>
mov    %eax,%edi
call   1070 <malloc@plt>
mov    %rax,%rbp
mov    %rax,%rdi
mov    %rbx,%rsi
call   1040 <strcpy@plt>
mov    %rbp,%rax
add    $0x7e0,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [6 x i8] c"utf-8\00"
@.str.1 = [37 x i8] c"/?charset=%s&name=%s&opt=view&pos=%s\00"
define i8* @httpsqs_view(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca [3 x i8]
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i32
%10 = alloca [2000 x i8]
%11 = alloca i8*
store i8* %0, i8** %3
store i8* %1, i8** %4
store i32 0, i32* %8
store i32 0, i32* %9
%12 = load i8*, i8** %3
%13 = call i32 @strlen(i8* %12)
%14 = call i32 @strlen(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%15 = add nsw i32 %13, %14
%16 = load i8*, i8** %4
%17 = call i32 @strlen(i8* %16)
%18 = add nsw i32 %15, %17
%19 = add nsw i32 %18, 31
%20 = sext i32 %19 to i64
%21 = mul i64 %20, 1
%22 = trunc i64 %21 to i32
%23 = call i64 @malloc(i32 %22)
%24 = inttoptr i64 %23 to i8*
store i8* %24, i8** %7
%25 = load i8*, i8** %7
%26 = load i8*, i8** %3
%27 = load i8*, i8** %4
%28 = call i32 @sprintf(i8* %25, i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %26, i8* %27)
%29 = load i8*, i8** %7
%30 = call i32 @http_get(i8* %29)
store i32 %30, i32* %6
%31 = load i8*, i8** %7
%32 = call i32 @free(i8* %31)
br label %33
33: ; preds = %57, %2
%34 = load i32, i32* %6
%35 = getelementptr inbounds [3 x i8], [3 x i8]* %5, i64 0, i64 0
%36 = call i64 @read(i32 %34, i8* %35, i32 1)
%37 = icmp sgt i64 %36, 0
br i1 %37, label %38, label %58
38: ; preds = %33
%39 = load i32, i32* %9
%40 = icmp sge i32 %39, 7
br i1 %40, label %41, label %49
41: ; preds = %38
%42 = getelementptr inbounds [3 x i8], [3 x i8]* %5, i64 0, i64 0
%43 = load i8, i8* %42
%44 = load i32, i32* %8
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds [2000 x i8], [2000 x i8]* %10, i64 0, i64 %45
store i8 %43, i8* %46
%47 = load i32, i32* %8
%48 = add nsw i32 %47, 1
store i32 %48, i32* %8
br label %49
49: ; preds = %41, %38
%50 = getelementptr inbounds [3 x i8], [3 x i8]* %5, i64 0, i64 0
%51 = load i8, i8* %50
%52 = sext i8 %51 to i32
%53 = icmp eq i32 %52, 10
br i1 %53, label %54, label %57
54: ; preds = %49
%55 = load i32, i32* %9
%56 = add nsw i32 %55, 1
store i32 %56, i32* %9
br label %57
57: ; preds = %54, %49
br label %33
58: ; preds = %33
%59 = getelementptr inbounds [2000 x i8], [2000 x i8]* %10, i64 0, i64 0
%60 = call i32 @strlen(i8* %59)
%61 = icmp sgt i32 %60, 0
br i1 %61, label %62, label %66
62: ; preds = %58
%63 = load i32, i32* %8
%64 = sext i32 %63 to i64
%65 = getelementptr inbounds [2000 x i8], [2000 x i8]* %10, i64 0, i64 %64
store i8 0, i8* %65
br label %66
66: ; preds = %62, %58
%67 = getelementptr inbounds [2000 x i8], [2000 x i8]* %10, i64 0, i64 0
%68 = call i32 @strlen(i8* %67)
%69 = sext i32 %68 to i64
%70 = mul i64 %69, 1
%71 = trunc i64 %70 to i32
%72 = call i64 @malloc(i32 %71)
%73 = inttoptr i64 %72 to i8*
store i8* %73, i8** %11
%74 = load i8*, i8** %11
%75 = getelementptr inbounds [2000 x i8], [2000 x i8]* %10, i64 0, i64 0
%76 = call i32 @strcpy(i8* %74, i8* %75)
%77 = load i8*, i8** %11
ret i8* %77
}

LLVM IR (-O2):
@.str = [6 x i8] c"utf-8\00"
@.str.1 = [37 x i8] c"/?charset=%s&name=%s&opt=view&pos=%s\00"
define i8* @httpsqs_view(i8* %0, i8* %1) {
%3 = alloca [3 x i8]
%4 = alloca [2000 x i8]
%5 = getelementptr inbounds [3 x i8], [3 x i8]* %3, i64 0, i64 0
%6 = getelementptr inbounds [2000 x i8], [2000 x i8]* %4, i64 0, i64 0
%7 = tail call i32 @strlen(i8* %0)
%8 = tail call i32 @strlen(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%9 = tail call i32 @strlen(i8* %1)
%10 = add i32 %7, 31
%11 = add i32 %10, %8
%12 = add i32 %11, %9
%13 = tail call i64 @malloc(i32 %12)
%14 = inttoptr i64 %13 to i8*
%15 = tail call i32 @sprintf(i8* dereferenceable(1) %14, i8* dereferenceable(1) getelementptr inbounds ([37 x i8], [37 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %0, i8* %1)
%16 = tail call i32 @http_get(i8* %14)
%17 = tail call i32 @free(i8* %14)
%18 = call i64 @read(i32 %16, i8* %5, i32 1)
%19 = icmp sgt i64 %18, 0
br i1 %19, label %20, label %36
20: ; preds = %2, %29
%21 = phi i32 [ %30, %29 ], [ 0, %2 ]
%22 = phi i32 [ %33, %29 ], [ 0, %2 ]
%23 = icmp ugt i32 %22, 6
%24 = load i8, i8* %5
br i1 %23, label %25, label %29
25: ; preds = %20
%26 = sext i32 %21 to i64
%27 = getelementptr inbounds [2000 x i8], [2000 x i8]* %4, i64 0, i64 %26
store i8 %24, i8* %27
%28 = add nsw i32 %21, 1
br label %29
29: ; preds = %20, %25
%30 = phi i32 [ %28, %25 ], [ %21, %20 ]
%31 = icmp eq i8 %24, 10
%32 = zext i1 %31 to i32
%33 = add nuw nsw i32 %22, %32
%34 = call i64 @read(i32 %16, i8* %5, i32 1)
%35 = icmp sgt i64 %34, 0
br i1 %35, label %20, label %36
36: ; preds = %29, %2
%37 = phi i32 [ 0, %2 ], [ %30, %29 ]
%38 = call i32 @strlen(i8* %6)
%39 = icmp sgt i32 %38, 0
br i1 %39, label %40, label %43
40: ; preds = %36
%41 = sext i32 %37 to i64
%42 = getelementptr inbounds [2000 x i8], [2000 x i8]* %4, i64 0, i64 %41
store i8 0, i8* %42
br label %43
43: ; preds = %40, %36
%44 = call i32 @strlen(i8* %6)
%45 = call i64 @malloc(i32 %44)
%46 = inttoptr i64 %45 to i8*
%47 = call i32 @strcpy(i8* %46, i8* %6)
ret i8* %46
}