#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*/ user;
typedef int /*<<< orphan*/ uri;
typedef int /*<<< orphan*/ password;
typedef int /*<<< orphan*/ intrespons;
typedef int /*<<< orphan*/ collection;
typedef int /*<<< orphan*/ all;

/* Variables and functions */
int /*<<< orphan*/ MSG_WAITALL;
int /*<<< orphan*/ memset(char *, char, int);
int /*<<< orphan*/ perror(char *);
int recv(int, int *, int, int /*<<< orphan*/);
int /*<<< orphan*/ sendpacked(int, int, int, int, char *, char *);
int /*<<< orphan*/ strncpy(char *, char *, int);
int cmc_pathaccess(int socketha, char collection_in[], char uri_in[],
                   char user_in[], char password_in[]) {
  char collection[64];
  char uri[512];
  char user[64];
  char password[64];
  int intrespons;
  int i;
  char all[64 + 512 + 64 + 64];
  memset(collection, '\0', sizeof(collection));
  strncpy(all, collection_in, sizeof(collection));
  strncpy(all + 64, uri_in, sizeof(uri));
  strncpy(all + 512 + 64, user_in, sizeof(user));
  strncpy(all + 512 + 64 + 64, password_in, sizeof(password));
  sendpacked(socketha, 4, 1, sizeof(all), all, collection);
  if ((i = recv(socketha, &intrespons, sizeof(intrespons), MSG_WAITALL)) ==
      -1) {
    perror("Cant recv respons");
    return 0;
  }
  return intrespons;
}


