#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 */
typedef int /*<<< orphan*/ uint8_t;

/* Variables and functions */
int ts_get_adaptation(int /*<<< orphan*/ *);
int /*<<< orphan*/ ts_has_adaptation(int /*<<< orphan*/ *);
int /*<<< orphan*/ ts_has_payload(int /*<<< orphan*/ *);
uint8_t *ts_payload(uint8_t *p_ts) {
  if (!ts_has_payload(p_ts))
    return p_ts + 188;
  if (!ts_has_adaptation(p_ts))
    return p_ts + 4;
  return p_ts + 4 + 1 + ts_get_adaptation(p_ts);
}


x86 assembly (clang, -O0):
<ts_payload>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    -0x10(%rbp),%rdi
call   1050 <ts_has_payload@plt>
cmp    $0x0,%eax
jne    1161 <ts_payload+0x31>
mov    -0x10(%rbp),%rax
add    $0x2f0,%rax
mov    %rax,-0x8(%rbp)
jmp    11b1 <ts_payload+0x81>
mov    -0x10(%rbp),%rdi
call   1030 <ts_has_adaptation@plt>
cmp    $0x0,%eax
jne    1184 <ts_payload+0x54>
mov    -0x10(%rbp),%rax
add    $0x10,%rax
mov    %rax,-0x8(%rbp)
jmp    11b1 <ts_payload+0x81>
mov    -0x10(%rbp),%rax
add    $0x10,%rax
add    $0x4,%rax
mov    %rax,-0x18(%rbp)
mov    -0x10(%rbp),%rdi
call   1040 <ts_get_adaptation@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%rax
movslq %ecx,%rcx
shl    $0x2,%rcx
add    %rcx,%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<ts_payload>:
push   %rbx
mov    %rdi,%rbx
call   1050 <ts_has_payload@plt>
test   %eax,%eax
je     115d <ts_payload+0x2d>
mov    %rbx,%rdi
call   1030 <ts_has_adaptation@plt>
test   %eax,%eax
je     1166 <ts_payload+0x36>
mov    %rbx,%rdi
call   1040 <ts_get_adaptation@plt>
cltq
lea    (%rbx,%rax,4),%rbx
add    $0x14,%rbx
jmp    116a <ts_payload+0x3a>
add    $0x2f0,%rbx
jmp    116a <ts_payload+0x3a>
add    $0x10,%rbx
mov    %rbx,%rax
pop    %rbx
ret

LLVM IR (-O0):
define i32* @ts_payload(i32* %0) {
%2 = alloca i32*
%3 = alloca i32*
store i32* %0, i32** %3
%4 = load i32*, i32** %3
%5 = call i32 @ts_has_payload(i32* %4)
%6 = icmp ne i32 %5, 0
br i1 %6, label %10, label %7
7: ; preds = %1
%8 = load i32*, i32** %3
%9 = getelementptr inbounds i32, i32* %8, i64 188
store i32* %9, i32** %2
br label %25
10: ; preds = %1
%11 = load i32*, i32** %3
%12 = call i32 @ts_has_adaptation(i32* %11)
%13 = icmp ne i32 %12, 0
br i1 %13, label %17, label %14
14: ; preds = %10
%15 = load i32*, i32** %3
%16 = getelementptr inbounds i32, i32* %15, i64 4
store i32* %16, i32** %2
br label %25
17: ; preds = %10
%18 = load i32*, i32** %3
%19 = getelementptr inbounds i32, i32* %18, i64 4
%20 = getelementptr inbounds i32, i32* %19, i64 1
%21 = load i32*, i32** %3
%22 = call i32 @ts_get_adaptation(i32* %21)
%23 = sext i32 %22 to i64
%24 = getelementptr inbounds i32, i32* %20, i64 %23
store i32* %24, i32** %2
br label %25
25: ; preds = %17, %14, %7
%26 = load i32*, i32** %2
ret i32* %26
}

LLVM IR (-O2):
define i32* @ts_payload(i32* %0) {
%2 = tail call i32 @ts_has_payload(i32* %0)
%3 = icmp eq i32 %2, 0
br i1 %3, label %4, label %6
4: ; preds = %1
%5 = getelementptr inbounds i32, i32* %0, i64 188
br label %16
6: ; preds = %1
%7 = tail call i32 @ts_has_adaptation(i32* %0)
%8 = icmp eq i32 %7, 0
br i1 %8, label %9, label %11
9: ; preds = %6
%10 = getelementptr inbounds i32, i32* %0, i64 4
br label %16
11: ; preds = %6
%12 = getelementptr inbounds i32, i32* %0, i64 5
%13 = tail call i32 @ts_get_adaptation(i32* %0)
%14 = sext i32 %13 to i64
%15 = getelementptr inbounds i32, i32* %12, i64 %14
br label %16
16: ; preds = %11, %9, %4
%17 = phi i32* [ %15, %11 ], [ %10, %9 ], [ %5, %4 ]
ret i32* %17
}