#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 */

/* Type definitions */
struct raster {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ drawtext(struct raster *, int, int, char *, int, int, int,
                            int);
int strlen(char *);
void drawctext(struct raster *ra, int x, int y, char *s, int size, int r, int g,
               int b) {
  x -= (strlen(s) * (2 * size) + strlen(s) * ((size == 1 ? 2 : 1) * size)) / 2;
  drawtext(ra, x, y, s, size, r, g, b);
}


x86 assembly (clang, -O0):
<drawctext>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    0x18(%rbp),%eax
mov    0x10(%rbp),%eax
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %rcx,-0x18(%rbp)
mov    %r8d,-0x1c(%rbp)
mov    %r9d,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <strlen@plt>
mov    -0x1c(%rbp),%ecx
shl    $0x1,%ecx
imul   %ecx,%eax
mov    %eax,-0x24(%rbp)
mov    -0x18(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x24(%rbp),%eax
mov    -0x1c(%rbp),%edi
mov    $0x1,%edx
mov    $0x2,%esi
cmp    $0x1,%edi
cmove  %esi,%edx
imul   -0x1c(%rbp),%edx
imul   %edx,%ecx
add    %ecx,%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
mov    %eax,%ecx
mov    -0xc(%rbp),%eax
sub    %ecx,%eax
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    -0x18(%rbp),%rcx
mov    -0x1c(%rbp),%r8d
mov    -0x20(%rbp),%r9d
mov    0x10(%rbp),%r10d
mov    0x18(%rbp),%eax
mov    %r10d,(%rsp)
mov    %eax,0x8(%rsp)
call   1030 <drawtext@plt>
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<drawctext>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r9d,0x4(%rsp)
mov    %r8d,%r12d
mov    %rcx,%rbx
mov    %edx,%r15d
mov    %esi,%ebp
mov    %rdi,%r13
mov    %rcx,%rdi
call   1040 <strlen@plt>
mov    %eax,%r14d
mov    %rbx,%rdi
call   1040 <strlen@plt>
xor    %ecx,%ecx
cmp    $0x1,%r12d
sete   %cl
add    $0x1,%ecx
imul   %eax,%ecx
lea    (%rcx,%r14,2),%eax
imul   %r12d,%eax
mov    %eax,%ecx
shr    $0x1f,%ecx
add    %eax,%ecx
sar    %ecx
sub    %ecx,%ebp
mov    %r13,%rdi
mov    %ebp,%esi
mov    %r15d,%edx
mov    %rbx,%rcx
mov    %r12d,%r8d
mov    0x4(%rsp),%r9d
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <drawtext@plt>

LLVM IR (-O0):
%struct.raster = type { i32 }
define void @drawctext(%struct.raster* %0, i32 %1, i32 %2, i8* %3, i32 %4, i32 %5, i32 %6, i32 %7) {
%9 = alloca %struct.raster*
%10 = alloca i32
%11 = alloca i32
%12 = alloca i8*
%13 = alloca i32
%14 = alloca i32
%15 = alloca i32
%16 = alloca i32
store %struct.raster* %0, %struct.raster** %9
store i32 %1, i32* %10
store i32 %2, i32* %11
store i8* %3, i8** %12
store i32 %4, i32* %13
store i32 %5, i32* %14
store i32 %6, i32* %15
store i32 %7, i32* %16
%17 = load i8*, i8** %12
%18 = call i32 @strlen(i8* %17)
%19 = load i32, i32* %13
%20 = mul nsw i32 2, %19
%21 = mul nsw i32 %18, %20
%22 = load i8*, i8** %12
%23 = call i32 @strlen(i8* %22)
%24 = load i32, i32* %13
%25 = icmp eq i32 %24, 1
%26 = zext i1 %25 to i64
%27 = select i1 %25, i32 2, i32 1
%28 = load i32, i32* %13
%29 = mul nsw i32 %27, %28
%30 = mul nsw i32 %23, %29
%31 = add nsw i32 %21, %30
%32 = sdiv i32 %31, 2
%33 = load i32, i32* %10
%34 = sub nsw i32 %33, %32
store i32 %34, i32* %10
%35 = load %struct.raster*, %struct.raster** %9
%36 = load i32, i32* %10
%37 = load i32, i32* %11
%38 = load i8*, i8** %12
%39 = load i32, i32* %13
%40 = load i32, i32* %14
%41 = load i32, i32* %15
%42 = load i32, i32* %16
%43 = call i32 @drawtext(%struct.raster* %35, i32 %36, i32 %37, i8* %38, i32 %39, i32 %40, i32 %41, i32 %42)
ret void
}

LLVM IR (-O2):
%struct.raster = type { i32 }
define void @drawctext(%struct.raster* %0, i32 %1, i32 %2, i8* %3, i32 %4, i32 %5, i32 %6, i32 %7) {
%9 = tail call i32 @strlen(i8* %3)
%10 = shl i32 %9, 1
%11 = tail call i32 @strlen(i8* %3)
%12 = icmp eq i32 %4, 1
%13 = select i1 %12, i32 2, i32 1
%14 = mul i32 %11, %13
%15 = add i32 %14, %10
%16 = mul i32 %15, %4
%17 = sdiv i32 %16, -2
%18 = add i32 %17, %1
%19 = tail call i32 @drawtext(%struct.raster* %0, i32 %18, i32 %2, i8* %3, i32 %4, i32 %5, i32 %6, i32 %7)
ret void
}