#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 */
struct _libc_fpstate {
  int /*<<< orphan*/ *_st;
};

/* Variables and functions */
int /*<<< orphan*/ print_fp_reg(int /*<<< orphan*/ *);
int /*<<< orphan*/ printf(char *, ...);
void print_fp_regs(struct _libc_fpstate *fpstate) {
  int i;
  for (i = 0; i < 8; i++) {
    printf("reg %d: ", i);
    print_fp_reg(&fpstate->_st[i]);
    printf("\n");
  }
}


x86 assembly (clang, -O0):
<print_fp_regs>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
cmpl   $0x8,-0xc(%rbp)
jge    1181 <print_fp_regs+0x61>
mov    -0xc(%rbp),%esi
lea    0xeb9(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%rax
mov    (%rax),%rdi
movslq -0xc(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rdi
call   1030 <print_fp_reg@plt>
lea    0xe9d(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0xc(%rbp)
jmp    1133 <print_fp_regs+0x13>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_fp_regs>:
push   %r14
push   %rbx
push   %rax
mov    %rdi,%rbx
lea    0xec2(%rip),%r14
mov    %r14,%rdi
xor    %esi,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    (%rbx),%rdi
call   1040 <print_fp_reg@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    %r14,%rdi
mov    $0x1,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    (%rbx),%rdi
add    $0x4,%rdi
call   1040 <print_fp_reg@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    %r14,%rdi
mov    $0x2,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    (%rbx),%rdi
add    $0x8,%rdi
call   1040 <print_fp_reg@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    %r14,%rdi
mov    $0x3,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    (%rbx),%rdi
add    $0xc,%rdi
call   1040 <print_fp_reg@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    %r14,%rdi
mov    $0x4,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    (%rbx),%rdi
add    $0x10,%rdi
call   1040 <print_fp_reg@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    %r14,%rdi
mov    $0x5,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    (%rbx),%rdi
add    $0x14,%rdi
call   1040 <print_fp_reg@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    %r14,%rdi
mov    $0x6,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    (%rbx),%rdi
add    $0x18,%rdi
call   1040 <print_fp_reg@plt>
mov    $0xa,%edi
call   1030 <putchar@plt>
mov    %r14,%rdi
mov    $0x7,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    (%rbx),%rdi
add    $0x1c,%rdi
call   1040 <print_fp_reg@plt>
mov    $0xa,%edi
add    $0x8,%rsp
pop    %rbx
pop    %r14
jmp    1030 <putchar@plt>

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

LLVM IR (-O2):
%struct._libc_fpstate = type { i32* }
@.str = [9 x i8] c"reg %d: \00"
define void @print_fp_regs(%struct._libc_fpstate* nocapture %0) {
%2 = getelementptr inbounds %struct._libc_fpstate, %struct._libc_fpstate* %0, i64 0, i32 0
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 0)
%4 = load i32*, i32** %2
%5 = tail call i32 @print_fp_reg(i32* %4)
%6 = tail call i32 @putchar(i32 10)
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 1)
%8 = load i32*, i32** %2
%9 = getelementptr inbounds i32, i32* %8, i64 1
%10 = tail call i32 @print_fp_reg(i32* %9)
%11 = tail call i32 @putchar(i32 10)
%12 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 2)
%13 = load i32*, i32** %2
%14 = getelementptr inbounds i32, i32* %13, i64 2
%15 = tail call i32 @print_fp_reg(i32* %14)
%16 = tail call i32 @putchar(i32 10)
%17 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 3)
%18 = load i32*, i32** %2
%19 = getelementptr inbounds i32, i32* %18, i64 3
%20 = tail call i32 @print_fp_reg(i32* %19)
%21 = tail call i32 @putchar(i32 10)
%22 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 4)
%23 = load i32*, i32** %2
%24 = getelementptr inbounds i32, i32* %23, i64 4
%25 = tail call i32 @print_fp_reg(i32* %24)
%26 = tail call i32 @putchar(i32 10)
%27 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 5)
%28 = load i32*, i32** %2
%29 = getelementptr inbounds i32, i32* %28, i64 5
%30 = tail call i32 @print_fp_reg(i32* %29)
%31 = tail call i32 @putchar(i32 10)
%32 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 6)
%33 = load i32*, i32** %2
%34 = getelementptr inbounds i32, i32* %33, i64 6
%35 = tail call i32 @print_fp_reg(i32* %34)
%36 = tail call i32 @putchar(i32 10)
%37 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i32 7)
%38 = load i32*, i32** %2
%39 = getelementptr inbounds i32, i32* %38, i64 7
%40 = tail call i32 @print_fp_reg(i32* %39)
%41 = tail call i32 @putchar(i32 10)
ret void
}