#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*/ fprintf(int /*<<< orphan*/, char *, char *);
int /*<<< orphan*/ free(char *);
char *malloc(int);
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ perror(char *);
char *sk_recv(int, int);
int /*<<< orphan*/ sk_send(int, char *, int);
char *srv_readstr(int, int);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ strcat(char *, char const *);
char *strchr(char *, char);
int /*<<< orphan*/ strcpy(char *, char *);
char *strdup(char const *);
scalar_t__ strncmp(char *, char *, int);
int /*<<< orphan*/ strncpy(char *, char *, int);
scalar_t__ strstr(char *, char *);
char *srv_login(int sock, const char *server, const char *user,
                const char *pass, const char *resource, int ssl) {
  char *stringtosend = malloc(2048);
  char *response, *aux;
  char *idsession = malloc(128);
  int pos = 0;
  char *username = strdup(user);
  char *servername = (char *)server;
  if (strchr(username, '@')) {
    servername = strchr(username, '@');
    *servername++ = 0;
  }
  memset(stringtosend, 0, 2048);
  strcpy(stringtosend, "<?xml version='1.0' encoding='UTF-8' ?>");
  strcat(stringtosend, "<stream:stream to='");
  strcat(stringtosend, servername);
  strcat(stringtosend, "' xmlns='jabber:client' xmlns:stream='");
  strcat(stringtosend, "http://etherx.jabber.org/streams'>\n");
  if (!sk_send(sock, stringtosend, ssl)) {
    perror("senddata (server.c:132)");
    return NULL;
  }
  response = sk_recv(sock, ssl);
  if (strstr(response, "error")) {
    fprintf(stderr, "Response not valid:\n%s\n\n", response);
    return NULL;
  }
  aux = response;
  while (strncmp(aux, "id", 2))
    aux++;
  pos = 0;
  aux += 4;
  while (strncmp(aux, "'", 1) && strncmp(aux, "\"", 1)) {
    aux++;
    pos++;
  }
  aux -= pos;
  strncpy(idsession, aux, pos);
  free(response);
  strcpy(stringtosend, "<iq type='set' id='1000'>");
  strcat(stringtosend, "<query xmlns='jabber:iq:auth'>");
  strcat(stringtosend, "<username>");
  strcat(stringtosend, username);
  strcat(stringtosend, "</username><password>");
  strcat(stringtosend, pass);
  strcat(stringtosend, "</password><resource>");
  strcat(stringtosend, resource);
  strcat(stringtosend, "</resource></query></iq>\n");
  if (!sk_send(sock, stringtosend, ssl)) {
    perror("senddata (server.c:167)");
    return NULL;
  }
  response = srv_readstr(sock, ssl);
  if (strstr(response, "error")) {
    free(idsession);
    return NULL;
  }
  free(response);
  free(stringtosend);
  return idsession;
}


