#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;
  scalar_t__ nitems;
  int /*<<< orphan*/ encoding;
};
typedef TYPE_1__ XTextProperty;
typedef int /*<<< orphan*/ Display;

/* Variables and functions */
int /*<<< orphan*/ LC_CTYPE;
scalar_t__ Success;
int /*<<< orphan*/ XCloseDisplay(int /*<<< orphan*/ *);
char *XGetAtomName(int /*<<< orphan*/ *, int /*<<< orphan*/);
int /*<<< orphan*/ *XOpenDisplay(int /*<<< orphan*/ *);
int /*<<< orphan*/ XTextStyle;
scalar_t__ XmbTextListToTextProperty(int /*<<< orphan*/ *, char **, int,
                                     int /*<<< orphan*/, TYPE_1__ *);
int /*<<< orphan*/ assert(int);
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ setlocale(int /*<<< orphan*/, char *);
int /*<<< orphan*/ stderr;
int main(int argc, char *argv[]) {
  Display *display;
  XTextProperty textprop;
  char *input;
  if (argc != 1)
    exit(1);
  setlocale(LC_CTYPE, "");
  display = XOpenDisplay(NULL);
  if (display == NULL) {
    fprintf(stderr, "cannot open display\n");
    exit(1);
  }
  input = "";
  if (XmbTextListToTextProperty(display, &input, 1, XTextStyle, &textprop) !=
      Success) {
    fprintf(stderr, "XmbTextListToTextProperty failed\n");
    exit(1);
  }
  assert(textprop.format == 8);
  assert(textprop.nitems == 0);
  printf("%s\n", XGetAtomName(display, textprop.encoding));
  XCloseDisplay(display);
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x1,-0x8(%rbp)
je     11ba <main+0x2a>
mov    $0x1,%edi
call   10a0 <exit@plt>
mov    0x2e1f(%rip),%rax
mov    (%rax),%edi
lea    0xe6c(%rip),%rsi
call   1090 <setlocale@plt>
xor    %eax,%eax
mov    %eax,%edi
call   1050 <XOpenDisplay@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1206 <main+0x76>
mov    0x2dda(%rip),%rax
mov    (%rax),%edi
lea    0xe09(%rip),%rsi
call   1070 <fprintf@plt>
mov    $0x1,%edi
call   10a0 <exit@plt>
lea    0xe29(%rip),%rax
mov    %rax,-0x38(%rbp)
mov    -0x18(%rbp),%rdi
mov    0x2dbc(%rip),%rax
mov    (%rax),%ecx
lea    -0x38(%rbp),%rsi
mov    $0x1,%edx
lea    -0x30(%rbp),%r8
call   1030 <XmbTextListToTextProperty@plt>
mov    0x2dc1(%rip),%rcx
cmp    (%rcx),%rax
je     125f <main+0xcf>
mov    0x2d81(%rip),%rax
mov    (%rax),%edi
lea    0xdc5(%rip),%rsi
call   1070 <fprintf@plt>
mov    $0x1,%edi
call   10a0 <exit@plt>
cmpl   $0x8,-0x30(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
cmpq   $0x0,-0x28(%rbp)
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1060 <assert@plt>
mov    -0x18(%rbp),%rdi
mov    -0x20(%rbp),%esi
call   1080 <XGetAtomName@plt>
mov    %rax,%rsi
lea    0xd9f(%rip),%rdi
call   1040 <printf@plt>
mov    -0x18(%rbp),%rdi
call   10b0 <XCloseDisplay@plt>
xor    %edi,%edi
call   10a0 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
sub    $0x28,%rsp
cmp    $0x1,%edi
jne    11d5 <main+0x45>
mov    0x2e3d(%rip),%rax
mov    (%rax),%edi
lea    0xe8a(%rip),%r14
mov    %r14,%rsi
call   1090 <setlocale@plt>
xor    %edi,%edi
call   1050 <XOpenDisplay@plt>
test   %rax,%rax
jne    11df <main+0x4f>
mov    0x2e01(%rip),%rax
mov    (%rax),%edi
lea    0xe30(%rip),%rsi
jmp    126e <main+0xde>
mov    $0x1,%edi
call   10a0 <exit@plt>
mov    %rax,%rbx
mov    %r14,0x8(%rsp)
mov    0x2dea(%rip),%rax
mov    (%rax),%ecx
lea    0x8(%rsp),%rsi
lea    0x10(%rsp),%r8
mov    %rbx,%rdi
mov    $0x1,%edx
call   1030 <XmbTextListToTextProperty@plt>
mov    0x2dea(%rip),%rcx
cmp    (%rcx),%rax
jne    125e <main+0xce>
xor    %edi,%edi
cmpl   $0x8,0x10(%rsp)
sete   %dil
call   1060 <assert@plt>
xor    %edi,%edi
cmpq   $0x0,0x18(%rsp)
sete   %dil
call   1060 <assert@plt>
mov    0x20(%rsp),%esi
mov    %rbx,%rdi
call   1080 <XGetAtomName@plt>
lea    0xdf0(%rip),%rdi
mov    %rax,%rsi
call   1040 <printf@plt>
mov    %rbx,%rdi
call   10b0 <XCloseDisplay@plt>
xor    %edi,%edi
call   10a0 <exit@plt>
mov    0x2d63(%rip),%rax
mov    (%rax),%edi
lea    0xda7(%rip),%rsi
call   1070 <fprintf@plt>
mov    $0x1,%edi
call   10a0 <exit@plt>

LLVM IR (-O0):
%struct.TYPE_3__ = type { i32, i64, i32 }
@LC_CTYPE = global i32 0
@.str = [1 x i8] zeroinitializer
@stderr = global i32 0
@.str.1 = [21 x i8] c"cannot open display\0A\00"
@XTextStyle = global i32 0
@Success = global i64 0
@.str.2 = [34 x i8] c"XmbTextListToTextProperty failed\0A\00"
@.str.3 = [4 x i8] c"%s\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca %struct.TYPE_3__
%8 = alloca i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = load i32, i32* %4
%10 = icmp ne i32 %9, 1
br i1 %10, label %11, label %13
11: ; preds = %2
%12 = call i32 @exit(i32 1)
unreachable
13: ; preds = %2
%14 = load i32, i32* @LC_CTYPE
%15 = call i32 @setlocale(i32 %14, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
%16 = call i32* @XOpenDisplay(i32* null)
store i32* %16, i32** %6
%17 = load i32*, i32** %6
%18 = icmp eq i32* %17, null
br i1 %18, label %19, label %23
19: ; preds = %13
%20 = load i32, i32* @stderr
%21 = call i32 @fprintf(i32 %20, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0))
%22 = call i32 @exit(i32 1)
unreachable
23: ; preds = %13
store i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0), i8** %8
%24 = load i32*, i32** %6
%25 = load i32, i32* @XTextStyle
%26 = call i64 @XmbTextListToTextProperty(i32* %24, i8** %8, i32 1, i32 %25, %struct.TYPE_3__* %7)
%27 = load i64, i64* @Success
%28 = icmp ne i64 %26, %27
br i1 %28, label %29, label %33
29: ; preds = %23
%30 = load i32, i32* @stderr
%31 = call i32 @fprintf(i32 %30, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.2, i64 0, i64 0))
%32 = call i32 @exit(i32 1)
unreachable
33: ; preds = %23
%34 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %7, i32 0, i32 0
%35 = load i32, i32* %34
%36 = icmp eq i32 %35, 8
%37 = zext i1 %36 to i32
%38 = call i32 @assert(i32 %37)
%39 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %7, i32 0, i32 1
%40 = load i64, i64* %39
%41 = icmp eq i64 %40, 0
%42 = zext i1 %41 to i32
%43 = call i32 @assert(i32 %42)
%44 = load i32*, i32** %6
%45 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %7, i32 0, i32 2
%46 = load i32, i32* %45
%47 = call i8* @XGetAtomName(i32* %44, i32 %46)
%48 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* %47)
%49 = load i32*, i32** %6
%50 = call i32 @XCloseDisplay(i32* %49)
%51 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
%struct.TYPE_3__ = type { i32, i64, i32 }
@LC_CTYPE = global i32 0
@.str = [1 x i8] zeroinitializer
@stderr = global i32 0
@.str.1 = [21 x i8] c"cannot open display\0A\00"
@XTextStyle = global i32 0
@Success = global i64 0
@.str.2 = [34 x i8] c"XmbTextListToTextProperty failed\0A\00"
@.str.3 = [4 x i8] c"%s\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca %struct.TYPE_3__
%4 = alloca i8*
%5 = bitcast %struct.TYPE_3__* %3 to i8*
%6 = bitcast i8** %4 to i8*
%7 = icmp eq i32 %0, 1
br i1 %7, label %10, label %8
8: ; preds = %2
%9 = tail call i32 @exit(i32 1)
unreachable
10: ; preds = %2
%11 = load i32, i32* @LC_CTYPE
%12 = tail call i32 @setlocale(i32 %11, i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0))
%13 = tail call i32* @XOpenDisplay(i32* null)
%14 = icmp eq i32* %13, null
br i1 %14, label %15, label %19
15: ; preds = %10
%16 = load i32, i32* @stderr
%17 = tail call i32 @fprintf(i32 %16, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0))
%18 = tail call i32 @exit(i32 1)
unreachable
19: ; preds = %10
store i8* getelementptr inbounds ([1 x i8], [1 x i8]* @.str, i64 0, i64 0), i8** %4
%20 = load i32, i32* @XTextStyle
%21 = call i64 @XmbTextListToTextProperty(i32* %13, i8** %4, i32 1, i32 %20, %struct.TYPE_3__* %3)
%22 = load i64, i64* @Success
%23 = icmp eq i64 %21, %22
br i1 %23, label %28, label %24
24: ; preds = %19
%25 = load i32, i32* @stderr
%26 = call i32 @fprintf(i32 %25, i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.2, i64 0, i64 0))
%27 = call i32 @exit(i32 1)
unreachable
28: ; preds = %19
%29 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %3, i64 0, i32 0
%30 = load i32, i32* %29
%31 = icmp eq i32 %30, 8
%32 = zext i1 %31 to i32
%33 = call i32 @assert(i32 %32)
%34 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %3, i64 0, i32 1
%35 = load i64, i64* %34
%36 = icmp eq i64 %35, 0
%37 = zext i1 %36 to i32
%38 = call i32 @assert(i32 %37)
%39 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %3, i64 0, i32 2
%40 = load i32, i32* %39
%41 = call i8* @XGetAtomName(i32* %13, i32 %40)
%42 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i8* %41)
%43 = call i32 @XCloseDisplay(i32* %13)
%44 = call i32 @exit(i32 0)
unreachable
}