#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_maxqueue(char *name, char *num) {
  char data[3];
  int sock;
  char *query;
  char max[300];
  int i = 0, j = 0;
  char *fs;
  query = (char *)malloc((strlen(name) + strlen(num) + strlen("utf-8") + 35) *
                         sizeof(char));
  sprintf(query, "/?charset=%s&name=%s&opt=maxqueue&num=%s", "utf-8", name,
          num);
  sock = http_get(query);
  free(query);
  while (read(sock, data, 1) > 0) {
    if (j >= 7) {
      max[i] = data[0];
      i++;
    }
    if (data[0] == '\n') {
      j++;
    }
  }
  if (strlen(max) > 0) {
    max[i] = '\0';
  }
  fs = (char *)malloc(strlen(max) * sizeof(char));
  strcpy(fs, max);
  return fs;
}


x86 assembly (clang, -O0):
<httpsqs_maxqueue>:
push   %rbp
mov    %rsp,%rbp
sub    $0x170,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x154(%rbp)
movl   $0x0,-0x158(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,-0x168(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,%ecx
mov    -0x168(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x164(%rbp)
lea    0xe3a(%rip),%rdi
call   1050 <strlen@plt>
mov    %eax,%ecx
mov    -0x164(%rbp),%eax
add    %ecx,%eax
add    $0x23,%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    0xe0a(%rip),%rsi
lea    0xdfd(%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    1286 <httpsqs_maxqueue+0x116>
cmpl   $0x7,-0x158(%rbp)
jl     1265 <httpsqs_maxqueue+0xf5>
mov    -0x13(%rbp),%cl
movslq -0x154(%rbp),%rax
mov    %cl,-0x150(%rbp,%rax,1)
mov    -0x154(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x154(%rbp)
movsbl -0x13(%rbp),%eax
cmp    $0xa,%eax
jne    1281 <httpsqs_maxqueue+0x111>
mov    -0x158(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x158(%rbp)
jmp    121d <httpsqs_maxqueue+0xad>
lea    -0x150(%rbp),%rdi
call   1050 <strlen@plt>
cmp    $0x0,%eax
jle    12aa <httpsqs_maxqueue+0x13a>
movslq -0x154(%rbp),%rax
movb   $0x0,-0x150(%rbp,%rax,1)
lea    -0x150(%rbp),%rdi
call   1050 <strlen@plt>
cltq
shl    $0x0,%rax
mov    %eax,%edi
call   1070 <malloc@plt>
mov    %rax,-0x160(%rbp)
mov    -0x160(%rbp),%rdi
lea    -0x150(%rbp),%rsi
call   1040 <strcpy@plt>
mov    -0x160(%rbp),%rax
add    $0x170,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<httpsqs_maxqueue>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x140,%rsp
mov    %rsi,%r14
mov    %rdi,%r15
call   1050 <strlen@plt>
mov    %eax,%ebp
mov    %r14,%rdi
call   1050 <strlen@plt>
mov    %eax,%ebx
lea    0xe63(%rip),%r12
mov    %r12,%rdi
call   1050 <strlen@plt>
add    %ebp,%ebx
lea    (%rax,%rbx,1),%edi
add    $0x23,%edi
call   1070 <malloc@plt>
mov    %rax,%rbp
lea    0xe4a(%rip),%rsi
mov    %rax,%rdi
mov    %r12,%rdx
mov    %r15,%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_maxqueue+0xd4>
lea    0xd(%rsp),%r14
xor    %ebx,%ebx
jmp    122e <httpsqs_maxqueue+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_maxqueue+0xd4>
movzbl 0xd(%rsp),%eax
cmp    $0x7,%ebx
jb     1210 <httpsqs_maxqueue+0xa0>
movslq %ebp,%rbp
mov    %al,0x10(%rsp,%rbp,1)
add    $0x1,%ebp
jmp    1210 <httpsqs_maxqueue+0xa0>
lea    0x10(%rsp),%rdi
call   1050 <strlen@plt>
test   %eax,%eax
jle    125a <httpsqs_maxqueue+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    $0x140,%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 = [41 x i8] c"/?charset=%s&name=%s&opt=maxqueue&num=%s\00"
define i8* @httpsqs_maxqueue(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca [3 x i8]
%6 = alloca i32
%7 = alloca i8*
%8 = alloca [300 x i8]
%9 = alloca i32
%10 = alloca i32
%11 = alloca i8*
store i8* %0, i8** %3
store i8* %1, i8** %4
store i32 0, i32* %9
store i32 0, i32* %10
%12 = load i8*, i8** %3
%13 = call i32 @strlen(i8* %12)
%14 = load i8*, i8** %4
%15 = call i32 @strlen(i8* %14)
%16 = add nsw i32 %13, %15
%17 = call i32 @strlen(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%18 = add nsw i32 %16, %17
%19 = add nsw i32 %18, 35
%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 ([41 x i8], [41 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* %10
%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* %9
%45 = sext i32 %44 to i64
%46 = getelementptr inbounds [300 x i8], [300 x i8]* %8, i64 0, i64 %45
store i8 %43, i8* %46
%47 = load i32, i32* %9
%48 = add nsw i32 %47, 1
store i32 %48, i32* %9
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* %10
%56 = add nsw i32 %55, 1
store i32 %56, i32* %10
br label %57
57: ; preds = %54, %49
br label %33
58: ; preds = %33
%59 = getelementptr inbounds [300 x i8], [300 x i8]* %8, 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* %9
%64 = sext i32 %63 to i64
%65 = getelementptr inbounds [300 x i8], [300 x i8]* %8, i64 0, i64 %64
store i8 0, i8* %65
br label %66
66: ; preds = %62, %58
%67 = getelementptr inbounds [300 x i8], [300 x i8]* %8, 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 [300 x i8], [300 x i8]* %8, 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 = [41 x i8] c"/?charset=%s&name=%s&opt=maxqueue&num=%s\00"
define i8* @httpsqs_maxqueue(i8* %0, i8* %1) {
%3 = alloca [3 x i8]
%4 = alloca [300 x i8]
%5 = getelementptr inbounds [3 x i8], [3 x i8]* %3, i64 0, i64 0
%6 = getelementptr inbounds [300 x i8], [300 x i8]* %4, i64 0, i64 0
%7 = tail call i32 @strlen(i8* %0)
%8 = tail call i32 @strlen(i8* %1)
%9 = tail call i32 @strlen(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%10 = add i32 %7, 35
%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 ([41 x i8], [41 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 [300 x i8], [300 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 [300 x i8], [300 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
}