#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 /*<<< orphan*/ assert(int);
int /*<<< orphan*/ fflush(int /*<<< orphan*/);
int /*<<< orphan*/ fwrite(char const *, int, int /*<<< orphan*/,
                          int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdout;
int /*<<< orphan*/ strlen(char const *);
void fossil_puts(const char *z, int toStdErr) {
  assert(toStdErr == 0 || toStdErr == 1);
  fwrite(z, 1, strlen(z), toStdErr ? stderr : stdout);
  fflush(toStdErr ? stderr : stdout);
}


x86 assembly (clang, -O0):
<fossil_puts>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    $0x1,%al
cmpl   $0x0,-0xc(%rbp)
mov    %al,-0xd(%rbp)
je     1168 <fossil_puts+0x28>
cmpl   $0x1,-0xc(%rbp)
sete   %al
mov    %al,-0xd(%rbp)
mov    -0xd(%rbp),%al
and    $0x1,%al
movzbl %al,%edi
call   1040 <assert@plt>
mov    -0x8(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0xc(%rbp)
je     11a4 <fossil_puts+0x64>
mov    0x2e46(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x24(%rbp)
jmp    11b0 <fossil_puts+0x70>
mov    0x2e2d(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x24(%rbp)
mov    -0x14(%rbp),%edx
mov    -0x20(%rbp),%rdi
mov    -0x24(%rbp),%ecx
mov    $0x1,%esi
call   1060 <fwrite@plt>
cmpl   $0x0,-0xc(%rbp)
je     11df <fossil_puts+0x9f>
mov    0x2e0b(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x28(%rbp)
jmp    11eb <fossil_puts+0xab>
mov    0x2df2(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x28(%rbp)
mov    -0x28(%rbp),%edi
call   1050 <fflush@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<fossil_puts>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebp
mov    %rdi,%rbx
xor    %edi,%edi
cmp    $0x2,%esi
setb   %dil
call   1040 <assert@plt>
mov    %rbx,%rdi
call   1030 <strlen@plt>
test   %ebp,%ebp
jne    116b <fossil_puts+0x2b>
mov    0x2e6f(%rip),%rbp
jmp    1172 <fossil_puts+0x32>
mov    0x2e6e(%rip),%rbp
mov    0x0(%rbp),%ecx
mov    %rbx,%rdi
mov    $0x1,%esi
mov    %eax,%edx
call   1060 <fwrite@plt>
mov    0x0(%rbp),%edi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1050 <fflush@plt>

LLVM IR (-O0):
@stderr = global i32 0
@stdout = global i32 0
define void @fossil_puts(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
store i8* %0, i8** %3
store i32 %1, i32* %4
%5 = load i32, i32* %4
%6 = icmp eq i32 %5, 0
br i1 %6, label %10, label %7
7: ; preds = %2
%8 = load i32, i32* %4
%9 = icmp eq i32 %8, 1
br label %10
10: ; preds = %7, %2
%11 = phi i1 [ true, %2 ], [ %9, %7 ]
%12 = zext i1 %11 to i32
%13 = call i32 @assert(i32 %12)
%14 = load i8*, i8** %3
%15 = load i8*, i8** %3
%16 = call i32 @strlen(i8* %15)
%17 = load i32, i32* %4
%18 = icmp ne i32 %17, 0
br i1 %18, label %19, label %21
19: ; preds = %10
%20 = load i32, i32* @stderr
br label %23
21: ; preds = %10
%22 = load i32, i32* @stdout
br label %23
23: ; preds = %21, %19
%24 = phi i32 [ %20, %19 ], [ %22, %21 ]
%25 = call i32 @fwrite(i8* %14, i32 1, i32 %16, i32 %24)
%26 = load i32, i32* %4
%27 = icmp ne i32 %26, 0
br i1 %27, label %28, label %30
28: ; preds = %23
%29 = load i32, i32* @stderr
br label %32
30: ; preds = %23
%31 = load i32, i32* @stdout
br label %32
32: ; preds = %30, %28
%33 = phi i32 [ %29, %28 ], [ %31, %30 ]
%34 = call i32 @fflush(i32 %33)
ret void
}

LLVM IR (-O2):
@stderr = global i32 0
@stdout = global i32 0
define void @fossil_puts(i8* %0, i32 %1) {
%3 = icmp ult i32 %1, 2
%4 = zext i1 %3 to i32
%5 = tail call i32 @assert(i32 %4)
%6 = tail call i32 @strlen(i8* %0)
%7 = icmp eq i32 %1, 0
%8 = load i32, i32* @stderr
%9 = load i32, i32* @stdout
%10 = select i1 %7, i32 %9, i32 %8
%11 = tail call i32 @fwrite(i8* %0, i32 1, i32 %6, i32 %10)
%12 = load i32, i32* @stderr
%13 = load i32, i32* @stdout
%14 = select i1 %7, i32 %13, i32 %12
%15 = tail call i32 @fflush(i32 %14)
ret void
}