#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 write(int, char *, int);
int msmtp_write_data(int fd, char *buf) {
  char *p = buf;
  while (*p) {
    if (p[0] == '\r') {
      p++;
      continue;
    }
    if (write(fd, p, 1) != 1)
      return 0;
    p++;
  }
  return 1;
}


x86 assembly (clang, -O0):
<msmtp_write_data>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
cmpb   $0x0,(%rax)
je     118c <msmtp_write_data+0x7c>
mov    -0x18(%rbp),%rax
movsbl (%rax),%eax
cmp    $0xd,%eax
jne    1155 <msmtp_write_data+0x45>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    1127 <msmtp_write_data+0x17>
mov    -0x8(%rbp),%edi
mov    -0x18(%rbp),%rsi
mov    $0x1,%edx
call   1030 <write@plt>
cmp    $0x1,%eax
je     117b <msmtp_write_data+0x6b>
movl   $0x0,-0x4(%rbp)
jmp    1193 <msmtp_write_data+0x83>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    1127 <msmtp_write_data+0x17>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<msmtp_write_data>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%rbx
mov    %edi,%ebp
mov    $0x1,%r14d
jmp    1134 <msmtp_write_data+0x24>
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
add    $0x1,%rbx
movzbl (%rbx),%eax
cmp    $0xd,%al
je     1130 <msmtp_write_data+0x20>
test   %al,%al
je     1156 <msmtp_write_data+0x46>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    $0x1,%edx
call   1030 <write@plt>
cmp    $0x1,%eax
je     1130 <msmtp_write_data+0x20>
xor    %r14d,%r14d
mov    %r14d,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
define i32 @msmtp_write_data(i32 %0, i8* %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8*
store i32 %0, i32* %4
store i8* %1, i8** %5
%7 = load i8*, i8** %5
store i8* %7, i8** %6
br label %8
8: ; preds = %27, %18, %2
%9 = load i8*, i8** %6
%10 = load i8, i8* %9
%11 = icmp ne i8 %10, 0
br i1 %11, label %12, label %30
12: ; preds = %8
%13 = load i8*, i8** %6
%14 = getelementptr inbounds i8, i8* %13, i64 0
%15 = load i8, i8* %14
%16 = sext i8 %15 to i32
%17 = icmp eq i32 %16, 13
br i1 %17, label %18, label %21
18: ; preds = %12
%19 = load i8*, i8** %6
%20 = getelementptr inbounds i8, i8* %19, i32 1
store i8* %20, i8** %6
br label %8
21: ; preds = %12
%22 = load i32, i32* %4
%23 = load i8*, i8** %6
%24 = call i32 @write(i32 %22, i8* %23, i32 1)
%25 = icmp ne i32 %24, 1
br i1 %25, label %26, label %27
26: ; preds = %21
store i32 0, i32* %3
br label %31
27: ; preds = %21
%28 = load i8*, i8** %6
%29 = getelementptr inbounds i8, i8* %28, i32 1
store i8* %29, i8** %6
br label %8
30: ; preds = %8
store i32 1, i32* %3
br label %31
31: ; preds = %30, %26
%32 = load i32, i32* %3
ret i32 %32
}

LLVM IR (-O2):
define i32 @msmtp_write_data(i32 %0, i8* nocapture %1) {
br label %3
3: ; preds = %6, %2
%4 = phi i8* [ %1, %2 ], [ %7, %6 ]
%5 = load i8, i8* %4
switch i8 %5, label %8 [
i8 0, label %11
i8 13, label %6
]
6: ; preds = %8, %3
%7 = getelementptr inbounds i8, i8* %4, i64 1
br label %3
8: ; preds = %3
%9 = tail call i32 @write(i32 %0, i8* %4, i32 1)
%10 = icmp eq i32 %9, 1
br i1 %10, label %6, label %11
11: ; preds = %3, %8
%12 = phi i32 [ 0, %8 ], [ 1, %3 ]
ret i32 %12
}