#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 bufout {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ bufout_putc(struct bufout *, char const);
int bufout_puts(struct bufout *b, const char *s) {
  while (*s) {
    if (!bufout_putc(b, *s))
      return 0;
    s++;
  }
  return 1;
}


x86 assembly (clang, -O0):
<bufout_puts>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    -0x18(%rbp),%rax
cmpb   $0x0,(%rax)
je     1163 <bufout_puts+0x53>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rax
movsbl (%rax),%esi
call   1030 <bufout_putc@plt>
cmp    $0x0,%eax
jne    1152 <bufout_puts+0x42>
movl   $0x0,-0x4(%rbp)
jmp    116a <bufout_puts+0x5a>
mov    -0x18(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x18(%rbp)
jmp    1120 <bufout_puts+0x10>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<bufout_puts>:
push   %rbp
push   %r14
push   %rbx
mov    (%rsi),%al
mov    $0x1,%r14d
test   %al,%al
je     114f <bufout_puts+0x3f>
mov    %rsi,%rbx
mov    %rdi,%rbp
add    $0x1,%rbx
nopw   0x0(%rax,%rax,1)
movsbl %al,%esi
mov    %rbp,%rdi
call   1030 <bufout_putc@plt>
test   %eax,%eax
je     114c <bufout_puts+0x3c>
movzbl (%rbx),%eax
add    $0x1,%rbx
test   %al,%al
jne    1130 <bufout_puts+0x20>
jmp    114f <bufout_puts+0x3f>
xor    %r14d,%r14d
mov    %r14d,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
%struct.bufout = type { i32 }
define i32 @bufout_puts(%struct.bufout* %0, i8* %1) {
%3 = alloca i32
%4 = alloca %struct.bufout*
%5 = alloca i8*
store %struct.bufout* %0, %struct.bufout** %4
store i8* %1, i8** %5
br label %6
6: ; preds = %17, %2
%7 = load i8*, i8** %5
%8 = load i8, i8* %7
%9 = icmp ne i8 %8, 0
br i1 %9, label %10, label %20
10: ; preds = %6
%11 = load %struct.bufout*, %struct.bufout** %4
%12 = load i8*, i8** %5
%13 = load i8, i8* %12
%14 = call i32 @bufout_putc(%struct.bufout* %11, i8 signext %13)
%15 = icmp ne i32 %14, 0
br i1 %15, label %17, label %16
16: ; preds = %10
store i32 0, i32* %3
br label %21
17: ; preds = %10
%18 = load i8*, i8** %5
%19 = getelementptr inbounds i8, i8* %18, i32 1
store i8* %19, i8** %5
br label %6
20: ; preds = %6
store i32 1, i32* %3
br label %21
21: ; preds = %20, %16
%22 = load i32, i32* %3
ret i32 %22
}

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