x86 assembly (clang, -O0):
<srv_login>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
mov    %edi,-0xc(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    %r8,-0x30(%rbp)
mov    %r9d,-0x34(%rbp)
mov    $0x800,%edi
call   10b0 <malloc@plt>
mov    %rax,-0x40(%rbp)
mov    $0x80,%edi
call   10b0 <malloc@plt>
mov    %rax,-0x58(%rbp)
movl   $0x0,-0x5c(%rbp)
mov    -0x20(%rbp),%rdi
call   1100 <strdup@plt>
mov    %rax,-0x68(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x70(%rbp)
mov    -0x68(%rbp),%rdi
mov    $0x40,%esi
call   1070 <strchr@plt>
cmp    $0x0,%rax
je     1286 <srv_login+0x96>
mov    -0x68(%rbp),%rdi
mov    $0x40,%esi
call   1070 <strchr@plt>
mov    %rax,-0x70(%rbp)
mov    -0x70(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x70(%rbp)
movb   $0x0,(%rax)
mov    -0x40(%rbp),%rdi
xor    %esi,%esi
mov    $0x800,%edx
call   1080 <memset@plt>
mov    -0x40(%rbp),%rdi
lea    0xd5f(%rip),%rsi
call   1060 <strcpy@plt>
mov    -0x40(%rbp),%rdi
lea    0xd77(%rip),%rsi
call   10f0 <strcat@plt>
mov    -0x40(%rbp),%rdi
mov    -0x70(%rbp),%rsi
call   10f0 <strcat@plt>
mov    -0x40(%rbp),%rdi
lea    0xd6e(%rip),%rsi
call   10f0 <strcat@plt>
mov    -0x40(%rbp),%rdi
lea    0xd85(%rip),%rsi
call   10f0 <strcat@plt>
mov    -0xc(%rbp),%edi
mov    -0x40(%rbp),%rsi
mov    -0x34(%rbp),%edx
call   10d0 <sk_send@plt>
cmp    $0x0,%eax
jne    1314 <srv_login+0x124>
lea    0xd85(%rip),%rdi
call   10e0 <perror@plt>
movq   $0x0,-0x8(%rbp)
jmp    155e <srv_login+0x36e>
mov    -0xc(%rbp),%edi
mov    -0x34(%rbp),%esi
call   10c0 <sk_recv@plt>
mov    %rax,-0x48(%rbp)
mov    -0x48(%rbp),%rdi
lea    0xd71(%rip),%rsi
call   1110 <strstr@plt>
cmp    $0x0,%rax
je     1363 <srv_login+0x173>
mov    0x2c9c(%rip),%rax
mov    (%rax),%edi
mov    -0x48(%rbp),%rdx
lea    0xd54(%rip),%rsi
call   10a0 <fprintf@plt>
movq   $0x0,-0x8(%rbp)
jmp    155e <srv_login+0x36e>
mov    -0x48(%rbp),%rax
mov    %rax,-0x50(%rbp)
mov    -0x50(%rbp),%rdi
lea    0xd48(%rip),%rsi
mov    $0x2,%edx
call   1050 <strncmp@plt>
cmp    $0x0,%rax
je     139b <srv_login+0x1ab>
mov    -0x50(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x50(%rbp)
jmp    136b <srv_login+0x17b>
movl   $0x0,-0x5c(%rbp)
mov    -0x50(%rbp),%rax
add    $0x4,%rax
mov    %rax,-0x50(%rbp)
mov    -0x50(%rbp),%rdi
lea    0xca8(%rip),%rsi
mov    $0x1,%edx
call   1050 <strncmp@plt>
mov    %rax,%rcx
xor    %eax,%eax
cmp    $0x0,%rcx
mov    %al,-0x71(%rbp)
je     13f4 <srv_login+0x204>
mov    -0x50(%rbp),%rdi
lea    0xce1(%rip),%rsi
mov    $0x1,%edx
call   1050 <strncmp@plt>
cmp    $0x0,%rax
setne  %al
mov    %al,-0x71(%rbp)
mov    -0x71(%rbp),%al
test   $0x1,%al
jne    1404 <srv_login+0x214>
jmp    141e <srv_login+0x22e>
mov    -0x50(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x50(%rbp)
mov    -0x5c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x5c(%rbp)
jmp    13ae <srv_login+0x1be>
mov    -0x5c(%rbp),%ecx
mov    -0x50(%rbp),%rax
movslq %ecx,%rdx
xor    %ecx,%ecx
sub    %rdx,%rcx
add    %rcx,%rax
mov    %rax,-0x50(%rbp)
mov    -0x58(%rbp),%rdi
mov    -0x50(%rbp),%rsi
mov    -0x5c(%rbp),%edx
call   1040 <strncpy@plt>
mov    -0x48(%rbp),%rdi
call   1030 <free@plt>
mov    -0x40(%rbp),%rdi
lea    0xc6b(%rip),%rsi
call   1060 <strcpy@plt>
mov    -0x40(%rbp),%rdi
lea    0xc75(%rip),%rsi
call   10f0 <strcat@plt>
mov    -0x40(%rbp),%rdi
lea    0xc84(%rip),%rsi
call   10f0 <strcat@plt>
mov    -0x40(%rbp),%rdi
mov    -0x68(%rbp),%rsi
call   10f0 <strcat@plt>
mov    -0x40(%rbp),%rdi
lea    0xc72(%rip),%rsi
call   10f0 <strcat@plt>
mov    -0x40(%rbp),%rdi
mov    -0x28(%rbp),%rsi
call   10f0 <strcat@plt>
mov    -0x40(%rbp),%rdi
lea    0xc6b(%rip),%rsi
call   10f0 <strcat@plt>
mov    -0x40(%rbp),%rdi
mov    -0x30(%rbp),%rsi
call   10f0 <strcat@plt>
mov    -0x40(%rbp),%rdi
lea    0xc64(%rip),%rsi
call   10f0 <strcat@plt>
mov    -0xc(%rbp),%edi
mov    -0x40(%rbp),%rsi
mov    -0x34(%rbp),%edx
call   10d0 <sk_send@plt>
cmp    $0x0,%eax
jne    1505 <srv_login+0x315>
lea    0xc5a(%rip),%rdi
call   10e0 <perror@plt>
movq   $0x0,-0x8(%rbp)
jmp    155e <srv_login+0x36e>
mov    -0xc(%rbp),%edi
mov    -0x34(%rbp),%esi
call   1090 <srv_readstr@plt>
mov    %rax,-0x48(%rbp)
mov    -0x48(%rbp),%rdi
lea    0xb80(%rip),%rsi
call   1110 <strstr@plt>
cmp    $0x0,%rax
je     1544 <srv_login+0x354>
mov    -0x58(%rbp),%rdi
call   1030 <free@plt>
movq   $0x0,-0x8(%rbp)
jmp    155e <srv_login+0x36e>
mov    -0x48(%rbp),%rdi
call   1030 <free@plt>
mov    -0x40(%rbp),%rdi
call   1030 <free@plt>
mov    -0x58(%rbp),%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<srv_login>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %r9d,%r15d
mov    %r8,0x20(%rsp)
mov    %rcx,0x18(%rsp)
mov    %rdx,%rbx
mov    %rsi,%rbp
mov    %edi,%r13d
mov    $0x800,%edi
call   10b0 <malloc@plt>
mov    %rax,%r12
mov    $0x80,%edi
call   10b0 <malloc@plt>
mov    %rax,%r14
mov    %rbx,%rdi
call   1100 <strdup@plt>
mov    %rax,%rbx
mov    %rax,%rdi
mov    $0x40,%esi
call   1070 <strchr@plt>
test   %rax,%rax
je     1255 <srv_login+0x65>
mov    %rax,%rbp
add    $0x1,%rbp
movb   $0x0,(%rax)
mov    %r12,%rdi
xor    %esi,%esi
mov    $0x800,%edx
call   1080 <memset@plt>
lea    0xd95(%rip),%rsi
mov    %r12,%rdi
call   1060 <strcpy@plt>
lea    0xdae(%rip),%rsi
mov    %r12,%rdi
call   10f0 <strcat@plt>
mov    %r12,%rdi
mov    %rbp,%rsi
call   10f0 <strcat@plt>
lea    0xda8(%rip),%rsi
mov    %r12,%rdi
call   10f0 <strcat@plt>
lea    0xdc0(%rip),%rsi
mov    %r12,%rdi
call   10f0 <strcat@plt>
mov    %r13d,%edi
mov    %r12,%rsi
mov    %r15d,%edx
call   10d0 <sk_send@plt>
test   %eax,%eax
je     1494 <srv_login+0x2a4>
mov    %rbx,0x10(%rsp)
mov    %r13d,%edi
mov    %r15d,%esi
call   10c0 <sk_recv@plt>
mov    %rax,%rbx
lea    0xdc4(%rip),%rsi
mov    %rax,%rdi
call   1110 <strstr@plt>
test   %rax,%rax
je     1305 <srv_login+0x115>
mov    0x2cf1(%rip),%rax
mov    (%rax),%edi
lea    0xdad(%rip),%rsi
mov    %rbx,%rdx
call   10a0 <fprintf@plt>
jmp    14a9 <srv_login+0x2b9>
mov    %r13d,(%rsp)
lea    0xdae(%rip),%rbp
mov    %rbx,%r13
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %r13,%rdi
mov    %rbp,%rsi
mov    $0x2,%edx
call   1050 <strncmp@plt>
add    $0x1,%r13
test   %rax,%rax
jne    1320 <srv_login+0x130>
mov    %r15d,0x4(%rsp)
mov    %r14,0x8(%rsp)
add    $0x3,%r13
lea    0xd13(%rip),%rsi
mov    %r13,%rdi
mov    $0x1,%edx
call   1050 <strncmp@plt>
xor    %ebp,%ebp
test   %rax,%rax
je     13a1 <srv_login+0x1b1>
lea    0xd58(%rip),%r15
lea    0xcf1(%rip),%r14
mov    %r13,%rdi
mov    %r15,%rsi
mov    $0x1,%edx
call   1050 <strncmp@plt>
test   %rax,%rax
je     13a1 <srv_login+0x1b1>
add    $0x1,%r13
add    $0x1,%ebp
mov    %r13,%rdi
mov    %r14,%rsi
mov    $0x1,%edx
call   1050 <strncmp@plt>
test   %rax,%rax
jne    1370 <srv_login+0x180>
mov    %ebp,%eax
sub    %rax,%r13
mov    0x8(%rsp),%r14
mov    %r14,%rdi
mov    %r13,%rsi
mov    %ebp,%edx
call   1040 <strncpy@plt>
mov    %rbx,%rdi
call   1030 <free@plt>
lea    0xcfc(%rip),%rsi
mov    %r12,%rdi
call   1060 <strcpy@plt>
lea    0xd07(%rip),%rsi
mov    %r12,%rdi
call   10f0 <strcat@plt>
lea    0xd17(%rip),%rsi
mov    %r12,%rdi
call   10f0 <strcat@plt>
mov    %r12,%rdi
mov    0x10(%rsp),%rsi
call   10f0 <strcat@plt>
lea    0xd06(%rip),%rsi
mov    %r12,%rdi
call   10f0 <strcat@plt>
mov    %r12,%rdi
mov    0x18(%rsp),%rsi
call   10f0 <strcat@plt>
lea    0xd00(%rip),%rsi
mov    %r12,%rdi
call   10f0 <strcat@plt>
mov    %r12,%rdi
mov    0x20(%rsp),%rsi
call   10f0 <strcat@plt>
lea    0xcfa(%rip),%rsi
mov    %r12,%rdi
call   10f0 <strcat@plt>
mov    (%rsp),%ebp
mov    %ebp,%edi
mov    %r12,%rsi
mov    0x4(%rsp),%ebx
mov    %ebx,%edx
call   10d0 <sk_send@plt>
test   %eax,%eax
je     149d <srv_login+0x2ad>
mov    %ebp,%edi
mov    %ebx,%esi
call   1090 <srv_readstr@plt>
mov    %rax,%rbp
lea    0xc34(%rip),%rsi
mov    %rax,%rdi
call   1110 <strstr@plt>
test   %rax,%rax
je     1482 <srv_login+0x292>
mov    %r14,%rdi
call   1030 <free@plt>
jmp    14a9 <srv_login+0x2b9>
mov    %rbp,%rdi
call   1030 <free@plt>
mov    %r12,%rdi
call   1030 <free@plt>
jmp    14ac <srv_login+0x2bc>
lea    0xbec(%rip),%rdi
jmp    14a4 <srv_login+0x2b4>
lea    0xca9(%rip),%rdi
call   10e0 <perror@plt>
xor    %r14d,%r14d
mov    %r14,%rax
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [40 x i8] c"<?xml version='1.0' encoding='UTF-8' ?>\00"
@.str.1 = [20 x i8] c"<stream:stream to='\00"
@.str.2 = [39 x i8] c"' xmlns='jabber:client' xmlns:stream='\00"
@.str.3 = [36 x i8] c"http://etherx.jabber.org/streams'>\0A\00"
@.str.4 = [24 x i8] c"senddata (server.c:132)\00"
@.str.5 = [6 x i8] c"error\00"
@stderr = global i32 0
@.str.6 = [25 x i8] c"Response not valid:\0A%s\0A\0A\00"
@.str.7 = [3 x i8] c"id\00"
@.str.8 = [2 x i8] c"'\00"
@.str.9 = [2 x i8] c"\22\00"
@.str.10 = [26 x i8] c"<iq type='set' id='1000'>\00"
@.str.11 = [31 x i8] c"<query xmlns='jabber:iq:auth'>\00"
@.str.12 = [11 x i8] c"<username>\00"
@.str.13 = [22 x i8] c"</username><password>\00"
@.str.14 = [22 x i8] c"</password><resource>\00"
@.str.15 = [26 x i8] c"</resource></query></iq>\0A\00"
@.str.16 = [24 x i8] c"senddata (server.c:167)\00"
define i8* @srv_login(i32 %0, i8* %1, i8* %2, i8* %3, i8* %4, i32 %5) {
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i8*
%12 = alloca i8*
%13 = alloca i32
%14 = alloca i8*
%15 = alloca i8*
%16 = alloca i8*
%17 = alloca i8*
%18 = alloca i32
%19 = alloca i8*
%20 = alloca i8*
store i32 %0, i32* %8
store i8* %1, i8** %9
store i8* %2, i8** %10
store i8* %3, i8** %11
store i8* %4, i8** %12
store i32 %5, i32* %13
%21 = call i8* @malloc(i32 2048)
store i8* %21, i8** %14
%22 = call i8* @malloc(i32 128)
store i8* %22, i8** %17
store i32 0, i32* %18
%23 = load i8*, i8** %10
%24 = call i8* @strdup(i8* %23)
store i8* %24, i8** %19
%25 = load i8*, i8** %9
store i8* %25, i8** %20
%26 = load i8*, i8** %19
%27 = call i8* @strchr(i8* %26, i8 signext 64)
%28 = icmp ne i8* %27, null
br i1 %28, label %29, label %34
29: ; preds = %6
%30 = load i8*, i8** %19
%31 = call i8* @strchr(i8* %30, i8 signext 64)
store i8* %31, i8** %20
%32 = load i8*, i8** %20
%33 = getelementptr inbounds i8, i8* %32, i32 1
store i8* %33, i8** %20
store i8 0, i8* %32
br label %34
34: ; preds = %29, %6
%35 = load i8*, i8** %14
%36 = call i32 @memset(i8* %35, i32 0, i32 2048)
%37 = load i8*, i8** %14
%38 = call i32 @strcpy(i8* %37, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str, i64 0, i64 0))
%39 = load i8*, i8** %14
%40 = call i32 @strcat(i8* %39, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0))
%41 = load i8*, i8** %14
%42 = load i8*, i8** %20
%43 = call i32 @strcat(i8* %41, i8* %42)
%44 = load i8*, i8** %14
%45 = call i32 @strcat(i8* %44, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.2, i64 0, i64 0))
%46 = load i8*, i8** %14
%47 = call i32 @strcat(i8* %46, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.3, i64 0, i64 0))
%48 = load i32, i32* %8
%49 = load i8*, i8** %14
%50 = load i32, i32* %13
%51 = call i32 @sk_send(i32 %48, i8* %49, i32 %50)
%52 = icmp ne i32 %51, 0
br i1 %52, label %55, label %53
53: ; preds = %34
%54 = call i32 @perror(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0))
store i8* null, i8** %7
br label %149
55: ; preds = %34
%56 = load i32, i32* %8
%57 = load i32, i32* %13
%58 = call i8* @sk_recv(i32 %56, i32 %57)
store i8* %58, i8** %15
%59 = load i8*, i8** %15
%60 = call i64 @strstr(i8* %59, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0))
%61 = icmp ne i64 %60, 0
br i1 %61, label %62, label %66
62: ; preds = %55
%63 = load i32, i32* @stderr
%64 = load i8*, i8** %15
%65 = call i32 @fprintf(i32 %63, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.6, i64 0, i64 0), i8* %64)
store i8* null, i8** %7
br label %149
66: ; preds = %55
%67 = load i8*, i8** %15
store i8* %67, i8** %16
br label %68
68: ; preds = %72, %66
%69 = load i8*, i8** %16
%70 = call i64 @strncmp(i8* %69, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i32 2)
%71 = icmp ne i64 %70, 0
br i1 %71, label %72, label %75
72: ; preds = %68
%73 = load i8*, i8** %16
%74 = getelementptr inbounds i8, i8* %73, i32 1
store i8* %74, i8** %16
br label %68
75: ; preds = %68
store i32 0, i32* %18
%76 = load i8*, i8** %16
%77 = getelementptr inbounds i8, i8* %76, i64 4
store i8* %77, i8** %16
br label %78
78: ; preds = %88, %75
%79 = load i8*, i8** %16
%80 = call i64 @strncmp(i8* %79, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0), i32 1)
%81 = icmp ne i64 %80, 0
br i1 %81, label %82, label %86
82: ; preds = %78
%83 = load i8*, i8** %16
%84 = call i64 @strncmp(i8* %83, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.9, i64 0, i64 0), i32 1)
%85 = icmp ne i64 %84, 0
br label %86
86: ; preds = %82, %78
%87 = phi i1 [ false, %78 ], [ %85, %82 ]
br i1 %87, label %88, label %93
88: ; preds = %86
%89 = load i8*, i8** %16
%90 = getelementptr inbounds i8, i8* %89, i32 1
store i8* %90, i8** %16
%91 = load i32, i32* %18
%92 = add nsw i32 %91, 1
store i32 %92, i32* %18
br label %78
93: ; preds = %86
%94 = load i32, i32* %18
%95 = load i8*, i8** %16
%96 = sext i32 %94 to i64
%97 = sub i64 0, %96
%98 = getelementptr inbounds i8, i8* %95, i64 %97
store i8* %98, i8** %16
%99 = load i8*, i8** %17
%100 = load i8*, i8** %16
%101 = load i32, i32* %18
%102 = call i32 @strncpy(i8* %99, i8* %100, i32 %101)
%103 = load i8*, i8** %15
%104 = call i32 @free(i8* %103)
%105 = load i8*, i8** %14
%106 = call i32 @strcpy(i8* %105, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.10, i64 0, i64 0))
%107 = load i8*, i8** %14
%108 = call i32 @strcat(i8* %107, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.11, i64 0, i64 0))
%109 = load i8*, i8** %14
%110 = call i32 @strcat(i8* %109, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.12, i64 0, i64 0))
%111 = load i8*, i8** %14
%112 = load i8*, i8** %19
%113 = call i32 @strcat(i8* %111, i8* %112)
%114 = load i8*, i8** %14
%115 = call i32 @strcat(i8* %114, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.13, i64 0, i64 0))
%116 = load i8*, i8** %14
%117 = load i8*, i8** %11
%118 = call i32 @strcat(i8* %116, i8* %117)
%119 = load i8*, i8** %14
%120 = call i32 @strcat(i8* %119, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.14, i64 0, i64 0))
%121 = load i8*, i8** %14
%122 = load i8*, i8** %12
%123 = call i32 @strcat(i8* %121, i8* %122)
%124 = load i8*, i8** %14
%125 = call i32 @strcat(i8* %124, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.15, i64 0, i64 0))
%126 = load i32, i32* %8
%127 = load i8*, i8** %14
%128 = load i32, i32* %13
%129 = call i32 @sk_send(i32 %126, i8* %127, i32 %128)
%130 = icmp ne i32 %129, 0
br i1 %130, label %133, label %131
131: ; preds = %93
%132 = call i32 @perror(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.16, i64 0, i64 0))
store i8* null, i8** %7
br label %149
133: ; preds = %93
%134 = load i32, i32* %8
%135 = load i32, i32* %13
%136 = call i8* @srv_readstr(i32 %134, i32 %135)
store i8* %136, i8** %15
%137 = load i8*, i8** %15
%138 = call i64 @strstr(i8* %137, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0))
%139 = icmp ne i64 %138, 0
br i1 %139, label %140, label %143
140: ; preds = %133
%141 = load i8*, i8** %17
%142 = call i32 @free(i8* %141)
store i8* null, i8** %7
br label %149
143: ; preds = %133
%144 = load i8*, i8** %15
%145 = call i32 @free(i8* %144)
%146 = load i8*, i8** %14
%147 = call i32 @free(i8* %146)
%148 = load i8*, i8** %17
store i8* %148, i8** %7
br label %149
149: ; preds = %143, %140, %131, %62, %53
%150 = load i8*, i8** %7
ret i8* %150
}

