#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 */
typedef struct TYPE_5__ TYPE_2__;
typedef struct TYPE_4__ TYPE_1__;

/* Type definitions */
struct TYPE_4__ {
  int /*<<< orphan*/ *gregs;
};
struct TYPE_5__ {
  TYPE_1__ uc_mcontext;
};
typedef TYPE_2__ ucontext_t;

/* Variables and functions */
int NGREG;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
void print_reg(ucontext_t *uc) {
  int i;
  for (i = 0; i < NGREG; i++) {
    fprintf(stderr,
            "reg[%02d]: 0x"
            "%016lx"
            "\n",
            i, uc->uc_mcontext.gregs[i]);
  }
}


x86 assembly (clang, -O0):
<print_reg>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
mov    -0xc(%rbp),%eax
mov    0x2ea3(%rip),%rcx
cmp    (%rcx),%eax
jge    1169 <print_reg+0x59>
mov    0x2ea4(%rip),%rax
mov    (%rax),%edi
mov    -0xc(%rbp),%edx
mov    -0x8(%rbp),%rax
mov    (%rax),%rax
movslq -0xc(%rbp),%rcx
mov    (%rax,%rcx,4),%ecx
lea    0xeaa(%rip),%rsi
call   1030 <fprintf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1123 <print_reg+0x13>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_reg>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
mov    0x2eb0(%rip),%r12
cmpl   $0x0,(%r12)
jle    1161 <print_reg+0x51>
mov    %rdi,%r14
xor    %ebx,%ebx
mov    0x2ead(%rip),%r13
lea    0xec6(%rip),%r15
nopw   0x0(%rax,%rax,1)
mov    0x0(%r13),%edi
mov    (%r14),%rax
mov    (%rax,%rbx,4),%ecx
mov    %r15,%rsi
mov    %ebx,%edx
call   1030 <fprintf@plt>
add    $0x1,%rbx
movslq (%r12),%rax
cmp    %rax,%rbx
jl     1140 <print_reg+0x30>
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.TYPE_5__ = type { %struct.TYPE_4__ }
%struct.TYPE_4__ = type { i32* }
@NGREG = global i32 0
@stderr = global i32 0
@.str = [21 x i8] c"reg[%02d]: 0x%016lx\0A\00"
define void @print_reg(%struct.TYPE_5__* %0) {
%2 = alloca %struct.TYPE_5__*
%3 = alloca i32
store %struct.TYPE_5__* %0, %struct.TYPE_5__** %2
store i32 0, i32* %3
br label %4
4: ; preds = %20, %1
%5 = load i32, i32* %3
%6 = load i32, i32* @NGREG
%7 = icmp slt i32 %5, %6
br i1 %7, label %8, label %23
8: ; preds = %4
%9 = load i32, i32* @stderr
%10 = load i32, i32* %3
%11 = load %struct.TYPE_5__*, %struct.TYPE_5__** %2
%12 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %11, i32 0, i32 0
%13 = getelementptr inbounds %struct.TYPE_4__, %struct.TYPE_4__* %12, i32 0, i32 0
%14 = load i32*, i32** %13
%15 = load i32, i32* %3
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds i32, i32* %14, i64 %16
%18 = load i32, i32* %17
%19 = call i32 @fprintf(i32 %9, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i32 %10, i32 %18)
br label %20
20: ; preds = %8
%21 = load i32, i32* %3
%22 = add nsw i32 %21, 1
store i32 %22, i32* %3
br label %4
23: ; preds = %4
ret void
}

LLVM IR (-O2):
%struct.TYPE_5__ = type { %struct.TYPE_4__ }
%struct.TYPE_4__ = type { i32* }
@NGREG = global i32 0
@stderr = global i32 0
@.str = [21 x i8] c"reg[%02d]: 0x%016lx\0A\00"
define void @print_reg(%struct.TYPE_5__* nocapture %0) {
%2 = load i32, i32* @NGREG
%3 = icmp sgt i32 %2, 0
br i1 %3, label %4, label %18
4: ; preds = %1
%5 = getelementptr inbounds %struct.TYPE_5__, %struct.TYPE_5__* %0, i64 0, i32 0, i32 0
br label %6
6: ; preds = %4, %6
%7 = phi i64 [ 0, %4 ], [ %14, %6 ]
%8 = load i32, i32* @stderr
%9 = load i32*, i32** %5
%10 = getelementptr inbounds i32, i32* %9, i64 %7
%11 = load i32, i32* %10
%12 = trunc i64 %7 to i32
%13 = tail call i32 @fprintf(i32 %8, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i32 %12, i32 %11)
%14 = add nuw nsw i64 %7, 1
%15 = load i32, i32* @NGREG
%16 = sext i32 %15 to i64
%17 = icmp slt i64 %14, %16
br i1 %17, label %6, label %18
18: ; preds = %6, %1
ret void
}