#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 char *String;
typedef int /*<<< orphan*/ GC;
typedef int /*<<< orphan*/ Drawable;
typedef int /*<<< orphan*/ Display;

/* Variables and functions */
int /*<<< orphan*/ XDrawImageString(int /*<<< orphan*/ *, int /*<<< orphan*/,
                                    int /*<<< orphan*/, int, int, char *, int);
char *strnchr(char *, char, int);
void XfwfDrawImageString(Display *display, Drawable drawable, GC gc, int x,
                         int y, String string, int length, int *tabs) {
  register char *p, *ep;
  register int tx, tab;
  tab = tx = 0;
  for (p = string; length;) {
    ep = strnchr(p, '\t', length);
    if (ep && tabs) {
      XDrawImageString(display, drawable, gc, x + tx, y, p, ep - p);
      tx = tabs[tab++];
      length -= ep - p + 1;
      p = ep + 1;
    } else {
      XDrawImageString(display, drawable, gc, x + tx, y, p, length);
      break;
    }
  }
}


x86 assembly (clang, -O0):
<XfwfDrawImageString>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    0x18(%rbp),%rax
mov    0x10(%rbp),%eax
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %ecx,-0x14(%rbp)
mov    %r8d,-0x18(%rbp)
mov    %r9,-0x20(%rbp)
movl   $0x0,-0x34(%rbp)
movl   $0x0,-0x38(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x28(%rbp)
cmpl   $0x0,0x10(%rbp)
je     1229 <XfwfDrawImageString+0x109>
mov    -0x28(%rbp),%rdi
mov    0x10(%rbp),%edx
mov    $0x9,%esi
call   1030 <strnchr@plt>
mov    %rax,-0x30(%rbp)
cmpq   $0x0,-0x30(%rbp)
je     11fc <XfwfDrawImageString+0xdc>
cmpq   $0x0,0x18(%rbp)
je     11fc <XfwfDrawImageString+0xdc>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    -0x14(%rbp),%ecx
add    -0x34(%rbp),%ecx
mov    -0x18(%rbp),%r8d
mov    -0x28(%rbp),%r9
mov    -0x30(%rbp),%rax
mov    -0x28(%rbp),%r10
sub    %r10,%rax
mov    %eax,(%rsp)
call   1040 <XDrawImageString@plt>
mov    0x18(%rbp),%rax
mov    -0x38(%rbp),%ecx
mov    %ecx,%edx
add    $0x1,%edx
mov    %edx,-0x38(%rbp)
movslq %ecx,%rcx
mov    (%rax,%rcx,4),%eax
mov    %eax,-0x34(%rbp)
mov    -0x30(%rbp),%rcx
mov    -0x28(%rbp),%rax
sub    %rax,%rcx
add    $0x1,%rcx
movslq 0x10(%rbp),%rax
sub    %rcx,%rax
mov    %eax,0x10(%rbp)
mov    -0x30(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
jmp    1224 <XfwfDrawImageString+0x104>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    -0x14(%rbp),%ecx
add    -0x34(%rbp),%ecx
mov    -0x18(%rbp),%r8d
mov    -0x28(%rbp),%r9
mov    0x10(%rbp),%eax
mov    %eax,(%rsp)
call   1040 <XDrawImageString@plt>
jmp    1229 <XfwfDrawImageString+0x109>
jmp    115a <XfwfDrawImageString+0x3a>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<XfwfDrawImageString>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %r8d,0x18(%rsp)
mov    %ecx,0x1c(%rsp)
mov    %edx,0x14(%rsp)
mov    %esi,0x10(%rsp)
mov    %rdi,0x20(%rsp)
mov    0x60(%rsp),%ebp
test   %ebp,%ebp
je     11e1 <XfwfDrawImageString+0xc1>
mov    %r9,%r12
mov    0x68(%rsp),%r13
xor    %r15d,%r15d
nopl   0x0(%rax,%rax,1)
mov    %r12,%rdi
mov    $0x9,%esi
mov    %ebp,%edx
call   1030 <strnchr@plt>
add    0x1c(%rsp),%r15d
cmpq   $0x0,0x68(%rsp)
je     11c1 <XfwfDrawImageString+0xa1>
mov    %rax,%r14
test   %rax,%rax
je     11c1 <XfwfDrawImageString+0xa1>
mov    %r14d,%ebx
sub    %r12d,%ebx
mov    %ebx,(%rsp)
mov    0x20(%rsp),%rdi
mov    0x10(%rsp),%esi
mov    0x14(%rsp),%edx
mov    %r15d,%ecx
mov    0x18(%rsp),%r8d
mov    %r12,%r9
call   1040 <XDrawImageString@plt>
mov    0x0(%r13),%r15d
not    %ebx
add    $0x1,%r14
add    $0x4,%r13
mov    %r14,%r12
add    %ebx,%ebp
jne    1160 <XfwfDrawImageString+0x40>
jmp    11e1 <XfwfDrawImageString+0xc1>
mov    %ebp,(%rsp)
mov    0x20(%rsp),%rdi
mov    0x10(%rsp),%esi
mov    0x14(%rsp),%edx
mov    %r15d,%ecx
mov    0x18(%rsp),%r8d
mov    %r12,%r9
call   1040 <XDrawImageString@plt>
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define void @XfwfDrawImageString(i32* %0, i32 %1, i32 %2, i32 %3, i32 %4, i8* %5, i32 %6, i32* %7) {
%9 = alloca i32*
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i8*
%15 = alloca i32
%16 = alloca i32*
%17 = alloca i8*
%18 = alloca i8*
%19 = alloca i32
%20 = alloca i32
store i32* %0, i32** %9
store i32 %1, i32* %10
store i32 %2, i32* %11
store i32 %3, i32* %12
store i32 %4, i32* %13
store i8* %5, i8** %14
store i32 %6, i32* %15
store i32* %7, i32** %16
store i32 0, i32* %19
store i32 0, i32* %20
%21 = load i8*, i8** %14
store i8* %21, i8** %17
br label %22
22: ; preds = %79, %8
%23 = load i32, i32* %15
%24 = icmp ne i32 %23, 0
br i1 %24, label %25, label %80
25: ; preds = %22
%26 = load i8*, i8** %17
%27 = load i32, i32* %15
%28 = call i8* @strnchr(i8* %26, i8 signext 9, i32 %27)
store i8* %28, i8** %18
%29 = load i8*, i8** %18
%30 = icmp ne i8* %29, null
br i1 %30, label %31, label %68
31: ; preds = %25
%32 = load i32*, i32** %16
%33 = icmp ne i32* %32, null
br i1 %33, label %34, label %68
34: ; preds = %31
%35 = load i32*, i32** %9
%36 = load i32, i32* %10
%37 = load i32, i32* %11
%38 = load i32, i32* %12
%39 = load i32, i32* %19
%40 = add nsw i32 %38, %39
%41 = load i32, i32* %13
%42 = load i8*, i8** %17
%43 = load i8*, i8** %18
%44 = load i8*, i8** %17
%45 = ptrtoint i8* %43 to i64
%46 = ptrtoint i8* %44 to i64
%47 = sub i64 %45, %46
%48 = trunc i64 %47 to i32
%49 = call i32 @XDrawImageString(i32* %35, i32 %36, i32 %37, i32 %40, i32 %41, i8* %42, i32 %48)
%50 = load i32*, i32** %16
%51 = load i32, i32* %20
%52 = add nsw i32 %51, 1
store i32 %52, i32* %20
%53 = sext i32 %51 to i64
%54 = getelementptr inbounds i32, i32* %50, i64 %53
%55 = load i32, i32* %54
store i32 %55, i32* %19
%56 = load i8*, i8** %18
%57 = load i8*, i8** %17
%58 = ptrtoint i8* %56 to i64
%59 = ptrtoint i8* %57 to i64
%60 = sub i64 %58, %59
%61 = add nsw i64 %60, 1
%62 = load i32, i32* %15
%63 = sext i32 %62 to i64
%64 = sub nsw i64 %63, %61
%65 = trunc i64 %64 to i32
store i32 %65, i32* %15
%66 = load i8*, i8** %18
%67 = getelementptr inbounds i8, i8* %66, i64 1
store i8* %67, i8** %17
br label %79
68: ; preds = %31, %25
%69 = load i32*, i32** %9
%70 = load i32, i32* %10
%71 = load i32, i32* %11
%72 = load i32, i32* %12
%73 = load i32, i32* %19
%74 = add nsw i32 %72, %73
%75 = load i32, i32* %13
%76 = load i8*, i8** %17
%77 = load i32, i32* %15
%78 = call i32 @XDrawImageString(i32* %69, i32 %70, i32 %71, i32 %74, i32 %75, i8* %76, i32 %77)
br label %80
79: ; preds = %34
br label %22
80: ; preds = %68, %22
ret void
}

LLVM IR (-O2):
define void @XfwfDrawImageString(i32* %0, i32 %1, i32 %2, i32 %3, i32 %4, i8* %5, i32 %6, i32* %7) {
%9 = icmp eq i32 %6, 0
br i1 %9, label %36, label %10
10: ; preds = %8
%11 = icmp ne i32* %7, null
br label %12
12: ; preds = %10, %21
%13 = phi i64 [ 0, %10 ], [ %27, %21 ]
%14 = phi i32 [ 0, %10 ], [ %29, %21 ]
%15 = phi i32 [ %6, %10 ], [ %31, %21 ]
%16 = phi i8* [ %5, %10 ], [ %32, %21 ]
%17 = tail call i8* @strnchr(i8* %16, i8 signext 9, i32 %15)
%18 = icmp ne i8* %17, null
%19 = and i1 %11, %18
%20 = add nsw i32 %14, %3
br i1 %19, label %21, label %34
21: ; preds = %12
%22 = ptrtoint i8* %17 to i64
%23 = ptrtoint i8* %16 to i64
%24 = sub i64 %22, %23
%25 = trunc i64 %24 to i32
%26 = tail call i32 @XDrawImageString(i32* %0, i32 %1, i32 %2, i32 %20, i32 %4, i8* %16, i32 %25)
%27 = add nuw i64 %13, 1
%28 = getelementptr inbounds i32, i32* %7, i64 %13
%29 = load i32, i32* %28
%30 = xor i32 %25, -1
%31 = add i32 %15, %30
%32 = getelementptr inbounds i8, i8* %17, i64 1
%33 = icmp eq i32 %31, 0
br i1 %33, label %36, label %12
34: ; preds = %12
%35 = tail call i32 @XDrawImageString(i32* %0, i32 %1, i32 %2, i32 %20, i32 %4, i8* %16, i32 %15)
br label %36
36: ; preds = %21, %8, %34
ret void
}