LLVM IR (-O2):
@.str = [40 x i8] c"<?xml version='1.0' encoding='UTF-8' ?>\00"
@.str.1 = [20 x i8] c"<stream:stream to='\00"
@.str.2 = [39 x i8] c"' xmlns='jabber:client' xmlns:stream='\00"
@.str.3 = [36 x i8] c"http://etherx.jabber.org/streams'>\0A\00"
@.str.4 = [24 x i8] c"senddata (server.c:132)\00"
@.str.5 = [6 x i8] c"error\00"
@stderr = global i32 0
@.str.6 = [25 x i8] c"Response not valid:\0A%s\0A\0A\00"
@.str.7 = [3 x i8] c"id\00"
@.str.8 = [2 x i8] c"'\00"
@.str.9 = [2 x i8] c"\22\00"
@.str.10 = [26 x i8] c"<iq type='set' id='1000'>\00"
@.str.11 = [31 x i8] c"<query xmlns='jabber:iq:auth'>\00"
@.str.12 = [11 x i8] c"<username>\00"
@.str.13 = [22 x i8] c"</username><password>\00"
@.str.14 = [22 x i8] c"</password><resource>\00"
@.str.15 = [26 x i8] c"</resource></query></iq>\0A\00"
@.str.16 = [24 x i8] c"senddata (server.c:167)\00"
define i8* @srv_login(i32 %0, i8* %1, i8* nocapture %2, i8* %3, i8* %4, i32 %5) {
%7 = tail call dereferenceable_or_null(2048) i8* @malloc(i32 2048)
%8 = tail call dereferenceable_or_null(128) i8* @malloc(i32 128)
%9 = tail call i8* @strdup(i8* %2)
%10 = tail call i8* @strchr(i8* dereferenceable(1) %9, i8 signext 64)
%11 = icmp eq i8* %10, null
br i1 %11, label %14, label %12
12: ; preds = %6
%13 = getelementptr inbounds i8, i8* %10, i64 1
store i8 0, i8* %10
br label %14
14: ; preds = %12, %6
%15 = phi i8* [ %13, %12 ], [ %1, %6 ]
%16 = tail call i32 @memset(i8* %7, i32 0, i32 2048)
%17 = tail call i32 @strcpy(i8* %7, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str, i64 0, i64 0))
%18 = tail call i32 @strcat(i8* %7, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0))
%19 = tail call i32 @strcat(i8* %7, i8* %15)
%20 = tail call i32 @strcat(i8* %7, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.2, i64 0, i64 0))
%21 = tail call i32 @strcat(i8* %7, i8* getelementptr inbounds ([36 x i8], [36 x i8]* @.str.3, i64 0, i64 0))
%22 = tail call i32 @sk_send(i32 %0, i8* %7, i32 %5)
%23 = icmp eq i32 %22, 0
br i1 %23, label %24, label %26
24: ; preds = %14
%25 = tail call i32 @perror(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0))
br label %82
26: ; preds = %14
%27 = tail call i8* @sk_recv(i32 %0, i32 %5)
%28 = tail call i64 @strstr(i8* %27, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0))
%29 = icmp eq i64 %28, 0
br i1 %29, label %33, label %30
30: ; preds = %26
%31 = load i32, i32* @stderr
%32 = tail call i32 @fprintf(i32 %31, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.6, i64 0, i64 0), i8* %27)
br label %82
33: ; preds = %26, %33
%34 = phi i8* [ %37, %33 ], [ %27, %26 ]
%35 = tail call i64 @strncmp(i8* %34, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.7, i64 0, i64 0), i32 2)
%36 = icmp eq i64 %35, 0
%37 = getelementptr inbounds i8, i8* %34, i64 1
br i1 %36, label %38, label %33
38: ; preds = %33
%39 = getelementptr inbounds i8, i8* %34, i64 4
%40 = tail call i64 @strncmp(i8* %39, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0), i32 1)
%41 = icmp eq i64 %40, 0
br i1 %41, label %52, label %42
42: ; preds = %38, %47
%43 = phi i32 [ %49, %47 ], [ 0, %38 ]
%44 = phi i8* [ %48, %47 ], [ %39, %38 ]
%45 = tail call i64 @strncmp(i8* %44, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.9, i64 0, i64 0), i32 1)
%46 = icmp eq i64 %45, 0
br i1 %46, label %52, label %47
47: ; preds = %42
%48 = getelementptr inbounds i8, i8* %44, i64 1
%49 = add nuw nsw i32 %43, 1
%50 = tail call i64 @strncmp(i8* %48, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0), i32 1)
%51 = icmp eq i64 %50, 0
br i1 %51, label %52, label %42
52: ; preds = %42, %47, %38
%53 = phi i8* [ %39, %38 ], [ %48, %47 ], [ %44, %42 ]
%54 = phi i32 [ 0, %38 ], [ %49, %47 ], [ %43, %42 ]
%55 = zext i32 %54 to i64
%56 = sub nsw i64 0, %55
%57 = getelementptr inbounds i8, i8* %53, i64 %56
%58 = tail call i32 @strncpy(i8* %8, i8* %57, i32 %54)
%59 = tail call i32 @free(i8* %27)
%60 = tail call i32 @strcpy(i8* %7, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.10, i64 0, i64 0))
%61 = tail call i32 @strcat(i8* %7, i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str.11, i64 0, i64 0))
%62 = tail call i32 @strcat(i8* %7, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.12, i64 0, i64 0))
%63 = tail call i32 @strcat(i8* %7, i8* %9)
%64 = tail call i32 @strcat(i8* %7, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.13, i64 0, i64 0))
%65 = tail call i32 @strcat(i8* %7, i8* %3)
%66 = tail call i32 @strcat(i8* %7, i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.14, i64 0, i64 0))
%67 = tail call i32 @strcat(i8* %7, i8* %4)
%68 = tail call i32 @strcat(i8* %7, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.15, i64 0, i64 0))
%69 = tail call i32 @sk_send(i32 %0, i8* %7, i32 %5)
%70 = icmp eq i32 %69, 0
br i1 %70, label %71, label %73
71: ; preds = %52
%72 = tail call i32 @perror(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.16, i64 0, i64 0))
br label %82
73: ; preds = %52
%74 = tail call i8* @srv_readstr(i32 %0, i32 %5)
%75 = tail call i64 @strstr(i8* %74, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.5, i64 0, i64 0))
%76 = icmp eq i64 %75, 0
br i1 %76, label %79, label %77
77: ; preds = %73
%78 = tail call i32 @free(i8* %8)
br label %82
79: ; preds = %73
%80 = tail call i32 @free(i8* %74)
%81 = tail call i32 @free(i8* %7)
br label %82
82: ; preds = %79, %77, %71, %30, %24
%83 = phi i8* [ null, %30 ], [ null, %77 ], [ %8, %79 ], [ null, %71 ], [ null, %24 ]
ret i8* %83
}