#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 send(int, char const *, int, int /*<<< orphan*/);
int /*<<< orphan*/ send_int(int, int);
int strlen(char const *);
int send_str(int sock, const char *str) {
  int len = strlen(str);
  if (!send_int(sock, strlen(str)))
    return 0;
  if (send(sock, str, len, 0) != len)
    return 0;
  return 1;
}


x86 assembly (clang, -O0):
<send_str>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x18(%rbp),%edi
mov    %eax,%esi
call   1050 <send_int@plt>
cmp    $0x0,%eax
jne    1179 <send_str+0x49>
movl   $0x0,-0x4(%rbp)
jmp    11a6 <send_str+0x76>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
xor    %ecx,%ecx
call   1040 <send@plt>
cmp    -0x14(%rbp),%eax
je     119f <send_str+0x6f>
movl   $0x0,-0x4(%rbp)
jmp    11a6 <send_str+0x76>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<send_str>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%rbx
mov    %edi,%ebp
mov    %rsi,%rdi
call   1030 <strlen@plt>
mov    %eax,%r14d
mov    %rbx,%rdi
call   1030 <strlen@plt>
mov    %ebp,%edi
mov    %eax,%esi
call   1050 <send_int@plt>
test   %eax,%eax
je     1174 <send_str+0x44>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %r14d,%edx
xor    %ecx,%ecx
call   1040 <send@plt>
mov    %eax,%ecx
xor    %eax,%eax
cmp    %r14d,%ecx
sete   %al
jmp    1176 <send_str+0x46>
xor    %eax,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define i32 @send_str(i32 %0, i8* %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i32
store i32 %0, i32* %4
store i8* %1, i8** %5
%7 = load i8*, i8** %5
%8 = call i32 @strlen(i8* %7)
store i32 %8, i32* %6
%9 = load i32, i32* %4
%10 = load i8*, i8** %5
%11 = call i32 @strlen(i8* %10)
%12 = call i32 @send_int(i32 %9, i32 %11)
%13 = icmp ne i32 %12, 0
br i1 %13, label %15, label %14
14: ; preds = %2
store i32 0, i32* %3
br label %24
15: ; preds = %2
%16 = load i32, i32* %4
%17 = load i8*, i8** %5
%18 = load i32, i32* %6
%19 = call i32 @send(i32 %16, i8* %17, i32 %18, i32 0)
%20 = load i32, i32* %6
%21 = icmp ne i32 %19, %20
br i1 %21, label %22, label %23
22: ; preds = %15
store i32 0, i32* %3
br label %24
23: ; preds = %15
store i32 1, i32* %3
br label %24
24: ; preds = %23, %22, %14
%25 = load i32, i32* %3
ret i32 %25
}

LLVM IR (-O2):
define i32 @send_str(i32 %0, i8* %1) {
%3 = tail call i32 @strlen(i8* %1)
%4 = tail call i32 @strlen(i8* %1)
%5 = tail call i32 @send_int(i32 %0, i32 %4)
%6 = icmp eq i32 %5, 0
br i1 %6, label %11, label %7
7: ; preds = %2
%8 = tail call i32 @send(i32 %0, i8* %1, i32 %3, i32 0)
%9 = icmp eq i32 %8, %3
%10 = zext i1 %9 to i32
br label %11
11: ; preds = %7, %2
%12 = phi i32 [ 0, %2 ], [ %10, %7 ]
ret i32 %12
}