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

/* Variables and functions */
int /*<<< orphan*/ prefetch_data(int *, int);
struct tgl_message *tgl_message_get(struct tgl_state *, int);
int /*<<< orphan*/ tglf_fetch_message(struct tgl_state *, struct tgl_message *);
struct tgl_message *tglm_message_alloc(struct tgl_state *, int);
struct tgl_message *tglf_fetch_alloc_message(struct tgl_state *TLS) {
  int data[3];
  prefetch_data(data, 12);
  struct tgl_message *M =
      tgl_message_get(TLS, data[0] != (int)0x83e5de54 ? data[2] : data[1]);
  if (!M) {
    M = tglm_message_alloc(TLS, data[0] != (int)0x83e5de54 ? data[2] : data[1]);
  }
  tglf_fetch_message(TLS, M);
  return M;
}


x86 assembly (clang, -O0):
<tglf_fetch_alloc_message>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
mov    %rdi,-0x8(%rbp)
lea    -0x14(%rbp),%rdi
mov    $0xc,%esi
call   1050 <prefetch_data@plt>
mov    -0x8(%rbp),%rax
mov    %rax,-0x28(%rbp)
cmpl   $0x83e5de54,-0x14(%rbp)
je     117a <tglf_fetch_alloc_message+0x3a>
mov    -0xc(%rbp),%eax
mov    %eax,-0x2c(%rbp)
jmp    1180 <tglf_fetch_alloc_message+0x40>
mov    -0x10(%rbp),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x2c(%rbp),%esi
call   1040 <tgl_message_get@plt>
mov    %rax,-0x20(%rbp)
cmpq   $0x0,-0x20(%rbp)
jne    11d1 <tglf_fetch_alloc_message+0x91>
mov    -0x8(%rbp),%rax
mov    %rax,-0x38(%rbp)
cmpl   $0x83e5de54,-0x14(%rbp)
je     11bb <tglf_fetch_alloc_message+0x7b>
mov    -0xc(%rbp),%eax
mov    %eax,-0x3c(%rbp)
jmp    11c1 <tglf_fetch_alloc_message+0x81>
mov    -0x10(%rbp),%eax
mov    %eax,-0x3c(%rbp)
mov    -0x38(%rbp),%rdi
mov    -0x3c(%rbp),%esi
call   1030 <tglm_message_alloc@plt>
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
mov    -0x20(%rbp),%rsi
call   1060 <tglf_fetch_message@plt>
mov    -0x20(%rbp),%rax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<tglf_fetch_alloc_message>:
push   %r14
push   %rbx
sub    $0x18,%rsp
mov    %rdi,%r14
lea    0xc(%rsp),%rdi
mov    $0xc,%esi
call   1050 <prefetch_data@plt>
xor    %eax,%eax
cmpl   $0x83e5de54,0xc(%rsp)
83
setne  %al
mov    0x10(%rsp,%rax,4),%esi
mov    %r14,%rdi
call   1040 <tgl_message_get@plt>
mov    %rax,%rbx
test   %rax,%rax
jne    1196 <tglf_fetch_alloc_message+0x56>
xor    %eax,%eax
cmpl   $0x83e5de54,0xc(%rsp)
83
setne  %al
mov    0x10(%rsp,%rax,4),%esi
mov    %r14,%rdi
call   1030 <tglm_message_alloc@plt>
mov    %rax,%rbx
mov    %r14,%rdi
mov    %rbx,%rsi
call   1060 <tglf_fetch_message@plt>
mov    %rbx,%rax
add    $0x18,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
%struct.tgl_message = type { i32 }
%struct.tgl_state = type { i32 }
define %struct.tgl_message* @tglf_fetch_alloc_message(%struct.tgl_state* %0) {
%2 = alloca %struct.tgl_state*
%3 = alloca [3 x i32]
%4 = alloca %struct.tgl_message*
store %struct.tgl_state* %0, %struct.tgl_state** %2
%5 = getelementptr inbounds [3 x i32], [3 x i32]* %3, i64 0, i64 0
%6 = call i32 @prefetch_data(i32* %5, i32 12)
%7 = load %struct.tgl_state*, %struct.tgl_state** %2
%8 = getelementptr inbounds [3 x i32], [3 x i32]* %3, i64 0, i64 0
%9 = load i32, i32* %8
%10 = icmp ne i32 %9, -2082087340
br i1 %10, label %11, label %14
11: ; preds = %1
%12 = getelementptr inbounds [3 x i32], [3 x i32]* %3, i64 0, i64 2
%13 = load i32, i32* %12
br label %17
14: ; preds = %1
%15 = getelementptr inbounds [3 x i32], [3 x i32]* %3, i64 0, i64 1
%16 = load i32, i32* %15
br label %17
17: ; preds = %14, %11
%18 = phi i32 [ %13, %11 ], [ %16, %14 ]
%19 = call %struct.tgl_message* @tgl_message_get(%struct.tgl_state* %7, i32 %18)
store %struct.tgl_message* %19, %struct.tgl_message** %4
%20 = load %struct.tgl_message*, %struct.tgl_message** %4
%21 = icmp ne %struct.tgl_message* %20, null
br i1 %21, label %36, label %22
22: ; preds = %17
%23 = load %struct.tgl_state*, %struct.tgl_state** %2
%24 = getelementptr inbounds [3 x i32], [3 x i32]* %3, i64 0, i64 0
%25 = load i32, i32* %24
%26 = icmp ne i32 %25, -2082087340
br i1 %26, label %27, label %30
27: ; preds = %22
%28 = getelementptr inbounds [3 x i32], [3 x i32]* %3, i64 0, i64 2
%29 = load i32, i32* %28
br label %33
30: ; preds = %22
%31 = getelementptr inbounds [3 x i32], [3 x i32]* %3, i64 0, i64 1
%32 = load i32, i32* %31
br label %33
33: ; preds = %30, %27
%34 = phi i32 [ %29, %27 ], [ %32, %30 ]
%35 = call %struct.tgl_message* @tglm_message_alloc(%struct.tgl_state* %23, i32 %34)
store %struct.tgl_message* %35, %struct.tgl_message** %4
br label %36
36: ; preds = %33, %17
%37 = load %struct.tgl_state*, %struct.tgl_state** %2
%38 = load %struct.tgl_message*, %struct.tgl_message** %4
%39 = call i32 @tglf_fetch_message(%struct.tgl_state* %37, %struct.tgl_message* %38)
%40 = load %struct.tgl_message*, %struct.tgl_message** %4
ret %struct.tgl_message* %40
}

