#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 GenerateDataContext {
  int dummy;
};
typedef void DataChunk;

/* Variables and functions */
int GenerateDataContext_packetSpace(struct GenerateDataContext *);
void *GenerateDataContext_reserveHeader(struct GenerateDataContext *,
                                        int /*<<< orphan*/);
int GenerateDataContext_simulateRequest(struct GenerateDataContext *gctx) {
  struct DataChunk *test = GenerateDataContext_reserveHeader(gctx, 0);
  if (test == ((void *)0)) {
    return -1;
  }
  int maxLen = GenerateDataContext_packetSpace(gctx);
  return maxLen;
}


x86 assembly (clang, -O0):
<GenerateDataContext_simulateRequest>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
xor    %esi,%esi
call   1040 <GenerateDataContext_reserveHeader@plt>
mov    %rax,-0x18(%rbp)
cmpq   $0x0,-0x18(%rbp)
jne    1152 <GenerateDataContext_simulateRequest+0x32>
movl   $0xffffffff,-0x4(%rbp)
jmp    1164 <GenerateDataContext_simulateRequest+0x44>
mov    -0x10(%rbp),%rdi
call   1030 <GenerateDataContext_packetSpace@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<GenerateDataContext_simulateRequest>:
push   %rbx
mov    %rdi,%rbx
xor    %esi,%esi
call   1040 <GenerateDataContext_reserveHeader@plt>
test   %rax,%rax
je     1139 <GenerateDataContext_simulateRequest+0x19>
mov    %rbx,%rdi
pop    %rbx
jmp    1030 <GenerateDataContext_packetSpace@plt>
mov    $0xffffffff,%eax
pop    %rbx
ret

LLVM IR (-O0):
%struct.GenerateDataContext = type { i32 }
%struct.DataChunk = type opaque
define i32 @GenerateDataContext_simulateRequest(%struct.GenerateDataContext* %0) {
%2 = alloca i32
%3 = alloca %struct.GenerateDataContext*
%4 = alloca %struct.DataChunk*
%5 = alloca i32
store %struct.GenerateDataContext* %0, %struct.GenerateDataContext** %3
%6 = load %struct.GenerateDataContext*, %struct.GenerateDataContext** %3
%7 = call i8* @GenerateDataContext_reserveHeader(%struct.GenerateDataContext* %6, i32 0)
%8 = bitcast i8* %7 to %struct.DataChunk*
store %struct.DataChunk* %8, %struct.DataChunk** %4
%9 = load %struct.DataChunk*, %struct.DataChunk** %4
%10 = icmp eq %struct.DataChunk* %9, null
br i1 %10, label %11, label %12
11: ; preds = %1
store i32 -1, i32* %2
br label %16
12: ; preds = %1
%13 = load %struct.GenerateDataContext*, %struct.GenerateDataContext** %3
%14 = call i32 @GenerateDataContext_packetSpace(%struct.GenerateDataContext* %13)
store i32 %14, i32* %5
%15 = load i32, i32* %5
store i32 %15, i32* %2
br label %16
16: ; preds = %12, %11
%17 = load i32, i32* %2
ret i32 %17
}

LLVM IR (-O2):
%struct.GenerateDataContext = type { i32 }
define i32 @GenerateDataContext_simulateRequest(%struct.GenerateDataContext* %0) {
%2 = tail call i8* @GenerateDataContext_reserveHeader(%struct.GenerateDataContext* %0, i32 0)
%3 = icmp eq i8* %2, null
br i1 %3, label %6, label %4
4: ; preds = %1
%5 = tail call i32 @GenerateDataContext_packetSpace(%struct.GenerateDataContext* %0)
br label %6
6: ; preds = %1, %4
%7 = phi i32 [ %5, %4 ], [ -1, %1 ]
ret i32 %7
}