#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*/ va_list;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ *stderr;
int strlen(char const *);
int vfprintf(int /*<<< orphan*/ *, char const *, int /*<<< orphan*/);
int inchi_vfprintf(FILE *f, const char *lpszFormat, va_list argList) {
  int ret = 0;
  if (f == stderr && lpszFormat && lpszFormat[0] &&
      '\r' == lpszFormat[strlen(lpszFormat) - 1]) {
    ret = vfprintf(f, lpszFormat, argList);
  } else {
    ret = vfprintf(f, lpszFormat, argList);
  }
  return ret;
}


x86 assembly (clang, -O0):
<inchi_vfprintf>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x8(%rbp),%rax
mov    0x2e9b(%rip),%rcx
cmp    (%rcx),%rax
jne    11af <inchi_vfprintf+0x8f>
cmpq   $0x0,-0x10(%rbp)
je     11af <inchi_vfprintf+0x8f>
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     11af <inchi_vfprintf+0x8f>
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
call   1030 <strlen@plt>
mov    %eax,%ecx
mov    -0x20(%rbp),%rax
sub    $0x1,%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%ecx
mov    $0xd,%eax
cmp    %ecx,%eax
jne    11af <inchi_vfprintf+0x8f>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
call   1040 <vfprintf@plt>
mov    %eax,-0x18(%rbp)
jmp    11c2 <inchi_vfprintf+0xa2>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
call   1040 <vfprintf@plt>
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<inchi_vfprintf>:
push   %rbp
push   %r14
push   %rbx
mov    %edx,%r14d
mov    %rsi,%rbx
mov    %rdi,%rbp
test   %rsi,%rsi
je     1152 <inchi_vfprintf+0x32>
mov    0x2ea7(%rip),%rax
cmp    %rbp,(%rax)
jne    1152 <inchi_vfprintf+0x32>
cmpb   $0x0,(%rbx)
je     1152 <inchi_vfprintf+0x32>
mov    %rbx,%rdi
call   1030 <strlen@plt>
cltq
cmpb   $0xd,-0x1(%rax,%rbx,1)
mov    %rbp,%rdi
mov    %rbx,%rsi
mov    %r14d,%edx
pop    %rbx
pop    %r14
pop    %rbp
jmp    1040 <vfprintf@plt>

LLVM IR (-O0):
@stderr = global i32* null
define i32 @inchi_vfprintf(i32* %0, i8* %1, i32 %2) {
%4 = alloca i32*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca i32
store i32* %0, i32** %4
store i8* %1, i8** %5
store i32 %2, i32* %6
store i32 0, i32* %7
%8 = load i32*, i32** %4
%9 = load i32*, i32** @stderr
%10 = icmp eq i32* %8, %9
br i1 %10, label %11, label %35
11: ; preds = %3
%12 = load i8*, i8** %5
%13 = icmp ne i8* %12, null
br i1 %13, label %14, label %35
14: ; preds = %11
%15 = load i8*, i8** %5
%16 = getelementptr inbounds i8, i8* %15, i64 0
%17 = load i8, i8* %16
%18 = sext i8 %17 to i32
%19 = icmp ne i32 %18, 0
br i1 %19, label %20, label %35
20: ; preds = %14
%21 = load i8*, i8** %5
%22 = load i8*, i8** %5
%23 = call i32 @strlen(i8* %22)
%24 = sub nsw i32 %23, 1
%25 = sext i32 %24 to i64
%26 = getelementptr inbounds i8, i8* %21, i64 %25
%27 = load i8, i8* %26
%28 = sext i8 %27 to i32
%29 = icmp eq i32 13, %28
br i1 %29, label %30, label %35
30: ; preds = %20
%31 = load i32*, i32** %4
%32 = load i8*, i8** %5
%33 = load i32, i32* %6
%34 = call i32 @vfprintf(i32* %31, i8* %32, i32 %33)
store i32 %34, i32* %7
br label %40
35: ; preds = %20, %14, %11, %3
%36 = load i32*, i32** %4
%37 = load i8*, i8** %5
%38 = load i32, i32* %6
%39 = call i32 @vfprintf(i32* %36, i8* %37, i32 %38)
store i32 %39, i32* %7
br label %40
40: ; preds = %35, %30
%41 = load i32, i32* %7
ret i32 %41
}

LLVM IR (-O2):
@stderr = global i32* null
define i32 @inchi_vfprintf(i32* nocapture %0, i8* %1, i32 %2) {
%4 = load i32*, i32** @stderr
%5 = icmp eq i32* %4, %0
%6 = icmp ne i8* %1, null
%7 = and i1 %6, %5
br i1 %7, label %8, label %20
8: ; preds = %3
%9 = load i8, i8* %1
%10 = icmp eq i8 %9, 0
br i1 %10, label %20, label %11
11: ; preds = %8
%12 = tail call i32 @strlen(i8* %1)
%13 = add nsw i32 %12, -1
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds i8, i8* %1, i64 %14
%16 = load i8, i8* %15
%17 = icmp eq i8 %16, 13
br i1 %17, label %18, label %20
18: ; preds = %11
%19 = tail call i32 @vfprintf(i32* %0, i8* %1, i32 %2)
br label %22
20: ; preds = %11, %8, %3
%21 = tail call i32 @vfprintf(i32* %0, i8* %1, i32 %2)
br label %22
22: ; preds = %20, %18
%23 = phi i32 [ %19, %18 ], [ %21, %20 ]
ret i32 %23
}