#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 /*<<< orphan*/ time_t;
struct link {
  int dummy;
};
typedef int /*<<< orphan*/ int64_t;

/* Variables and functions */
int /*<<< orphan*/ getenv(char *);
struct link *http_query_size_via_proxy(char *, char const *, char const *,
                                       int /*<<< orphan*/ *, int /*<<< orphan*/,
                                       int);
int /*<<< orphan*/ strcpy(char *, int /*<<< orphan*/);
char *strtok(char *, char *);
struct link *http_query_size(const char *url, const char *action, int64_t *size,
                             time_t stoptime, int cache_reload) {
  if (!getenv("HTTP_PROXY")) {
    return http_query_size_via_proxy(0, url, action, size, stoptime,
                                     cache_reload);
  } else {
    char proxies[4096];
    char *proxy;
    strcpy(proxies, getenv("HTTP_PROXY"));
    proxy = strtok(proxies, ";");
    while (proxy) {
      struct link *result;
      result = http_query_size_via_proxy(proxy, url, action, size, stoptime,
                                         cache_reload);
      if (result)
        return result;
      proxy = strtok(0, ";");
    }
    return 0;
  }
}


x86 assembly (clang, -O0):
<http_query_size>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1050,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %ecx,-0x24(%rbp)
mov    %r8d,-0x28(%rbp)
lea    0xe9b(%rip),%rdi
call   1030 <getenv@plt>
cmp    $0x0,%eax
jne    1199 <http_query_size+0x59>
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rcx
mov    -0x24(%rbp),%r8d
mov    -0x28(%rbp),%r9d
xor    %eax,%eax
mov    %eax,%edi
call   1050 <http_query_size_via_proxy@plt>
mov    %rax,-0x8(%rbp)
jmp    1252 <http_query_size+0x112>
lea    -0x1030(%rbp),%rax
mov    %rax,-0x1048(%rbp)
lea    0xe52(%rip),%rdi
call   1030 <getenv@plt>
mov    -0x1048(%rbp),%rdi
mov    %eax,%esi
call   1040 <strcpy@plt>
lea    -0x1030(%rbp),%rdi
lea    0xe3c(%rip),%rsi
call   1060 <strtok@plt>
mov    %rax,-0x1038(%rbp)
cmpq   $0x0,-0x1038(%rbp)
je     124a <http_query_size+0x10a>
mov    -0x1038(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rdx
mov    -0x20(%rbp),%rcx
mov    -0x24(%rbp),%r8d
mov    -0x28(%rbp),%r9d
call   1050 <http_query_size_via_proxy@plt>
mov    %rax,-0x1040(%rbp)
cmpq   $0x0,-0x1040(%rbp)
je     122e <http_query_size+0xee>
mov    -0x1040(%rbp),%rax
mov    %rax,-0x8(%rbp)
jmp    1252 <http_query_size+0x112>
xor    %eax,%eax
mov    %eax,%edi
lea    0xdd2(%rip),%rsi
call   1060 <strtok@plt>
mov    %rax,-0x1038(%rbp)
jmp    11db <http_query_size+0x9b>
movq   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x1050,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<http_query_size>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x1018,%rsp
mov    %r8d,%r14d
mov    %ecx,%r15d
mov    %rdx,%r12
mov    %rsi,%rbp
mov    %rdi,%rbx
lea    0xe99(%rip),%rdi
call   1030 <getenv@plt>
test   %eax,%eax
je     11dd <http_query_size+0x9d>
lea    0x10(%rsp),%r13
mov    %r13,%rdi
mov    %eax,%esi
call   1040 <strcpy@plt>
lea    0xe85(%rip),%rsi
mov    %r13,%rdi
call   1060 <strtok@plt>
test   %rax,%rax
je     1204 <http_query_size+0xc4>
lea    0xe71(%rip),%r13
xor    %ecx,%ecx
mov    %rcx,0x8(%rsp)
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %rax,%rdi
mov    %rbx,%rsi
mov    %rbp,%rdx
mov    %r12,%rcx
mov    %r15d,%r8d
mov    %r14d,%r9d
call   1050 <http_query_size_via_proxy@plt>
test   %rax,%rax
jne    1206 <http_query_size+0xc6>
xor    %edi,%edi
mov    %r13,%rsi
call   1060 <strtok@plt>
test   %rax,%rax
jne    11b0 <http_query_size+0x70>
jmp    120b <http_query_size+0xcb>
xor    %edi,%edi
mov    %rbx,%rsi
mov    %rbp,%rdx
mov    %r12,%rcx
mov    %r15d,%r8d
mov    %r14d,%r9d
add    $0x1018,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1050 <http_query_size_via_proxy@plt>
xor    %eax,%eax
mov    %rax,0x8(%rsp)
mov    0x8(%rsp),%rax
add    $0x1018,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.link = type { i32 }
@.str = [11 x i8] c"HTTP_PROXY\00"
@.str.1 = [2 x i8] c";\00"
define %struct.link* @http_query_size(i8* %0, i8* %1, i32* %2, i32 %3, i32 %4) {
%6 = alloca %struct.link*
%7 = alloca i8*
%8 = alloca i8*
%9 = alloca i32*
%10 = alloca i32
%11 = alloca i32
%12 = alloca [4096 x i8]
%13 = alloca i8*
%14 = alloca %struct.link*
store i8* %0, i8** %7
store i8* %1, i8** %8
store i32* %2, i32** %9
store i32 %3, i32* %10
store i32 %4, i32* %11
%15 = call i32 @getenv(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%16 = icmp ne i32 %15, 0
br i1 %16, label %24, label %17
17: ; preds = %5
%18 = load i8*, i8** %7
%19 = load i8*, i8** %8
%20 = load i32*, i32** %9
%21 = load i32, i32* %10
%22 = load i32, i32* %11
%23 = call %struct.link* @http_query_size_via_proxy(i8* null, i8* %18, i8* %19, i32* %20, i32 %21, i32 %22)
store %struct.link* %23, %struct.link** %6
br label %48
24: ; preds = %5
%25 = getelementptr inbounds [4096 x i8], [4096 x i8]* %12, i64 0, i64 0
%26 = call i32 @getenv(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%27 = call i32 @strcpy(i8* %25, i32 %26)
%28 = getelementptr inbounds [4096 x i8], [4096 x i8]* %12, i64 0, i64 0
%29 = call i8* @strtok(i8* %28, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i8* %29, i8** %13
br label %30
30: ; preds = %45, %24
%31 = load i8*, i8** %13
%32 = icmp ne i8* %31, null
br i1 %32, label %33, label %47
33: ; preds = %30
%34 = load i8*, i8** %13
%35 = load i8*, i8** %7
%36 = load i8*, i8** %8
%37 = load i32*, i32** %9
%38 = load i32, i32* %10
%39 = load i32, i32* %11
%40 = call %struct.link* @http_query_size_via_proxy(i8* %34, i8* %35, i8* %36, i32* %37, i32 %38, i32 %39)
store %struct.link* %40, %struct.link** %14
%41 = load %struct.link*, %struct.link** %14
%42 = icmp ne %struct.link* %41, null
br i1 %42, label %43, label %45
43: ; preds = %33
%44 = load %struct.link*, %struct.link** %14
store %struct.link* %44, %struct.link** %6
br label %48
45: ; preds = %33
%46 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i8* %46, i8** %13
br label %30
47: ; preds = %30
store %struct.link* null, %struct.link** %6
br label %48
48: ; preds = %47, %43, %17
%49 = load %struct.link*, %struct.link** %6
ret %struct.link* %49
}

LLVM IR (-O2):
%struct.link = type { i32 }
@.str = [11 x i8] c"HTTP_PROXY\00"
@.str.1 = [2 x i8] c";\00"
define %struct.link* @http_query_size(i8* %0, i8* %1, i32* %2, i32 %3, i32 %4) {
%6 = alloca [4096 x i8]
%7 = tail call i32 @getenv(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0))
%8 = icmp eq i32 %7, 0
br i1 %8, label %9, label %11
9: ; preds = %5
%10 = tail call %struct.link* @http_query_size_via_proxy(i8* null, i8* %0, i8* %1, i32* %2, i32 %3, i32 %4)
br label %25
11: ; preds = %5
%12 = getelementptr inbounds [4096 x i8], [4096 x i8]* %6, i64 0, i64 0
%13 = call i32 @strcpy(i8* %12, i32 %7)
%14 = call i8* @strtok(i8* %12, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%15 = icmp eq i8* %14, null
br i1 %15, label %23, label %16
16: ; preds = %11, %20
%17 = phi i8* [ %21, %20 ], [ %14, %11 ]
%18 = call %struct.link* @http_query_size_via_proxy(i8* %17, i8* %0, i8* %1, i32* %2, i32 %3, i32 %4)
%19 = icmp eq %struct.link* %18, null
br i1 %19, label %20, label %23
20: ; preds = %16
%21 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%22 = icmp eq i8* %21, null
br i1 %22, label %23, label %16
23: ; preds = %20, %16, %11
%24 = phi %struct.link* [ null, %11 ], [ %18, %16 ], [ null, %20 ]
br label %25
25: ; preds = %23, %9
%26 = phi %struct.link* [ %24, %23 ], [ %10, %9 ]
ret %struct.link* %26
}