#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 sockaddr_un {
  int dummy;
};
typedef int /*<<< orphan*/ sizes;

/* Variables and functions */
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ test_connect(struct sockaddr_un *);
int /*<<< orphan*/ test_connect_send(struct sockaddr_un *);
int /*<<< orphan*/ test_connect_send_recv(struct sockaddr_un *, size_t);
int /*<<< orphan*/ test_connect_send_recv_count(struct sockaddr_un *, int,
                                                size_t);
int /*<<< orphan*/ test_connect_shutdown_send(struct sockaddr_un *);
int /*<<< orphan*/ test_sendto(struct sockaddr_un *);
void client(struct sockaddr_un *sun) {
  size_t sizes[] = {1,   2,    4,    8,    16,   32,    64,    128,  256,
                    512, 1024, 2048, 4096, 8192, 16384, 32768, 65536};
  int c, i;
  test_connect(sun);
  test_connect_send(sun);
  test_connect_shutdown_send(sun);
  for (i = 0; i < sizeof(sizes) / sizeof(sizes[0]); i++)
    test_connect_send_recv(sun, sizes[i]);
  for (c = 1; c <= 8; c++) {
    for (i = 0; i < sizeof(sizes) / sizeof(sizes[0]); i++)
      test_connect_send_recv_count(sun, c, sizes[i]);
  }
  test_sendto(sun);
  printf("client done\n");
}


