#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*/ fprintf(int /*<<< orphan*/ *, char *, char const *);
int /*<<< orphan*/ fputc(char const, int /*<<< orphan*/ *);
void mprint(FILE *f, const char *s, const char *separator) {
  for (; s && (*s || *(s + 1)); s++)
    if (!*s)
      fprintf(f, "%s", separator);
    else
      fputc(*s, f);
}


x86 assembly (clang, -O0):
<mprint>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
xor    %eax,%eax
cmpq   $0x0,-0x10(%rbp)
mov    %al,-0x19(%rbp)
je     1170 <mprint+0x50>
mov    -0x10(%rbp),%rax
movsbl (%rax),%ecx
mov    $0x1,%al
cmp    $0x0,%ecx
mov    %al,-0x1a(%rbp)
jne    116a <mprint+0x4a>
mov    -0x10(%rbp),%rax
movsbl 0x1(%rax),%eax
cmp    $0x0,%eax
setne  %al
mov    %al,-0x1a(%rbp)
mov    -0x1a(%rbp),%al
mov    %al,-0x19(%rbp)
mov    -0x19(%rbp),%al
test   $0x1,%al
jne    1180 <mprint+0x60>
jmp    11ce <mprint+0xae>
mov    -0x10(%rbp),%rax
cmpb   $0x0,(%rax)
jne    11a6 <mprint+0x86>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rdx
lea    0xe64(%rip),%rsi
call   1040 <fprintf@plt>
jmp    11b8 <mprint+0x98>
mov    -0x10(%rbp),%rax
mov    (%rax),%al
mov    -0x8(%rbp),%rsi
movsbl %al,%edi
call   1030 <fputc@plt>
jmp    11bd <mprint+0x9d>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    1134 <mprint+0x14>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<mprint>:
push   %r15
push   %r14
push   %rbx
test   %rsi,%rsi
je     1169 <mprint+0x49>
mov    %rdx,%r14
mov    %rsi,%rbx
mov    %rdi,%r15
jmp    114b <mprint+0x2b>
cs nopw 0x0(%rax,%rax,1)
nop
movsbl %al,%edi
mov    %r15,%rsi
call   1040 <fputc@plt>
add    $0x1,%rbx
movzbl -0x1(%rbx),%eax
test   %al,%al
jne    1140 <mprint+0x20>
cmpb   $0x0,(%rbx)
je     1169 <mprint+0x49>
mov    %r14,%rdi
mov    %r15,%rsi
call   1030 <fputs@plt>
jmp    114b <mprint+0x2b>
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%s\00"
define void @mprint(i32* %0, i8* %1, i8* %2) {
%4 = alloca i32*
%5 = alloca i8*
%6 = alloca i8*
store i32* %0, i32** %4
store i8* %1, i8** %5
store i8* %2, i8** %6
br label %7
7: ; preds = %39, %3
%8 = load i8*, i8** %5
%9 = icmp ne i8* %8, null
br i1 %9, label %10, label %23
10: ; preds = %7
%11 = load i8*, i8** %5
%12 = load i8, i8* %11
%13 = sext i8 %12 to i32
%14 = icmp ne i32 %13, 0
br i1 %14, label %21, label %15
15: ; preds = %10
%16 = load i8*, i8** %5
%17 = getelementptr inbounds i8, i8* %16, i64 1
%18 = load i8, i8* %17
%19 = sext i8 %18 to i32
%20 = icmp ne i32 %19, 0
br label %21
21: ; preds = %15, %10
%22 = phi i1 [ true, %10 ], [ %20, %15 ]
br label %23
23: ; preds = %21, %7
%24 = phi i1 [ false, %7 ], [ %22, %21 ]
br i1 %24, label %25, label %42
25: ; preds = %23
%26 = load i8*, i8** %5
%27 = load i8, i8* %26
%28 = icmp ne i8 %27, 0
br i1 %28, label %33, label %29
29: ; preds = %25
%30 = load i32*, i32** %4
%31 = load i8*, i8** %6
%32 = call i32 @fprintf(i32* %30, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %31)
br label %38
33: ; preds = %25
%34 = load i8*, i8** %5
%35 = load i8, i8* %34
%36 = load i32*, i32** %4
%37 = call i32 @fputc(i8 signext %35, i32* %36)
br label %38
38: ; preds = %33, %29
br label %39
39: ; preds = %38
%40 = load i8*, i8** %5
%41 = getelementptr inbounds i8, i8* %40, i32 1
store i8* %41, i8** %5
br label %7
42: ; preds = %23
ret void
}

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