#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 */
#define R_PPC_REL14 129
#define R_PPC_REL24 128
int /*<<< orphan*/ reloc_pc14(int /*<<< orphan*/ *, intptr_t);
int /*<<< orphan*/ reloc_pc24(int /*<<< orphan*/ *, intptr_t);
int /*<<< orphan*/ tcg_abort();
void patch_reloc(uint8_t *code_ptr, int type, intptr_t value, intptr_t addend) {
  value += addend;
  switch (type) {
  case R_PPC_REL14:
    reloc_pc14(code_ptr, value);
    break;
  case R_PPC_REL24:
    reloc_pc24(code_ptr, value);
    break;
  default:
    tcg_abort();
  }
}


x86 assembly (clang, -O0):
<patch_reloc>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %rcx,-0x20(%rbp)
mov    -0x20(%rbp),%rcx
mov    -0x18(%rbp),%rax
add    %rcx,%rax
mov    %rax,-0x18(%rbp)
mov    -0xc(%rbp),%eax
mov    %eax,-0x24(%rbp)
sub    $0x80,%eax
je     1191 <patch_reloc+0x61>
jmp    116c <patch_reloc+0x3c>
mov    -0x24(%rbp),%eax
sub    $0x81,%eax
jne    11a3 <patch_reloc+0x73>
jmp    117f <patch_reloc+0x4f>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <reloc_pc14@plt>
jmp    11aa <patch_reloc+0x7a>
mov    -0x8(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1050 <reloc_pc24@plt>
jmp    11aa <patch_reloc+0x7a>
mov    $0x0,%al
call   1040 <tcg_abort@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<patch_reloc>:
add    %rcx,%rdx
cmp    $0x80,%esi
je     114b <patch_reloc+0x1b>
cmp    $0x81,%esi
jne    1153 <patch_reloc+0x23>
mov    %rdx,%rsi
jmp    1030 <reloc_pc14@plt>
mov    %rdx,%rsi
jmp    1050 <reloc_pc24@plt>
xor    %eax,%eax
jmp    1040 <tcg_abort@plt>

LLVM IR (-O0):
define void @patch_reloc(i32* %0, i32 %1, i64 %2, i64 %3) {
%5 = alloca i32*
%6 = alloca i32
%7 = alloca i64
%8 = alloca i64
store i32* %0, i32** %5
store i32 %1, i32* %6
store i64 %2, i64* %7
store i64 %3, i64* %8
%9 = load i64, i64* %8
%10 = load i64, i64* %7
%11 = add nsw i64 %10, %9
store i64 %11, i64* %7
%12 = load i32, i32* %6
switch i32 %12, label %21 [
i32 129, label %13
i32 128, label %17
]
13: ; preds = %4
%14 = load i32*, i32** %5
%15 = load i64, i64* %7
%16 = call i32 @reloc_pc14(i32* %14, i64 %15)
br label %23
17: ; preds = %4
%18 = load i32*, i32** %5
%19 = load i64, i64* %7
%20 = call i32 @reloc_pc24(i32* %18, i64 %19)
br label %23
21: ; preds = %4
%22 = call i32 (...) @tcg_abort()
br label %23
23: ; preds = %21, %17, %13
ret void
}

LLVM IR (-O2):
define void @patch_reloc(i32* %0, i32 %1, i64 %2, i64 %3) {
%5 = add nsw i64 %3, %2
switch i32 %1, label %10 [
i32 129, label %6
i32 128, label %8
]
6: ; preds = %4
%7 = tail call i32 @reloc_pc14(i32* %0, i64 %5)
br label %12
8: ; preds = %4
%9 = tail call i32 @reloc_pc24(i32* %0, i64 %5)
br label %12
10: ; preds = %4
%11 = tail call i32 (...) @tcg_abort()
br label %12
12: ; preds = %10, %8, %6
ret void
}