x86 assembly (clang, -O0):
<cmc_pathaccess>:
push   %rbp
mov    %rsp,%rbp
sub    $0x5c0,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
lea    -0x70(%rbp),%rdi
xor    %esi,%esi
mov    $0x40,%edx
call   1050 <memset@plt>
lea    -0x5c0(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    $0x40,%edx
call   1040 <strncpy@plt>
lea    -0x5c0(%rbp),%rdi
add    $0x40,%rdi
mov    -0x18(%rbp),%rsi
mov    $0x200,%edx
call   1040 <strncpy@plt>
lea    -0x5c0(%rbp),%rdi
add    $0x200,%rdi
add    $0x40,%rdi
mov    -0x20(%rbp),%rsi
mov    $0x40,%edx
call   1040 <strncpy@plt>
lea    -0x5c0(%rbp),%rdi
add    $0x200,%rdi
add    $0x40,%rdi
add    $0x40,%rdi
mov    -0x28(%rbp),%rsi
mov    $0x40,%edx
call   1040 <strncpy@plt>
mov    -0x8(%rbp),%edi
lea    -0x5c0(%rbp),%r8
lea    -0x70(%rbp),%r9
mov    $0x4,%esi
mov    $0x1,%edx
mov    $0x2c0,%ecx
call   1070 <sendpacked@plt>
mov    -0x8(%rbp),%edi
mov    0x2dbc(%rip),%rax
mov    (%rax),%ecx
lea    -0x2f4(%rbp),%rsi
mov    $0x4,%edx
call   1030 <recv@plt>
mov    %eax,-0x2f8(%rbp)
cmp    $0xffffffff,%eax
jne    1256 <cmc_pathaccess+0x106>
lea    0xdbb(%rip),%rdi
call   1060 <perror@plt>
movl   $0x0,-0x4(%rbp)
jmp    125f <cmc_pathaccess+0x10f>
mov    -0x2f4(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x5c0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cmc_pathaccess>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x318,%rsp
mov    %r8,%r13
mov    %rcx,%rbx
mov    %rdx,%r14
mov    %rsi,%r12
mov    %edi,%ebp
lea    0x10(%rsp),%rdi
xor    %r15d,%r15d
xor    %esi,%esi
mov    $0x40,%edx
call   1050 <memset@plt>
lea    0x50(%rsp),%rdi
mov    %r12,%rsi
mov    $0x40,%edx
call   1040 <strncpy@plt>
lea    0x90(%rsp),%rdi
mov    %r14,%rsi
mov    $0x200,%edx
call   1040 <strncpy@plt>
lea    0x290(%rsp),%rdi
mov    %rbx,%rsi
mov    $0x40,%edx
call   1040 <strncpy@plt>
lea    0x2d0(%rsp),%rdi
mov    %r13,%rsi
mov    $0x40,%edx
call   1040 <strncpy@plt>
mov    %ebp,%edi
mov    $0x4,%esi
mov    $0x1,%edx
mov    $0x2c0,%ecx
lea    0x50(%rsp),%r8
lea    0x10(%rsp),%r9
call   1070 <sendpacked@plt>
mov    0x2ddd(%rip),%rax
mov    (%rax),%ecx
lea    0xc(%rsp),%rsi
mov    %ebp,%edi
mov    $0x4,%edx
call   1030 <recv@plt>
cmp    $0xffffffff,%eax
je     122d <cmc_pathaccess+0xdd>
mov    0xc(%rsp),%r15d
mov    %r15d,%eax
add    $0x318,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xdcc(%rip),%rdi
call   1060 <perror@plt>
jmp    1218 <cmc_pathaccess+0xc8>

LLVM IR (-O0):
@MSG_WAITALL = global i32 0
@.str = [18 x i8] c"Cant recv respons\00"
define i32 @cmc_pathaccess(i32 %0, i8* %1, i8* %2, i8* %3, i8* %4) {
%6 = alloca i32
%7 = alloca i32
%8 = alloca i8*
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i8*
%12 = alloca [64 x i8]
%13 = alloca [512 x i8]
%14 = alloca [64 x i8]
%15 = alloca [64 x i8]
%16 = alloca i32
%17 = alloca i32
%18 = alloca [704 x i8]
store i32 %0, i32* %7
store i8* %1, i8** %8
store i8* %2, i8** %9
store i8* %3, i8** %10
store i8* %4, i8** %11
%19 = getelementptr inbounds [64 x i8], [64 x i8]* %12, i64 0, i64 0
%20 = call i32 @memset(i8* %19, i8 signext 0, i32 64)
%21 = getelementptr inbounds [704 x i8], [704 x i8]* %18, i64 0, i64 0
%22 = load i8*, i8** %8
%23 = call i32 @strncpy(i8* %21, i8* %22, i32 64)
%24 = getelementptr inbounds [704 x i8], [704 x i8]* %18, i64 0, i64 0
%25 = getelementptr inbounds i8, i8* %24, i64 64
%26 = load i8*, i8** %9
%27 = call i32 @strncpy(i8* %25, i8* %26, i32 512)
%28 = getelementptr inbounds [704 x i8], [704 x i8]* %18, i64 0, i64 0
%29 = getelementptr inbounds i8, i8* %28, i64 512
%30 = getelementptr inbounds i8, i8* %29, i64 64
%31 = load i8*, i8** %10
%32 = call i32 @strncpy(i8* %30, i8* %31, i32 64)
%33 = getelementptr inbounds [704 x i8], [704 x i8]* %18, i64 0, i64 0
%34 = getelementptr inbounds i8, i8* %33, i64 512
%35 = getelementptr inbounds i8, i8* %34, i64 64
%36 = getelementptr inbounds i8, i8* %35, i64 64
%37 = load i8*, i8** %11
%38 = call i32 @strncpy(i8* %36, i8* %37, i32 64)
%39 = load i32, i32* %7
%40 = getelementptr inbounds [704 x i8], [704 x i8]* %18, i64 0, i64 0
%41 = getelementptr inbounds [64 x i8], [64 x i8]* %12, i64 0, i64 0
%42 = call i32 @sendpacked(i32 %39, i32 4, i32 1, i32 704, i8* %40, i8* %41)
%43 = load i32, i32* %7
%44 = load i32, i32* @MSG_WAITALL
%45 = call i32 @recv(i32 %43, i32* %16, i32 4, i32 %44)
store i32 %45, i32* %17
%46 = icmp eq i32 %45, -1
br i1 %46, label %47, label %49
47: ; preds = %5
%48 = call i32 @perror(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %6
br label %51
49: ; preds = %5
%50 = load i32, i32* %16
store i32 %50, i32* %6
br label %51
51: ; preds = %49, %47
%52 = load i32, i32* %6
ret i32 %52
}

LLVM IR (-O2):
@MSG_WAITALL = global i32 0
@.str = [18 x i8] c"Cant recv respons\00"
define i32 @cmc_pathaccess(i32 %0, i8* %1, i8* %2, i8* %3, i8* %4) {
%6 = alloca [64 x i8]
%7 = alloca i32
%8 = alloca [704 x i8]
%9 = getelementptr inbounds [64 x i8], [64 x i8]* %6, i64 0, i64 0
%10 = bitcast i32* %7 to i8*
%11 = getelementptr inbounds [704 x i8], [704 x i8]* %8, i64 0, i64 0
%12 = call i32 @memset(i8* %9, i8 signext 0, i32 64)
%13 = call i32 @strncpy(i8* %11, i8* %1, i32 64)
%14 = getelementptr inbounds [704 x i8], [704 x i8]* %8, i64 0, i64 64
%15 = call i32 @strncpy(i8* %14, i8* %2, i32 512)
%16 = getelementptr inbounds [704 x i8], [704 x i8]* %8, i64 0, i64 576
%17 = call i32 @strncpy(i8* %16, i8* %3, i32 64)
%18 = getelementptr inbounds [704 x i8], [704 x i8]* %8, i64 0, i64 640
%19 = call i32 @strncpy(i8* %18, i8* %4, i32 64)
%20 = call i32 @sendpacked(i32 %0, i32 4, i32 1, i32 704, i8* %11, i8* %9)
%21 = load i32, i32* @MSG_WAITALL
%22 = call i32 @recv(i32 %0, i32* %7, i32 4, i32 %21)
%23 = icmp eq i32 %22, -1
br i1 %23, label %24, label %26
24: ; preds = %5
%25 = call i32 @perror(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
br label %28
26: ; preds = %5
%27 = load i32, i32* %7
br label %28
28: ; preds = %26, %24
%29 = phi i32 [ 0, %24 ], [ %27, %26 ]
ret i32 %29
}