#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_9__ TYPE_3__;
typedef struct TYPE_8__ TYPE_2__;
typedef struct TYPE_7__ TYPE_1__;

/* Type definitions */
typedef int /*<<< orphan*/ XtPointer;
typedef TYPE_2__ *XrmValuePtr;
typedef int /*<<< orphan*/ *XPointer;
typedef TYPE_3__ *Widget;
struct TYPE_7__ {
  int /*<<< orphan*/ xrm_name;
};
struct TYPE_9__ {
  TYPE_1__ core;
};
struct TYPE_8__ {
  scalar_t__ size;
  int /*<<< orphan*/ *addr;
};
typedef char *String;
typedef int /*<<< orphan*/ Display;
typedef scalar_t__ Cardinal;
typedef int /*<<< orphan*/ Boolean;

/* Variables and functions */
int /*<<< orphan*/ False;
int /*<<< orphan*/ True;
char *XrmQuarkToString(int /*<<< orphan*/);
int /*<<< orphan*/ strcpy(char *, char *);
scalar_t__ strlen(char *);
Boolean XmuCvtWidgetToString(Display *dpy, XrmValuePtr args, Cardinal *num_args,
                             XrmValuePtr fromVal, XrmValuePtr toVal,
                             XtPointer *data) {
  static String buffer;
  Cardinal size;
  Widget widget;
  widget = *(Widget *)fromVal->addr;
  if (widget)
    buffer = XrmQuarkToString(widget->core.xrm_name);
  else
    buffer = "(null)";
  size = strlen(buffer) + 1;
  if (toVal->addr != NULL) {
    if (toVal->size < size) {
      toVal->size = size;
      return (False);
    }
    strcpy((char *)toVal->addr, buffer);
  } else
    toVal->addr = (XPointer)buffer;
  toVal->size = sizeof(String);
  return (True);
}


