#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 /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
int /*<<< orphan*/ print_struct(int /*<<< orphan*/ *, char *, char *, int);
void print_structs(FILE *fd, int count) {
  int i;
  fprintf(fd, "static struct _mpi const\n");
  print_struct(fd, "p", "P", count);
  print_struct(fd, "q", "Q", count);
  print_struct(fd, "g", "G", count);
  print_struct(fd, "y", "Y", count);
  fprintf(fd, "*const base[][3] = {");
  for (i = 0; i < count; i++)
    fprintf(fd, "{ &g[%d], &y[%d], NULL},", i, i);
  fprintf(fd, "}; \n");
}


x86 assembly (clang, -O0):
<print_structs>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xec6(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%ecx
lea    0xecb(%rip),%rsi
lea    0xec6(%rip),%rdx
call   1030 <print_struct@plt>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%ecx
lea    0xeb5(%rip),%rsi
lea    0xeb0(%rip),%rdx
call   1030 <print_struct@plt>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%ecx
lea    0xe9f(%rip),%rsi
lea    0xe9a(%rip),%rdx
call   1030 <print_struct@plt>
mov    -0x8(%rbp),%rdi
mov    -0xc(%rbp),%ecx
lea    0xe89(%rip),%rsi
lea    0xe84(%rip),%rdx
call   1030 <print_struct@plt>
mov    -0x8(%rbp),%rdi
lea    0xe76(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
movl   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0xc(%rbp),%eax
jge    11f4 <print_structs+0xd4>
mov    -0x8(%rbp),%rdi
mov    -0x10(%rbp),%edx
mov    -0x10(%rbp),%ecx
lea    0xe60(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    11c2 <print_structs+0xa2>
mov    -0x8(%rbp),%rdi
lea    0xe59(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<print_structs>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %esi,%r15d
mov    %rdi,%rbx
lea    0xebc(%rip),%rdi
mov    $0x19,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1050 <fwrite@plt>
lea    0xebd(%rip),%rsi
lea    0xeb8(%rip),%rdx
mov    %rbx,%rdi
mov    %r15d,%ecx
call   1030 <print_struct@plt>
lea    0xea8(%rip),%rsi
lea    0xea3(%rip),%rdx
mov    %rbx,%rdi
mov    %r15d,%ecx
call   1030 <print_struct@plt>
lea    0xe93(%rip),%rsi
lea    0xe8e(%rip),%rdx
mov    %rbx,%rdi
mov    %r15d,%ecx
call   1030 <print_struct@plt>
lea    0xe7e(%rip),%rsi
lea    0xe79(%rip),%rdx
mov    %rbx,%rdi
mov    %r15d,%ecx
call   1030 <print_struct@plt>
lea    0xe69(%rip),%rdi
mov    $0x14,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
call   1050 <fwrite@plt>
test   %r15d,%r15d
jle    1209 <print_structs+0xd9>
lea    0xe60(%rip),%r14
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax,%rax,1)
mov    %rbx,%rdi
mov    %r14,%rsi
mov    %ebp,%edx
mov    %ebp,%ecx
xor    %eax,%eax
call   1040 <fprintf@plt>
add    $0x1,%ebp
cmp    %ebp,%r15d
jne    11f0 <print_structs+0xc0>
lea    0xe48(%rip),%rdi
mov    $0x4,%esi
mov    $0x1,%edx
mov    %rbx,%rcx
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1050 <fwrite@plt>

LLVM IR (-O0):
@.str = [26 x i8] c"static struct _mpi const\0A\00"
@.str.1 = [2 x i8] c"p\00"
@.str.2 = [2 x i8] c"P\00"
@.str.3 = [2 x i8] c"q\00"
@.str.4 = [2 x i8] c"Q\00"
@.str.5 = [2 x i8] c"g\00"
@.str.6 = [2 x i8] c"G\00"
@.str.7 = [2 x i8] c"y\00"
@.str.8 = [2 x i8] c"Y\00"
@.str.9 = [21 x i8] c"*const base[][3] = {\00"
@.str.10 = [25 x i8] c"{ &g[%d], &y[%d], NULL},\00"
@.str.11 = [5 x i8] c"}; \0A\00"
define void @print_structs(i32* %0, i32 %1) {
%3 = alloca i32*
%4 = alloca i32
%5 = alloca i32
store i32* %0, i32** %3
store i32 %1, i32* %4
%6 = load i32*, i32** %3
%7 = call i32 (i32*, i8*, ...) @fprintf(i32* %6, i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0))
%8 = load i32*, i32** %3
%9 = load i32, i32* %4
%10 = call i32 @print_struct(i32* %8, 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), i32 %9)
%11 = load i32*, i32** %3
%12 = load i32, i32* %4
%13 = call i32 @print_struct(i32* %11, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0), i32 %12)
%14 = load i32*, i32** %3
%15 = load i32, i32* %4
%16 = call i32 @print_struct(i32* %14, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0), i32 %15)
%17 = load i32*, i32** %3
%18 = load i32, i32* %4
%19 = call i32 @print_struct(i32* %17, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0), i32 %18)
%20 = load i32*, i32** %3
%21 = call i32 (i32*, i8*, ...) @fprintf(i32* %20, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.9, i64 0, i64 0))
store i32 0, i32* %5
br label %22
22: ; preds = %31, %2
%23 = load i32, i32* %5
%24 = load i32, i32* %4
%25 = icmp slt i32 %23, %24
br i1 %25, label %26, label %34
26: ; preds = %22
%27 = load i32*, i32** %3
%28 = load i32, i32* %5
%29 = load i32, i32* %5
%30 = call i32 (i32*, i8*, ...) @fprintf(i32* %27, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.10, i64 0, i64 0), i32 %28, i32 %29)
br label %31
31: ; preds = %26
%32 = load i32, i32* %5
%33 = add nsw i32 %32, 1
store i32 %33, i32* %5
br label %22
34: ; preds = %22
%35 = load i32*, i32** %3
%36 = call i32 (i32*, i8*, ...) @fprintf(i32* %35, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.11, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str = [26 x i8] c"static struct _mpi const\0A\00"
@.str.1 = [2 x i8] c"p\00"
@.str.2 = [2 x i8] c"P\00"
@.str.3 = [2 x i8] c"q\00"
@.str.4 = [2 x i8] c"Q\00"
@.str.5 = [2 x i8] c"g\00"
@.str.6 = [2 x i8] c"G\00"
@.str.7 = [2 x i8] c"y\00"
@.str.8 = [2 x i8] c"Y\00"
@.str.9 = [21 x i8] c"*const base[][3] = {\00"
@.str.10 = [25 x i8] c"{ &g[%d], &y[%d], NULL},\00"
@.str.11 = [5 x i8] c"}; \0A\00"
define void @print_structs(i32* %0, i32 %1) {
%3 = tail call i64 @fwrite(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str, i64 0, i64 0), i64 25, i64 1, i32* %0)
%4 = tail call i32 @print_struct(i32* %0, 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), i32 %1)
%5 = tail call i32 @print_struct(i32* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0), i32 %1)
%6 = tail call i32 @print_struct(i32* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.6, i64 0, i64 0), i32 %1)
%7 = tail call i32 @print_struct(i32* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.7, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.8, i64 0, i64 0), i32 %1)
%8 = tail call i64 @fwrite(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.9, i64 0, i64 0), i64 20, i64 1, i32* %0)
%9 = icmp sgt i32 %1, 0
br i1 %9, label %10, label %15
10: ; preds = %2, %10
%11 = phi i32 [ %13, %10 ], [ 0, %2 ]
%12 = tail call i32 (i32*, i8*, ...) @fprintf(i32* %0, i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.10, i64 0, i64 0), i32 %11, i32 %11)
%13 = add nuw nsw i32 %11, 1
%14 = icmp eq i32 %13, %1
br i1 %14, label %15, label %10
15: ; preds = %10, %2
%16 = tail call i64 @fwrite(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.11, i64 0, i64 0), i64 4, i64 1, i32* %0)
ret void
}