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


x86 assembly (clang, -O0):
<httpsqs_reset>:
push   %rbp
mov    %rsp,%rbp
sub    $0x170,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0x154(%rbp)
movl   $0x0,-0x158(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <strlen@plt>
mov    %eax,-0x164(%rbp)
lea    0xe57(%rip),%rdi
call   1050 <strlen@plt>
mov    %eax,%ecx
mov    -0x164(%rbp),%eax
add    %ecx,%eax
add    $0x1b,%eax
cltq
shl    $0x0,%rax
mov    %eax,%edi
call   1070 <malloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
mov    -0x8(%rbp),%rcx
lea    0xe2b(%rip),%rsi
lea    0xe1e(%rip),%rdx
call   1090 <sprintf@plt>
mov    -0x18(%rbp),%rdi
call   1080 <http_get@plt>
mov    %eax,-0x10(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
mov    -0x10(%rbp),%edi
lea    -0xb(%rbp),%rsi
mov    $0x1,%edx
call   1060 <read@plt>
cmp    $0x0,%rax
jle    1265 <httpsqs_reset+0xf5>
cmpl   $0x7,-0x158(%rbp)
jl     1244 <httpsqs_reset+0xd4>
mov    -0xb(%rbp),%cl
movslq -0x154(%rbp),%rax
mov    %cl,-0x150(%rbp,%rax,1)
mov    -0x154(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x154(%rbp)
movsbl -0xb(%rbp),%eax
cmp    $0xa,%eax
jne    1260 <httpsqs_reset+0xf0>
mov    -0x158(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x158(%rbp)
jmp    11fc <httpsqs_reset+0x8c>
lea    -0x150(%rbp),%rdi
call   1050 <strlen@plt>
cmp    $0x0,%eax
jle    1289 <httpsqs_reset+0x119>
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_reset>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x148,%rsp
mov    %rdi,%rbx
call   1050 <strlen@plt>
mov    %eax,%r14d
lea    0xe71(%rip),%r15
mov    %r15,%rdi
call   1050 <strlen@plt>
lea    (%r14,%rax,1),%edi
add    $0x1b,%edi
call   1070 <malloc@plt>
mov    %rax,%r14
lea    0xe59(%rip),%rsi
mov    %rax,%rdi
mov    %r15,%rdx
mov    %rbx,%rcx
call   1090 <sprintf@plt>
mov    %r14,%rdi
call   1080 <http_get@plt>
mov    %eax,%r15d
mov    %r14,%rdi
call   1030 <free@plt>
lea    0xd(%rsp),%rsi
mov    %r15d,%edi
mov    $0x1,%edx
call   1060 <read@plt>
xor    %ebx,%ebx
test   %rax,%rax
jle    1224 <httpsqs_reset+0xb4>
lea    0xd(%rsp),%r14
xor    %ebp,%ebp
jmp    120e <httpsqs_reset+0x9e>
xor    %ecx,%ecx
cmp    $0xa,%al
sete   %cl
add    %ecx,%ebp
mov    %r15d,%edi
mov    %r14,%rsi
mov    $0x1,%edx
call   1060 <read@plt>
test   %rax,%rax
jle    1224 <httpsqs_reset+0xb4>
movzbl 0xd(%rsp),%eax
cmp    $0x7,%ebp
jb     11f0 <httpsqs_reset+0x80>
movslq %ebx,%rbx
mov    %al,0x10(%rsp,%rbx,1)
add    $0x1,%ebx
jmp    11f0 <httpsqs_reset+0x80>
lea    0x10(%rsp),%rdi
call   1050 <strlen@plt>
test   %eax,%eax
jle    123a <httpsqs_reset+0xca>
movslq %ebx,%rax
movb   $0x0,0x10(%rsp,%rax,1)
lea    0x10(%rsp),%r14
mov    %r14,%rdi
call   1050 <strlen@plt>
mov    %eax,%edi
call   1070 <malloc@plt>
mov    %rax,%rbx
mov    %rax,%rdi
mov    %r14,%rsi
call   1040 <strcpy@plt>
mov    %rbx,%rax
add    $0x148,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

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

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