#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*/ username;

/* Variables and functions */
int /*<<< orphan*/ boithoa_getLdapResponsList(int, char ***, int *);
int cconnect(char *, int);
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ sendall(int, char *, int);
int /*<<< orphan*/ sendpacked(int, int, int, int /*<<< orphan*/,
                              int /*<<< orphan*/ *, char *);
int /*<<< orphan*/ strncpy(char *, char const *, int);
int boithoad_groupsForUser(const char username_in[], char **respons_list[],
                           int *nrofresponses) {
  int socketha;
  char username[64];
  strncpy(username, username_in, sizeof(username));
  if ((socketha = cconnect("localhost", 3491)) == 0) {
    printf("boithoad_groupsForUser: can't connect\n");
    return 0;
  }
  sendpacked(socketha, 20, 1, 0, NULL, "");
  sendall(socketha, username, sizeof(username));
  if (!boithoa_getLdapResponsList(socketha, respons_list, nrofresponses)) {
    printf("boithoad_groupsForUser: can't getLdapResponsList for user \"%s\"\n",
           username);
    return 0;
  }
  close(socketha);
  return 1;
}


x86 assembly (clang, -O0):
<boithoad_groupsForUser>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
lea    -0x70(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    $0x40,%edx
call   1030 <strncpy@plt>
lea    0xe63(%rip),%rdi
mov    $0xda3,%esi
call   1090 <cconnect@plt>
mov    %eax,-0x24(%rbp)
cmp    $0x0,%eax
jne    11cd <boithoad_groupsForUser+0x5d>
lea    0xe50(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1244 <boithoad_groupsForUser+0xd4>
mov    -0x24(%rbp),%edi
mov    $0x14,%esi
mov    $0x1,%edx
xor    %ecx,%ecx
xor    %eax,%eax
mov    %eax,%r8d
lea    0xe88(%rip),%r9
call   1080 <sendpacked@plt>
mov    -0x24(%rbp),%edi
lea    -0x70(%rbp),%rsi
mov    $0x40,%edx
call   1060 <sendall@plt>
mov    -0x24(%rbp),%edi
mov    -0x18(%rbp),%rsi
mov    -0x20(%rbp),%rdx
call   1070 <boithoa_getLdapResponsList@plt>
cmp    $0x0,%eax
jne    1235 <boithoad_groupsForUser+0xc5>
lea    -0x70(%rbp),%rsi
lea    0xe0f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1244 <boithoad_groupsForUser+0xd4>
mov    -0x24(%rbp),%edi
call   1050 <close@plt>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<boithoad_groupsForUser>:
push   %rbp
push   %r15
push   %r14
push   %rbx
sub    $0x48,%rsp
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%rsi
mov    %rsp,%rdi
mov    $0x40,%edx
call   1030 <strncpy@plt>
lea    0xe59(%rip),%rdi
mov    $0xda3,%esi
call   10a0 <cconnect@plt>
test   %eax,%eax
je     1204 <boithoad_groupsForUser+0x84>
mov    %eax,%ebp
lea    0xe8b(%rip),%r9
xor    %ebx,%ebx
mov    %eax,%edi
mov    $0x14,%esi
mov    $0x1,%edx
xor    %ecx,%ecx
xor    %r8d,%r8d
call   1090 <sendpacked@plt>
mov    %rsp,%rsi
mov    %ebp,%edi
mov    $0x40,%edx
call   1070 <sendall@plt>
mov    %ebp,%edi
mov    %r15,%rsi
mov    %r14,%rdx
call   1080 <boithoa_getLdapResponsList@plt>
test   %eax,%eax
je     1214 <boithoad_groupsForUser+0x94>
mov    %ebp,%edi
call   1060 <close@plt>
mov    $0x1,%ebx
jmp    1225 <boithoad_groupsForUser+0xa5>
lea    0xe3f(%rip),%rdi
call   1040 <puts@plt>
xor    %ebx,%ebx
jmp    1225 <boithoad_groupsForUser+0xa5>
lea    0xdef(%rip),%rdi
mov    %rsp,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %ebx,%eax
add    $0x48,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [10 x i8] c"localhost\00"
@.str.1 = [39 x i8] c"boithoad_groupsForUser: can't connect\0A\00"
@.str.2 = [1 x i8] zeroinitializer
@.str.3 = [64 x i8] c"boithoad_groupsForUser: can't getLdapResponsList for user \22%s\22\0A\00"
define i32 @boithoad_groupsForUser(i8* %0, i8*** %1, i32* %2) {
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8***
%7 = alloca i32*
%8 = alloca i32
%9 = alloca [64 x i8]
store i8* %0, i8** %5
store i8*** %1, i8**** %6
store i32* %2, i32** %7
%10 = getelementptr inbounds [64 x i8], [64 x i8]* %9, i64 0, i64 0
%11 = load i8*, i8** %5
%12 = call i32 @strncpy(i8* %10, i8* %11, i32 64)
%13 = call i32 @cconnect(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 3491)
store i32 %13, i32* %8
%14 = icmp eq i32 %13, 0
br i1 %14, label %15, label %17
15: ; preds = %3
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* %4
br label %34
17: ; preds = %3
%18 = load i32, i32* %8
%19 = call i32 @sendpacked(i32 %18, i32 20, i32 1, i32 0, i32* null, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0))
%20 = load i32, i32* %8
%21 = getelementptr inbounds [64 x i8], [64 x i8]* %9, i64 0, i64 0
%22 = call i32 @sendall(i32 %20, i8* %21, i32 64)
%23 = load i32, i32* %8
%24 = load i8***, i8**** %6
%25 = load i32*, i32** %7
%26 = call i32 @boithoa_getLdapResponsList(i32 %23, i8*** %24, i32* %25)
%27 = icmp ne i32 %26, 0
br i1 %27, label %31, label %28
28: ; preds = %17
%29 = getelementptr inbounds [64 x i8], [64 x i8]* %9, i64 0, i64 0
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([64 x i8], [64 x i8]* @.str.3, i64 0, i64 0), i8* %29)
store i32 0, i32* %4
br label %34
31: ; preds = %17
%32 = load i32, i32* %8
%33 = call i32 @close(i32 %32)
store i32 1, i32* %4
br label %34
34: ; preds = %31, %28, %15
%35 = load i32, i32* %4
ret i32 %35
}

