#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 */
typedef struct TYPE_3__ TYPE_1__;

/* Type definitions */
struct TYPE_3__ {
  int format;
  int nitems;
  unsigned char *value;
  int /*<<< orphan*/ encoding;
};
typedef TYPE_1__ XTextProperty;
typedef int /*<<< orphan*/ FILE;
typedef int /*<<< orphan*/ Display;

/* Variables and functions */
int Success;
int /*<<< orphan*/ XInternAtom(int /*<<< orphan*/ *, char *,
                               int /*<<< orphan*/);
int /*<<< orphan*/ *XOpenDisplay(int /*<<< orphan*/ *);
int Xutf8TextPropertyToTextList(int /*<<< orphan*/ *, TYPE_1__ *, char ***,
                                int *);
int /*<<< orphan*/ abort();
scalar_t__ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ printf(char *, ...);
scalar_t__ strcmp(char *, char *);
int strlen(char *);
char *strtok(char *, char *);
void *strtol(char *, int /*<<< orphan*/ *, int);
int main(void) {
  Display *display;
  static XTextProperty text_prop;
  FILE *fp;
  char buf[128];
  int good = 1;
  int count = 0;
  display = XOpenDisplay(NULL);
  if (!display) {
    printf("cannot open DISPLAY\n");
    abort();
  }
  fp = fopen("../tempfile.txt", "r");
  if (!fp) {
    printf("cannot open tempfile.utf8\n");
    abort();
  }
  while (fgets(buf, 128, fp)) {
    char *part;
    int blen = 0;
    int u;
    char bytes[128];
    int ret;
    char **tlist;
    int tcount;
    char utf8[128];
    int utf8len = 0;
    count++;
    part = strtok(buf, " ");
    u = strtol(part, NULL, 0);
    while ((part = strtok(NULL, " "))) {
      bytes[blen++] = strtol(part, NULL, 16);
    }
    bytes[blen] = '\0';
    fgets(buf, 128, fp);
    part = strtok(buf, " ");
    utf8[utf8len++] = strtol(part, NULL, 16);
    while ((part = strtok(NULL, " "))) {
      utf8[utf8len++] = strtol(part, NULL, 16);
    }
    utf8[utf8len] = '\0';
    text_prop.encoding = XInternAtom(display, "COMPOUND_TEXT", 0);
    text_prop.format = 8;
    text_prop.nitems = blen;
    text_prop.value = (unsigned char *)bytes;
    ret = Xutf8TextPropertyToTextList(display, &text_prop, &tlist, &tcount);
    if (ret != Success) {
      int i;
      printf("U+%04X\n", u);
      printf("  Xutf8TextPropertyToTextList ret %d\n", ret);
      printf("  bytes ");
      for (i = 0; i < blen; i++) {
        printf(" %02X", (int)(unsigned char)bytes[i]);
      }
      printf("\n");
      continue;
    }
    if (strcmp(utf8, tlist[0]) != 0) {
      int i;
      printf("U+%04X\n", u);
      printf("  Xutf8TextPropertyToTextList different\n");
      printf("  got utf8  ");
      for (i = 0; i < strlen(tlist[0]); i++) {
        printf(" %02X", (int)(unsigned char)tlist[0][i]);
      }
      printf("\n");
      printf("  want utf8 ");
      for (i = 0; i < utf8len; i++) {
        printf(" %02X", (int)(unsigned char)utf8[i]);
      }
      printf("\n");
    }
  }
  printf("total count %d\n", count);
  if (!good) {
    abort();
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x1f0,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0xa4(%rbp)
movl   $0x0,-0xa8(%rbp)
xor    %eax,%eax
mov    %eax,%edi
call   1090 <XOpenDisplay@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1203 <main+0x53>
lea    0xe0b(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    $0x0,%al
call   1040 <abort@plt>
lea    0xe0b(%rip),%rdi
lea    0xe14(%rip),%rsi
call   10c0 <fopen@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    123a <main+0x8a>
lea    0xdfb(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    $0x0,%al
call   1040 <abort@plt>
jmp    123f <main+0x8f>
lea    -0xa0(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    $0x80,%esi
call   1070 <fgets@plt>
cmp    $0x0,%rax
je     1622 <main+0x472>
movl   $0x0,-0xb4(%rbp)
movl   $0x0,-0x1e4(%rbp)
mov    -0xa8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xa8(%rbp)
lea    -0xa0(%rbp),%rdi
lea    0xe32(%rip),%rsi
call   10d0 <strtok@plt>
mov    %rax,-0xb0(%rbp)
mov    -0xb0(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
xor    %edx,%edx
call   10a0 <strtol@plt>
mov    %eax,-0xb8(%rbp)
xor    %eax,%eax
mov    %eax,%edi
lea    0xe03(%rip),%rsi
call   10d0 <strtok@plt>
mov    %rax,-0xb0(%rbp)
cmp    $0x0,%rax
je     130a <main+0x15a>
mov    -0xb0(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0x10,%edx
call   10a0 <strtol@plt>
mov    %al,%cl
mov    -0xb4(%rbp),%eax
mov    %eax,%edx
add    $0x1,%edx
mov    %edx,-0xb4(%rbp)
cltq
mov    %cl,-0x140(%rbp,%rax,1)
jmp    12b3 <main+0x103>
movslq -0xb4(%rbp),%rax
movb   $0x0,-0x140(%rbp,%rax,1)
lea    -0xa0(%rbp),%rdi
mov    -0x18(%rbp),%rdx
mov    $0x80,%esi
call   1070 <fgets@plt>
lea    -0xa0(%rbp),%rdi
lea    0xd85(%rip),%rsi
call   10d0 <strtok@plt>
mov    %rax,-0xb0(%rbp)
mov    -0xb0(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0x10,%edx
call   10a0 <strtol@plt>
mov    %al,%cl
mov    -0x1e4(%rbp),%eax
mov    %eax,%edx
add    $0x1,%edx
mov    %edx,-0x1e4(%rbp)
cltq
mov    %cl,-0x1e0(%rbp,%rax,1)
xor    %eax,%eax
mov    %eax,%edi
lea    0xd3d(%rip),%rsi
call   10d0 <strtok@plt>
mov    %rax,-0xb0(%rbp)
cmp    $0x0,%rax
je     13d0 <main+0x220>
mov    -0xb0(%rbp),%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0x10,%edx
call   10a0 <strtol@plt>
mov    %al,%cl
mov    -0x1e4(%rbp),%eax
mov    %eax,%edx
add    $0x1,%edx
mov    %edx,-0x1e4(%rbp)
cltq
mov    %cl,-0x1e0(%rbp,%rax,1)
jmp    1379 <main+0x1c9>
movslq -0x1e4(%rbp),%rax
movb   $0x0,-0x1e0(%rbp,%rax,1)
mov    -0x10(%rbp),%rdi
lea    0xc58(%rip),%rsi
xor    %edx,%edx
call   10b0 <XInternAtom@plt>
mov    %eax,0x2c99(%rip)
movl   $0x8,0x2c7f(%rip)
mov    -0xb4(%rbp),%eax
mov    %eax,0x2c77(%rip)
lea    -0x140(%rbp),%rax
mov    %rax,0x2c6d(%rip)
mov    -0x10(%rbp),%rdi
lea    0x2c5a(%rip),%rsi
lea    -0x150(%rbp),%rdx
lea    -0x154(%rbp),%rcx
call   1030 <Xutf8TextPropertyToTextList@plt>
mov    %eax,-0x144(%rbp)
mov    -0x144(%rbp),%eax
mov    0x2bac(%rip),%rcx
cmp    (%rcx),%eax
je     14ea <main+0x33a>
mov    -0xb8(%rbp),%esi
lea    0xbef(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x144(%rbp),%esi
lea    0xbe3(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xbfb(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0x0,-0x1e8(%rbp)
mov    -0x1e8(%rbp),%eax
cmp    -0xb4(%rbp),%eax
jge    14d7 <main+0x327>
movslq -0x1e8(%rbp),%rax
movzbl -0x140(%rbp,%rax,1),%esi
ff
lea    0xbcb(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x1e8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1e8(%rbp)
jmp    1494 <main+0x2e4>
lea    0xb62(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    123f <main+0x8f>
lea    -0x1e0(%rbp),%rdi
mov    -0x150(%rbp),%rax
mov    (%rax),%rsi
call   1080 <strcmp@plt>
cmp    $0x0,%rax
je     161d <main+0x46d>
mov    -0xb8(%rbp),%esi
lea    0xb39(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xb68(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xb83(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0x0,-0x1ec(%rbp)
mov    -0x1ec(%rbp),%eax
mov    %eax,-0x1f0(%rbp)
mov    -0x150(%rbp),%rax
mov    (%rax),%rdi
call   1050 <strlen@plt>
mov    %eax,%ecx
mov    -0x1f0(%rbp),%eax
cmp    %ecx,%eax
jge    15a6 <main+0x3f6>
mov    -0x150(%rbp),%rax
mov    (%rax),%rax
movslq -0x1ec(%rbp),%rcx
movzbl (%rax,%rcx,1),%esi
lea    0xafc(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x1ec(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1ec(%rbp)
jmp    1544 <main+0x394>
lea    0xa93(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
lea    0xb08(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
movl   $0x0,-0x1ec(%rbp)
mov    -0x1ec(%rbp),%eax
cmp    -0x1e4(%rbp),%eax
jge    160f <main+0x45f>
movslq -0x1ec(%rbp),%rax
movzbl -0x1e0(%rbp,%rax,1),%esi
ff
lea    0xa93(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x1ec(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1ec(%rbp)
jmp    15cc <main+0x41c>
lea    0xa2a(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
jmp    123f <main+0x8f>
mov    -0xa8(%rbp),%esi
lea    0xaa1(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
cmpl   $0x0,-0xa4(%rbp)
jne    164a <main+0x49a>
mov    $0x0,%al
call   1040 <abort@plt>
xor    %eax,%eax
add    $0x1f0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x1b8,%rsp
xor    %edi,%edi
call   10b0 <XOpenDisplay@plt>
mov    %rax,0x20(%rsp)
test   %rax,%rax
je     1578 <main+0x3a8>
lea    0xe03(%rip),%rdi
lea    0xe0c(%rip),%rsi
call   10e0 <fopen@plt>
test   %rax,%rax
je     1581 <main+0x3b1>
mov    %rax,%r12
lea    0x130(%rsp),%rdi
mov    $0x80,%esi
mov    %rax,%rdx
call   1090 <fgets@plt>
test   %rax,%rax
je     1550 <main+0x380>
lea    0xe2e(%rip),%rbx
lea    0x130(%rsp),%rbp
xor    %r14d,%r14d
mov    %r12,0x10(%rsp)
jmp    1286 <main+0xb6>
nopl   0x0(%rax)
mov    $0xa,%edi
call   1040 <putchar@plt>
lea    0xe07(%rip),%rbx
add    $0x1,%r14d
lea    0x130(%rsp),%rbp
mov    %rbp,%rdi
mov    $0x80,%esi
mov    %r12,%rdx
call   1090 <fgets@plt>
test   %rax,%rax
je     1553 <main+0x383>
mov    %r14d,0x4(%rsp)
mov    %rbp,%rdi
mov    %rbx,%rsi
call   10f0 <strtok@plt>
mov    %rax,%rdi
xor    %esi,%esi
xor    %edx,%edx
call   10c0 <strtol@plt>
mov    %rax,0x18(%rsp)
xor    %edi,%edi
mov    %rbx,%rsi
call   10f0 <strtok@plt>
mov    $0x0,%r14d
test   %rax,%rax
je     12ea <main+0x11a>
xor    %r14d,%r14d
nop
mov    %rax,%rdi
xor    %esi,%esi
mov    $0x10,%edx
call   10c0 <strtol@plt>
mov    %al,0xb0(%rsp,%r14,1)
add    $0x1,%r14
xor    %edi,%edi
mov    %rbx,%rsi
call   10f0 <strtok@plt>
test   %rax,%rax
jne    12c0 <main+0xf0>
mov    %r14d,%r13d
movb   $0x0,0xb0(%rsp,%r13,1)
mov    %rbp,%rdi
mov    $0x80,%esi
mov    %r12,%rdx
call   1090 <fgets@plt>
mov    %rbp,%rdi
mov    %rbx,%rsi
call   10f0 <strtok@plt>
mov    %rax,%rdi
xor    %esi,%esi
mov    $0x10,%edx
call   10c0 <strtol@plt>
mov    %al,0x30(%rsp)
xor    %edi,%edi
mov    %rbx,%rsi
call   10f0 <strtok@plt>
test   %rax,%rax
je     1370 <main+0x1a0>
mov    $0x1,%r15d
nopl   0x0(%rax)
mov    %rax,%rdi
xor    %esi,%esi
mov    $0x10,%edx
call   10c0 <strtol@plt>
mov    %al,0x30(%rsp,%r15,1)
add    $0x1,%r15
xor    %edi,%edi
mov    %rbx,%rsi
call   10f0 <strtok@plt>
test   %rax,%rax
jne    1340 <main+0x170>
jmp    1376 <main+0x1a6>
nopl   0x0(%rax)
mov    $0x1,%r15d
mov    %r15d,%eax
movb   $0x0,0x30(%rsp,%rax,1)
mov    0x20(%rsp),%rbp
mov    %rbp,%rdi
lea    0xc85(%rip),%rsi
xor    %edx,%edx
call   10d0 <XInternAtom@plt>
mov    %eax,0x2d06(%rip)
movl   $0x8,0x2cec(%rip)
mov    %r14d,0x2ce9(%rip)
lea    0xb0(%rsp),%rax
mov    %rax,0x2cde(%rip)
mov    %rbp,%rdi
lea    0x2ccc(%rip),%rsi
lea    0x8(%rsp),%rdx
lea    0x2c(%rsp),%rcx
call   1030 <Xutf8TextPropertyToTextList@plt>
mov    %eax,%r12d
mov    0x2c1b(%rip),%rax
cmp    (%rax),%r12d
jne    14e0 <main+0x310>
mov    0x8(%rsp),%rax
mov    (%rax),%rsi
lea    0x30(%rsp),%rdi
call   10a0 <strcmp@plt>
test   %rax,%rax
mov    0x10(%rsp),%r12
mov    0x4(%rsp),%r14d
je     1261 <main+0x91>
lea    0xc0e(%rip),%rdi
mov    0x18(%rsp),%rsi
xor    %eax,%eax
call   1080 <printf@plt>
lea    0xc90(%rip),%rdi
call   1060 <puts@plt>
lea    0xc2c(%rip),%rdi
xor    %eax,%eax
call   1080 <printf@plt>
mov    0x8(%rsp),%rax
mov    (%rax),%rdi
call   1070 <strlen@plt>
test   %eax,%eax
lea    0xc09(%rip),%rbx
jle    148e <main+0x2be>
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    0x8(%rsp),%rax
mov    (%rax),%rax
movzbl (%rax,%rbp,1),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1080 <printf@plt>
add    $0x1,%rbp
mov    0x8(%rsp),%rax
mov    (%rax),%rdi
call   1070 <strlen@plt>
cltq
cmp    %rax,%rbp
jl     1460 <main+0x290>
mov    $0xa,%edi
call   1040 <putchar@plt>
lea    0xbcb(%rip),%rdi
xor    %eax,%eax
call   1080 <printf@plt>
cmp    $0x2,%r15d
mov    $0x1,%eax
cmovb  %eax,%r15d
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nop
movzbl 0x30(%rsp,%rbp,1),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1080 <printf@plt>
add    $0x1,%rbp
cmp    %rbp,%r15
jne    14c0 <main+0x2f0>
jmp    1250 <main+0x80>
nopl   (%rax)
lea    0xb39(%rip),%rdi
mov    0x18(%rsp),%rsi
xor    %eax,%eax
call   1080 <printf@plt>
lea    0xb2e(%rip),%rdi
mov    %r12d,%esi
xor    %eax,%eax
call   1080 <printf@plt>
lea    0xb43(%rip),%rdi
xor    %eax,%eax
call   1080 <printf@plt>
test   %r14d,%r14d
mov    0x10(%rsp),%r12
mov    0x4(%rsp),%r14d
lea    0xb31(%rip),%rbx
je     1250 <main+0x80>
xor    %ebp,%ebp
xchg   %ax,%ax
movzbl 0xb0(%rsp,%rbp,1),%esi
mov    %rbx,%rdi
xor    %eax,%eax
call   1080 <printf@plt>
add    $0x1,%rbp
cmp    %rbp,%r13
jne    1530 <main+0x360>
jmp    1250 <main+0x80>
xor    %r14d,%r14d
lea    0xb1d(%rip),%rdi
mov    %r14d,%esi
xor    %eax,%eax
call   1080 <printf@plt>
xor    %eax,%eax
add    $0x1b8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
lea    0xb08(%rip),%rdi
jmp    1588 <main+0x3b8>
lea    0xb13(%rip),%rdi
call   1060 <puts@plt>
xor    %eax,%eax
call   1050 <abort@plt>

LLVM IR (-O0):
%struct.TYPE_3__ = type { i32, i32, i8*, i32 }
@main.text_prop = internal global %struct.TYPE_3__ zeroinitializer
@.str = [21 x i8] c"cannot open DISPLAY\0A\00"
@.str.1 = [16 x i8] c"../tempfile.txt\00"
@.str.2 = [2 x i8] c"r\00"
@.str.3 = [27 x i8] c"cannot open tempfile.utf8\0A\00"
@.str.4 = [2 x i8] c" \00"
@.str.5 = [14 x i8] c"COMPOUND_TEXT\00"
@Success = global i32 0
@.str.6 = [8 x i8] c"U+%04X\0A\00"
@.str.7 = [38 x i8] c" Xutf8TextPropertyToTextList ret %d\0A\00"
@.str.8 = [9 x i8] c" bytes \00"
@.str.9 = [6 x i8] c" %02X\00"
@.str.10 = [2 x i8] c"\0A\00"
@.str.11 = [41 x i8] c" Xutf8TextPropertyToTextList different\0A\00"
@.str.12 = [13 x i8] c" got utf8 \00"
@.str.13 = [13 x i8] c" want utf8 \00"
@.str.14 = [16 x i8] c"total count %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca i32*
%4 = alloca [128 x i8]
%5 = alloca i32
%6 = alloca i32
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i32
%10 = alloca [128 x i8]
%11 = alloca i32
%12 = alloca i8**
%13 = alloca i32
%14 = alloca [128 x i8]
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32
store i32 0, i32* %1
store i32 1, i32* %5
store i32 0, i32* %6
%18 = call i32* @XOpenDisplay(i32* null)
store i32* %18, i32** %2
%19 = load i32*, i32** %2
%20 = icmp ne i32* %19, null
br i1 %20, label %24, label %21
21: ; preds = %0
%22 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
%23 = call i32 (...) @abort()
unreachable
24: ; preds = %0
%25 = call i32* @fopen(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
store i32* %25, i32** %3
%26 = load i32*, i32** %3
%27 = icmp ne i32* %26, null
br i1 %27, label %31, label %28
28: ; preds = %24
%29 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.3, i64 0, i64 0))
%30 = call i32 (...) @abort()
unreachable
31: ; preds = %24
br label %32
32: ; preds = %169, %116, %31
%33 = getelementptr inbounds [128 x i8], [128 x i8]* %4, i64 0, i64 0
%34 = load i32*, i32** %3
%35 = call i64 @fgets(i8* %33, i32 128, i32* %34)
%36 = icmp ne i64 %35, 0
br i1 %36, label %37, label %170
37: ; preds = %32
store i32 0, i32* %8
store i32 0, i32* %15
%38 = load i32, i32* %6
%39 = add nsw i32 %38, 1
store i32 %39, i32* %6
%40 = getelementptr inbounds [128 x i8], [128 x i8]* %4, i64 0, i64 0
%41 = call i8* @strtok(i8* %40, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
store i8* %41, i8** %7
%42 = load i8*, i8** %7
%43 = call i8* @strtol(i8* %42, i32* null, i32 0)
%44 = ptrtoint i8* %43 to i32
store i32 %44, i32* %9
br label %45
45: ; preds = %48, %37
%46 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
store i8* %46, i8** %7
%47 = icmp ne i8* %46, null
br i1 %47, label %48, label %56
48: ; preds = %45
%49 = load i8*, i8** %7
%50 = call i8* @strtol(i8* %49, i32* null, i32 16)
%51 = ptrtoint i8* %50 to i8
%52 = load i32, i32* %8
%53 = add nsw i32 %52, 1
store i32 %53, i32* %8
%54 = sext i32 %52 to i64
%55 = getelementptr inbounds [128 x i8], [128 x i8]* %10, i64 0, i64 %54
store i8 %51, i8* %55
br label %45
56: ; preds = %45
%57 = load i32, i32* %8
%58 = sext i32 %57 to i64
%59 = getelementptr inbounds [128 x i8], [128 x i8]* %10, i64 0, i64 %58
store i8 0, i8* %59
%60 = getelementptr inbounds [128 x i8], [128 x i8]* %4, i64 0, i64 0
%61 = load i32*, i32** %3
%62 = call i64 @fgets(i8* %60, i32 128, i32* %61)
%63 = getelementptr inbounds [128 x i8], [128 x i8]* %4, i64 0, i64 0
%64 = call i8* @strtok(i8* %63, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
store i8* %64, i8** %7
%65 = load i8*, i8** %7
%66 = call i8* @strtol(i8* %65, i32* null, i32 16)
%67 = ptrtoint i8* %66 to i8
%68 = load i32, i32* %15
%69 = add nsw i32 %68, 1
store i32 %69, i32* %15
%70 = sext i32 %68 to i64
%71 = getelementptr inbounds [128 x i8], [128 x i8]* %14, i64 0, i64 %70
store i8 %67, i8* %71
br label %72
72: ; preds = %75, %56
%73 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
store i8* %73, i8** %7
%74 = icmp ne i8* %73, null
br i1 %74, label %75, label %83
75: ; preds = %72
%76 = load i8*, i8** %7
%77 = call i8* @strtol(i8* %76, i32* null, i32 16)
%78 = ptrtoint i8* %77 to i8
%79 = load i32, i32* %15
%80 = add nsw i32 %79, 1
store i32 %80, i32* %15
%81 = sext i32 %79 to i64
%82 = getelementptr inbounds [128 x i8], [128 x i8]* %14, i64 0, i64 %81
store i8 %78, i8* %82
br label %72
83: ; preds = %72
%84 = load i32, i32* %15
%85 = sext i32 %84 to i64
%86 = getelementptr inbounds [128 x i8], [128 x i8]* %14, i64 0, i64 %85
store i8 0, i8* %86
%87 = load i32*, i32** %2
%88 = call i32 @XInternAtom(i32* %87, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0), i32 0)
store i32 %88, i32* getelementptr inbounds (%struct.TYPE_3__, %struct.TYPE_3__* @main.text_prop, i32 0, i32 3)
store i32 8, i32* getelementptr inbounds (%struct.TYPE_3__, %struct.TYPE_3__* @main.text_prop, i32 0, i32 0)
%89 = load i32, i32* %8
store i32 %89, i32* getelementptr inbounds (%struct.TYPE_3__, %struct.TYPE_3__* @main.text_prop, i32 0, i32 1)
%90 = getelementptr inbounds [128 x i8], [128 x i8]* %10, i64 0, i64 0
store i8* %90, i8** getelementptr inbounds (%struct.TYPE_3__, %struct.TYPE_3__* @main.text_prop, i32 0, i32 2)
%91 = load i32*, i32** %2
%92 = call i32 @Xutf8TextPropertyToTextList(i32* %91, %struct.TYPE_3__* @main.text_prop, i8*** %12, i32* %13)
store i32 %92, i32* %11
%93 = load i32, i32* %11
%94 = load i32, i32* @Success
%95 = icmp ne i32 %93, %94
br i1 %95, label %96, label %118
96: ; preds = %83
%97 = load i32, i32* %9
%98 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.6, i64 0, i64 0), i32 %97)
%99 = load i32, i32* %11
%100 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([38 x i8], [38 x i8]* @.str.7, i64 0, i64 0), i32 %99)
%101 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.8, i64 0, i64 0))
store i32 0, i32* %16
br label %102
102: ; preds = %113, %96
%103 = load i32, i32* %16
%104 = load i32, i32* %8
%105 = icmp slt i32 %103, %104
br i1 %105, label %106, label %116
106: ; preds = %102
%107 = load i32, i32* %16
%108 = sext i32 %107 to i64
%109 = getelementptr inbounds [128 x i8], [128 x i8]* %10, i64 0, i64 %108
%110 = load i8, i8* %109
%111 = zext i8 %110 to i32
%112 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.9, i64 0, i64 0), i32 %111)
br label %113
113: ; preds = %106
%114 = load i32, i32* %16
%115 = add nsw i32 %114, 1
store i32 %115, i32* %16
br label %102
116: ; preds = %102
%117 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.10, i64 0, i64 0))
br label %32
118: ; preds = %83
%119 = getelementptr inbounds [128 x i8], [128 x i8]* %14, i64 0, i64 0
%120 = load i8**, i8*** %12
%121 = getelementptr inbounds i8*, i8** %120, i64 0
%122 = load i8*, i8** %121
%123 = call i64 @strcmp(i8* %119, i8* %122)
%124 = icmp ne i64 %123, 0
br i1 %124, label %125, label %169
125: ; preds = %118
%126 = load i32, i32* %9
%127 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.6, i64 0, i64 0), i32 %126)
%128 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.11, i64 0, i64 0))
%129 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.12, i64 0, i64 0))
store i32 0, i32* %17
br label %130
130: ; preds = %147, %125
%131 = load i32, i32* %17
%132 = load i8**, i8*** %12
%133 = getelementptr inbounds i8*, i8** %132, i64 0
%134 = load i8*, i8** %133
%135 = call i32 @strlen(i8* %134)
%136 = icmp slt i32 %131, %135
br i1 %136, label %137, label %150
137: ; preds = %130
%138 = load i8**, i8*** %12
%139 = getelementptr inbounds i8*, i8** %138, i64 0
%140 = load i8*, i8** %139
%141 = load i32, i32* %17
%142 = sext i32 %141 to i64
%143 = getelementptr inbounds i8, i8* %140, i64 %142
%144 = load i8, i8* %143
%145 = zext i8 %144 to i32
%146 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.9, i64 0, i64 0), i32 %145)
br label %147
147: ; preds = %137
%148 = load i32, i32* %17
%149 = add nsw i32 %148, 1
store i32 %149, i32* %17
br label %130
150: ; preds = %130
%151 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.10, i64 0, i64 0))
%152 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.13, i64 0, i64 0))
store i32 0, i32* %17
br label %153
153: ; preds = %164, %150
%154 = load i32, i32* %17
%155 = load i32, i32* %15
%156 = icmp slt i32 %154, %155
br i1 %156, label %157, label %167
157: ; preds = %153
%158 = load i32, i32* %17
%159 = sext i32 %158 to i64
%160 = getelementptr inbounds [128 x i8], [128 x i8]* %14, i64 0, i64 %159
%161 = load i8, i8* %160
%162 = zext i8 %161 to i32
%163 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.9, i64 0, i64 0), i32 %162)
br label %164
164: ; preds = %157
%165 = load i32, i32* %17
%166 = add nsw i32 %165, 1
store i32 %166, i32* %17
br label %153
167: ; preds = %153
%168 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.10, i64 0, i64 0))
br label %169
169: ; preds = %167, %118
br label %32
170: ; preds = %32
%171 = load i32, i32* %6
%172 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.14, i64 0, i64 0), i32 %171)
%173 = load i32, i32* %5
%174 = icmp ne i32 %173, 0
br i1 %174, label %177, label %175
175: ; preds = %170
%176 = call i32 (...) @abort()
unreachable
177: ; preds = %170
ret i32 0
}

