#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_2__;
typedef struct TYPE_6__ TYPE_1__;

/* Type definitions */
struct TYPE_6__ {
  unsigned long foreground;
  int /*<<< orphan*/ font;
};
typedef TYPE_1__ XGCValues;
struct TYPE_7__ {
  int ascent;
  int descent;
  int /*<<< orphan*/ fid;
};
typedef TYPE_2__ XFontStruct;
typedef int /*<<< orphan*/ Pixel;
typedef int /*<<< orphan*/ GC;
typedef int /*<<< orphan*/ Drawable;
typedef int /*<<< orphan*/ Display;

/* Variables and functions */
int GCFont;
int GCForeground;
int /*<<< orphan*/ XCreateGC(int /*<<< orphan*/ *, int /*<<< orphan*/, int,
                             TYPE_1__ *);
int /*<<< orphan*/ XDrawString(int /*<<< orphan*/ *, int /*<<< orphan*/,
                               int /*<<< orphan*/, int, int, char *,
                               int /*<<< orphan*/);
int /*<<< orphan*/ XFillRectangle(int /*<<< orphan*/ *, int /*<<< orphan*/,
                                  int /*<<< orphan*/, int, int, int, int);
int /*<<< orphan*/ XFreeGC(int /*<<< orphan*/ *, int /*<<< orphan*/);
int /*<<< orphan*/ draw_shaded_rectangle(int /*<<< orphan*/ *,
                                         int /*<<< orphan*/, int, int, int, int,
                                         int, int /*<<< orphan*/,
                                         int /*<<< orphan*/);
int string_width(TYPE_2__ *, char *);
int /*<<< orphan*/ strlen(char *);
void draw_button(Display *dpy, Drawable dialog, XFontStruct *font,
                 unsigned long foreground, unsigned long background,
                 char *label, int x, int y, int width, int height,
                 int shadow_width, Pixel shadow_light, Pixel shadow_dark,
                 int button_down) {
  XGCValues gcv;
  GC gc1, gc2;
  int sw;
  int label_x, label_y;
  gcv.foreground = foreground;
  gcv.font = font->fid;
  gc1 = XCreateGC(dpy, dialog, GCForeground | GCFont, &gcv);
  gcv.foreground = background;
  gc2 = XCreateGC(dpy, dialog, GCForeground, &gcv);
  XFillRectangle(dpy, dialog, gc2, x, y, width, height);
  sw = string_width(font, label);
  label_x = x + ((width - sw) / 2);
  label_y = (y + (height - (font->ascent + font->descent)) / 2 + font->ascent);
  if (button_down) {
    label_x += 2;
    label_y += 2;
  }
  XDrawString(dpy, dialog, gc1, label_x, label_y, label, strlen(label));
  XFreeGC(dpy, gc1);
  XFreeGC(dpy, gc2);
  draw_shaded_rectangle(dpy, dialog, x, y, width, height, shadow_width,
                        shadow_light, shadow_dark);
}