LLVM IR (-O2):
@.str = [10 x i8] c"localhost\00"
@.str.2 = [1 x i8] zeroinitializer
@.str.3 = [64 x i8] c"boithoad_groupsForUser: can't getLdapResponsList for user \22%s\22\0A\00"
@str = [38 x i8] c"boithoad_groupsForUser: can't connect\00"
define i32 @boithoad_groupsForUser(i8* %0, i8*** %1, i32* %2) {
%4 = alloca [64 x i8]
%5 = getelementptr inbounds [64 x i8], [64 x i8]* %4, i64 0, i64 0
%6 = call i32 @strncpy(i8* %5, i8* %0, i32 64)
%7 = call i32 @cconnect(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 3491)
%8 = icmp eq i32 %7, 0
br i1 %8, label %9, label %11
9: ; preds = %3
%10 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @str, i64 0, i64 0))
br label %20
11: ; preds = %3
%12 = call i32 @sendpacked(i32 %7, i32 20, i32 1, i32 0, i32* null, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str.2, i64 0, i64 0))
%13 = call i32 @sendall(i32 %7, i8* %5, i32 64)
%14 = call i32 @boithoa_getLdapResponsList(i32 %7, i8*** %1, i32* %2)
%15 = icmp eq i32 %14, 0
br i1 %15, label %16, label %18
16: ; preds = %11
%17 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([64 x i8], [64 x i8]* @.str.3, i64 0, i64 0), i8* %5)
br label %20
18: ; preds = %11
%19 = call i32 @close(i32 %7)
br label %20
20: ; preds = %18, %16, %9
%21 = phi i32 [ 0, %9 ], [ 1, %18 ], [ 0, %16 ]
ret i32 %21
}