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

/* Variables and functions */
int /*<<< orphan*/ PutImage(int, int, int, int, unsigned char *);
int /*<<< orphan*/ SetBackColor(int, int, int, unsigned char *);
int /*<<< orphan*/ font_blit(unsigned char *, unsigned char *, int, int);
int get_width(short *, char *, int);
int /*<<< orphan*/ kol_process_info(int, unsigned char *);
int /*<<< orphan*/ picture(short *, char *, unsigned char *, int, int);
int /*<<< orphan*/ zfree(unsigned char *);
scalar_t__ zmalloc(int);
int __attribute__((stdcall)) text_out(short *string, char *buffer, int height,
                                      int color, int back_color, int x, int y) {
  unsigned char *from_zone;
  unsigned char *to_zone;
  int px, py;
  unsigned char app_data[1024];
  int width;
  width = get_width(string, buffer, height);
  from_zone = (char *)zmalloc(3 * height * width);
  to_zone = (char *)zmalloc(height * width);
  kol_process_info(-1, app_data);
  px = app_data[35] * 256 + app_data[34] + app_data[55] * 256 + app_data[54];
  py = app_data[39] * 256 + app_data[38] + app_data[59] * 256 + app_data[58];
  SetBackColor(back_color, width, height, from_zone);
  picture(string, buffer, to_zone, width, height);
  font_blit(from_zone, to_zone, color, width * height);
  PutImage(x, y, width, height, from_zone);
  zfree(from_zone);
  zfree(to_zone);
  return 0;
}


