#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 */
typedef int /*<<< orphan*/ XFontStruct;
struct TYPE_3__ {
  int ascent;
  int descent;
  int rbearing;
  int lbearing;
};
typedef TYPE_1__ XCharStruct;

/* Variables and functions */
int /*<<< orphan*/ XTextExtents(int /*<<< orphan*/ *, char const *,
                                int /*<<< orphan*/, int *, int *, int *,
                                TYPE_1__ *);
int /*<<< orphan*/ strlen(char const *);
void get_text_extents(XFontStruct *xfs, int *w, int *h) {
  static const char *text = "1000x1000+50+50";
  int dir, ascent, descent;
  XCharStruct overall;
  XTextExtents(xfs, text, strlen(text), &dir, &ascent, &descent, &overall);
  *h = overall.ascent + overall.descent + 2 * 1;
  *w = overall.rbearing - overall.lbearing;
  *w += 1.5 * 10;
}


x86 assembly (clang, -O0):
<get_text_extents>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rax
mov    %rax,-0x48(%rbp)
mov    0x2eed(%rip),%rax
mov    %rax,-0x40(%rbp)
mov    0x2ee2(%rip),%rdi
call   1030 <strlen@plt>
mov    -0x48(%rbp),%rdi
mov    -0x40(%rbp),%rsi
mov    %eax,%edx
lea    -0x1c(%rbp),%rcx
lea    -0x20(%rbp),%r8
lea    -0x24(%rbp),%r9
lea    -0x38(%rbp),%rax
mov    %rax,(%rsp)
call   1040 <XTextExtents@plt>
mov    -0x38(%rbp),%ecx
add    -0x34(%rbp),%ecx
add    $0x2,%ecx
mov    -0x18(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x30(%rbp),%ecx
sub    -0x2c(%rbp),%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,(%rax)
mov    -0x10(%rbp),%rax
cvtsi2sdl (%rax),%xmm0
movsd  0xe5f(%rip),%xmm1
addsd  %xmm1,%xmm0
cvttsd2si %xmm0,%ecx
mov    %ecx,(%rax)
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<get_text_extents>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x28,%rsp
mov    %rdx,%r15
mov    %rsi,%r14
mov    %rdi,%rbx
lea    0xec5(%rip),%r12
mov    %r12,%rdi
call   1030 <strlen@plt>
lea    0x8(%rsp),%rcx
mov    %rcx,(%rsp)
lea    0x24(%rsp),%rcx
lea    0x20(%rsp),%r8
lea    0x1c(%rsp),%r9
mov    %rbx,%rdi
mov    %r12,%rsi
mov    %eax,%edx
call   1040 <XTextExtents@plt>
mov    0x8(%rsp),%eax
mov    0xc(%rsp),%ecx
add    %ecx,%eax
add    $0x2,%eax
mov    %eax,(%r15)
mov    0x10(%rsp),%eax
sub    0x14(%rsp),%eax
add    $0xf,%eax
mov    %eax,(%r14)
add    $0x28,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.TYPE_3__ = type { i32, i32, i32, i32 }
@get_text_extents.text = internal global i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i32 0, i32 0)
@.str = [16 x i8] c"1000x1000+50+50\00"
define void @get_text_extents(i32* %0, i32* %1, i32* %2) {
%4 = alloca i32*
%5 = alloca i32*
%6 = alloca i32*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca %struct.TYPE_3__
store i32* %0, i32** %4
store i32* %1, i32** %5
store i32* %2, i32** %6
%11 = load i32*, i32** %4
%12 = load i8*, i8** @get_text_extents.text
%13 = load i8*, i8** @get_text_extents.text
%14 = call i32 @strlen(i8* %13)
%15 = call i32 @XTextExtents(i32* %11, i8* %12, i32 %14, i32* %7, i32* %8, i32* %9, %struct.TYPE_3__* %10)
%16 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %10, i32 0, i32 0
%17 = load i32, i32* %16
%18 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %10, i32 0, i32 1
%19 = load i32, i32* %18
%20 = add nsw i32 %17, %19
%21 = add nsw i32 %20, 2
%22 = load i32*, i32** %6
store i32 %21, i32* %22
%23 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %10, i32 0, i32 2
%24 = load i32, i32* %23
%25 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %10, i32 0, i32 3
%26 = load i32, i32* %25
%27 = sub nsw i32 %24, %26
%28 = load i32*, i32** %5
store i32 %27, i32* %28
%29 = load i32*, i32** %5
%30 = load i32, i32* %29
%31 = sitofp i32 %30 to double
%32 = fadd double %31, 1.500000e+01
%33 = fptosi double %32 to i32
store i32 %33, i32* %29
ret void
}

LLVM IR (-O2):
%struct.TYPE_3__ = type { i32, i32, i32, i32 }
@.str = [16 x i8] c"1000x1000+50+50\00"
define void @get_text_extents(i32* %0, i32* nocapture writeonly %1, i32* nocapture writeonly %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca %struct.TYPE_3__
%8 = bitcast i32* %4 to i8*
%9 = bitcast i32* %5 to i8*
%10 = bitcast i32* %6 to i8*
%11 = bitcast %struct.TYPE_3__* %7 to i8*
%12 = tail call i32 @strlen(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
%13 = call i32 @XTextExtents(i32* %0, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i32 %12, i32* %4, i32* %5, i32* %6, %struct.TYPE_3__* %7)
%14 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %7, i64 0, i32 0
%15 = load i32, i32* %14
%16 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %7, i64 0, i32 1
%17 = load i32, i32* %16
%18 = add i32 %15, 2
%19 = add i32 %18, %17
store i32 %19, i32* %2
%20 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %7, i64 0, i32 2
%21 = load i32, i32* %20
%22 = getelementptr inbounds %struct.TYPE_3__, %struct.TYPE_3__* %7, i64 0, i32 3
%23 = load i32, i32* %22
%24 = sub nsw i32 %21, %23
%25 = add i32 %24, 15
store i32 %25, i32* %1
ret void
}