#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_7__ TYPE_3__;
typedef struct TYPE_6__ TYPE_2__;
typedef struct TYPE_5__ TYPE_1__;

/* Type definitions */
struct TYPE_6__ {
  int format;
  int /*<<< orphan*/ message_type;
  scalar_t__ window;
  int /*<<< orphan*/ *display;
};
struct TYPE_5__ {
  int /*<<< orphan*/ type;
};
struct TYPE_7__ {
  TYPE_2__ xclient;
  TYPE_1__ xany;
};
typedef TYPE_3__ XEvent;
typedef scalar_t__ Window;
typedef int /*<<< orphan*/ Display;

/* Variables and functions */
int /*<<< orphan*/ ClientMessage;
int /*<<< orphan*/ ExecExternalApplication(int /*<<< orphan*/ *, int, int,
                                           char *, char *, char *, char *,
                                           char *);
int /*<<< orphan*/ False;
scalar_t__ FindSomeIconWin(int /*<<< orphan*/ *);
int /*<<< orphan*/ MakeAtoms(int /*<<< orphan*/ *);
int /*<<< orphan*/ XInternAtom(int /*<<< orphan*/ *, char *,
                               int /*<<< orphan*/);
int /*<<< orphan*/ XSendEvent(int /*<<< orphan*/ *, scalar_t__,
                              int /*<<< orphan*/, long, TYPE_3__ *);
int /*<<< orphan*/ XStoreBuffer(int /*<<< orphan*/ *, char *, scalar_t__, int);
int /*<<< orphan*/ sprintf(char *, char *, int);
scalar_t__ strlen(char *);
void ExternalApplication(Display *dpy, int x, int y, char *label, char *icon,
                         char *cmd, char *drop, char *dir) {
  char X[20], Y[20];
  Window tycoonwin;
  XEvent event;
  MakeAtoms(dpy);
  tycoonwin = FindSomeIconWin(dpy);
  if (tycoonwin == 0) {
    ExecExternalApplication(dpy, x, y, label, icon, cmd, drop, dir);
    return;
  }
  sprintf(X, "%i", x);
  sprintf(Y, "%i", y);
  XStoreBuffer(dpy, X, strlen(X) + 1, 1);
  XStoreBuffer(dpy, Y, strlen(Y) + 1, 2);
  XStoreBuffer(dpy, label, strlen(label) + 1, 3);
  XStoreBuffer(dpy, icon, strlen(icon) + 1, 4);
  XStoreBuffer(dpy, cmd, strlen(cmd) + 1, 5);
  XStoreBuffer(dpy, drop, strlen(drop) + 1, 6);
  event.xany.type = ClientMessage;
  event.xclient.display = dpy;
  event.xclient.window = tycoonwin;
  event.xclient.format = 32;
  event.xclient.message_type = XInternAtom(dpy, "_ADD_ICON", False);
  XSendEvent(dpy, tycoonwin, False, 0L, &event);
}