LLVM IR (-O2):
%struct.tgl_message = type { i32 }
%struct.tgl_state = type { i32 }
define %struct.tgl_message* @tglf_fetch_alloc_message(%struct.tgl_state* %0) {
%2 = alloca [3 x i32]
%3 = bitcast [3 x i32]* %2 to i8*
%4 = getelementptr inbounds [3 x i32], [3 x i32]* %2, i64 0, i64 0
%5 = call i32 @prefetch_data(i32* %4, i32 12)
%6 = load i32, i32* %4
%7 = icmp eq i32 %6, -2082087340
%8 = getelementptr inbounds [3 x i32], [3 x i32]* %2, i64 0, i64 2
%9 = load i32, i32* %8
%10 = getelementptr inbounds [3 x i32], [3 x i32]* %2, i64 0, i64 1
%11 = load i32, i32* %10
%12 = select i1 %7, i32 %11, i32 %9
%13 = call %struct.tgl_message* @tgl_message_get(%struct.tgl_state* %0, i32 %12)
%14 = icmp eq %struct.tgl_message* %13, null
br i1 %14, label %15, label %22
15: ; preds = %1
%16 = load i32, i32* %4
%17 = icmp eq i32 %16, -2082087340
%18 = load i32, i32* %8
%19 = load i32, i32* %10
%20 = select i1 %17, i32 %19, i32 %18
%21 = call %struct.tgl_message* @tglm_message_alloc(%struct.tgl_state* %0, i32 %20)
br label %22
22: ; preds = %15, %1
%23 = phi %struct.tgl_message* [ %13, %1 ], [ %21, %15 ]
%24 = call i32 @tglf_fetch_message(%struct.tgl_state* %0, %struct.tgl_message* %23)
ret %struct.tgl_message* %23
}