x86 assembly (clang, -O0):
<text_out>:
push   %rbp
mov    %rsp,%rbp
sub    $0x450,%rsp
mov    0x10(%rbp),%eax
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
mov    %ecx,-0x18(%rbp)
mov    %r8d,-0x1c(%rbp)
mov    %r9d,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x14(%rbp),%edx
call   1080 <get_width@plt>
mov    %eax,-0x444(%rbp)
imul   $0x3,-0x14(%rbp),%edi
imul   -0x444(%rbp),%edi
call   1060 <zmalloc@plt>
mov    %rax,-0x28(%rbp)
mov    -0x14(%rbp),%edi
imul   -0x444(%rbp),%edi
call   1060 <zmalloc@plt>
mov    %rax,-0x30(%rbp)
lea    -0x440(%rbp),%rsi
mov    $0xffffffff,%edi
call   1070 <kol_process_info@plt>
movzbl -0x41d(%rbp),%eax
shl    $0x8,%eax
movzbl -0x41e(%rbp),%ecx
add    %ecx,%eax
movzbl -0x409(%rbp),%ecx
shl    $0x8,%ecx
add    %ecx,%eax
movzbl -0x40a(%rbp),%ecx
add    %ecx,%eax
mov    %eax,-0x34(%rbp)
movzbl -0x419(%rbp),%eax
shl    $0x8,%eax
movzbl -0x41a(%rbp),%ecx
add    %ecx,%eax
movzbl -0x405(%rbp),%ecx
shl    $0x8,%ecx
add    %ecx,%eax
movzbl -0x406(%rbp),%ecx
add    %ecx,%eax
mov    %eax,-0x38(%rbp)
mov    -0x1c(%rbp),%edi
mov    -0x444(%rbp),%esi
mov    -0x14(%rbp),%edx
mov    -0x28(%rbp),%rcx
call   1040 <SetBackColor@plt>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%rsi
mov    -0x30(%rbp),%rdx
mov    -0x444(%rbp),%ecx
mov    -0x14(%rbp),%r8d
call   1030 <picture@plt>
mov    -0x28(%rbp),%rdi
mov    -0x30(%rbp),%rsi
mov    -0x18(%rbp),%edx
mov    -0x444(%rbp),%ecx
imul   -0x14(%rbp),%ecx
call   10a0 <font_blit@plt>
mov    -0x20(%rbp),%edi
mov    0x10(%rbp),%esi
mov    -0x444(%rbp),%edx
mov    -0x14(%rbp),%ecx
mov    -0x28(%rbp),%r8
call   1050 <PutImage@plt>
mov    -0x28(%rbp),%rdi
call   1090 <zfree@plt>
mov    -0x30(%rbp),%rdi
call   1090 <zfree@plt>
xor    %eax,%eax
add    $0x450,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<text_out>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x428,%rsp
mov    %r9d,0x14(%rsp)
mov    %r8d,0xc(%rsp)
mov    %ecx,0x10(%rsp)
mov    %edx,%ebx
mov    %rsi,0x18(%rsp)
mov    %rdi,%r15
call   1080 <get_width@plt>
mov    %eax,%r13d
mov    %eax,%r12d
imul   %ebx,%r12d
lea    (%r12,%r12,2),%edi
call   1060 <zmalloc@plt>
mov    %rax,%rbp
mov    %r12d,%edi
call   1060 <zmalloc@plt>
mov    %rax,%r14
lea    0x20(%rsp),%rsi
mov    $0xffffffff,%edi
call   1070 <kol_process_info@plt>
mov    0xc(%rsp),%edi
mov    %r13d,%esi
mov    %ebx,%edx
mov    %rbp,%rcx
call   1040 <SetBackColor@plt>
mov    %r15,%rdi
mov    0x18(%rsp),%rsi
mov    %r14,%rdx
mov    %r13d,%ecx
mov    %ebx,%r8d
call   1030 <picture@plt>
mov    %rbp,%rdi
mov    %r14,%rsi
mov    0x10(%rsp),%edx
mov    %r12d,%ecx
call   10a0 <font_blit@plt>
mov    0x14(%rsp),%edi
mov    0x460(%rsp),%esi
mov    %r13d,%edx
mov    %ebx,%ecx
mov    %rbp,%r8
call   1050 <PutImage@plt>
mov    %rbp,%rdi
call   1090 <zfree@plt>
mov    %r14,%rdi
call   1090 <zfree@plt>
xor    %eax,%eax
add    $0x428,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @text_out(i16* %0, i8* %1, i32 %2, i32 %3, i32 %4, i32 %5, i32 %6) {
%8 = alloca i16*
%9 = alloca i8*
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
%14 = alloca i32
%15 = alloca i8*
%16 = alloca i8*
%17 = alloca i32
%18 = alloca i32
%19 = alloca [1024 x i8]
%20 = alloca i32
store i16* %0, i16** %8
store i8* %1, i8** %9
store i32 %2, i32* %10
store i32 %3, i32* %11
store i32 %4, i32* %12
store i32 %5, i32* %13
store i32 %6, i32* %14
%21 = load i16*, i16** %8
%22 = load i8*, i8** %9
%23 = load i32, i32* %10
%24 = call i32 @get_width(i16* %21, i8* %22, i32 %23)
store i32 %24, i32* %20
%25 = load i32, i32* %10
%26 = mul nsw i32 3, %25
%27 = load i32, i32* %20
%28 = mul nsw i32 %26, %27
%29 = call i64 @zmalloc(i32 %28)
%30 = inttoptr i64 %29 to i8*
store i8* %30, i8** %15
%31 = load i32, i32* %10
%32 = load i32, i32* %20
%33 = mul nsw i32 %31, %32
%34 = call i64 @zmalloc(i32 %33)
%35 = inttoptr i64 %34 to i8*
store i8* %35, i8** %16
%36 = getelementptr inbounds [1024 x i8], [1024 x i8]* %19, i64 0, i64 0
%37 = call i32 @kol_process_info(i32 -1, i8* %36)
%38 = getelementptr inbounds [1024 x i8], [1024 x i8]* %19, i64 0, i64 35
%39 = load i8, i8* %38
%40 = zext i8 %39 to i32
%41 = mul nsw i32 %40, 256
%42 = getelementptr inbounds [1024 x i8], [1024 x i8]* %19, i64 0, i64 34
%43 = load i8, i8* %42
%44 = zext i8 %43 to i32
%45 = add nsw i32 %41, %44
%46 = getelementptr inbounds [1024 x i8], [1024 x i8]* %19, i64 0, i64 55
%47 = load i8, i8* %46
%48 = zext i8 %47 to i32
%49 = mul nsw i32 %48, 256
%50 = add nsw i32 %45, %49
%51 = getelementptr inbounds [1024 x i8], [1024 x i8]* %19, i64 0, i64 54
%52 = load i8, i8* %51
%53 = zext i8 %52 to i32
%54 = add nsw i32 %50, %53
store i32 %54, i32* %17
%55 = getelementptr inbounds [1024 x i8], [1024 x i8]* %19, i64 0, i64 39
%56 = load i8, i8* %55
%57 = zext i8 %56 to i32
%58 = mul nsw i32 %57, 256
%59 = getelementptr inbounds [1024 x i8], [1024 x i8]* %19, i64 0, i64 38
%60 = load i8, i8* %59
%61 = zext i8 %60 to i32
%62 = add nsw i32 %58, %61
%63 = getelementptr inbounds [1024 x i8], [1024 x i8]* %19, i64 0, i64 59
%64 = load i8, i8* %63
%65 = zext i8 %64 to i32
%66 = mul nsw i32 %65, 256
%67 = add nsw i32 %62, %66
%68 = getelementptr inbounds [1024 x i8], [1024 x i8]* %19, i64 0, i64 58
%69 = load i8, i8* %68
%70 = zext i8 %69 to i32
%71 = add nsw i32 %67, %70
store i32 %71, i32* %18
%72 = load i32, i32* %12
%73 = load i32, i32* %20
%74 = load i32, i32* %10
%75 = load i8*, i8** %15
%76 = call i32 @SetBackColor(i32 %72, i32 %73, i32 %74, i8* %75)
%77 = load i16*, i16** %8
%78 = load i8*, i8** %9
%79 = load i8*, i8** %16
%80 = load i32, i32* %20
%81 = load i32, i32* %10
%82 = call i32 @picture(i16* %77, i8* %78, i8* %79, i32 %80, i32 %81)
%83 = load i8*, i8** %15
%84 = load i8*, i8** %16
%85 = load i32, i32* %11
%86 = load i32, i32* %20
%87 = load i32, i32* %10
%88 = mul nsw i32 %86, %87
%89 = call i32 @font_blit(i8* %83, i8* %84, i32 %85, i32 %88)
%90 = load i32, i32* %13
%91 = load i32, i32* %14
%92 = load i32, i32* %20
%93 = load i32, i32* %10
%94 = load i8*, i8** %15
%95 = call i32 @PutImage(i32 %90, i32 %91, i32 %92, i32 %93, i8* %94)
%96 = load i8*, i8** %15
%97 = call i32 @zfree(i8* %96)
%98 = load i8*, i8** %16
%99 = call i32 @zfree(i8* %98)
ret i32 0
}

LLVM IR (-O2):
define i32 @text_out(i16* %0, i8* %1, i32 %2, i32 %3, i32 %4, i32 %5, i32 %6) {
%8 = alloca [1024 x i8]
%9 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%10 = tail call i32 @get_width(i16* %0, i8* %1, i32 %2)
%11 = mul i32 %10, %2
%12 = mul i32 %11, 3
%13 = tail call i64 @zmalloc(i32 %12)
%14 = inttoptr i64 %13 to i8*
%15 = tail call i64 @zmalloc(i32 %11)
%16 = inttoptr i64 %15 to i8*
%17 = call i32 @kol_process_info(i32 -1, i8* %9)
%18 = call i32 @SetBackColor(i32 %4, i32 %10, i32 %2, i8* %14)
%19 = call i32 @picture(i16* %0, i8* %1, i8* %16, i32 %10, i32 %2)
%20 = call i32 @font_blit(i8* %14, i8* %16, i32 %3, i32 %11)
%21 = call i32 @PutImage(i32 %5, i32 %6, i32 %10, i32 %2, i8* %14)
%22 = call i32 @zfree(i8* %14)
%23 = call i32 @zfree(i8* %16)
ret i32 0
}