x86 assembly (clang, -O0):
<ExternalApplication>:
push   %rbp
mov    %rsp,%rbp
sub    $0x100,%rsp
mov    0x18(%rbp),%rax
mov    0x10(%rbp),%rax
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %rcx,-0x18(%rbp)
mov    %r8,-0x20(%rbp)
mov    %r9,-0x28(%rbp)
mov    -0x8(%rbp),%rdi
call   1070 <MakeAtoms@plt>
mov    -0x8(%rbp),%rdi
call   1060 <FindSomeIconWin@plt>
mov    %rax,-0x68(%rbp)
cmpq   $0x0,-0x68(%rbp)
jne    11fb <ExternalApplication+0x7b>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    -0x18(%rbp),%rcx
mov    -0x20(%rbp),%r8
mov    -0x28(%rbp),%r9
mov    0x10(%rbp),%r10
mov    0x18(%rbp),%rax
mov    %r10,(%rsp)
mov    %rax,0x8(%rsp)
call   1080 <ExecExternalApplication@plt>
jmp    13fb <ExternalApplication+0x27b>
lea    -0x40(%rbp),%rdi
mov    -0xc(%rbp),%edx
lea    0xdf7(%rip),%rsi
call   10a0 <sprintf@plt>
lea    -0x60(%rbp),%rdi
mov    -0x10(%rbp),%edx
lea    0xde4(%rip),%rsi
call   10a0 <sprintf@plt>
mov    -0x8(%rbp),%rax
mov    %rax,-0xe8(%rbp)
lea    -0x40(%rbp),%rax
mov    %rax,-0xe0(%rbp)
lea    -0x40(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0xe8(%rbp),%rdi
mov    -0xe0(%rbp),%rsi
mov    %rax,%rdx
add    $0x1,%rdx
mov    $0x1,%ecx
call   1050 <XStoreBuffer@plt>
mov    -0x8(%rbp),%rax
mov    %rax,-0xd8(%rbp)
lea    -0x60(%rbp),%rax
mov    %rax,-0xd0(%rbp)
lea    -0x60(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0xd8(%rbp),%rdi
mov    -0xd0(%rbp),%rsi
mov    %rax,%rdx
add    $0x1,%rdx
mov    $0x2,%ecx
call   1050 <XStoreBuffer@plt>
mov    -0x8(%rbp),%rax
mov    %rax,-0xc8(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0xc0(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0xc8(%rbp),%rdi
mov    -0xc0(%rbp),%rsi
mov    %rax,%rdx
add    $0x1,%rdx
mov    $0x3,%ecx
call   1050 <XStoreBuffer@plt>
mov    -0x8(%rbp),%rax
mov    %rax,-0xb8(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0xb0(%rbp)
mov    -0x20(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0xb8(%rbp),%rdi
mov    -0xb0(%rbp),%rsi
mov    %rax,%rdx
add    $0x1,%rdx
mov    $0x4,%ecx
call   1050 <XStoreBuffer@plt>
mov    -0x8(%rbp),%rax
mov    %rax,-0xa8(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,-0xa0(%rbp)
mov    -0x28(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0xa8(%rbp),%rdi
mov    -0xa0(%rbp),%rsi
mov    %rax,%rdx
add    $0x1,%rdx
mov    $0x5,%ecx
call   1050 <XStoreBuffer@plt>
mov    -0x8(%rbp),%rax
mov    %rax,-0x98(%rbp)
mov    0x10(%rbp),%rax
mov    %rax,-0x90(%rbp)
mov    0x10(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x98(%rbp),%rdi
mov    -0x90(%rbp),%rsi
mov    %rax,%rdx
add    $0x1,%rdx
mov    $0x6,%ecx
call   1050 <XStoreBuffer@plt>
mov    0x2c44(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x70(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x78(%rbp)
mov    -0x68(%rbp),%rax
mov    %rax,-0x80(%rbp)
movl   $0x20,-0x88(%rbp)
mov    -0x8(%rbp),%rdi
mov    0x2c22(%rip),%rax
mov    (%rax),%edx
lea    0xc34(%rip),%rsi
call   1090 <XInternAtom@plt>
mov    %eax,-0x84(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x68(%rbp),%rsi
mov    0x2bff(%rip),%rax
mov    (%rax),%edx
xor    %eax,%eax
mov    %eax,%ecx
lea    -0x88(%rbp),%r8
call   1030 <XSendEvent@plt>
add    $0x100,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ExternalApplication>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x88,%rsp
mov    %r9,%r14
mov    %r8,%r13
mov    %rcx,0x8(%rsp)
mov    %edx,%r15d
mov    %esi,%r12d
mov    %rdi,%rbx
mov    0xc0(%rsp),%rbp
call   1070 <MakeAtoms@plt>
mov    %rbx,%rdi
call   1060 <FindSomeIconWin@plt>
test   %rax,%rax
je     1328 <ExternalApplication+0x1a8>
mov    %rbp,0x20(%rsp)
mov    %r14,0x18(%rsp)
lea    0xe2c(%rip),%r14
mov    %r13,0x10(%rsp)
lea    0x70(%rsp),%r13
mov    %r13,%rdi
mov    %r14,%rsi
mov    %r12d,%edx
mov    %rax,0x28(%rsp)
call   10a0 <sprintf@plt>
lea    0x50(%rsp),%r12
mov    %r12,%rdi
mov    %r14,%rsi
mov    %r15d,%edx
call   10a0 <sprintf@plt>
mov    %r13,%rdi
call   1040 <strlen@plt>
lea    0x1(%rax),%rdx
mov    %rbx,%rdi
mov    %r13,%rsi
mov    $0x1,%ecx
call   1050 <XStoreBuffer@plt>
mov    %r12,%rdi
call   1040 <strlen@plt>
lea    0x1(%rax),%rdx
mov    %rbx,%rdi
mov    %r12,%rsi
mov    $0x2,%ecx
call   1050 <XStoreBuffer@plt>
mov    0x8(%rsp),%rbp
mov    %rbp,%rdi
call   1040 <strlen@plt>
lea    0x1(%rax),%rdx
mov    %rbx,%rdi
mov    %rbp,%rsi
mov    $0x3,%ecx
call   1050 <XStoreBuffer@plt>
mov    0x10(%rsp),%rbp
mov    %rbp,%rdi
call   1040 <strlen@plt>
lea    0x1(%rax),%rdx
mov    %rbx,%rdi
mov    %rbp,%rsi
mov    $0x4,%ecx
call   1050 <XStoreBuffer@plt>
mov    0x18(%rsp),%rbp
mov    %rbp,%rdi
call   1040 <strlen@plt>
lea    0x1(%rax),%rdx
mov    %rbx,%rdi
mov    %rbp,%rsi
mov    $0x5,%ecx
call   1050 <XStoreBuffer@plt>
mov    0x20(%rsp),%rbp
mov    %rbp,%rdi
call   1040 <strlen@plt>
lea    0x1(%rax),%rdx
mov    %rbx,%rdi
mov    %rbp,%rsi
mov    $0x6,%ecx
call   1050 <XStoreBuffer@plt>
mov    0x2d19(%rip),%rax
mov    (%rax),%eax
mov    %eax,0x48(%rsp)
mov    %rbx,0x40(%rsp)
mov    0x28(%rsp),%rbp
mov    %rbp,0x38(%rsp)
movl   $0x20,0x30(%rsp)
mov    0x2cfd(%rip),%r14
mov    (%r14),%edx
lea    0xd0e(%rip),%rsi
mov    %rbx,%rdi
call   1090 <XInternAtom@plt>
mov    %eax,0x34(%rsp)
mov    (%r14),%edx
lea    0x30(%rsp),%r8
mov    %rbx,%rdi
mov    %rbp,%rsi
xor    %ecx,%ecx
call   1030 <XSendEvent@plt>
add    $0x88,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %rbx,%rdi
mov    %r12d,%esi
mov    %r15d,%edx
mov    0x8(%rsp),%rcx
mov    %r13,%r8
mov    %r14,%r9
add    $0x88,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1080 <ExecExternalApplication@plt>

LLVM IR (-O0):
%struct.TYPE_7__ = type { %struct.TYPE_6__, %struct.TYPE_5__ }
%struct.TYPE_6__ = type { i32, i32, i64, i32* }
%struct.TYPE_5__ = type { i32 }
@.str = [3 x i8] c"%i\00"
@ClientMessage = global i32 0
@.str.1 = [10 x i8] c"_ADD_ICON\00"
@False = global i32 0
define void @ExternalApplication(i32* %0, i32 %1, i32 %2, i8* %3, i8* %4, i8* %5, i8* %6, i8* %7) {
%9 = alloca i32*
%10 = alloca i32
%11 = alloca i32
%12 = alloca i8*
%13 = alloca i8*
%14 = alloca i8*
%15 = alloca i8*
%16 = alloca i8*
%17 = alloca [20 x i8]
%18 = alloca [20 x i8]
%19 = alloca i64
%20 = alloca %struct.TYPE_7__
store i32* %0, i32** %9
store i32 %1, i32* %10
store i32 %2, i32* %11
store i8* %3, i8** %12
store i8* %4, i8** %13
store i8* %5, i8** %14
store i8* %6, i8** %15
store i8* %7, i8** %16
%21 = load i32*, i32** %9
%22 = call i32 @MakeAtoms(i32* %21)
%23 = load i32*, i32** %9
%24 = call i64 @FindSomeIconWin(i32* %23)
store i64 %24, i64* %19
%25 = load i64, i64* %19
%26 = icmp eq i64 %25, 0
br i1 %26, label %27, label %37
27: ; preds = %8
%28 = load i32*, i32** %9
%29 = load i32, i32* %10
%30 = load i32, i32* %11
%31 = load i8*, i8** %12
%32 = load i8*, i8** %13
%33 = load i8*, i8** %14
%34 = load i8*, i8** %15
%35 = load i8*, i8** %16
%36 = call i32 @ExecExternalApplication(i32* %28, i32 %29, i32 %30, i8* %31, i8* %32, i8* %33, i8* %34, i8* %35)
br label %100
37: ; preds = %8
%38 = getelementptr inbounds [20 x i8], [20 x i8]* %17, i64 0, i64 0
%39 = load i32, i32* %10
%40 = call i32 @sprintf(i8* %38, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %39)
%41 = getelementptr inbounds [20 x i8], [20 x i8]* %18, i64 0, i64 0
%42 = load i32, i32* %11
%43 = call i32 @sprintf(i8* %41, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %42)
%44 = load i32*, i32** %9
%45 = getelementptr inbounds [20 x i8], [20 x i8]* %17, i64 0, i64 0
%46 = getelementptr inbounds [20 x i8], [20 x i8]* %17, i64 0, i64 0
%47 = call i64 @strlen(i8* %46)
%48 = add nsw i64 %47, 1
%49 = call i32 @XStoreBuffer(i32* %44, i8* %45, i64 %48, i32 1)
%50 = load i32*, i32** %9
%51 = getelementptr inbounds [20 x i8], [20 x i8]* %18, i64 0, i64 0
%52 = getelementptr inbounds [20 x i8], [20 x i8]* %18, i64 0, i64 0
%53 = call i64 @strlen(i8* %52)
%54 = add nsw i64 %53, 1
%55 = call i32 @XStoreBuffer(i32* %50, i8* %51, i64 %54, i32 2)
%56 = load i32*, i32** %9
%57 = load i8*, i8** %12
%58 = load i8*, i8** %12
%59 = call i64 @strlen(i8* %58)
%60 = add nsw i64 %59, 1
%61 = call i32 @XStoreBuffer(i32* %56, i8* %57, i64 %60, i32 3)
%62 = load i32*, i32** %9
%63 = load i8*, i8** %13
%64 = load i8*, i8** %13
%65 = call i64 @strlen(i8* %64)
%66 = add nsw i64 %65, 1
%67 = call i32 @XStoreBuffer(i32* %62, i8* %63, i64 %66, i32 4)
%68 = load i32*, i32** %9
%69 = load i8*, i8** %14
%70 = load i8*, i8** %14
%71 = call i64 @strlen(i8* %70)
%72 = add nsw i64 %71, 1
%73 = call i32 @XStoreBuffer(i32* %68, i8* %69, i64 %72, i32 5)
%74 = load i32*, i32** %9
%75 = load i8*, i8** %15
%76 = load i8*, i8** %15
%77 = call i64 @strlen(i8* %76)
%78 = add nsw i64 %77, 1
%79 = call i32 @XStoreBuffer(i32* %74, i8* %75, i64 %78, i32 6)
%80 = load i32, i32* @ClientMessage
%81 = getelementptr inbounds %struct.TYPE_7__, %struct.TYPE_7__* %20, i32 0, i32 1
%82 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %81, i32 0, i32 0
store i32 %80, i32* %82
%83 = load i32*, i32** %9
%84 = getelementptr inbounds %struct.TYPE_7__, %struct.TYPE_7__* %20, i32 0, i32 0
%85 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %84, i32 0, i32 3
store i32* %83, i32** %85
%86 = load i64, i64* %19
%87 = getelementptr inbounds %struct.TYPE_7__, %struct.TYPE_7__* %20, i32 0, i32 0
%88 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %87, i32 0, i32 2
store i64 %86, i64* %88
%89 = getelementptr inbounds %struct.TYPE_7__, %struct.TYPE_7__* %20, i32 0, i32 0
%90 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %89, i32 0, i32 0
store i32 32, i32* %90
%91 = load i32*, i32** %9
%92 = load i32, i32* @False
%93 = call i32 @XInternAtom(i32* %91, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i32 %92)
%94 = getelementptr inbounds %struct.TYPE_7__, %struct.TYPE_7__* %20, i32 0, i32 0
%95 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %94, i32 0, i32 1
store i32 %93, i32* %95
%96 = load i32*, i32** %9
%97 = load i64, i64* %19
%98 = load i32, i32* @False
%99 = call i32 @XSendEvent(i32* %96, i64 %97, i32 %98, i64 0, %struct.TYPE_7__* %20)
br label %100
100: ; preds = %37, %27
ret void
}

LLVM IR (-O2):
%struct.TYPE_7__ = type { %struct.TYPE_6__, %struct.TYPE_5__ }
%struct.TYPE_6__ = type { i32, i32, i64, i32* }
%struct.TYPE_5__ = type { i32 }
@.str = [3 x i8] c"%i\00"
@ClientMessage = global i32 0
@.str.1 = [10 x i8] c"_ADD_ICON\00"
@False = global i32 0
define void @ExternalApplication(i32* %0, i32 %1, i32 %2, i8* %3, i8* %4, i8* %5, i8* %6, i8* %7) {
%9 = alloca [20 x i8]
%10 = alloca [20 x i8]
%11 = alloca %struct.TYPE_7__
%12 = getelementptr inbounds [20 x i8], [20 x i8]* %9, i64 0, i64 0
%13 = getelementptr inbounds [20 x i8], [20 x i8]* %10, i64 0, i64 0
%14 = bitcast %struct.TYPE_7__* %11 to i8*
%15 = tail call i32 @MakeAtoms(i32* %0)
%16 = tail call i64 @FindSomeIconWin(i32* %0)
%17 = icmp eq i64 %16, 0
br i1 %17, label %18, label %20
18: ; preds = %8
%19 = tail call i32 @ExecExternalApplication(i32* %0, i32 %1, i32 %2, i8* %3, i8* %4, i8* %5, i8* %6, i8* %7)
br label %51
20: ; preds = %8
%21 = call i32 @sprintf(i8* %12, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %1)
%22 = call i32 @sprintf(i8* %13, i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 %2)
%23 = call i64 @strlen(i8* %12)
%24 = add nsw i64 %23, 1
%25 = call i32 @XStoreBuffer(i32* %0, i8* %12, i64 %24, i32 1)
%26 = call i64 @strlen(i8* %13)
%27 = add nsw i64 %26, 1
%28 = call i32 @XStoreBuffer(i32* %0, i8* %13, i64 %27, i32 2)
%29 = call i64 @strlen(i8* dereferenceable(1) %3)
%30 = add nsw i64 %29, 1
%31 = call i32 @XStoreBuffer(i32* %0, i8* %3, i64 %30, i32 3)
%32 = call i64 @strlen(i8* dereferenceable(1) %4)
%33 = add nsw i64 %32, 1
%34 = call i32 @XStoreBuffer(i32* %0, i8* %4, i64 %33, i32 4)
%35 = call i64 @strlen(i8* dereferenceable(1) %5)
%36 = add nsw i64 %35, 1
%37 = call i32 @XStoreBuffer(i32* %0, i8* %5, i64 %36, i32 5)
%38 = call i64 @strlen(i8* dereferenceable(1) %6)
%39 = add nsw i64 %38, 1
%40 = call i32 @XStoreBuffer(i32* %0, i8* %6, i64 %39, i32 6)
%41 = load i32, i32* @ClientMessage
%42 = getelementptr inbounds %struct.TYPE_7__, %struct.TYPE_7__* %11, i64 0, i32 1, i32 0
store i32 %41, i32* %42
%43 = getelementptr inbounds %struct.TYPE_7__, %struct.TYPE_7__* %11, i64 0, i32 0, i32 3
store i32* %0, i32** %43
%44 = getelementptr inbounds %struct.TYPE_7__, %struct.TYPE_7__* %11, i64 0, i32 0, i32 2
store i64 %16, i64* %44
%45 = getelementptr inbounds %struct.TYPE_7__, %struct.TYPE_7__* %11, i64 0, i32 0, i32 0
store i32 32, i32* %45
%46 = load i32, i32* @False
%47 = call i32 @XInternAtom(i32* %0, i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i32 %46)
%48 = getelementptr inbounds %struct.TYPE_7__, %struct.TYPE_7__* %11, i64 0, i32 0, i32 1
store i32 %47, i32* %48
%49 = load i32, i32* @False
%50 = call i32 @XSendEvent(i32* %0, i64 %16, i32 %49, i64 0, %struct.TYPE_7__* %11)
br label %51
51: ; preds = %20, %18
ret void
}