#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 */

/* Variables and functions */
unsigned char *gdb_cpu_getreg(int, size_t *);
int /*<<< orphan*/ gdb_tx_char(char);
int /*<<< orphan*/ gdb_tx_mem(unsigned char *, size_t);
void gdb_tx_reg(int regnum) {
  unsigned char *regp;
  size_t regsz;
  regp = gdb_cpu_getreg(regnum, &regsz);
  if (regp == NULL) {
    while (regsz--) {
      gdb_tx_char('x');
      gdb_tx_char('x');
    }
  } else
    gdb_tx_mem(regp, regsz);
}


x86 assembly (clang, -O0):
<gdb_tx_reg>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%edi
lea    -0x18(%rbp),%rsi
call   1040 <gdb_cpu_getreg@plt>
mov    %rax,-0x10(%rbp)
cmpq   $0x0,-0x10(%rbp)
jne    1192 <gdb_tx_reg+0x62>
jmp    115b <gdb_tx_reg+0x2b>
mov    -0x18(%rbp),%rax
mov    %rax,%rcx
add    $0xffffffffffffffff,%rcx
mov    %rcx,-0x18(%rbp)
cmp    $0x0,%rax
je     118d <gdb_tx_reg+0x5d>
mov    $0x78,%edi
call   1050 <gdb_tx_char@plt>
mov    $0x78,%edi
call   1050 <gdb_tx_char@plt>
jmp    115b <gdb_tx_reg+0x2b>
jmp    119f <gdb_tx_reg+0x6f>
mov    -0x10(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1030 <gdb_tx_mem@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gdb_tx_reg>:
push   %rax
mov    %rsp,%rsi
call   1040 <gdb_cpu_getreg@plt>
mov    (%rsp),%rsi
test   %rax,%rax
je     114c <gdb_tx_reg+0x1c>
mov    %rax,%rdi
call   1030 <gdb_tx_mem@plt>
jmp    117b <gdb_tx_reg+0x4b>
sub    $0x1,%rsi
mov    %rsi,(%rsp)
jb     117b <gdb_tx_reg+0x4b>
cs nopw 0x0(%rax,%rax,1)
mov    $0x78,%edi
call   1050 <gdb_tx_char@plt>
mov    $0x78,%edi
call   1050 <gdb_tx_char@plt>
subq   $0x1,(%rsp)
jae    1160 <gdb_tx_reg+0x30>
pop    %rax
ret

LLVM IR (-O0):
define void @gdb_tx_reg(i32 %0) {
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i64
store i32 %0, i32* %2
%5 = load i32, i32* %2
%6 = call i8* @gdb_cpu_getreg(i32 %5, i64* %4)
store i8* %6, i8** %3
%7 = load i8*, i8** %3
%8 = icmp eq i8* %7, null
br i1 %8, label %9, label %18
9: ; preds = %1
br label %10
10: ; preds = %14, %9
%11 = load i64, i64* %4
%12 = add i64 %11, -1
store i64 %12, i64* %4
%13 = icmp ne i64 %11, 0
br i1 %13, label %14, label %17
14: ; preds = %10
%15 = call i32 @gdb_tx_char(i8 signext 120)
%16 = call i32 @gdb_tx_char(i8 signext 120)
br label %10
17: ; preds = %10
br label %22
18: ; preds = %1
%19 = load i8*, i8** %3
%20 = load i64, i64* %4
%21 = call i32 @gdb_tx_mem(i8* %19, i64 %20)
br label %22
22: ; preds = %18, %17
ret void
}

LLVM IR (-O2):
define void @gdb_tx_reg(i32 %0) {
%2 = alloca i64
%3 = bitcast i64* %2 to i8*
%4 = call i8* @gdb_cpu_getreg(i32 %0, i64* %2)
%5 = icmp eq i8* %4, null
%6 = load i64, i64* %2
br i1 %5, label %7, label %16
7: ; preds = %1
%8 = add i64 %6, -1
store i64 %8, i64* %2
%9 = icmp eq i64 %6, 0
br i1 %9, label %18, label %10
10: ; preds = %7, %10
%11 = call i32 @gdb_tx_char(i8 signext 120)
%12 = call i32 @gdb_tx_char(i8 signext 120)
%13 = load i64, i64* %2
%14 = add i64 %13, -1
store i64 %14, i64* %2
%15 = icmp eq i64 %13, 0
br i1 %15, label %18, label %10
16: ; preds = %1
%17 = call i32 @gdb_tx_mem(i8* %4, i64 %6)
br label %18
18: ; preds = %10, %7, %16
ret void
}