#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*/ Send(int, char *, int, int /*<<< orphan*/);
int strlen(char *);
void sendch(int sockfd, char *buf_all) {
  char buf[1];
  int i;
  for (i = 0; i < strlen(buf_all); i++) {
    buf[0] = buf_all[i];
    Send(sockfd, buf, 1, 0);
  }
  buf[0] = '\r';
  Send(sockfd, buf, 1, 0);
}


x86 assembly (clang, -O0):
<sendch>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    %eax,-0x1c(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x1c(%rbp),%eax
cmp    %ecx,%eax
jge    1181 <sendch+0x61>
mov    -0x10(%rbp),%rax
movslq -0x18(%rbp),%rcx
mov    (%rax,%rcx,1),%al
mov    %al,-0x11(%rbp)
mov    -0x4(%rbp),%edi
lea    -0x11(%rbp),%rsi
mov    $0x1,%edx
xor    %ecx,%ecx
call   1040 <Send@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1136 <sendch+0x16>
movb   $0xd,-0x11(%rbp)
mov    -0x4(%rbp),%edi
lea    -0x11(%rbp),%rsi
mov    $0x1,%edx
xor    %ecx,%ecx
call   1040 <Send@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<sendch>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    %edi,%r15d
mov    %rsi,%rdi
call   1030 <strlen@plt>
test   %eax,%eax
jle    116d <sendch+0x4d>
xor    %ebp,%ebp
lea    0x7(%rsp),%r14
movzbl (%rbx,%rbp,1),%eax
mov    %al,0x7(%rsp)
mov    %r15d,%edi
mov    %r14,%rsi
mov    $0x1,%edx
xor    %ecx,%ecx
call   1040 <Send@plt>
add    $0x1,%rbp
mov    %rbx,%rdi
call   1030 <strlen@plt>
cltq
cmp    %rax,%rbp
jl     1140 <sendch+0x20>
movb   $0xd,0x7(%rsp)
lea    0x7(%rsp),%rsi
mov    %r15d,%edi
mov    $0x1,%edx
xor    %ecx,%ecx
call   1040 <Send@plt>
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @sendch(i32 %0, i8* %1) {
%3 = alloca i32
%4 = alloca i8*
%5 = alloca [1 x i8]
%6 = alloca i32
store i32 %0, i32* %3
store i8* %1, i8** %4
store i32 0, i32* %6
br label %7
7: ; preds = %22, %2
%8 = load i32, i32* %6
%9 = load i8*, i8** %4
%10 = call i32 @strlen(i8* %9)
%11 = icmp slt i32 %8, %10
br i1 %11, label %12, label %25
12: ; preds = %7
%13 = load i8*, i8** %4
%14 = load i32, i32* %6
%15 = sext i32 %14 to i64
%16 = getelementptr inbounds i8, i8* %13, i64 %15
%17 = load i8, i8* %16
%18 = getelementptr inbounds [1 x i8], [1 x i8]* %5, i64 0, i64 0
store i8 %17, i8* %18
%19 = load i32, i32* %3
%20 = getelementptr inbounds [1 x i8], [1 x i8]* %5, i64 0, i64 0
%21 = call i32 @Send(i32 %19, i8* %20, i32 1, i32 0)
br label %22
22: ; preds = %12
%23 = load i32, i32* %6
%24 = add nsw i32 %23, 1
store i32 %24, i32* %6
br label %7
25: ; preds = %7
%26 = getelementptr inbounds [1 x i8], [1 x i8]* %5, i64 0, i64 0
store i8 13, i8* %26
%27 = load i32, i32* %3
%28 = getelementptr inbounds [1 x i8], [1 x i8]* %5, i64 0, i64 0
%29 = call i32 @Send(i32 %27, i8* %28, i32 1, i32 0)
ret void
}

LLVM IR (-O2):
define void @sendch(i32 %0, i8* %1) {
%3 = alloca [1 x i8]
%4 = getelementptr inbounds [1 x i8], [1 x i8]* %3, i64 0, i64 0
%5 = call i32 @strlen(i8* %1)
%6 = icmp sgt i32 %5, 0
br i1 %6, label %7, label %16
7: ; preds = %2, %7
%8 = phi i64 [ %12, %7 ], [ 0, %2 ]
%9 = getelementptr inbounds i8, i8* %1, i64 %8
%10 = load i8, i8* %9
store i8 %10, i8* %4
%11 = call i32 @Send(i32 %0, i8* %4, i32 1, i32 0)
%12 = add nuw nsw i64 %8, 1
%13 = call i32 @strlen(i8* %1)
%14 = sext i32 %13 to i64
%15 = icmp slt i64 %12, %14
br i1 %15, label %7, label %16
16: ; preds = %7, %2
store i8 13, i8* %4
%17 = call i32 @Send(i32 %0, i8* %4, i32 1, i32 0)
ret void
}