#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 tgl_state {
  int dummy;
};

/* Variables and functions */
int /*<<< orphan*/ add_log_event(struct tgl_state *, int *, int);
int *alloc_log_event(int);
int /*<<< orphan*/ memcpy(int *, unsigned char *, int);
void bl_do_encr_chat_init(struct tgl_state *TLS, int id, int user_id,
                          unsigned char random[], unsigned char g_a[]) {
  int *ev = alloc_log_event(524);
  ev[0] = 0xe08a8252;
  ev[1] = id;
  ev[2] = user_id;
  memcpy(ev + 3, random, 256);
  memcpy(ev + 67, g_a, 256);
  add_log_event(TLS, ev, 524);
}


x86 assembly (clang, -O0):
<bl_do_encr_chat_init>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %edx,-0x10(%rbp)
mov    %rcx,-0x18(%rbp)
mov    %r8,-0x20(%rbp)
mov    $0x20c,%edi
call   1040 <alloc_log_event@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
movl   $0xe08a8252,(%rax)
mov    -0xc(%rbp),%ecx
mov    -0x28(%rbp),%rax
mov    %ecx,0x4(%rax)
mov    -0x10(%rbp),%ecx
mov    -0x28(%rbp),%rax
mov    %ecx,0x8(%rax)
mov    -0x28(%rbp),%rdi
add    $0xc,%rdi
mov    -0x18(%rbp),%rsi
mov    $0x100,%edx
call   1050 <memcpy@plt>
mov    -0x28(%rbp),%rdi
add    $0x10c,%rdi
mov    -0x20(%rbp),%rsi
mov    $0x100,%edx
call   1050 <memcpy@plt>
mov    -0x8(%rbp),%rdi
mov    -0x28(%rbp),%rsi
mov    $0x20c,%edx
call   1030 <add_log_event@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<bl_do_encr_chat_init>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %r8,%r14
mov    %rcx,%r15
mov    %edx,%r13d
mov    %esi,%ebx
mov    %rdi,%r12
mov    $0x20c,%edi
call   1040 <alloc_log_event@plt>
mov    %rax,%rbp
movl   $0xe08a8252,(%rax)
mov    %ebx,0x4(%rax)
mov    %r13d,0x8(%rax)
lea    0xc(%rax),%rdi
mov    %r15,%rsi
mov    $0x100,%edx
call   1050 <memcpy@plt>
lea    0x10c(%rbp),%rdi
mov    %r14,%rsi
mov    $0x100,%edx
call   1050 <memcpy@plt>
mov    %r12,%rdi
mov    %rbp,%rsi
mov    $0x20c,%edx
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <add_log_event@plt>

LLVM IR (-O0):
%struct.tgl_state = type { i32 }
define void @bl_do_encr_chat_init(%struct.tgl_state* %0, i32 %1, i32 %2, i8* %3, i8* %4) {
%6 = alloca %struct.tgl_state*
%7 = alloca i32
%8 = alloca i32
%9 = alloca i8*
%10 = alloca i8*
%11 = alloca i32*
store %struct.tgl_state* %0, %struct.tgl_state** %6
store i32 %1, i32* %7
store i32 %2, i32* %8
store i8* %3, i8** %9
store i8* %4, i8** %10
%12 = call i32* @alloc_log_event(i32 524)
store i32* %12, i32** %11
%13 = load i32*, i32** %11
%14 = getelementptr inbounds i32, i32* %13, i64 0
store i32 -527793582, i32* %14
%15 = load i32, i32* %7
%16 = load i32*, i32** %11
%17 = getelementptr inbounds i32, i32* %16, i64 1
store i32 %15, i32* %17
%18 = load i32, i32* %8
%19 = load i32*, i32** %11
%20 = getelementptr inbounds i32, i32* %19, i64 2
store i32 %18, i32* %20
%21 = load i32*, i32** %11
%22 = getelementptr inbounds i32, i32* %21, i64 3
%23 = load i8*, i8** %9
%24 = call i32 @memcpy(i32* %22, i8* %23, i32 256)
%25 = load i32*, i32** %11
%26 = getelementptr inbounds i32, i32* %25, i64 67
%27 = load i8*, i8** %10
%28 = call i32 @memcpy(i32* %26, i8* %27, i32 256)
%29 = load %struct.tgl_state*, %struct.tgl_state** %6
%30 = load i32*, i32** %11
%31 = call i32 @add_log_event(%struct.tgl_state* %29, i32* %30, i32 524)
ret void
}

LLVM IR (-O2):
%struct.tgl_state = type { i32 }
define void @bl_do_encr_chat_init(%struct.tgl_state* %0, i32 %1, i32 %2, i8* %3, i8* %4) {
%6 = tail call i32* @alloc_log_event(i32 524)
store i32 -527793582, i32* %6
%7 = getelementptr inbounds i32, i32* %6, i64 1
store i32 %1, i32* %7
%8 = getelementptr inbounds i32, i32* %6, i64 2
store i32 %2, i32* %8
%9 = getelementptr inbounds i32, i32* %6, i64 3
%10 = tail call i32 @memcpy(i32* %9, i8* %3, i32 256)
%11 = getelementptr inbounds i32, i32* %6, i64 67
%12 = tail call i32 @memcpy(i32* %11, i8* %4, i32 256)
%13 = tail call i32 @add_log_event(%struct.tgl_state* %0, i32* %6, i32 524)
ret void
}