#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_5__ TYPE_1__;

/* Type definitions */
typedef int /*<<< orphan*/ XTextProperty;
struct TYPE_5__ {
  char *res_name;
  char *res_class;
};
typedef TYPE_1__ XClassHint;
typedef int /*<<< orphan*/ Window;
typedef int /*<<< orphan*/ Display;

/* Variables and functions */
TYPE_1__ *XAllocClassHint();
int /*<<< orphan*/ XFree(TYPE_1__ *);
int /*<<< orphan*/ XSetWMProperties(int /*<<< orphan*/ *, int /*<<< orphan*/,
                                    int /*<<< orphan*/ *, int /*<<< orphan*/ *,
                                    char **, int, int /*<<< orphan*/ *,
                                    int /*<<< orphan*/ *, TYPE_1__ *);
int /*<<< orphan*/ XStringListToTextProperty(char **, int,
                                             int /*<<< orphan*/ *);
void SetWMProperties(Display *dpy, Window w, const char *res_class,
                     const char *res_name, int argc, char *const *argv) {
  XClassHint *class_hint = XAllocClassHint();
  class_hint->res_name = (char *)res_name;
  class_hint->res_class = (char *)res_class;
  XTextProperty name_prop;
  XStringListToTextProperty((char **)&res_name, 1, &name_prop);
  XSetWMProperties(dpy, w, &name_prop, &name_prop, (char **)argv, argc, NULL,
                   NULL, class_hint);
  XFree(class_hint);
}


x86 assembly (clang, -O0):
<SetWMProperties>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8d,-0x24(%rbp)
mov    %r9,-0x30(%rbp)
mov    $0x0,%al
call   1030 <XAllocClassHint@plt>
mov    %rax,-0x38(%rbp)
mov    -0x20(%rbp),%rcx
mov    -0x38(%rbp),%rax
mov    %rcx,(%rax)
mov    -0x18(%rbp),%rcx
mov    -0x38(%rbp),%rax
mov    %rcx,0x8(%rax)
lea    -0x20(%rbp),%rdi
mov    $0x1,%esi
lea    -0x3c(%rbp),%rdx
call   1060 <XStringListToTextProperty@plt>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x30(%rbp),%r8
mov    -0x24(%rbp),%r9d
mov    -0x38(%rbp),%rax
lea    -0x3c(%rbp),%rcx
xor    %edx,%edx
mov    %rcx,%rdx
movq   $0x0,(%rsp)
movq   $0x0,0x8(%rsp)
mov    %rax,0x10(%rsp)
call   1040 <XSetWMProperties@plt>
mov    -0x38(%rbp),%rdi
call   1050 <XFree@plt>
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<SetWMProperties>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    %r9,0x20(%rsp)
mov    %r8d,%r15d
mov    %rcx,%rbx
mov    %rdx,%rbp
mov    %esi,%r12d
mov    %rdi,%r13
mov    %rcx,0x28(%rsp)
xor    %eax,%eax
call   1030 <XAllocClassHint@plt>
mov    %rax,%r14
mov    %rbx,(%rax)
mov    %rbp,0x8(%rax)
lea    0x28(%rsp),%rdi
lea    0x34(%rsp),%rbx
mov    $0x1,%esi
mov    %rbx,%rdx
call   1060 <XStringListToTextProperty@plt>
mov    %r14,0x10(%rsp)
xorps  %xmm0,%xmm0
movups %xmm0,(%rsp)
mov    %r13,%rdi
mov    %r12d,%esi
mov    %rbx,%rdx
mov    %rbx,%rcx
mov    0x20(%rsp),%r8
mov    %r15d,%r9d
call   1040 <XSetWMProperties@plt>
mov    %r14,%rdi
call   1050 <XFree@plt>
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.TYPE_5__ = type { i8*, i8* }
define void @SetWMProperties(i32* %0, i32 %1, i8* %2, i8* %3, i32 %4, i8** %5) {
%7 = alloca i32*
%8 = alloca i32
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i32
%12 = alloca i8**
%13 = alloca %struct.TYPE_5__*
%14 = alloca i32
store i32* %0, i32** %7
store i32 %1, i32* %8
store i8* %2, i8** %9
store i8* %3, i8** %10
store i32 %4, i32* %11
store i8** %5, i8*** %12
%15 = call %struct.TYPE_5__* (...) @XAllocClassHint()
store %struct.TYPE_5__* %15, %struct.TYPE_5__** %13
%16 = load i8*, i8** %10
%17 = load %struct.TYPE_5__*, %struct.TYPE_5__** %13
%18 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %17, i32 0, i32 0
store i8* %16, i8** %18
%19 = load i8*, i8** %9
%20 = load %struct.TYPE_5__*, %struct.TYPE_5__** %13
%21 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %20, i32 0, i32 1
store i8* %19, i8** %21
%22 = call i32 @XStringListToTextProperty(i8** %10, i32 1, i32* %14)
%23 = load i32*, i32** %7
%24 = load i32, i32* %8
%25 = load i8**, i8*** %12
%26 = load i32, i32* %11
%27 = load %struct.TYPE_5__*, %struct.TYPE_5__** %13
%28 = call i32 @XSetWMProperties(i32* %23, i32 %24, i32* %14, i32* %14, i8** %25, i32 %26, i32* null, i32* null, %struct.TYPE_5__* %27)
%29 = load %struct.TYPE_5__*, %struct.TYPE_5__** %13
%30 = call i32 @XFree(%struct.TYPE_5__* %29)
ret void
}

LLVM IR (-O2):
%struct.TYPE_5__ = type { i8*, i8* }
define void @SetWMProperties(i32* %0, i32 %1, i8* %2, i8* %3, i32 %4, i8** %5) {
%7 = alloca i8*
%8 = alloca i32
store i8* %3, i8** %7
%9 = tail call %struct.TYPE_5__* (...) @XAllocClassHint()
%10 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %9, i64 0, i32 0
store i8* %3, i8** %10
%11 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %9, i64 0, i32 1
store i8* %2, i8** %11
%12 = bitcast i32* %8 to i8*
%13 = call i32 @XStringListToTextProperty(i8** %7, i32 1, i32* %8)
%14 = call i32 @XSetWMProperties(i32* %0, i32 %1, i32* %8, i32* %8, i8** %5, i32 %4, i32* null, i32* null, %struct.TYPE_5__* %9)
%15 = call i32 @XFree(%struct.TYPE_5__* %9)
ret void
}