#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*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ assert(int /*<<< orphan*/);
int escputc(char const, int /*<<< orphan*/ *);
int escputs(const char *s, FILE *f) {
  const char *p;
  int r;
  assert(f != NULL);
  assert(s != NULL);
  for (p = s; *p != '\0'; p++) {
    r = escputc(*p, f);
    if (r < 0) {
      return -1;
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<escputs>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
cmpq   $0x0,-0x10(%rbp)
setne  %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     11ad <escputs+0x8d>
mov    -0x20(%rbp),%rax
mov    (%rax),%al
mov    -0x18(%rbp),%rsi
movsbl %al,%edi
call   1030 <escputc@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
jge    1197 <escputs+0x77>
movl   $0xffffffff,-0x4(%rbp)
jmp    11b4 <escputs+0x94>
jmp    119c <escputs+0x7c>
mov    -0x20(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x20(%rbp)
jmp    115c <escputs+0x3c>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<escputs>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%r14
mov    %rdi,%rbx
xor    %edi,%edi
test   %rsi,%rsi
setne  %dil
call   1040 <assert@plt>
xor    %edi,%edi
test   %rbx,%rbx
setne  %dil
call   1040 <assert@plt>
mov    (%rbx),%al
xor    %ebp,%ebp
test   %al,%al
je     1181 <escputs+0x61>
add    $0x1,%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movsbl %al,%edi
mov    %r14,%rsi
call   1030 <escputc@plt>
test   %eax,%eax
js     117c <escputs+0x5c>
movzbl (%rbx),%eax
add    $0x1,%rbx
test   %al,%al
jne    1160 <escputs+0x40>
jmp    1181 <escputs+0x61>
mov    $0xffffffff,%ebp
mov    %ebp,%eax
pop    %rbx
pop    %r14
pop    %rbp
ret

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

LLVM IR (-O2):
define i32 @escputs(i8* %0, i32* %1) {
%3 = icmp ne i32* %1, null
%4 = zext i1 %3 to i32
%5 = tail call i32 @assert(i32 %4)
%6 = icmp ne i8* %0, null
%7 = zext i1 %6 to i32
%8 = tail call i32 @assert(i32 %7)
%9 = load i8, i8* %0
%10 = icmp eq i8 %9, 0
br i1 %10, label %20, label %14
11: ; preds = %14
%12 = load i8, i8* %19
%13 = icmp eq i8 %12, 0
br i1 %13, label %20, label %14
14: ; preds = %2, %11
%15 = phi i8 [ %12, %11 ], [ %9, %2 ]
%16 = phi i8* [ %19, %11 ], [ %0, %2 ]
%17 = tail call i32 @escputc(i8 signext %15, i32* %1)
%18 = icmp slt i32 %17, 0
%19 = getelementptr inbounds i8, i8* %16, i64 1
br i1 %18, label %20, label %11
20: ; preds = %14, %11, %2
%21 = phi i32 [ 0, %2 ], [ 0, %11 ], [ -1, %14 ]
ret i32 %21
}