x86 assembly (clang, -O0):
<XmuCvtWidgetToString>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %rdx,-0x20(%rbp)
mov    %rcx,-0x28(%rbp)
mov    %r8,-0x30(%rbp)
mov    %r9,-0x38(%rbp)
mov    -0x28(%rbp),%rax
mov    0x8(%rax),%rax
mov    (%rax),%rax
mov    %rax,-0x48(%rbp)
cmpq   $0x0,-0x48(%rbp)
je     1181 <XmuCvtWidgetToString+0x51>
mov    -0x48(%rbp),%rax
mov    (%rax),%edi
call   1030 <XrmQuarkToString@plt>
mov    %rax,0x2ec4(%rip)
jmp    118f <XmuCvtWidgetToString+0x5f>
lea    0xe78(%rip),%rax
mov    %rax,0x2eb1(%rip)
mov    0x2eaa(%rip),%rdi
call   1050 <strlen@plt>
add    $0x1,%rax
mov    %rax,-0x40(%rbp)
mov    -0x30(%rbp),%rax
cmpq   $0x0,0x8(%rax)
je     11f8 <XmuCvtWidgetToString+0xc8>
mov    -0x30(%rbp),%rax
mov    (%rax),%rax
cmp    -0x40(%rbp),%rax
jge    11df <XmuCvtWidgetToString+0xaf>
mov    -0x40(%rbp),%rcx
mov    -0x30(%rbp),%rax
mov    %rcx,(%rax)
mov    0x2e13(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    121e <XmuCvtWidgetToString+0xee>
mov    -0x30(%rbp),%rax
mov    0x8(%rax),%rdi
mov    0x2e52(%rip),%rsi
call   1040 <strcpy@plt>
jmp    1207 <XmuCvtWidgetToString+0xd7>
mov    0x2e41(%rip),%rcx
mov    -0x30(%rbp),%rax
mov    %rcx,0x8(%rax)
mov    -0x30(%rbp),%rax
movq   $0x8,(%rax)
mov    0x2dc7(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<XmuCvtWidgetToString>:
push   %r14
push   %rbx
push   %rax
mov    %r8,%r14
mov    0x8(%rcx),%rax
mov    (%rax),%rax
test   %rax,%rax
je     114f <XmuCvtWidgetToString+0x1f>
mov    (%rax),%edi
call   1030 <XrmQuarkToString@plt>
mov    %rax,%rbx
jmp    1156 <XmuCvtWidgetToString+0x26>
lea    0xeaa(%rip),%rbx
mov    %rbx,0x2ee3(%rip)
mov    %rbx,%rdi
call   1050 <strlen@plt>
mov    0x8(%r14),%rdi
test   %rdi,%rdi
je     117d <XmuCvtWidgetToString+0x4d>
cmp    %rax,(%r14)
jle    1191 <XmuCvtWidgetToString+0x61>
mov    %rbx,%rsi
call   1040 <strcpy@plt>
jmp    1181 <XmuCvtWidgetToString+0x51>
mov    %rbx,0x8(%r14)
movq   $0x8,(%r14)
mov    0x2e51(%rip),%rax
jmp    119f <XmuCvtWidgetToString+0x6f>
add    $0x1,%rax
mov    %rax,(%r14)
mov    0x2e49(%rip),%rax
mov    (%rax),%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.TYPE_8__ = type { i64, i32* }
%struct.TYPE_9__ = type { %struct.TYPE_7__ }
%struct.TYPE_7__ = type { i32 }
@XmuCvtWidgetToString.buffer = internal global i8* null
@.str = [7 x i8] c"(null)\00"
@False = global i32 0
@True = global i32 0
define i32 @XmuCvtWidgetToString(i32* %0, %struct.TYPE_8__* %1, i64* %2, %struct.TYPE_8__* %3, %struct.TYPE_8__* %4, i32* %5) {
%7 = alloca i32
%8 = alloca i32*
%9 = alloca %struct.TYPE_8__*
%10 = alloca i64*
%11 = alloca %struct.TYPE_8__*
%12 = alloca %struct.TYPE_8__*
%13 = alloca i32*
%14 = alloca i64
%15 = alloca %struct.TYPE_9__*
store i32* %0, i32** %8
store %struct.TYPE_8__* %1, %struct.TYPE_8__** %9
store i64* %2, i64** %10
store %struct.TYPE_8__* %3, %struct.TYPE_8__** %11
store %struct.TYPE_8__* %4, %struct.TYPE_8__** %12
store i32* %5, i32** %13
%16 = load %struct.TYPE_8__*, %struct.TYPE_8__** %11
%17 = getelementptr inbounds %struct.TYPE_8__, %struct.TYPE_8__* %16, i32 0, i32 1
%18 = load i32*, i32** %17
%19 = bitcast i32* %18 to %struct.TYPE_9__**
%20 = load %struct.TYPE_9__*, %struct.TYPE_9__** %19
store %struct.TYPE_9__* %20, %struct.TYPE_9__** %15
%21 = load %struct.TYPE_9__*, %struct.TYPE_9__** %15
%22 = icmp ne %struct.TYPE_9__* %21, null
br i1 %22, label %23, label %29
23: ; preds = %6
%24 = load %struct.TYPE_9__*, %struct.TYPE_9__** %15
%25 = getelementptr inbounds %struct.TYPE_9__, %struct.TYPE_9__* %24, i32 0, i32 0
%26 = getelementptr inbounds %struct.TYPE_7__, %struct.TYPE_7__* %25, i32 0, i32 0
%27 = load i32, i32* %26
%28 = call i8* @XrmQuarkToString(i32 %27)
store i8* %28, i8** @XmuCvtWidgetToString.buffer
br label %30
29: ; preds = %6
store i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i8** @XmuCvtWidgetToString.buffer
br label %30
30: ; preds = %29, %23
%31 = load i8*, i8** @XmuCvtWidgetToString.buffer
%32 = call i64 @strlen(i8* %31)
%33 = add nsw i64 %32, 1
store i64 %33, i64* %14
%34 = load %struct.TYPE_8__*, %struct.TYPE_8__** %12
%35 = getelementptr inbounds %struct.TYPE_8__, %struct.TYPE_8__* %34, i32 0, i32 1
%36 = load i32*, i32** %35
%37 = icmp ne i32* %36, null
br i1 %37, label %38, label %56
38: ; preds = %30
%39 = load %struct.TYPE_8__*, %struct.TYPE_8__** %12
%40 = getelementptr inbounds %struct.TYPE_8__, %struct.TYPE_8__* %39, i32 0, i32 0
%41 = load i64, i64* %40
%42 = load i64, i64* %14
%43 = icmp slt i64 %41, %42
br i1 %43, label %44, label %49
44: ; preds = %38
%45 = load i64, i64* %14
%46 = load %struct.TYPE_8__*, %struct.TYPE_8__** %12
%47 = getelementptr inbounds %struct.TYPE_8__, %struct.TYPE_8__* %46, i32 0, i32 0
store i64 %45, i64* %47
%48 = load i32, i32* @False
store i32 %48, i32* %7
br label %65
49: ; preds = %38
%50 = load %struct.TYPE_8__*, %struct.TYPE_8__** %12
%51 = getelementptr inbounds %struct.TYPE_8__, %struct.TYPE_8__* %50, i32 0, i32 1
%52 = load i32*, i32** %51
%53 = bitcast i32* %52 to i8*
%54 = load i8*, i8** @XmuCvtWidgetToString.buffer
%55 = call i32 @strcpy(i8* %53, i8* %54)
br label %61
56: ; preds = %30
%57 = load i8*, i8** @XmuCvtWidgetToString.buffer
%58 = bitcast i8* %57 to i32*
%59 = load %struct.TYPE_8__*, %struct.TYPE_8__** %12
%60 = getelementptr inbounds %struct.TYPE_8__, %struct.TYPE_8__* %59, i32 0, i32 1
store i32* %58, i32** %60
br label %61
61: ; preds = %56, %49
%62 = load %struct.TYPE_8__*, %struct.TYPE_8__** %12
%63 = getelementptr inbounds %struct.TYPE_8__, %struct.TYPE_8__* %62, i32 0, i32 0
store i64 8, i64* %63
%64 = load i32, i32* @True
store i32 %64, i32* %7
br label %65
65: ; preds = %61, %44
%66 = load i32, i32* %7
ret i32 %66
}

LLVM IR (-O2):
%struct.TYPE_8__ = type { i64, i32* }
%struct.TYPE_9__ = type { %struct.TYPE_7__ }
%struct.TYPE_7__ = type { i32 }
@XmuCvtWidgetToString.buffer = internal unnamed_addr global i8* null
@.str = [7 x i8] c"(null)\00"
@False = global i32 0
@True = global i32 0
define i32 @XmuCvtWidgetToString(i32* nocapture readnone %0, %struct.TYPE_8__* nocapture readnone %1, i64* nocapture readnone %2, %struct.TYPE_8__* nocapture %3, %struct.TYPE_8__* nocapture %4, i32* nocapture readnone %5) {
%7 = getelementptr inbounds %struct.TYPE_8__, %struct.TYPE_8__* %3, i64 0, i32 1
%8 = bitcast i32** %7 to %struct.TYPE_9__***
%9 = load %struct.TYPE_9__**, %struct.TYPE_9__*** %8
%10 = load %struct.TYPE_9__*, %struct.TYPE_9__** %9
%11 = icmp eq %struct.TYPE_9__* %10, null
br i1 %11, label %16, label %12
12: ; preds = %6
%13 = getelementptr inbounds %struct.TYPE_9__, %struct.TYPE_9__* %10, i64 0, i32 0, i32 0
%14 = load i32, i32* %13
%15 = tail call i8* @XrmQuarkToString(i32 %14)
br label %16
16: ; preds = %6, %12
%17 = phi i8* [ %15, %12 ], [ getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), %6 ]
store i8* %17, i8** @XmuCvtWidgetToString.buffer
%18 = tail call i64 @strlen(i8* dereferenceable(1) %17)
%19 = add nsw i64 %18, 1
%20 = getelementptr inbounds %struct.TYPE_8__, %struct.TYPE_8__* %4, i64 0, i32 1
%21 = load i32*, i32** %20
%22 = icmp eq i32* %21, null
br i1 %22, label %31, label %23
23: ; preds = %16
%24 = getelementptr inbounds %struct.TYPE_8__, %struct.TYPE_8__* %4, i64 0, i32 0
%25 = load i64, i64* %24
%26 = icmp sgt i64 %25, %18
br i1 %26, label %28, label %27
27: ; preds = %23
store i64 %19, i64* %24
br label %35
28: ; preds = %23
%29 = bitcast i32* %21 to i8*
%30 = tail call i32 @strcpy(i8* %29, i8* %17)
br label %33
31: ; preds = %16
%32 = bitcast i32** %20 to i8**
store i8* %17, i8** %32
br label %33
33: ; preds = %31, %28
%34 = getelementptr inbounds %struct.TYPE_8__, %struct.TYPE_8__* %4, i64 0, i32 0
store i64 8, i64* %34
br label %35
35: ; preds = %33, %27
%36 = phi i32* [ @False, %27 ], [ @True, %33 ]
%37 = load i32, i32* %36
ret i32 %37
}