#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 */
struct tunnel {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ free(char *);
int http_request(struct tunnel *, char *, char *, char *, char **);
int parse_config(struct tunnel *, char *);
int parse_xml_config(struct tunnel *, char *);
int auth_get_config(struct tunnel *tunnel) {
  char *buffer;
  int ret;
  ret = http_request(tunnel, "GET", "/remote/fortisslvpn_xml", "", &buffer);
  if (ret == 1) {
    ret = parse_xml_config(tunnel, buffer);
    free(buffer);
  }
  if (ret == 1)
    return ret;
  ret = http_request(tunnel, "GET", "/remote/fortisslvpn", "", &buffer);
  if (ret == 1) {
    ret = parse_config(tunnel, buffer);
    free(buffer);
  }
  return ret;
}


x86 assembly (clang, -O0):
<auth_get_config>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xea9(%rip),%rsi
lea    0xea6(%rip),%rdx
lea    0xe9e(%rip),%rcx
lea    -0x18(%rbp),%r8
call   1040 <http_request@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x1,-0x1c(%rbp)
jne    1194 <auth_get_config+0x54>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1050 <parse_xml_config@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
cmpl   $0x1,-0x1c(%rbp)
jne    11a9 <auth_get_config+0x69>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11f7 <auth_get_config+0xb7>
mov    -0x10(%rbp),%rdi
lea    0xe4c(%rip),%rsi
lea    0xe61(%rip),%rdx
lea    0xe41(%rip),%rcx
lea    -0x18(%rbp),%r8
call   1040 <http_request@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x1,-0x1c(%rbp)
jne    11f1 <auth_get_config+0xb1>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1060 <parse_config@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
mov    -0x1c(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<auth_get_config>:
push   %rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
mov    %rdi,%rbx
lea    0xeae(%rip),%rsi
lea    0xeab(%rip),%rdx
lea    0xea3(%rip),%rcx
lea    0x8(%rsp),%r8
call   1040 <http_request@plt>
cmp    $0x1,%eax
jne    1194 <auth_get_config+0x54>
mov    0x8(%rsp),%rsi
mov    %rbx,%rdi
call   1050 <parse_xml_config@plt>
mov    %eax,%r14d
mov    0x8(%rsp),%rdi
call   1030 <free@plt>
mov    $0x1,%ebp
cmp    $0x1,%r14d
je     11d6 <auth_get_config+0x96>
lea    0xe65(%rip),%rsi
lea    0xe7a(%rip),%rdx
lea    0xe5a(%rip),%rcx
lea    0x8(%rsp),%r8
mov    %rbx,%rdi
call   1040 <http_request@plt>
mov    %eax,%ebp
cmp    $0x1,%eax
jne    11d6 <auth_get_config+0x96>
mov    0x8(%rsp),%rsi
mov    %rbx,%rdi
call   1060 <parse_config@plt>
mov    %eax,%ebp
mov    0x8(%rsp),%rdi
call   1030 <free@plt>
mov    %ebp,%eax
add    $0x10,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
%struct.tunnel = type { i32 }
@.str = [4 x i8] c"GET\00"
@.str.1 = [24 x i8] c"/remote/fortisslvpn_xml\00"
@.str.2 = [1 x i8] zeroinitializer
@.str.3 = [20 x i8] c"/remote/fortisslvpn\00"
define i32 @auth_get_config(%struct.tunnel* %0) {
%2 = alloca i32
%3 = alloca %struct.tunnel*
%4 = alloca i8*
%5 = alloca i32
store %struct.tunnel* %0, %struct.tunnel** %3
%6 = load %struct.tunnel*, %struct.tunnel** %3
%7 = call i32 @http_request(%struct.tunnel* %6, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0), i8** %4)
store i32 %7, i32* %5
%8 = load i32, i32* %5
%9 = icmp eq i32 %8, 1
br i1 %9, label %10, label %16
10: ; preds = %1
%11 = load %struct.tunnel*, %struct.tunnel** %3
%12 = load i8*, i8** %4
%13 = call i32 @parse_xml_config(%struct.tunnel* %11, i8* %12)
store i32 %13, i32* %5
%14 = load i8*, i8** %4
%15 = call i32 @free(i8* %14)
br label %16
16: ; preds = %10, %1
%17 = load i32, i32* %5
%18 = icmp eq i32 %17, 1
br i1 %18, label %19, label %21
19: ; preds = %16
%20 = load i32, i32* %5
store i32 %20, i32* %2
br label %34
21: ; preds = %16
%22 = load %struct.tunnel*, %struct.tunnel** %3
%23 = call i32 @http_request(%struct.tunnel* %22, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0), i8** %4)
store i32 %23, i32* %5
%24 = load i32, i32* %5
%25 = icmp eq i32 %24, 1
br i1 %25, label %26, label %32
26: ; preds = %21
%27 = load %struct.tunnel*, %struct.tunnel** %3
%28 = load i8*, i8** %4
%29 = call i32 @parse_config(%struct.tunnel* %27, i8* %28)
store i32 %29, i32* %5
%30 = load i8*, i8** %4
%31 = call i32 @free(i8* %30)
br label %32
32: ; preds = %26, %21
%33 = load i32, i32* %5
store i32 %33, i32* %2
br label %34
34: ; preds = %32, %19
%35 = load i32, i32* %2
ret i32 %35
}

LLVM IR (-O2):
%struct.tunnel = type { i32 }
@.str = [4 x i8] c"GET\00"
@.str.1 = [24 x i8] c"/remote/fortisslvpn_xml\00"
@.str.2 = [1 x i8] zeroinitializer
@.str.3 = [20 x i8] c"/remote/fortisslvpn\00"
define i32 @auth_get_config(%struct.tunnel* %0) {
%2 = alloca i8*
%3 = bitcast i8** %2 to i8*
%4 = call i32 @http_request(%struct.tunnel* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0), i8** %2)
%5 = icmp eq i32 %4, 1
br i1 %5, label %6, label %12
6: ; preds = %1
%7 = load i8*, i8** %2
%8 = call i32 @parse_xml_config(%struct.tunnel* %0, i8* %7)
%9 = load i8*, i8** %2
%10 = call i32 @free(i8* %9)
%11 = icmp eq i32 %8, 1
br i1 %11, label %20, label %12
12: ; preds = %1, %6
%13 = call i32 @http_request(%struct.tunnel* %0, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0), i8** %2)
%14 = icmp eq i32 %13, 1
br i1 %14, label %15, label %20
15: ; preds = %12
%16 = load i8*, i8** %2
%17 = call i32 @parse_config(%struct.tunnel* %0, i8* %16)
%18 = load i8*, i8** %2
%19 = call i32 @free(i8* %18)
br label %20
20: ; preds = %12, %15, %6
%21 = phi i32 [ 1, %6 ], [ %17, %15 ], [ %13, %12 ]
ret i32 %21
}