x86 assembly (clang, -O0):
<client>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
mov    %rdi,-0x8(%rbp)
lea    -0x90(%rbp),%rdi
lea    0xe63(%rip),%rsi
mov    $0x88,%edx
call   1070 <memcpy@plt>
mov    -0x8(%rbp),%rdi
call   1030 <test_connect@plt>
mov    -0x8(%rbp),%rdi
call   1080 <test_connect_send@plt>
mov    -0x8(%rbp),%rdi
call   1090 <test_connect_shutdown_send@plt>
movl   $0x0,-0x98(%rbp)
movslq -0x98(%rbp),%rax
cmp    $0x11,%rax
jae    1209 <client+0x89>
mov    -0x8(%rbp),%rdi
movslq -0x98(%rbp),%rax
mov    -0x90(%rbp,%rax,8),%rsi
ff
call   10a0 <test_connect_send_recv@plt>
mov    -0x98(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x98(%rbp)
jmp    11cc <client+0x4c>
movl   $0x1,-0x94(%rbp)
cmpl   $0x8,-0x94(%rbp)
jg     1286 <client+0x106>
movl   $0x0,-0x98(%rbp)
movslq -0x98(%rbp),%rax
cmp    $0x11,%rax
jae    126d <client+0xed>
mov    -0x8(%rbp),%rdi
mov    -0x94(%rbp),%esi
movslq -0x98(%rbp),%rax
mov    -0x90(%rbp,%rax,8),%rdx
ff
call   1060 <test_connect_send_recv_count@plt>
mov    -0x98(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x98(%rbp)
jmp    122a <client+0xaa>
jmp    1272 <client+0xf2>
mov    -0x94(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x94(%rbp)
jmp    1213 <client+0x93>
mov    -0x8(%rbp),%rdi
call   1040 <test_sendto@plt>
lea    0xdf2(%rip),%rdi
call   1050 <printf@plt>
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<client>:
push   %rbp
push   %rbx
push   %rax
mov    %rdi,%rbx
call   1040 <test_connect@plt>
mov    %rbx,%rdi
call   1070 <test_connect_send@plt>
mov    %rbx,%rdi
call   1080 <test_connect_shutdown_send@plt>
mov    $0x1,%esi
mov    %rbx,%rdi
call   1090 <test_connect_send_recv@plt>
mov    $0x2,%esi
mov    %rbx,%rdi
call   1090 <test_connect_send_recv@plt>
mov    $0x4,%esi
mov    %rbx,%rdi
call   1090 <test_connect_send_recv@plt>
mov    $0x8,%esi
mov    %rbx,%rdi
call   1090 <test_connect_send_recv@plt>
mov    $0x10,%esi
mov    %rbx,%rdi
call   1090 <test_connect_send_recv@plt>
mov    $0x20,%esi
mov    %rbx,%rdi
call   1090 <test_connect_send_recv@plt>
mov    $0x40,%esi
mov    %rbx,%rdi
call   1090 <test_connect_send_recv@plt>
mov    $0x80,%esi
mov    %rbx,%rdi
call   1090 <test_connect_send_recv@plt>
mov    $0x100,%esi
mov    %rbx,%rdi
call   1090 <test_connect_send_recv@plt>
mov    $0x200,%esi
mov    %rbx,%rdi
call   1090 <test_connect_send_recv@plt>
mov    $0x400,%esi
mov    %rbx,%rdi
call   1090 <test_connect_send_recv@plt>
mov    $0x800,%esi
mov    %rbx,%rdi
call   1090 <test_connect_send_recv@plt>
mov    $0x1000,%esi
mov    %rbx,%rdi
call   1090 <test_connect_send_recv@plt>
mov    $0x2000,%esi
mov    %rbx,%rdi
call   1090 <test_connect_send_recv@plt>
mov    $0x4000,%esi
mov    %rbx,%rdi
call   1090 <test_connect_send_recv@plt>
mov    $0x8000,%esi
mov    %rbx,%rdi
call   1090 <test_connect_send_recv@plt>
mov    $0x10000,%esi
mov    %rbx,%rdi
call   1090 <test_connect_send_recv@plt>
mov    $0x1,%ebp
nopl   (%rax)
mov    $0x1,%edx
mov    %rbx,%rdi
mov    %ebp,%esi
call   1060 <test_connect_send_recv_count@plt>
mov    $0x2,%edx
mov    %rbx,%rdi
mov    %ebp,%esi
call   1060 <test_connect_send_recv_count@plt>
mov    $0x4,%edx
mov    %rbx,%rdi
mov    %ebp,%esi
call   1060 <test_connect_send_recv_count@plt>
mov    $0x8,%edx
mov    %rbx,%rdi
mov    %ebp,%esi
call   1060 <test_connect_send_recv_count@plt>
mov    $0x10,%edx
mov    %rbx,%rdi
mov    %ebp,%esi
call   1060 <test_connect_send_recv_count@plt>
mov    $0x20,%edx
mov    %rbx,%rdi
mov    %ebp,%esi
call   1060 <test_connect_send_recv_count@plt>
mov    $0x40,%edx
mov    %rbx,%rdi
mov    %ebp,%esi
call   1060 <test_connect_send_recv_count@plt>
mov    $0x80,%edx
mov    %rbx,%rdi
mov    %ebp,%esi
call   1060 <test_connect_send_recv_count@plt>
mov    $0x100,%edx
mov    %rbx,%rdi
mov    %ebp,%esi
call   1060 <test_connect_send_recv_count@plt>
mov    $0x200,%edx
mov    %rbx,%rdi
mov    %ebp,%esi
call   1060 <test_connect_send_recv_count@plt>
mov    $0x400,%edx
mov    %rbx,%rdi
mov    %ebp,%esi
call   1060 <test_connect_send_recv_count@plt>
mov    $0x800,%edx
mov    %rbx,%rdi
mov    %ebp,%esi
call   1060 <test_connect_send_recv_count@plt>
mov    $0x1000,%edx
mov    %rbx,%rdi
mov    %ebp,%esi
call   1060 <test_connect_send_recv_count@plt>
mov    $0x2000,%edx
mov    %rbx,%rdi
mov    %ebp,%esi
call   1060 <test_connect_send_recv_count@plt>
mov    $0x4000,%edx
mov    %rbx,%rdi
mov    %ebp,%esi
call   1060 <test_connect_send_recv_count@plt>
mov    $0x8000,%edx
mov    %rbx,%rdi
mov    %ebp,%esi
call   1060 <test_connect_send_recv_count@plt>
mov    $0x10000,%edx
mov    %rbx,%rdi
mov    %ebp,%esi
call   1060 <test_connect_send_recv_count@plt>
add    $0x1,%ebp
cmp    $0x9,%ebp
jne    1270 <client+0x100>
mov    %rbx,%rdi
call   1050 <test_sendto@plt>
lea    0xc76(%rip),%rdi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1030 <puts@plt>

LLVM IR (-O0):
%struct.sockaddr_un = type { i32 }
@__const.client.sizes = [17 x i64] [i64 1, i64 2, i64 4, i64 8, i64 16, i64 32, i64 64, i64 128, i64 256, i64 512, i64 1024, i64 2048, i64 4096, i64 8192, i64 16384, i64 32768, i64 65536]
@.str = [13 x i8] c"client done\0A\00"
define void @client(%struct.sockaddr_un* %0) {
%2 = alloca %struct.sockaddr_un*
%3 = alloca [17 x i64]
%4 = alloca i32
%5 = alloca i32
store %struct.sockaddr_un* %0, %struct.sockaddr_un** %2
%6 = bitcast [17 x i64]* %3 to i8*
%7 = load %struct.sockaddr_un*, %struct.sockaddr_un** %2
%8 = call i32 @test_connect(%struct.sockaddr_un* %7)
%9 = load %struct.sockaddr_un*, %struct.sockaddr_un** %2
%10 = call i32 @test_connect_send(%struct.sockaddr_un* %9)
%11 = load %struct.sockaddr_un*, %struct.sockaddr_un** %2
%12 = call i32 @test_connect_shutdown_send(%struct.sockaddr_un* %11)
store i32 0, i32* %5
br label %13
13: ; preds = %24, %1
%14 = load i32, i32* %5
%15 = sext i32 %14 to i64
%16 = icmp ult i64 %15, 17
br i1 %16, label %17, label %27
17: ; preds = %13
%18 = load %struct.sockaddr_un*, %struct.sockaddr_un** %2
%19 = load i32, i32* %5
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds [17 x i64], [17 x i64]* %3, i64 0, i64 %20
%22 = load i64, i64* %21
%23 = call i32 @test_connect_send_recv(%struct.sockaddr_un* %18, i64 %22)
br label %24
24: ; preds = %17
%25 = load i32, i32* %5
%26 = add nsw i32 %25, 1
store i32 %26, i32* %5
br label %13
27: ; preds = %13
store i32 1, i32* %4
br label %28
28: ; preds = %48, %27
%29 = load i32, i32* %4
%30 = icmp sle i32 %29, 8
br i1 %30, label %31, label %51
31: ; preds = %28
store i32 0, i32* %5
br label %32
32: ; preds = %44, %31
%33 = load i32, i32* %5
%34 = sext i32 %33 to i64
%35 = icmp ult i64 %34, 17
br i1 %35, label %36, label %47
36: ; preds = %32
%37 = load %struct.sockaddr_un*, %struct.sockaddr_un** %2
%38 = load i32, i32* %4
%39 = load i32, i32* %5
%40 = sext i32 %39 to i64
%41 = getelementptr inbounds [17 x i64], [17 x i64]* %3, i64 0, i64 %40
%42 = load i64, i64* %41
%43 = call i32 @test_connect_send_recv_count(%struct.sockaddr_un* %37, i32 %38, i64 %42)
br label %44
44: ; preds = %36
%45 = load i32, i32* %5
%46 = add nsw i32 %45, 1
store i32 %46, i32* %5
br label %32
47: ; preds = %32
br label %48
48: ; preds = %47
%49 = load i32, i32* %4
%50 = add nsw i32 %49, 1
store i32 %50, i32* %4
br label %28
51: ; preds = %28
%52 = load %struct.sockaddr_un*, %struct.sockaddr_un** %2
%53 = call i32 @test_sendto(%struct.sockaddr_un* %52)
%54 = call i32 @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
%struct.sockaddr_un = type { i32 }
@str = [12 x i8] c"client done\00"
define void @client(%struct.sockaddr_un* %0) {
%2 = tail call i32 @test_connect(%struct.sockaddr_un* %0)
%3 = tail call i32 @test_connect_send(%struct.sockaddr_un* %0)
%4 = tail call i32 @test_connect_shutdown_send(%struct.sockaddr_un* %0)
%5 = tail call i32 @test_connect_send_recv(%struct.sockaddr_un* %0, i64 1)
%6 = tail call i32 @test_connect_send_recv(%struct.sockaddr_un* %0, i64 2)
%7 = tail call i32 @test_connect_send_recv(%struct.sockaddr_un* %0, i64 4)
%8 = tail call i32 @test_connect_send_recv(%struct.sockaddr_un* %0, i64 8)
%9 = tail call i32 @test_connect_send_recv(%struct.sockaddr_un* %0, i64 16)
%10 = tail call i32 @test_connect_send_recv(%struct.sockaddr_un* %0, i64 32)
%11 = tail call i32 @test_connect_send_recv(%struct.sockaddr_un* %0, i64 64)
%12 = tail call i32 @test_connect_send_recv(%struct.sockaddr_un* %0, i64 128)
%13 = tail call i32 @test_connect_send_recv(%struct.sockaddr_un* %0, i64 256)
%14 = tail call i32 @test_connect_send_recv(%struct.sockaddr_un* %0, i64 512)
%15 = tail call i32 @test_connect_send_recv(%struct.sockaddr_un* %0, i64 1024)
%16 = tail call i32 @test_connect_send_recv(%struct.sockaddr_un* %0, i64 2048)
%17 = tail call i32 @test_connect_send_recv(%struct.sockaddr_un* %0, i64 4096)
%18 = tail call i32 @test_connect_send_recv(%struct.sockaddr_un* %0, i64 8192)
%19 = tail call i32 @test_connect_send_recv(%struct.sockaddr_un* %0, i64 16384)
%20 = tail call i32 @test_connect_send_recv(%struct.sockaddr_un* %0, i64 32768)
%21 = tail call i32 @test_connect_send_recv(%struct.sockaddr_un* %0, i64 65536)
br label %22
22: ; preds = %1, %22
%23 = phi i32 [ %41, %22 ], [ 1, %1 ]
%24 = tail call i32 @test_connect_send_recv_count(%struct.sockaddr_un* %0, i32 %23, i64 1)
%25 = tail call i32 @test_connect_send_recv_count(%struct.sockaddr_un* %0, i32 %23, i64 2)
%26 = tail call i32 @test_connect_send_recv_count(%struct.sockaddr_un* %0, i32 %23, i64 4)
%27 = tail call i32 @test_connect_send_recv_count(%struct.sockaddr_un* %0, i32 %23, i64 8)
%28 = tail call i32 @test_connect_send_recv_count(%struct.sockaddr_un* %0, i32 %23, i64 16)
%29 = tail call i32 @test_connect_send_recv_count(%struct.sockaddr_un* %0, i32 %23, i64 32)
%30 = tail call i32 @test_connect_send_recv_count(%struct.sockaddr_un* %0, i32 %23, i64 64)
%31 = tail call i32 @test_connect_send_recv_count(%struct.sockaddr_un* %0, i32 %23, i64 128)
%32 = tail call i32 @test_connect_send_recv_count(%struct.sockaddr_un* %0, i32 %23, i64 256)
%33 = tail call i32 @test_connect_send_recv_count(%struct.sockaddr_un* %0, i32 %23, i64 512)
%34 = tail call i32 @test_connect_send_recv_count(%struct.sockaddr_un* %0, i32 %23, i64 1024)
%35 = tail call i32 @test_connect_send_recv_count(%struct.sockaddr_un* %0, i32 %23, i64 2048)
%36 = tail call i32 @test_connect_send_recv_count(%struct.sockaddr_un* %0, i32 %23, i64 4096)
%37 = tail call i32 @test_connect_send_recv_count(%struct.sockaddr_un* %0, i32 %23, i64 8192)
%38 = tail call i32 @test_connect_send_recv_count(%struct.sockaddr_un* %0, i32 %23, i64 16384)
%39 = tail call i32 @test_connect_send_recv_count(%struct.sockaddr_un* %0, i32 %23, i64 32768)
%40 = tail call i32 @test_connect_send_recv_count(%struct.sockaddr_un* %0, i32 %23, i64 65536)
%41 = add nuw nsw i32 %23, 1
%42 = icmp eq i32 %41, 9
br i1 %42, label %43, label %22
43: ; preds = %22
%44 = tail call i32 @test_sendto(%struct.sockaddr_un* %0)
%45 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str, i64 0, i64 0))
ret void
}