#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*/ uint8_t;
typedef int uint32_t;

/* Variables and functions */
int /*<<< orphan*/ add_seatalk_byte(int /*<<< orphan*/ *, int *,
                                    int /*<<< orphan*/, int);
void add_sentence(uint8_t *b, uint32_t *buflen, uint8_t *sentence,
                  uint32_t sentence_len) {
  int i;
  *buflen = 0;
  for (i = 0; i < sentence_len; i++) {
    add_seatalk_byte(b, buflen, sentence[i], (i == 0));
  }
}


x86 assembly (clang, -O0):
<add_sentence>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %ecx,-0x1c(%rbp)
mov    -0x10(%rbp),%rax
movl   $0x0,(%rax)
movl   $0x0,-0x20(%rbp)
mov    -0x20(%rbp),%eax
cmp    -0x1c(%rbp),%eax
jge    1176 <add_sentence+0x66>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x18(%rbp),%rax
movslq -0x20(%rbp),%rcx
mov    (%rax,%rcx,4),%edx
cmpl   $0x0,-0x20(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%ecx
call   1030 <add_seatalk_byte@plt>
mov    -0x20(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x20(%rbp)
jmp    1138 <add_sentence+0x28>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<add_sentence>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
movl   $0x0,(%rsi)
test   %ecx,%ecx
jle    1160 <add_sentence+0x50>
mov    %rdx,%r14
mov    %rsi,%r12
mov    %rdi,%r15
mov    %ecx,%r13d
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    (%r14,%rbx,4),%edx
xor    %ecx,%ecx
test   %rbx,%rbx
sete   %cl
mov    %r15,%rdi
mov    %r12,%rsi
call   1030 <add_seatalk_byte@plt>
add    $0x1,%rbx
cmp    %rbx,%r13
jne    1140 <add_sentence+0x30>
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

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

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