#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 *);
char *malloc(int);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ sk_send(int, char *, int);
char *srv_readstr(int, int);
int /*<<< orphan*/ strcat(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
char *srv_getroster(int sock, int ssl) {
  char *str = malloc(1024);
  strcpy(str, "<iq type='get' id='1001'><query xmlns='");
  strcat(str, "jabber:iq:roster'/></iq>\n");
  if (!sk_send(sock, str, ssl)) {
    perror("senddata (server.c:222)");
    return NULL;
  }
  free(str);
  return srv_readstr(sock, ssl);
}


x86 assembly (clang, -O0):
<srv_getroster>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0xc(%rbp)
mov    %esi,-0x10(%rbp)
mov    $0x400,%edi
call   1060 <malloc@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rdi
lea    0xe69(%rip),%rsi
call   1040 <strcpy@plt>
mov    -0x18(%rbp),%rdi
lea    0xe81(%rip),%rsi
call   1090 <strcat@plt>
mov    -0xc(%rbp),%edi
mov    -0x18(%rbp),%rsi
mov    -0x10(%rbp),%edx
call   1070 <sk_send@plt>
cmp    $0x0,%eax
jne    11dd <srv_getroster+0x6d>
lea    0xe77(%rip),%rdi
call   1080 <perror@plt>
movq   $0x0,-0x8(%rbp)
jmp    11f5 <srv_getroster+0x85>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
mov    -0xc(%rbp),%edi
mov    -0x10(%rbp),%esi
call   1050 <srv_readstr@plt>
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<srv_getroster>:
push   %rbp
push   %r14
push   %rbx
mov    %esi,%r14d
mov    %edi,%ebp
mov    $0x400,%edi
call   1060 <malloc@plt>
mov    %rax,%rbx
lea    0xe73(%rip),%rsi
mov    %rax,%rdi
call   1040 <strcpy@plt>
lea    0xe8c(%rip),%rsi
mov    %rbx,%rdi
call   1090 <strcat@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r14d,%edx
call   1070 <sk_send@plt>
test   %eax,%eax
je     11cb <srv_getroster+0x5b>
mov    %rbx,%rdi
call   1030 <free@plt>
mov    %ebp,%edi
mov    %r14d,%esi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1050 <srv_readstr@plt>
lea    0xe70(%rip),%rdi
call   1080 <perror@plt>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [40 x i8] c"<iq type='get' id='1001'><query xmlns='\00"
@.str.1 = [26 x i8] c"jabber:iq:roster'/></iq>\0A\00"
@.str.2 = [24 x i8] c"senddata (server.c:222)\00"
define i8* @srv_getroster(i32 %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8*
store i32 %0, i32* %4
store i32 %1, i32* %5
%7 = call i8* @malloc(i32 1024)
store i8* %7, i8** %6
%8 = load i8*, i8** %6
%9 = call i32 @strcpy(i8* %8, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str, i64 0, i64 0))
%10 = load i8*, i8** %6
%11 = call i32 @strcat(i8* %10, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0))
%12 = load i32, i32* %4
%13 = load i8*, i8** %6
%14 = load i32, i32* %5
%15 = call i32 @sk_send(i32 %12, i8* %13, i32 %14)
%16 = icmp ne i32 %15, 0
br i1 %16, label %19, label %17
17: ; preds = %2
%18 = call i32 @perror(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0))
store i8* null, i8** %3
br label %25
19: ; preds = %2
%20 = load i8*, i8** %6
%21 = call i32 @free(i8* %20)
%22 = load i32, i32* %4
%23 = load i32, i32* %5
%24 = call i8* @srv_readstr(i32 %22, i32 %23)
store i8* %24, i8** %3
br label %25
25: ; preds = %19, %17
%26 = load i8*, i8** %3
ret i8* %26
}

LLVM IR (-O2):
@.str = [40 x i8] c"<iq type='get' id='1001'><query xmlns='\00"
@.str.1 = [26 x i8] c"jabber:iq:roster'/></iq>\0A\00"
@.str.2 = [24 x i8] c"senddata (server.c:222)\00"
define i8* @srv_getroster(i32 %0, i32 %1) {
%3 = tail call dereferenceable_or_null(1024) i8* @malloc(i32 1024)
%4 = tail call i32 @strcpy(i8* %3, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str, i64 0, i64 0))
%5 = tail call i32 @strcat(i8* %3, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0))
%6 = tail call i32 @sk_send(i32 %0, i8* %3, i32 %1)
%7 = icmp eq i32 %6, 0
br i1 %7, label %8, label %10
8: ; preds = %2
%9 = tail call i32 @perror(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0))
br label %13
10: ; preds = %2
%11 = tail call i32 @free(i8* %3)
%12 = tail call i8* @srv_readstr(i32 %0, i32 %1)
br label %13
13: ; preds = %10, %8
%14 = phi i8* [ %12, %10 ], [ null, %8 ]
ret i8* %14
}