#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 uint16_t;

/* Variables and functions */
int /*<<< orphan*/ printf(char *, int, char *);
void stackdump(void) {
  uint8_t dummy = 0x55;
  uint16_t i;
  for (i = 0; i < 256; i++) {
    printf("%.2x%s", *(&dummy + i), ((i % 16) == 15) ? "\n" : " ");
  }
}


x86 assembly (clang, -O0):
<stackdump>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x55,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
cmpl   $0x100,-0x8(%rbp)
jge    1177 <stackdump+0x67>
movslq -0x8(%rbp),%rax
mov    -0x4(%rbp,%rax,4),%esi
mov    -0x8(%rbp),%eax
mov    $0x10,%ecx
cltd
idiv   %ecx
mov    %edx,%ecx
lea    0xeba(%rip),%rdx
lea    0xeb1(%rip),%rax
cmp    $0xf,%ecx
cmove  %rax,%rdx
lea    0xe9c(%rip),%rdi
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1126 <stackdump+0x16>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<stackdump>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
xor    %ebp,%ebp
lea    0xee7(%rip),%r14
lea    0xee2(%rip),%r15
lea    0xed2(%rip),%rbx
xchg   %ax,%ax
mov    %ebp,%eax
not    %eax
test   $0xf,%al
mov    %r15,%rdx
cmove  %r14,%rdx
mov    %rbx,%rdi
mov    $0x55,%esi
call   1030 <printf@plt>
add    $0x1,%ebp
cmp    $0x100,%ebp
jne    1130 <stackdump+0x20>
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [7 x i8] c"%.2x%s\00"
@.str.1 = [2 x i8] c"\0A\00"
@.str.2 = [2 x i8] c" \00"
define void @stackdump() {
%1 = alloca i32
%2 = alloca i32
store i32 85, i32* %1
store i32 0, i32* %2
br label %3
3: ; preds = %17, %0
%4 = load i32, i32* %2
%5 = icmp slt i32 %4, 256
br i1 %5, label %6, label %20
6: ; preds = %3
%7 = load i32, i32* %2
%8 = sext i32 %7 to i64
%9 = getelementptr inbounds i32, i32* %1, i64 %8
%10 = load i32, i32* %9
%11 = load i32, i32* %2
%12 = srem i32 %11, 16
%13 = icmp eq i32 %12, 15
%14 = zext i1 %13 to i64
%15 = select i1 %13, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0)
%16 = call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 %10, i8* %15)
br label %17
17: ; preds = %6
%18 = load i32, i32* %2
%19 = add nsw i32 %18, 1
store i32 %19, i32* %2
br label %3
20: ; preds = %3
ret void
}

LLVM IR (-O2):
@.str = [7 x i8] c"%.2x%s\00"
@.str.1 = [2 x i8] c"\0A\00"
@.str.2 = [2 x i8] c" \00"
define void @stackdump() {
br label %1
1: ; preds = %0, %1
%2 = phi i32 [ 0, %0 ], [ %7, %1 ]
%3 = and i32 %2, 15
%4 = icmp eq i32 %3, 15
%5 = select i1 %4, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0)
%6 = tail call i32 @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0), i32 85, i8* %5)
%7 = add nuw nsw i32 %2, 1
%8 = icmp eq i32 %7, 256
br i1 %8, label %9, label %1
9: ; preds = %1
ret void
}