LLVM IR (-O2):
%struct.TYPE_3__ = type { i32, i32, i8*, i32 }
@main.text_prop = internal global %struct.TYPE_3__ zeroinitializer
@.str.1 = [16 x i8] c"../tempfile.txt\00"
@.str.2 = [2 x i8] c"r\00"
@.str.4 = [2 x i8] c" \00"
@.str.5 = [14 x i8] c"COMPOUND_TEXT\00"
@Success = global i32 0
@.str.6 = [8 x i8] c"U+%04X\0A\00"
@.str.7 = [38 x i8] c" Xutf8TextPropertyToTextList ret %d\0A\00"
@.str.8 = [9 x i8] c" bytes \00"
@.str.9 = [6 x i8] c" %02X\00"
@.str.12 = [13 x i8] c" got utf8 \00"
@.str.13 = [13 x i8] c" want utf8 \00"
@.str.14 = [16 x i8] c"total count %d\0A\00"
@str = [20 x i8] c"cannot open DISPLAY\00"
@str.15 = [26 x i8] c"cannot open tempfile.utf8\00"
@str.16 = [40 x i8] c" Xutf8TextPropertyToTextList different\00"
define i32 @main() {
%1 = alloca [128 x i8]
%2 = alloca [128 x i8]
%3 = alloca i8**
%4 = alloca i32
%5 = alloca [128 x i8]
%6 = getelementptr inbounds [128 x i8], [128 x i8]* %1, i64 0, i64 0
%7 = tail call i32* @XOpenDisplay(i32* null)
%8 = icmp eq i32* %7, null
br i1 %8, label %9, label %12
9: ; preds = %0
%10 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str, i64 0, i64 0))
%11 = tail call i32 (...) @abort()
unreachable
12: ; preds = %0
%13 = tail call i32* @fopen(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%14 = icmp eq i32* %13, null
br i1 %14, label %23, label %15
15: ; preds = %12
%16 = call i64 @fgets(i8* %6, i32 128, i32* %13)
%17 = icmp eq i64 %16, 0
br i1 %17, label %136, label %18
18: ; preds = %15
%19 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 0
%20 = bitcast i8*** %3 to i8*
%21 = bitcast i32* %4 to i8*
%22 = getelementptr inbounds [128 x i8], [128 x i8]* %5, i64 0, i64 0
br label %26
23: ; preds = %12
%24 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @str.15, i64 0, i64 0))
%25 = tail call i32 (...) @abort()
unreachable
26: ; preds = %18, %133
%27 = phi i32 [ 0, %18 ], [ %28, %133 ]
%28 = add nuw nsw i32 %27, 1
%29 = call i8* @strtok(i8* %6, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%30 = call i8* @strtol(i8* nocapture %29, i32* null, i32 0)
%31 = ptrtoint i8* %30 to i64
%32 = trunc i64 %31 to i32
%33 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%34 = icmp eq i8* %33, null
br i1 %34, label %47, label %35
35: ; preds = %26, %35
%36 = phi i64 [ %41, %35 ], [ 0, %26 ]
%37 = phi i8* [ %43, %35 ], [ %33, %26 ]
%38 = call i8* @strtol(i8* nocapture %37, i32* null, i32 16)
%39 = ptrtoint i8* %38 to i64
%40 = trunc i64 %39 to i8
%41 = add nuw i64 %36, 1
%42 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 %36
store i8 %40, i8* %42
%43 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%44 = icmp eq i8* %43, null
br i1 %44, label %45, label %35
45: ; preds = %35
%46 = trunc i64 %41 to i32
br label %47
47: ; preds = %45, %26
%48 = phi i32 [ 0, %26 ], [ %46, %45 ]
%49 = zext i32 %48 to i64
%50 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 %49
store i8 0, i8* %50
%51 = call i64 @fgets(i8* %6, i32 128, i32* %13)
%52 = call i8* @strtok(i8* %6, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%53 = call i8* @strtol(i8* nocapture %52, i32* null, i32 16)
%54 = ptrtoint i8* %53 to i64
%55 = trunc i64 %54 to i8
store i8 %55, i8* %22
%56 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%57 = icmp eq i8* %56, null
br i1 %57, label %70, label %58
58: ; preds = %47, %58
%59 = phi i64 [ %64, %58 ], [ 1, %47 ]
%60 = phi i8* [ %66, %58 ], [ %56, %47 ]
%61 = call i8* @strtol(i8* nocapture %60, i32* null, i32 16)
%62 = ptrtoint i8* %61 to i64
%63 = trunc i64 %62 to i8
%64 = add nuw i64 %59, 1
%65 = getelementptr inbounds [128 x i8], [128 x i8]* %5, i64 0, i64 %59
store i8 %63, i8* %65
%66 = call i8* @strtok(i8* null, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%67 = icmp eq i8* %66, null
br i1 %67, label %68, label %58
68: ; preds = %58
%69 = trunc i64 %64 to i32
br label %70
70: ; preds = %68, %47
%71 = phi i32 [ 1, %47 ], [ %69, %68 ]
%72 = zext i32 %71 to i64
%73 = getelementptr inbounds [128 x i8], [128 x i8]* %5, i64 0, i64 %72
store i8 0, i8* %73
%74 = call i32 @XInternAtom(i32* %7, i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.5, i64 0, i64 0), i32 0)
store i32 %74, i32* getelementptr inbounds (%struct.TYPE_3__, %struct.TYPE_3__* @main.text_prop, i64 0, i32 3)
store i32 8, i32* getelementptr inbounds (%struct.TYPE_3__, %struct.TYPE_3__* @main.text_prop, i64 0, i32 0)
store i32 %48, i32* getelementptr inbounds (%struct.TYPE_3__, %struct.TYPE_3__* @main.text_prop, i64 0, i32 1)
store i8* %19, i8** getelementptr inbounds (%struct.TYPE_3__, %struct.TYPE_3__* @main.text_prop, i64 0, i32 2)
%75 = call i32 @Xutf8TextPropertyToTextList(i32* %7, %struct.TYPE_3__* @main.text_prop, i8*** %3, i32* %4)
%76 = load i32, i32* @Success
%77 = icmp eq i32 %75, %76
br i1 %77, label %91, label %78
78: ; preds = %70
%79 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.6, i64 0, i64 0), i32 %32)
%80 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([38 x i8], [38 x i8]* @.str.7, i64 0, i64 0), i32 %75)
%81 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.8, i64 0, i64 0))
%82 = icmp eq i32 %48, 0
br i1 %82, label %131, label %83
83: ; preds = %78, %83
%84 = phi i64 [ %89, %83 ], [ 0, %78 ]
%85 = getelementptr inbounds [128 x i8], [128 x i8]* %2, i64 0, i64 %84
%86 = load i8, i8* %85
%87 = zext i8 %86 to i32
%88 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.9, i64 0, i64 0), i32 %87)
%89 = add nuw nsw i64 %84, 1
%90 = icmp eq i64 %89, %49
br i1 %90, label %131, label %83
91: ; preds = %70
%92 = load i8**, i8*** %3
%93 = load i8*, i8** %92
%94 = call i64 @strcmp(i8* %22, i8* %93)
%95 = icmp eq i64 %94, 0
br i1 %95, label %133, label %96
96: ; preds = %91
%97 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.6, i64 0, i64 0), i32 %32)
%98 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @str.16, i64 0, i64 0))
%99 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.12, i64 0, i64 0))
%100 = load i8**, i8*** %3
%101 = load i8*, i8** %100
%102 = call i32 @strlen(i8* %101)
%103 = icmp sgt i32 %102, 0
br i1 %103, label %104, label %118
104: ; preds = %96, %104
%105 = phi i64 [ %112, %104 ], [ 0, %96 ]
%106 = load i8**, i8*** %3
%107 = load i8*, i8** %106
%108 = getelementptr inbounds i8, i8* %107, i64 %105
%109 = load i8, i8* %108
%110 = zext i8 %109 to i32
%111 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.9, i64 0, i64 0), i32 %110)
%112 = add nuw nsw i64 %105, 1
%113 = load i8**, i8*** %3
%114 = load i8*, i8** %113
%115 = call i32 @strlen(i8* %114)
%116 = sext i32 %115 to i64
%117 = icmp slt i64 %112, %116
br i1 %117, label %104, label %118
118: ; preds = %104, %96
%119 = call i32 @putchar(i32 10)
%120 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.13, i64 0, i64 0))
%121 = call i32 @llvm.umax.i32(i32 %71, i32 1)
%122 = zext i32 %121 to i64
br label %123
123: ; preds = %118, %123
%124 = phi i64 [ 0, %118 ], [ %129, %123 ]
%125 = getelementptr inbounds [128 x i8], [128 x i8]* %5, i64 0, i64 %124
%126 = load i8, i8* %125
%127 = zext i8 %126 to i32
%128 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.9, i64 0, i64 0), i32 %127)
%129 = add nuw nsw i64 %124, 1
%130 = icmp eq i64 %129, %122
br i1 %130, label %131, label %123
131: ; preds = %83, %123, %78
%132 = call i32 @putchar(i32 10)
br label %133
133: ; preds = %131, %91
%134 = call i64 @fgets(i8* %6, i32 128, i32* %13)
%135 = icmp eq i64 %134, 0
br i1 %135, label %136, label %26
136: ; preds = %133, %15
%137 = phi i32 [ 0, %15 ], [ %28, %133 ]
%138 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.14, i64 0, i64 0), i32 %137)
ret i32 0
}