#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_9__ TYPE_3__;
typedef struct TYPE_8__ TYPE_2__;
typedef struct TYPE_7__ TYPE_1__;

/* Type definitions */
struct TYPE_7__ {
  int width;
  int height;
};
typedef TYPE_1__ XWindowAttributes;
typedef int /*<<< orphan*/ XSetWindowAttributes;
struct TYPE_8__ {
  int type;
};
typedef TYPE_2__ XKeyEvent;
typedef int /*<<< orphan*/ XGCValues;
typedef int /*<<< orphan*/ XFontStruct;
typedef int /*<<< orphan*/ XEvent;
struct TYPE_9__ {
  int width;
  int ascent;
  int descent;
};
typedef TYPE_3__ XCharStruct;
typedef int /*<<< orphan*/ Window;
typedef int /*<<< orphan*/ Visual;
typedef int /*<<< orphan*/ GC;
typedef int /*<<< orphan*/ Display;

/* Variables and functions */
#define Expose 128
int /*<<< orphan*/ XDrawString(int /*<<< orphan*/ *, int /*<<< orphan*/,
                               int /*<<< orphan*/, int, int, char *, int);
int /*<<< orphan*/ XGetWindowAttributes(int /*<<< orphan*/ *,
                                        int /*<<< orphan*/, TYPE_1__ *);
int /*<<< orphan*/ XNextEvent(int /*<<< orphan*/ *, int /*<<< orphan*/ *);
int /*<<< orphan*/ XTextExtents(int /*<<< orphan*/ *, char *, int, int *, int *,
                                int *, TYPE_3__ *);
int /*<<< orphan*/ printf(char *, int, int);
int /*<<< orphan*/ snprintf(char *, int, char *, unsigned int);
int strlen(char *);
void display1(Display *display, Visual *visual,
              XSetWindowAttributes frame_attributes, Window frame_window,
              XFontStruct *fontinfo, XGCValues gr_values, GC graphical_context,
              XKeyEvent event, unsigned int bpm, float temp) {
  int depth;
  int text_x;
  int text_y;
  char hello_string[30];
  char bpm_string[30];
  snprintf(hello_string, 30, "Temperatura:%.1f°C", temp);
  snprintf(bpm_string, 30, "BPM:        %dBPM", bpm);
  int bpm_lenght = strlen(bpm_string);
  int hello_string_length = strlen(hello_string);
  XNextEvent(display, (XEvent *)&event);
  switch (event.type) {
  case Expose: {
    XWindowAttributes window_attributes;
    int font_direction, font_ascent, font_descent;
    XCharStruct text_structure;
    XTextExtents(fontinfo, hello_string, hello_string_length, &font_direction,
                 &font_ascent, &font_descent, &text_structure);
    XGetWindowAttributes(display, frame_window, &window_attributes);
    text_x = (window_attributes.width - text_structure.width) / 2;
    text_y = (window_attributes.height -
              (text_structure.ascent + text_structure.descent)) /
             2;
    XDrawString(display, frame_window, graphical_context, text_x, text_y,
                hello_string, hello_string_length);
    printf("X:%d\tY:%d\n", text_x, text_y);
    XDrawString(display, frame_window, graphical_context, text_x, text_y + 50,
                bpm_string, bpm_lenght);
    break;
  }
  default:
    break;
  }
}


