#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 */
char hexchar(unsigned int);
int /*<<< orphan*/ putch(char const);
void printreg(const char *p, unsigned val) {
  for (; *p; ++p)
    putch(*p);
  putch('=');
  putch(' ');
  putch(hexchar(val >> 28));
  putch(hexchar(val >> 24));
  putch(hexchar(val >> 20));
  putch(hexchar(val >> 16));
  putch(hexchar(val >> 12));
  putch(hexchar(val >> 8));
  putch(hexchar(val >> 4));
  putch(hexchar(val));
  putch('\n');
}


x86 assembly (clang, -O0):
<printreg>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%rax
cmpb   $0x0,(%rax)
je     1159 <printreg+0x39>
mov    -0x8(%rbp),%rax
movsbl (%rax),%edi
call   1040 <putch@plt>
mov    -0x8(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x8(%rbp)
jmp    112f <printreg+0xf>
mov    $0x3d,%edi
call   1040 <putch@plt>
mov    $0x20,%edi
call   1040 <putch@plt>
mov    -0xc(%rbp),%edi
shr    $0x1c,%edi
call   1030 <hexchar@plt>
movsbl %al,%edi
call   1040 <putch@plt>
mov    -0xc(%rbp),%edi
shr    $0x18,%edi
call   1030 <hexchar@plt>
movsbl %al,%edi
call   1040 <putch@plt>
mov    -0xc(%rbp),%edi
shr    $0x14,%edi
call   1030 <hexchar@plt>
movsbl %al,%edi
call   1040 <putch@plt>
mov    -0xc(%rbp),%edi
shr    $0x10,%edi
call   1030 <hexchar@plt>
movsbl %al,%edi
call   1040 <putch@plt>
mov    -0xc(%rbp),%edi
shr    $0xc,%edi
call   1030 <hexchar@plt>
movsbl %al,%edi
call   1040 <putch@plt>
mov    -0xc(%rbp),%edi
shr    $0x8,%edi
call   1030 <hexchar@plt>
movsbl %al,%edi
call   1040 <putch@plt>
mov    -0xc(%rbp),%edi
shr    $0x4,%edi
call   1030 <hexchar@plt>
movsbl %al,%edi
call   1040 <putch@plt>
mov    -0xc(%rbp),%edi
call   1030 <hexchar@plt>
movsbl %al,%edi
call   1040 <putch@plt>
mov    $0xa,%edi
call   1040 <putch@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<printreg>:
push   %rbp
push   %rbx
push   %rax
mov    %esi,%ebp
mov    (%rdi),%al
test   %al,%al
je     1153 <printreg+0x33>
mov    %rdi,%rbx
add    $0x1,%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
movsbl %al,%edi
call   1040 <putch@plt>
movzbl (%rbx),%eax
add    $0x1,%rbx
test   %al,%al
jne    1140 <printreg+0x20>
mov    $0x3d,%edi
call   1040 <putch@plt>
mov    $0x20,%edi
call   1040 <putch@plt>
mov    %ebp,%edi
shr    $0x1c,%edi
call   1030 <hexchar@plt>
movsbl %al,%edi
call   1040 <putch@plt>
mov    %ebp,%edi
shr    $0x18,%edi
call   1030 <hexchar@plt>
movsbl %al,%edi
call   1040 <putch@plt>
mov    %ebp,%edi
shr    $0x14,%edi
call   1030 <hexchar@plt>
movsbl %al,%edi
call   1040 <putch@plt>
mov    %ebp,%edi
shr    $0x10,%edi
call   1030 <hexchar@plt>
movsbl %al,%edi
call   1040 <putch@plt>
mov    %ebp,%edi
shr    $0xc,%edi
call   1030 <hexchar@plt>
movsbl %al,%edi
call   1040 <putch@plt>
mov    %ebp,%edi
shr    $0x8,%edi
call   1030 <hexchar@plt>
movsbl %al,%edi
call   1040 <putch@plt>
mov    %ebp,%edi
shr    $0x4,%edi
call   1030 <hexchar@plt>
movsbl %al,%edi
call   1040 <putch@plt>
mov    %ebp,%edi
call   1030 <hexchar@plt>
movsbl %al,%edi
call   1040 <putch@plt>
mov    $0xa,%edi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1040 <putch@plt>

LLVM IR (-O0):
define void @printreg(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
store i8* %0, i8** %3
store i32 %1, i32* %4
br label %5
5: ; preds = %13, %2
%6 = load i8*, i8** %3
%7 = load i8, i8* %6
%8 = icmp ne i8 %7, 0
br i1 %8, label %9, label %16
9: ; preds = %5
%10 = load i8*, i8** %3
%11 = load i8, i8* %10
%12 = call i32 @putch(i8 signext %11)
br label %13
13: ; preds = %9
%14 = load i8*, i8** %3
%15 = getelementptr inbounds i8, i8* %14, i32 1
store i8* %15, i8** %3
br label %5
16: ; preds = %5
%17 = call i32 @putch(i8 signext 61)
%18 = call i32 @putch(i8 signext 32)
%19 = load i32, i32* %4
%20 = lshr i32 %19, 28
%21 = call signext i8 @hexchar(i32 %20)
%22 = call i32 @putch(i8 signext %21)
%23 = load i32, i32* %4
%24 = lshr i32 %23, 24
%25 = call signext i8 @hexchar(i32 %24)
%26 = call i32 @putch(i8 signext %25)
%27 = load i32, i32* %4
%28 = lshr i32 %27, 20
%29 = call signext i8 @hexchar(i32 %28)
%30 = call i32 @putch(i8 signext %29)
%31 = load i32, i32* %4
%32 = lshr i32 %31, 16
%33 = call signext i8 @hexchar(i32 %32)
%34 = call i32 @putch(i8 signext %33)
%35 = load i32, i32* %4
%36 = lshr i32 %35, 12
%37 = call signext i8 @hexchar(i32 %36)
%38 = call i32 @putch(i8 signext %37)
%39 = load i32, i32* %4
%40 = lshr i32 %39, 8
%41 = call signext i8 @hexchar(i32 %40)
%42 = call i32 @putch(i8 signext %41)
%43 = load i32, i32* %4
%44 = lshr i32 %43, 4
%45 = call signext i8 @hexchar(i32 %44)
%46 = call i32 @putch(i8 signext %45)
%47 = load i32, i32* %4
%48 = call signext i8 @hexchar(i32 %47)
%49 = call i32 @putch(i8 signext %48)
%50 = call i32 @putch(i8 signext 10)
ret void
}

LLVM IR (-O2):
define void @printreg(i8* nocapture %0, i32 %1) {
%3 = load i8, i8* %0
%4 = icmp eq i8 %3, 0
br i1 %4, label %12, label %5
5: ; preds = %2, %5
%6 = phi i8 [ %10, %5 ], [ %3, %2 ]
%7 = phi i8* [ %9, %5 ], [ %0, %2 ]
%8 = tail call i32 @putch(i8 signext %6)
%9 = getelementptr inbounds i8, i8* %7, i64 1
%10 = load i8, i8* %9
%11 = icmp eq i8 %10, 0
br i1 %11, label %12, label %5
12: ; preds = %5, %2
%13 = tail call i32 @putch(i8 signext 61)
%14 = tail call i32 @putch(i8 signext 32)
%15 = lshr i32 %1, 28
%16 = tail call signext i8 @hexchar(i32 %15)
%17 = tail call i32 @putch(i8 signext %16)
%18 = lshr i32 %1, 24
%19 = tail call signext i8 @hexchar(i32 %18)
%20 = tail call i32 @putch(i8 signext %19)
%21 = lshr i32 %1, 20
%22 = tail call signext i8 @hexchar(i32 %21)
%23 = tail call i32 @putch(i8 signext %22)
%24 = lshr i32 %1, 16
%25 = tail call signext i8 @hexchar(i32 %24)
%26 = tail call i32 @putch(i8 signext %25)
%27 = lshr i32 %1, 12
%28 = tail call signext i8 @hexchar(i32 %27)
%29 = tail call i32 @putch(i8 signext %28)
%30 = lshr i32 %1, 8
%31 = tail call signext i8 @hexchar(i32 %30)
%32 = tail call i32 @putch(i8 signext %31)
%33 = lshr i32 %1, 4
%34 = tail call signext i8 @hexchar(i32 %33)
%35 = tail call i32 @putch(i8 signext %34)
%36 = tail call signext i8 @hexchar(i32 %1)
%37 = tail call i32 @putch(i8 signext %36)
%38 = tail call i32 @putch(i8 signext 10)
ret void
}