x86 assembly (clang, -O0):
<draw_button>:
push   %rbp
mov    %rsp,%rbp
sub    $0xa0,%rsp
mov    0x48(%rbp),%eax
mov    0x40(%rbp),%eax
mov    0x38(%rbp),%eax
mov    0x30(%rbp),%eax
mov    0x28(%rbp),%eax
mov    0x20(%rbp),%eax
mov    0x18(%rbp),%eax
mov    0x10(%rbp),%eax
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9,-0x30(%rbp)
mov    -0x20(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x18(%rbp),%rax
mov    0x8(%rax),%eax
mov    %eax,-0x38(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    0x2e1e(%rip),%rax
mov    (%rax),%edx
mov    0x2e05(%rip),%rax
or     (%rax),%edx
lea    -0x40(%rbp),%rcx
call   1070 <XCreateGC@plt>
mov    %eax,-0x44(%rbp)
mov    -0x28(%rbp),%rax
mov    %rax,-0x40(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    0x2df1(%rip),%rax
mov    (%rax),%edx
lea    -0x40(%rbp),%rcx
call   1070 <XCreateGC@plt>
mov    %eax,-0x48(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x48(%rbp),%edx
mov    0x10(%rbp),%ecx
mov    0x18(%rbp),%r8d
mov    0x20(%rbp),%r9d
mov    0x28(%rbp),%eax
mov    %eax,(%rsp)
call   1050 <XFillRectangle@plt>
mov    -0x18(%rbp),%rdi
mov    -0x30(%rbp),%rsi
call   1030 <string_width@plt>
mov    %eax,-0x4c(%rbp)
mov    0x10(%rbp),%eax
mov    %eax,-0x5c(%rbp)
mov    0x20(%rbp),%eax
sub    -0x4c(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x5c(%rbp),%eax
add    %ecx,%eax
mov    %eax,-0x50(%rbp)
mov    0x18(%rbp),%eax
mov    %eax,-0x58(%rbp)
mov    0x28(%rbp),%eax
mov    -0x18(%rbp),%rcx
mov    (%rcx),%ecx
mov    -0x18(%rbp),%rdx
add    0x4(%rdx),%ecx
sub    %ecx,%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0x58(%rbp),%eax
add    %ecx,%eax
mov    -0x18(%rbp),%rcx
add    (%rcx),%eax
mov    %eax,-0x54(%rbp)
cmpl   $0x0,0x48(%rbp)
je     129f <draw_button+0x12f>
mov    -0x50(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x50(%rbp)
mov    -0x54(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x54(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x80(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x78(%rbp)
mov    -0x44(%rbp),%eax
mov    %eax,-0x74(%rbp)
mov    -0x50(%rbp),%eax
mov    %eax,-0x70(%rbp)
mov    -0x54(%rbp),%eax
mov    %eax,-0x6c(%rbp)
mov    -0x30(%rbp),%rax
mov    %rax,-0x68(%rbp)
mov    -0x30(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x80(%rbp),%rdi
mov    -0x78(%rbp),%esi
mov    -0x74(%rbp),%edx
mov    -0x70(%rbp),%ecx
mov    -0x6c(%rbp),%r8d
mov    -0x68(%rbp),%r9
mov    %eax,(%rsp)
call   1060 <XDrawString@plt>
mov    -0x8(%rbp),%rdi
mov    -0x44(%rbp),%esi
call   1090 <XFreeGC@plt>
mov    -0x8(%rbp),%rdi
mov    -0x48(%rbp),%esi
call   1090 <XFreeGC@plt>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    0x10(%rbp),%edx
mov    0x18(%rbp),%ecx
mov    0x20(%rbp),%r8d
mov    0x28(%rbp),%r9d
mov    0x30(%rbp),%r11d
mov    0x38(%rbp),%r10d
mov    0x40(%rbp),%eax
mov    %r11d,(%rsp)
mov    %r10d,0x8(%rsp)
mov    %eax,0x10(%rsp)
call   1080 <draw_shaded_rectangle@plt>
add    $0xa0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<draw_button>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x38,%rsp
mov    %r9,0x20(%rsp)
mov    %r8,%rbx
mov    %rdx,%r13
mov    %esi,%r14d
mov    %rdi,%r12
mov    %rcx,0x28(%rsp)
mov    0x8(%rdx),%eax
mov    %eax,0x30(%rsp)
mov    0x2e46(%rip),%rbp
mov    0x2e2f(%rip),%rax
mov    (%rax),%edx
or     0x0(%rbp),%edx
lea    0x28(%rsp),%r15
mov    %r15,%rcx
call   1070 <XCreateGC@plt>
mov    %eax,0x1c(%rsp)
mov    %rbx,0x28(%rsp)
mov    0x0(%rbp),%edx
mov    %r12,%rdi
mov    %r14d,%esi
mov    %r15,%rcx
call   1070 <XCreateGC@plt>
mov    %eax,0x18(%rsp)
mov    0x88(%rsp),%ebp
mov    %ebp,(%rsp)
mov    %r12,%rdi
mov    %r14d,%esi
mov    %eax,%edx
mov    0x70(%rsp),%ecx
mov    0x78(%rsp),%r8d
mov    0x80(%rsp),%ebx
mov    %ebx,%r9d
call   1050 <XFillRectangle@plt>
mov    %r13,%rdi
mov    0x20(%rsp),%r15
mov    %r15,%rsi
call   1030 <string_width@plt>
sub    %eax,%ebx
mov    %ebx,%eax
shr    $0x1f,%eax
add    %ebx,%eax
sar    %eax
mov    0x70(%rsp),%ebx
lea    (%rax,%rbx,1),%ecx
mov    0x0(%r13),%edx
mov    0x4(%r13),%esi
add    %edx,%esi
mov    %ebp,%edi
sub    %esi,%edi
mov    %edi,%esi
shr    $0x1f,%esi
add    %edi,%esi
sar    %esi
mov    0x78(%rsp),%edi
add    %edi,%edx
lea    (%rdx,%rsi,1),%edi
cmpl   $0x0,0xa8(%rsp)
lea    0x2(%rax,%rbx,1),%ebp
lea    0x2(%rsi,%rdx,1),%ebx
cmove  %ecx,%ebp
cmove  %edi,%ebx
mov    %r15,%r13
mov    %r15,%rdi
call   1040 <strlen@plt>
mov    %eax,(%rsp)
mov    %r12,%rdi
mov    %r14d,%esi
mov    0x1c(%rsp),%r15d
mov    %r15d,%edx
mov    %ebp,%ecx
mov    %ebx,%r8d
mov    %r13,%r9
call   1060 <XDrawString@plt>
mov    %r12,%rdi
mov    %r15d,%esi
call   1090 <XFreeGC@plt>
mov    %r12,%rdi
mov    0x18(%rsp),%esi
call   1090 <XFreeGC@plt>
mov    0xa0(%rsp),%eax
mov    %eax,0x10(%rsp)
mov    0x98(%rsp),%eax
mov    %eax,0x8(%rsp)
mov    0x90(%rsp),%eax
mov    %eax,(%rsp)
mov    %r12,%rdi
mov    %r14d,%esi
mov    0x70(%rsp),%edx
mov    0x78(%rsp),%ecx
mov    0x80(%rsp),%r8d
mov    0x88(%rsp),%r9d
call   1080 <draw_shaded_rectangle@plt>
add    $0x38,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.TYPE_7__ = type { i32, i32, i32 }
%struct.TYPE_6__ = type { i64, i32 }
@GCForeground = global i32 0
@GCFont = global i32 0
define void @draw_button(i32* %0, i32 %1, %struct.TYPE_7__* %2, i64 %3, i64 %4, i8* %5, i32 %6, i32 %7, i32 %8, i32 %9, i32 %10, i32 %11, i32 %12, i32 %13) {
%15 = alloca i32*
%16 = alloca i32
%17 = alloca %struct.TYPE_7__*
%18 = alloca i64
%19 = alloca i64
%20 = alloca i8*
%21 = alloca i32
%22 = alloca i32
%23 = alloca i32
%24 = alloca i32
%25 = alloca i32
%26 = alloca i32
%27 = alloca i32
%28 = alloca i32
%29 = alloca %struct.TYPE_6__
%30 = alloca i32
%31 = alloca i32
%32 = alloca i32
%33 = alloca i32
%34 = alloca i32
store i32* %0, i32** %15
store i32 %1, i32* %16
store %struct.TYPE_7__* %2, %struct.TYPE_7__** %17
store i64 %3, i64* %18
store i64 %4, i64* %19
store i8* %5, i8** %20
store i32 %6, i32* %21
store i32 %7, i32* %22
store i32 %8, i32* %23
store i32 %9, i32* %24
store i32 %10, i32* %25
store i32 %11, i32* %26
store i32 %12, i32* %27
store i32 %13, i32* %28
%35 = load i64, i64* %18
%36 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %29, i32 0, i32 0
store i64 %35, i64* %36
%37 = load %struct.TYPE_7__*, %struct.TYPE_7__** %17
%38 = getelementptr inbounds %struct.TYPE_7__, %struct.TYPE_7__* %37, i32 0, i32 2
%39 = load i32, i32* %38
%40 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %29, i32 0, i32 1
store i32 %39, i32* %40
%41 = load i32*, i32** %15
%42 = load i32, i32* %16
%43 = load i32, i32* @GCForeground
%44 = load i32, i32* @GCFont
%45 = or i32 %43, %44
%46 = call i32 @XCreateGC(i32* %41, i32 %42, i32 %45, %struct.TYPE_6__* %29)
store i32 %46, i32* %30
%47 = load i64, i64* %19
%48 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %29, i32 0, i32 0
store i64 %47, i64* %48
%49 = load i32*, i32** %15
%50 = load i32, i32* %16
%51 = load i32, i32* @GCForeground
%52 = call i32 @XCreateGC(i32* %49, i32 %50, i32 %51, %struct.TYPE_6__* %29)
store i32 %52, i32* %31
%53 = load i32*, i32** %15
%54 = load i32, i32* %16
%55 = load i32, i32* %31
%56 = load i32, i32* %21
%57 = load i32, i32* %22
%58 = load i32, i32* %23
%59 = load i32, i32* %24
%60 = call i32 @XFillRectangle(i32* %53, i32 %54, i32 %55, i32 %56, i32 %57, i32 %58, i32 %59)
%61 = load %struct.TYPE_7__*, %struct.TYPE_7__** %17
%62 = load i8*, i8** %20
%63 = call i32 @string_width(%struct.TYPE_7__* %61, i8* %62)
store i32 %63, i32* %32
%64 = load i32, i32* %21
%65 = load i32, i32* %23
%66 = load i32, i32* %32
%67 = sub nsw i32 %65, %66
%68 = sdiv i32 %67, 2
%69 = add nsw i32 %64, %68
store i32 %69, i32* %33
%70 = load i32, i32* %22
%71 = load i32, i32* %24
%72 = load %struct.TYPE_7__*, %struct.TYPE_7__** %17
%73 = getelementptr inbounds %struct.TYPE_7__, %struct.TYPE_7__* %72, i32 0, i32 0
%74 = load i32, i32* %73
%75 = load %struct.TYPE_7__*, %struct.TYPE_7__** %17
%76 = getelementptr inbounds %struct.TYPE_7__, %struct.TYPE_7__* %75, i32 0, i32 1
%77 = load i32, i32* %76
%78 = add nsw i32 %74, %77
%79 = sub nsw i32 %71, %78
%80 = sdiv i32 %79, 2
%81 = add nsw i32 %70, %80
%82 = load %struct.TYPE_7__*, %struct.TYPE_7__** %17
%83 = getelementptr inbounds %struct.TYPE_7__, %struct.TYPE_7__* %82, i32 0, i32 0
%84 = load i32, i32* %83
%85 = add nsw i32 %81, %84
store i32 %85, i32* %34
%86 = load i32, i32* %28
%87 = icmp ne i32 %86, 0
br i1 %87, label %88, label %93
88: ; preds = %14
%89 = load i32, i32* %33
%90 = add nsw i32 %89, 2
store i32 %90, i32* %33
%91 = load i32, i32* %34
%92 = add nsw i32 %91, 2
store i32 %92, i32* %34
br label %93
93: ; preds = %88, %14
%94 = load i32*, i32** %15
%95 = load i32, i32* %16
%96 = load i32, i32* %30
%97 = load i32, i32* %33
%98 = load i32, i32* %34
%99 = load i8*, i8** %20
%100 = load i8*, i8** %20
%101 = call i32 @strlen(i8* %100)
%102 = call i32 @XDrawString(i32* %94, i32 %95, i32 %96, i32 %97, i32 %98, i8* %99, i32 %101)
%103 = load i32*, i32** %15
%104 = load i32, i32* %30
%105 = call i32 @XFreeGC(i32* %103, i32 %104)
%106 = load i32*, i32** %15
%107 = load i32, i32* %31
%108 = call i32 @XFreeGC(i32* %106, i32 %107)
%109 = load i32*, i32** %15
%110 = load i32, i32* %16
%111 = load i32, i32* %21
%112 = load i32, i32* %22
%113 = load i32, i32* %23
%114 = load i32, i32* %24
%115 = load i32, i32* %25
%116 = load i32, i32* %26
%117 = load i32, i32* %27
%118 = call i32 @draw_shaded_rectangle(i32* %109, i32 %110, i32 %111, i32 %112, i32 %113, i32 %114, i32 %115, i32 %116, i32 %117)
ret void
}

LLVM IR (-O2):
%struct.TYPE_7__ = type { i32, i32, i32 }
%struct.TYPE_6__ = type { i64, i32 }
@GCForeground = global i32 0
@GCFont = global i32 0
define void @draw_button(i32* %0, i32 %1, %struct.TYPE_7__* %2, i64 %3, i64 %4, i8* %5, i32 %6, i32 %7, i32 %8, i32 %9, i32 %10, i32 %11, i32 %12, i32 %13) {
%15 = alloca %struct.TYPE_6__
%16 = bitcast %struct.TYPE_6__* %15 to i8*
%17 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %15, i64 0, i32 0
store i64 %3, i64* %17
%18 = getelementptr inbounds %struct.TYPE_7__, %struct.TYPE_7__* %2, i64 0, i32 2
%19 = load i32, i32* %18
%20 = getelementptr inbounds %struct.TYPE_6__, %struct.TYPE_6__* %15, i64 0, i32 1
store i32 %19, i32* %20
%21 = load i32, i32* @GCForeground
%22 = load i32, i32* @GCFont
%23 = or i32 %22, %21
%24 = call i32 @XCreateGC(i32* %0, i32 %1, i32 %23, %struct.TYPE_6__* %15)
store i64 %4, i64* %17
%25 = load i32, i32* @GCForeground
%26 = call i32 @XCreateGC(i32* %0, i32 %1, i32 %25, %struct.TYPE_6__* %15)
%27 = call i32 @XFillRectangle(i32* %0, i32 %1, i32 %26, i32 %6, i32 %7, i32 %8, i32 %9)
%28 = call i32 @string_width(%struct.TYPE_7__* %2, i8* %5)
%29 = sub nsw i32 %8, %28
%30 = sdiv i32 %29, 2
%31 = add nsw i32 %30, %6
%32 = getelementptr inbounds %struct.TYPE_7__, %struct.TYPE_7__* %2, i64 0, i32 0
%33 = load i32, i32* %32
%34 = getelementptr inbounds %struct.TYPE_7__, %struct.TYPE_7__* %2, i64 0, i32 1
%35 = load i32, i32* %34
%36 = add i32 %33, %35
%37 = sub i32 %9, %36
%38 = sdiv i32 %37, 2
%39 = add i32 %33, %7
%40 = add i32 %39, %38
%41 = icmp eq i32 %13, 0
%42 = add nsw i32 %31, 2
%43 = add nsw i32 %40, 2
%44 = select i1 %41, i32 %31, i32 %42
%45 = select i1 %41, i32 %40, i32 %43
%46 = call i32 @strlen(i8* %5)
%47 = call i32 @XDrawString(i32* %0, i32 %1, i32 %24, i32 %44, i32 %45, i8* %5, i32 %46)
%48 = call i32 @XFreeGC(i32* %0, i32 %24)
%49 = call i32 @XFreeGC(i32* %0, i32 %26)
%50 = call i32 @draw_shaded_rectangle(i32* %0, i32 %1, i32 %6, i32 %7, i32 %8, i32 %9, i32 %10, i32 %11, i32 %12)
ret void
}