x86 assembly (clang, -O0):
<display1>:
push   %rbp
mov    %rsp,%rbp
sub    $0xd0,%rsp
mov    0x20(%rbp),%eax
mov    0x18(%rbp),%eax
mov    0x10(%rbp),%r10d
mov    %eax,-0x8(%rbp)
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    %ecx,-0x20(%rbp)
mov    %r8,-0x28(%rbp)
mov    %r9d,-0x2c(%rbp)
movss  %xmm0,-0x30(%rbp)
cvttss2si -0x30(%rbp),%rax
mov    %eax,%ecx
lea    0xe4e(%rip),%rdx
lea    -0x60(%rbp),%rdi
mov    %rdi,-0xb0(%rbp)
mov    $0x1e,%esi
mov    %esi,-0xbc(%rbp)
call   1050 <snprintf@plt>
mov    -0xbc(%rbp),%esi
mov    0x20(%rbp),%ecx
lea    0xe37(%rip),%rdx
lea    -0x80(%rbp),%rdi
mov    %rdi,-0xb8(%rbp)
call   1050 <snprintf@plt>
mov    -0xb8(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0xb0(%rbp),%rdi
mov    %eax,-0x84(%rbp)
call   1030 <strlen@plt>
mov    %eax,-0x88(%rbp)
mov    -0x10(%rbp),%rdi
lea    -0x8(%rbp),%rsi
call   1070 <XNextEvent@plt>
mov    -0x8(%rbp),%eax
sub    $0x80,%eax
jne    130e <display1+0x19e>
jmp    1231 <display1+0xc1>
mov    -0x28(%rbp),%rdi
lea    -0x60(%rbp),%rsi
mov    -0x88(%rbp),%edx
lea    -0x94(%rbp),%rcx
lea    -0x98(%rbp),%r8
lea    -0x9c(%rbp),%r9
lea    -0xa8(%rbp),%rax
mov    %rax,(%rsp)
call   1060 <XTextExtents@plt>
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%esi
lea    -0x90(%rbp),%rdx
call   1090 <XGetWindowAttributes@plt>
mov    -0x90(%rbp),%eax
sub    -0xa8(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x38(%rbp)
mov    -0x8c(%rbp),%eax
mov    -0xa4(%rbp),%ecx
add    -0xa0(%rbp),%ecx
sub    %ecx,%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,-0x3c(%rbp)
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%esi
mov    0x10(%rbp),%edx
mov    -0x38(%rbp),%ecx
mov    -0x3c(%rbp),%r8d
lea    -0x60(%rbp),%r9
mov    -0x88(%rbp),%eax
mov    %eax,(%rsp)
call   1080 <XDrawString@plt>
mov    -0x38(%rbp),%esi
mov    -0x3c(%rbp),%edx
lea    0xd49(%rip),%rdi
call   1040 <printf@plt>
mov    -0x10(%rbp),%rdi
mov    -0x20(%rbp),%esi
mov    0x10(%rbp),%edx
mov    -0x38(%rbp),%ecx
mov    -0x3c(%rbp),%r8d
add    $0x32,%r8d
lea    -0x80(%rbp),%r9
mov    -0x84(%rbp),%eax
mov    %eax,(%rsp)
call   1080 <XDrawString@plt>
jmp    1313 <display1+0x1a3>
jmp    1313 <display1+0x1a3>
add    $0xd0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<display1>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x78,%rsp
mov    %r8,%r13
mov    %ecx,%r12d
mov    %rdi,%r14
mov    0xc0(%rsp),%r15d
cvttss2si %xmm0,%rcx
lea    0xe65(%rip),%rdx
lea    0x30(%rsp),%rbp
mov    %rbp,%rdi
mov    $0x1e,%esi
call   1050 <snprintf@plt>
lea    0xe60(%rip),%rdx
lea    0x50(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x1e,%esi
mov    %r15d,%ecx
call   1050 <snprintf@plt>
mov    %rbx,%rdi
call   1030 <strlen@plt>
mov    %eax,%ebx
mov    %rbp,%rdi
call   1030 <strlen@plt>
mov    %eax,%r15d
lea    0xb8(%rsp),%rsi
mov    %r14,%rdi
call   1070 <XNextEvent@plt>
cmpl   $0x80,0xb8(%rsp)
jne    12b5 <display1+0x145>
lea    0x18(%rsp),%rax
mov    %rax,(%rsp)
lea    0x30(%rsp),%rsi
lea    0x2c(%rsp),%rcx
lea    0x28(%rsp),%r8
lea    0x24(%rsp),%r9
mov    %r13,%rdi
mov    %r15d,%edx
call   1060 <XTextExtents@plt>
lea    0x10(%rsp),%rdx
mov    %r14,%rdi
mov    %r12d,%esi
call   1090 <XGetWindowAttributes@plt>
mov    0x10(%rsp),%eax
mov    0x14(%rsp),%ecx
sub    0x18(%rsp),%eax
mov    %eax,%ebp
shr    $0x1f,%ebp
add    %eax,%ebp
sar    %ebp
mov    0x1c(%rsp),%eax
add    0x20(%rsp),%eax
sub    %eax,%ecx
mov    %ebx,%r13d
mov    %ecx,%ebx
shr    $0x1f,%ebx
add    %ecx,%ebx
sar    %ebx
mov    %r15d,(%rsp)
mov    %r14,%rdi
mov    %r12d,%esi
mov    0xb0(%rsp),%r15d
mov    %r15d,%edx
mov    %ebp,%ecx
mov    %ebx,%r8d
lea    0x30(%rsp),%r9
call   1080 <XDrawString@plt>
lea    0xd99(%rip),%rdi
mov    %ebp,%esi
mov    %ebx,%edx
call   1040 <printf@plt>
add    $0x32,%ebx
mov    %r13d,(%rsp)
lea    0x50(%rsp),%r9
mov    %r14,%rdi
mov    %r12d,%esi
mov    %r15d,%edx
mov    %ebp,%ecx
mov    %ebx,%r8d
call   1080 <XDrawString@plt>
add    $0x78,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.TYPE_8__ = type { i32 }
%struct.TYPE_7__ = type { i32, i32 }
%struct.TYPE_9__ = type { i32, i32, i32 }
@.str = [20 x i8] c"Temperatura:%.1f\C2\B0C\00"
@.str.1 = [18 x i8] c"BPM: %dBPM\00"
@.str.2 = [11 x i8] c"X:%d\09Y:%d\0A\00"
define void @display1(i32* %0, i32* %1, i32 %2, i32 %3, i32* %4, i32 %5, i32 %6, i32 %7, i32 %8, float %9) {
%11 = alloca %struct.TYPE_8__
%12 = alloca i32*
%13 = alloca i32*
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32*
%17 = alloca i32
%18 = alloca i32
%19 = alloca i32
%20 = alloca float
%21 = alloca i32
%22 = alloca i32
%23 = alloca i32
%24 = alloca [30 x i8]
%25 = alloca [30 x i8]
%26 = alloca i32
%27 = alloca i32
%28 = alloca %struct.TYPE_7__
%29 = alloca i32
%30 = alloca i32
%31 = alloca i32
%32 = alloca %struct.TYPE_9__
%33 = getelementptr inbounds %struct.TYPE_8__, %struct.TYPE_8__* %11, i32 0, i32 0
store i32 %7, i32* %33
store i32* %0, i32** %12
store i32* %1, i32** %13
store i32 %2, i32* %14
store i32 %3, i32* %15
store i32* %4, i32** %16
store i32 %5, i32* %17
store i32 %6, i32* %18
store i32 %8, i32* %19
store float %9, float* %20
%34 = getelementptr inbounds [30 x i8], [30 x i8]* %24, i64 0, i64 0
%35 = load float, float* %20
%36 = fptoui float %35 to i32
%37 = call i32 @snprintf(i8* %34, i32 30, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i32 %36)
%38 = getelementptr inbounds [30 x i8], [30 x i8]* %25, i64 0, i64 0
%39 = load i32, i32* %19
%40 = call i32 @snprintf(i8* %38, i32 30, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i32 %39)
%41 = getelementptr inbounds [30 x i8], [30 x i8]* %25, i64 0, i64 0
%42 = call i32 @strlen(i8* %41)
store i32 %42, i32* %26
%43 = getelementptr inbounds [30 x i8], [30 x i8]* %24, i64 0, i64 0
%44 = call i32 @strlen(i8* %43)
store i32 %44, i32* %27
%45 = load i32*, i32** %12
%46 = bitcast %struct.TYPE_8__* %11 to i32*
%47 = call i32 @XNextEvent(i32* %45, i32* %46)
%48 = getelementptr inbounds %struct.TYPE_8__, %struct.TYPE_8__* %11, i32 0, i32 0
%49 = load i32, i32* %48
switch i32 %49, label %93 [
i32 128, label %50
]
50: ; preds = %10
%51 = load i32*, i32** %16
%52 = getelementptr inbounds [30 x i8], [30 x i8]* %24, i64 0, i64 0
%53 = load i32, i32* %27
%54 = call i32 @XTextExtents(i32* %51, i8* %52, i32 %53, i32* %29, i32* %30, i32* %31, %struct.TYPE_9__* %32)
%55 = load i32*, i32** %12
%56 = load i32, i32* %15
%57 = call i32 @XGetWindowAttributes(i32* %55, i32 %56, %struct.TYPE_7__* %28)
%58 = getelementptr inbounds %struct.TYPE_7__, %struct.TYPE_7__* %28, i32 0, i32 0
%59 = load i32, i32* %58
%60 = getelementptr inbounds %struct.TYPE_9__, %struct.TYPE_9__* %32, i32 0, i32 0
%61 = load i32, i32* %60
%62 = sub nsw i32 %59, %61
%63 = sdiv i32 %62, 2
store i32 %63, i32* %22
%64 = getelementptr inbounds %struct.TYPE_7__, %struct.TYPE_7__* %28, i32 0, i32 1
%65 = load i32, i32* %64
%66 = getelementptr inbounds %struct.TYPE_9__, %struct.TYPE_9__* %32, i32 0, i32 1
%67 = load i32, i32* %66
%68 = getelementptr inbounds %struct.TYPE_9__, %struct.TYPE_9__* %32, i32 0, i32 2
%69 = load i32, i32* %68
%70 = add nsw i32 %67, %69
%71 = sub nsw i32 %65, %70
%72 = sdiv i32 %71, 2
store i32 %72, i32* %23
%73 = load i32*, i32** %12
%74 = load i32, i32* %15
%75 = load i32, i32* %18
%76 = load i32, i32* %22
%77 = load i32, i32* %23
%78 = getelementptr inbounds [30 x i8], [30 x i8]* %24, i64 0, i64 0
%79 = load i32, i32* %27
%80 = call i32 @XDrawString(i32* %73, i32 %74, i32 %75, i32 %76, i32 %77, i8* %78, i32 %79)
%81 = load i32, i32* %22
%82 = load i32, i32* %23
%83 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i32 %81, i32 %82)
%84 = load i32*, i32** %12
%85 = load i32, i32* %15
%86 = load i32, i32* %18
%87 = load i32, i32* %22
%88 = load i32, i32* %23
%89 = add nsw i32 %88, 50
%90 = getelementptr inbounds [30 x i8], [30 x i8]* %25, i64 0, i64 0
%91 = load i32, i32* %26
%92 = call i32 @XDrawString(i32* %84, i32 %85, i32 %86, i32 %87, i32 %89, i8* %90, i32 %91)
br label %94
93: ; preds = %10
br label %94
94: ; preds = %93, %50
ret void
}

LLVM IR (-O2):
%struct.TYPE_8__ = type { i32 }
%struct.TYPE_7__ = type { i32, i32 }
%struct.TYPE_9__ = type { i32, i32, i32 }
@.str = [20 x i8] c"Temperatura:%.1f\C2\B0C\00"
@.str.1 = [18 x i8] c"BPM: %dBPM\00"
@.str.2 = [11 x i8] c"X:%d\09Y:%d\0A\00"
define void @display1(i32* %0, i32* nocapture readnone %1, i32 %2, i32 %3, i32* %4, i32 %5, i32 %6, i32 %7, i32 %8, float %9) {
%11 = alloca %struct.TYPE_8__
%12 = alloca [30 x i8]
%13 = alloca [30 x i8]
%14 = alloca %struct.TYPE_7__
%15 = alloca i32
%16 = alloca i32
%17 = alloca i32
%18 = alloca %struct.TYPE_9__
%19 = getelementptr inbounds %struct.TYPE_8__, %struct.TYPE_8__* %11, i64 0, i32 0
store i32 %7, i32* %19
%20 = getelementptr inbounds [30 x i8], [30 x i8]* %12, i64 0, i64 0
%21 = getelementptr inbounds [30 x i8], [30 x i8]* %13, i64 0, i64 0
%22 = fptoui float %9 to i32
%23 = call i32 @snprintf(i8* %20, i32 30, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str, i64 0, i64 0), i32 %22)
%24 = call i32 @snprintf(i8* %21, i32 30, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.1, i64 0, i64 0), i32 %8)
%25 = call i32 @strlen(i8* %21)
%26 = call i32 @strlen(i8* %20)
%27 = call i32 @XNextEvent(i32* %0, i32* %19)
%28 = load i32, i32* %19
%29 = icmp eq i32 %28, 128
br i1 %29, label %30, label %57
30: ; preds = %10
%31 = bitcast %struct.TYPE_7__* %14 to i8*
%32 = bitcast i32* %15 to i8*
%33 = bitcast i32* %16 to i8*
%34 = bitcast i32* %17 to i8*
%35 = bitcast %struct.TYPE_9__* %18 to i8*
%36 = call i32 @XTextExtents(i32* %4, i8* %20, i32 %26, i32* %15, i32* %16, i32* %17, %struct.TYPE_9__* %18)
%37 = call i32 @XGetWindowAttributes(i32* %0, i32 %3, %struct.TYPE_7__* %14)
%38 = getelementptr inbounds %struct.TYPE_7__, %struct.TYPE_7__* %14, i64 0, i32 0
%39 = load i32, i32* %38
%40 = getelementptr inbounds %struct.TYPE_9__, %struct.TYPE_9__* %18, i64 0, i32 0
%41 = load i32, i32* %40
%42 = sub nsw i32 %39, %41
%43 = sdiv i32 %42, 2
%44 = getelementptr inbounds %struct.TYPE_7__, %struct.TYPE_7__* %14, i64 0, i32 1
%45 = load i32, i32* %44
%46 = getelementptr inbounds %struct.TYPE_9__, %struct.TYPE_9__* %18, i64 0, i32 1
%47 = load i32, i32* %46
%48 = getelementptr inbounds %struct.TYPE_9__, %struct.TYPE_9__* %18, i64 0, i32 2
%49 = load i32, i32* %48
%50 = add i32 %47, %49
%51 = sub i32 %45, %50
%52 = sdiv i32 %51, 2
%53 = call i32 @XDrawString(i32* %0, i32 %3, i32 %6, i32 %43, i32 %52, i8* %20, i32 %26)
%54 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i32 %43, i32 %52)
%55 = add nsw i32 %52, 50
%56 = call i32 @XDrawString(i32* %0, i32 %3, i32 %6, i32 %43, i32 %55, i8* %21, i32 %25)
br label %57
57: ; preds = %10, %30
ret void
}