#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 uint8_t;
typedef int int32_t;

/* Variables and functions */
size_t append_little_endian_uint32(int *, int);
size_t append_hex_post_loop_jump(uint8_t *dst, int32_t rel_dis) {
  dst[0] = 0x80;
  dst[1] = 0x39;
  dst[2] = 0x00;
  rel_dis -= 5;
  int32_t mask = ~0xff;
  if ((rel_dis & mask) == 0) {
    dst[3] = 0x75;
    dst[4] = rel_dis;
    return 5;
  }
  rel_dis -= 4;
  dst[3] = 0x0f;
  dst[4] = 0x85;
  return 5 + append_little_endian_uint32(dst + 5, rel_dis);
}


x86 assembly (clang, -O0):
<append_hex_post_loop_jump>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %esi,-0x14(%rbp)
mov    -0x10(%rbp),%rax
movl   $0x80,(%rax)
mov    -0x10(%rbp),%rax
movl   $0x39,0x4(%rax)
mov    -0x10(%rbp),%rax
movl   $0x0,0x8(%rax)
mov    -0x14(%rbp),%eax
sub    $0x5,%eax
mov    %eax,-0x14(%rbp)
movl   $0xffffff00,-0x18(%rbp)
mov    -0x14(%rbp),%eax
and    -0x18(%rbp),%eax
cmp    $0x0,%eax
jne    1180 <append_hex_post_loop_jump+0x70>
mov    -0x10(%rbp),%rax
movl   $0x75,0xc(%rax)
mov    -0x14(%rbp),%ecx
mov    -0x10(%rbp),%rax
mov    %ecx,0x10(%rax)
movq   $0x5,-0x8(%rbp)
jmp    11b7 <append_hex_post_loop_jump+0xa7>
mov    -0x14(%rbp),%eax
sub    $0x4,%eax
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rax
movl   $0xf,0xc(%rax)
mov    -0x10(%rbp),%rax
movl   $0x85,0x10(%rax)
mov    -0x10(%rbp),%rdi
add    $0x14,%rdi
mov    -0x14(%rbp),%esi
call   1030 <append_little_endian_uint32@plt>
add    $0x5,%rax
mov    %rax,-0x8(%rbp)
mov    -0x8(%rbp),%rax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<append_hex_post_loop_jump>:
push   %rax
movabs $0x3900000080,%rax
mov    %rax,(%rdi)
movl   $0x0,0x8(%rdi)
lea    -0x5(%rsi),%eax
cmp    $0xff,%eax
ja     1140 <append_hex_post_loop_jump+0x30>
movl   $0x75,0xc(%rdi)
mov    %eax,0x10(%rdi)
mov    $0x5,%eax
pop    %rcx
ret
add    $0xfffffff7,%esi
movabs $0x850000000f,%rax
mov    %rax,0xc(%rdi)
add    $0x14,%rdi
call   1030 <append_little_endian_uint32@plt>
add    $0x5,%rax
pop    %rcx
ret

LLVM IR (-O0):
define i64 @append_hex_post_loop_jump(i32* %0, i32 %1) {
%3 = alloca i64
%4 = alloca i32*
%5 = alloca i32
%6 = alloca i32
store i32* %0, i32** %4
store i32 %1, i32* %5
%7 = load i32*, i32** %4
%8 = getelementptr inbounds i32, i32* %7, i64 0
store i32 128, i32* %8
%9 = load i32*, i32** %4
%10 = getelementptr inbounds i32, i32* %9, i64 1
store i32 57, i32* %10
%11 = load i32*, i32** %4
%12 = getelementptr inbounds i32, i32* %11, i64 2
store i32 0, i32* %12
%13 = load i32, i32* %5
%14 = sub nsw i32 %13, 5
store i32 %14, i32* %5
store i32 -256, i32* %6
%15 = load i32, i32* %5
%16 = load i32, i32* %6
%17 = and i32 %15, %16
%18 = icmp eq i32 %17, 0
br i1 %18, label %19, label %25
19: ; preds = %2
%20 = load i32*, i32** %4
%21 = getelementptr inbounds i32, i32* %20, i64 3
store i32 117, i32* %21
%22 = load i32, i32* %5
%23 = load i32*, i32** %4
%24 = getelementptr inbounds i32, i32* %23, i64 4
store i32 %22, i32* %24
store i64 5, i64* %3
br label %37
25: ; preds = %2
%26 = load i32, i32* %5
%27 = sub nsw i32 %26, 4
store i32 %27, i32* %5
%28 = load i32*, i32** %4
%29 = getelementptr inbounds i32, i32* %28, i64 3
store i32 15, i32* %29
%30 = load i32*, i32** %4
%31 = getelementptr inbounds i32, i32* %30, i64 4
store i32 133, i32* %31
%32 = load i32*, i32** %4
%33 = getelementptr inbounds i32, i32* %32, i64 5
%34 = load i32, i32* %5
%35 = call i64 @append_little_endian_uint32(i32* %33, i32 %34)
%36 = add i64 5, %35
store i64 %36, i64* %3
br label %37
37: ; preds = %25, %19
%38 = load i64, i64* %3
ret i64 %38
}

LLVM IR (-O2):
define i64 @append_hex_post_loop_jump(i32* %0, i32 %1) {
store i32 128, i32* %0
%3 = getelementptr inbounds i32, i32* %0, i64 1
store i32 57, i32* %3
%4 = getelementptr inbounds i32, i32* %0, i64 2
store i32 0, i32* %4
%5 = add nsw i32 %1, -5
%6 = icmp ult i32 %5, 256
br i1 %6, label %7, label %10
7: ; preds = %2
%8 = getelementptr inbounds i32, i32* %0, i64 3
store i32 117, i32* %8
%9 = getelementptr inbounds i32, i32* %0, i64 4
store i32 %5, i32* %9
br label %17
10: ; preds = %2
%11 = add nsw i32 %1, -9
%12 = getelementptr inbounds i32, i32* %0, i64 3
store i32 15, i32* %12
%13 = getelementptr inbounds i32, i32* %0, i64 4
store i32 133, i32* %13
%14 = getelementptr inbounds i32, i32* %0, i64 5
%15 = tail call i64 @append_little_endian_uint32(i32* %14, i32 %11)
%16 = add i64 %15, 5
br label %17
17: ; preds = %10, %7
%18 = phi i64 [ 5, %7 ], [ %16, %10 ]
ret i64 %18
}