#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 unsigned char int64_t;

/* Variables and functions */
int /*<<< orphan*/ printf(char *, ...);
void gen_int_test(const char *reader, void *ptr, size_t bits,
                  int64_t expected) {
  printf("(check-eqv? (%s (open-input-bytes (bytes", reader);
  for (size_t i = 0; i < (bits / 8); i++) {
    printf(" #x%x", ((unsigned char *)ptr)[i]);
  }
  printf("))) %lld)\n", expected);
}


x86 assembly (clang, -O0):
<gen_int_test>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %cl,%al
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    %al,-0x19(%rbp)
mov    -0x8(%rbp),%rsi
lea    0xecc(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movq   $0x0,-0x28(%rbp)
mov    -0x28(%rbp),%rax
mov    -0x18(%rbp),%rcx
shr    $0x3,%rcx
cmp    %rcx,%rax
jae    1183 <gen_int_test+0x73>
mov    -0x10(%rbp),%rax
mov    -0x28(%rbp),%rcx
movzbl (%rax,%rcx,1),%esi
lea    0xebe(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x28(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x28(%rbp)
jmp    1143 <gen_int_test+0x33>
movzbl -0x19(%rbp),%esi
lea    0xea1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gen_int_test>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %ecx,%r14d
mov    %rdx,%rbx
mov    %rsi,%r12
mov    %rdi,%rsi
lea    0xed5(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
cmp    $0x8,%rbx
jb     1168 <gen_int_test+0x58>
shr    $0x3,%rbx
lea    0xee6(%rip),%r15
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nop
movzbl (%r12,%rbp,1),%esi
mov    %r15,%rdi
xor    %eax,%eax
call   1030 <printf@plt>
add    $0x1,%rbp
cmp    %rbp,%rbx
jne    1150 <gen_int_test+0x40>
movzbl %r14b,%esi
lea    0xebc(%rip),%rdi
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <printf@plt>

LLVM IR (-O0):
@.str = [41 x i8] c"(check-eqv? (%s (open-input-bytes (bytes\00"
@.str.1 = [6 x i8] c" #x%x\00"
@.str.2 = [11 x i8] c"))) %lld)\0A\00"
define void @gen_int_test(i8* %0, i8* %1, i64 %2, i8 zeroext %3) {
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca i64
%8 = alloca i8
%9 = alloca i64
store i8* %0, i8** %5
store i8* %1, i8** %6
store i64 %2, i64* %7
store i8 %3, i8* %8
%10 = load i8*, i8** %5
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0), i8* %10)
store i64 0, i64* %9
br label %12
12: ; preds = %24, %4
%13 = load i64, i64* %9
%14 = load i64, i64* %7
%15 = udiv i64 %14, 8
%16 = icmp ult i64 %13, %15
br i1 %16, label %17, label %27
17: ; preds = %12
%18 = load i8*, i8** %6
%19 = load i64, i64* %9
%20 = getelementptr inbounds i8, i8* %18, i64 %19
%21 = load i8, i8* %20
%22 = zext i8 %21 to i32
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %22)
br label %24
24: ; preds = %17
%25 = load i64, i64* %9
%26 = add i64 %25, 1
store i64 %26, i64* %9
br label %12
27: ; preds = %12
%28 = load i8, i8* %8
%29 = zext i8 %28 to i32
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i32 %29)
ret void
}

LLVM IR (-O2):
@.str = [41 x i8] c"(check-eqv? (%s (open-input-bytes (bytes\00"
@.str.1 = [6 x i8] c" #x%x\00"
@.str.2 = [11 x i8] c"))) %lld)\0A\00"
define void @gen_int_test(i8* %0, i8* nocapture %1, i64 %2, i8 zeroext %3) {
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @.str, i64 0, i64 0), i8* %0)
%6 = icmp ult i64 %2, 8
br i1 %6, label %9, label %7
7: ; preds = %4
%8 = lshr i64 %2, 3
br label %12
9: ; preds = %12, %4
%10 = zext i8 %3 to i32
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.2, i64 0, i64 0), i32 %10)
ret void
12: ; preds = %7, %12
%13 = phi i64 [ %18, %12 ], [ 0, %7 ]
%14 = getelementptr inbounds i8, i8* %1, i64 %13
%15 = load i8, i8* %14
%16 = zext i8 %15 to i32
%17 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %16)
%18 = add nuw nsw i64 %13, 1
%19 = icmp eq i64 %18, %8
br i1 %19, label %9, label %12
}